Commit 448f5246 authored by Ronan's avatar Ronan
Browse files

feat(c-wrapper): provide a way to link cpp type and c type

parent 4272b608
......@@ -25,16 +25,32 @@
// =============================================================================
#define L_REGISTER_TYPE(C_TYPE) \
extern Linphone ## C_TYPE *_linphone_ ## C_TYPE ## _init ();
#define L_INIT(C_TYPE) \
_linphone_ ## C_TYPE ## _init ()
LINPHONE_BEGIN_NAMESPACE
template<typename CppType, typename CType>
struct CppTypeToCType {
enum { Defined = false };
};
LINPHONE_END_NAMESPACE
#define L_REGISTER_TYPE(CPP_TYPE, C_TYPE) \
extern Linphone ## C_TYPE *_linphone_ ## C_TYPE ## _init (); \
namespace LINPHONE_NAMESPACE { \
class CPP_TYPE; \
}; \
template<> \
struct LINPHONE_NAMESPACE::CppTypeToCType<LINPHONE_NAMESPACE::CPP_TYPE, Linphone ## C_TYPE> { \
enum { Defined = true }; \
typedef C_TYPE cType; \
typedef LINPHONE_NAMESPACE::CPP_TYPE cppType; \
};
// =============================================================================
L_REGISTER_TYPE(Call);
L_REGISTER_TYPE(ChatMessage);
L_REGISTER_TYPE(ChatRoom);
L_REGISTER_TYPE(Participant);
L_REGISTER_TYPE(Call, Call);
L_REGISTER_TYPE(ChatMessage, ChatMessage);
L_REGISTER_TYPE(ChatRoom, ChatRoom);
L_REGISTER_TYPE(Participant, Participant);
#endif // ifndef _C_WRAPPER_H_
......@@ -350,6 +350,9 @@ LINPHONE_END_NAMESPACE
#define L_STRING_TO_C(STR) ((STR).empty() ? NULL : (STR).c_str())
#define L_C_TO_STRING(STR) ((STR) == NULL ? std::string() : (STR))
// Call the init function of wrapped C object.
#define L_INIT(C_TYPE) _linphone_ ## C_TYPE ## _init ()
// Get the cpp-ptr of a wrapped C object.
#define L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT, CPP_TYPE) \
LINPHONE_NAMESPACE::Wrapper::getCppPtrFromC< \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment