Commit 8cd99594 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Add macros to handle user data in c-tools.

parent 8e9bbb68
......@@ -201,15 +201,12 @@ void linphone_chat_room_unref(LinphoneChatRoom *cr) {
belle_sip_object_unref(cr);
}
void *linphone_chat_room_get_user_data(const LinphoneChatRoom *cr) {
// TODO
return nullptr;
//return cr->userData;
void * linphone_chat_room_get_user_data(const LinphoneChatRoom *cr) {
return L_GET_USER_DATA_FROM_C_STRUCT(cr, ChatRoom, ChatRoom);
}
void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void *ud) {
// TODO
//cr->userData = ud;
L_SET_USER_DATA_FROM_C_STRUCT(cr, ud, ChatRoom, ChatRoom);
}
......
......@@ -160,6 +160,32 @@ public:
// ---------------------------------------------------------------------------
template<typename T>
static void * getUserData (const std::shared_ptr<T> &cppPtr) {
Variant v = cppPtr->getProperty("LinphonePrivate::Wrapper::userData");
return v.getValue<void *>();
}
template<typename T>
static void * getUserData (T *cppPtr) {
Variant v = cppPtr->getProperty("LinphonePrivate::Wrapper::userData");
return v.getValue<void *>();
}
template<typename T>
static inline void setUserData (std::shared_ptr<T> object, void *value) {
L_ASSERT(object);
object->setProperty("LinphonePrivate::Wrapper::userData", value);
}
template<typename T>
static inline void setUserData (T *object, void *value) {
L_ASSERT(object);
object->setProperty("LinphonePrivate::Wrapper::userData", value);
}
// ---------------------------------------------------------------------------
template<typename T>
static inline bctbx_list_t * getCListFromCppList (std::list<T> cppList) {
bctbx_list_t *result = nullptr;
......@@ -295,6 +321,16 @@ LINPHONE_END_NAMESPACE
#define L_GET_C_BACK_PTR(OBJECT, C_TYPE, C_NAME) \
LINPHONE_NAMESPACE::Wrapper::getCBackPtr<Linphone ## C_TYPE>(OBJECT, _linphone_ ## C_NAME ## _init)
#define L_GET_USER_DATA_FROM_C_STRUCT(OBJECT, CPP_TYPE, C_TYPE) \
LINPHONE_NAMESPACE::Wrapper::getUserData( \
L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT, CPP_TYPE, C_TYPE) \
)
#define L_SET_USER_DATA_FROM_C_STRUCT(OBJECT, VALUE, CPP_TYPE, C_TYPE) \
LINPHONE_NAMESPACE::Wrapper::setUserData( \
L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT, CPP_TYPE, C_TYPE), \
VALUE \
)
#define L_GET_C_LIST_FROM_CPP_LIST(LIST, TYPE) \
LINPHONE_NAMESPACE::Wrapper::getCListFromCppList<TYPE *>(LIST)
#define L_GET_CPP_LIST_FROM_C_LIST(LIST, TYPE) \
......
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