Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
c18c2655
Commit
c18c2655
authored
Aug 29, 2017
by
Ronan
Browse files
feat(c-types): provide init internal functions
parent
a588e18a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
14 deletions
+42
-14
coreapi/private.h
coreapi/private.h
+3
-1
src/c-wrapper/c-types.cpp
src/c-wrapper/c-types.cpp
+27
-10
src/c-wrapper/c-types.h
src/c-wrapper/c-types.h
+12
-3
No files found.
coreapi/private.h
View file @
c18c2655
...
...
@@ -1891,7 +1891,9 @@ BELLE_SIP_TYPE_ID(LinphoneVideoActivationPolicy),
BELLE_SIP_TYPE_ID
(
LinphoneCallStats
),
BELLE_SIP_TYPE_ID
(
LinphonePlayer
),
BELLE_SIP_TYPE_ID
(
LinphonePlayerCbs
),
BELLE_SIP_TYPE_ID
(
LinphoneEventLog
)
BELLE_SIP_TYPE_ID
(
LinphoneEventLog
),
BELLE_SIP_TYPE_ID
(
LinphoneMessage
),
BELLE_SIP_TYPE_ID
(
LinphoneMessageEvent
)
BELLE_SIP_DECLARE_TYPES_END
...
...
src/c-wrapper/c-types.cpp
View file @
c18c2655
...
...
@@ -25,38 +25,44 @@
// Must be included before cpp headers.
#include "c-types.h"
#include "event-log/event
-log
.h"
#include "event-log/
message-
event.h"
// ================================================================²=============
using
namespace
std
;
extern
"C"
{
#define L_DECLARE_C_STRUCT_IMPL(STRUCT) \
#define L_DECLARE_C_STRUCT_IMPL(STRUCT
, C_NAME
) \
struct _Linphone ## STRUCT { \
belle_sip_object_t base; \
shared_ptr<LINPHONE_NAMESPACE::STRUCT> cppPtr; \
}; \
static void _linphone_ ## STRUCT ## _uninit(Linphone ## STRUCT * object) { \
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## STRUCT); \
static Linphone ## STRUCT *_linphone_ ## C_NAME ## _init() { \
Linphone ## STRUCT * object = belle_sip_object_new(Linphone ## STRUCT); \
new(&object->cppPtr) shared_ptr<LINPHONE_NAMESPACE::STRUCT>(); \
return object; \
} \
static void _linphone_ ## C_NAME ## _uninit(Linphone ## STRUCT * object) { \
object->cppPtr.reset(); \
object->cppPtr->~STRUCT (); \
} \
static void _linphone_ ##
STRUCT
## _clone(Linphone ## STRUCT * dest, const Linphone ## STRUCT * src) { \
static void _linphone_ ##
C_NAME
## _clone(Linphone ## STRUCT * dest, const Linphone ## STRUCT * src) { \
new(&dest->cppPtr) shared_ptr<LINPHONE_NAMESPACE::STRUCT>(); \
dest->cppPtr = make_shared<LINPHONE_NAMESPACE::STRUCT>(*src->cppPtr.get()); \
} \
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## STRUCT); \
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(Linphone ## STRUCT); \
BELLE_SIP_INSTANCIATE_VPTR(Linphone ## STRUCT, belle_sip_object_t, \
_linphone_ ##
STRUCT
## _uninit, \
_linphone_ ##
STRUCT
## _clone, \
_linphone_ ##
C_NAME
## _uninit, \
_linphone_ ##
C_NAME
## _clone, \
NULL, \
FALSE \
);
#define L_DECLARE_C_STRUCT_NEW_DEFAULT(STRUCT, C_NAME) \
Linphone ## STRUCT * CNAME ## _new() { \
Linphone ## STRUCT * object = belle_sip_object_new(Linphone ## STRUCT); \
Linphone ## STRUCT * object = _linphone_ ## C_NAME ## _init(); \
object->cppPtr = make_shared<LINPHONE_NAMESPACE::STRUCT>(); \
return object; \
}
...
...
@@ -64,12 +70,23 @@ extern "C" {
// Event log.
// -----------------------------------------------------------------------------
L_DECLARE_C_STRUCT_IMPL
(
EventLog
);
L_DECLARE_C_STRUCT_NEW_DEFAULT
(
EventLog
,
event_log
)
L_DECLARE_C_STRUCT_IMPL
(
EventLog
,
event_log
);
L_DECLARE_C_STRUCT_NEW_DEFAULT
(
EventLog
,
event_log
)
;
LinphoneEventLogType
event_log_get_type
(
const
LinphoneEventLog
*
eventLog
)
{
return
static_cast
<
LinphoneEventLogType
>
(
eventLog
->
cppPtr
->
getType
());
}
// -----------------------------------------------------------------------------
// Message Event.
// -----------------------------------------------------------------------------
// L_DECLARE_C_STRUCT_IMPL(MessageEvent, message_event);
//
// LinphoneMessageEvent *message_event_new (LinphoneMessage *message) {
// LinphoneMessageEvent *object = object->cppPtr = make_shared<LINPHONE_NAMESPACE::STRUCT>();
// return object;
// }
//
// LinphoneMessage *message_event_get_message (const LinphoneMessageEvent *messageEvent);
}
src/c-wrapper/c-types.h
View file @
c18c2655
...
...
@@ -30,14 +30,23 @@
extern
"C"
{
#endif
L_DECLARE_C_STRUCT
(
EventLog
);
L_DECLARE_C_STRUCT
(
Message
);
L_DECLARE_C_STRUCT
(
MessageEvent
);
// -----------------------------------------------------------------------------
// Event log.
// -----------------------------------------------------------------------------
L_DECLARE_C_STRUCT
(
EventLog
);
LINPHONE_PUBLIC
LinphoneEventLog
*
event_log_new
();
LINPHONE_PUBLIC
LinphoneEventLogType
event_log_get_type
(
const
LinphoneEventLog
*
eventLog
);
LINPHONE_PUBLIC
LinphoneEventLogType
event_log_get_type
(
const
LinphoneEventLog
*
event_log
);
// -----------------------------------------------------------------------------
// Message Event.
// -----------------------------------------------------------------------------
LINPHONE_PUBLIC
LinphoneMessageEvent
*
message_event_new
(
LinphoneMessage
*
message
);
LINPHONE_PUBLIC
LinphoneMessage
*
message_event_get_message
(
const
LinphoneMessageEvent
*
message_event
);
// -----------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment