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
dd6db193
Commit
dd6db193
authored
Sep 22, 2017
by
Ronan
Browse files
feat(c-wrapper): remove TYPE parameter of L_GET_C_LIST_FROM_CPP_LIST
parent
a38e2220
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/c-wrapper/api/c-chat-room.cpp
View file @
dd6db193
...
...
@@ -166,7 +166,7 @@ void linphone_chat_room_set_call (LinphoneChatRoom *cr, LinphoneCall *call) {
}
bctbx_list_t
*
linphone_chat_room_get_transient_messages
(
const
LinphoneChatRoom
*
cr
)
{
return
L_GET_C_LIST_FROM_CPP_LIST
(
GET_CPP_PRIVATE_PTR
(
cr
)
->
getTransientMessages
()
,
LinphoneChatMessage
);
return
L_GET_C_LIST_FROM_CPP_LIST
(
GET_CPP_PRIVATE_PTR
(
cr
)
->
getTransientMessages
());
}
void
linphone_chat_room_mark_as_read
(
LinphoneChatRoom
*
cr
)
{
...
...
@@ -190,11 +190,11 @@ void linphone_chat_room_delete_history (LinphoneChatRoom *cr) {
}
bctbx_list_t
*
linphone_chat_room_get_history_range
(
LinphoneChatRoom
*
cr
,
int
startm
,
int
endm
)
{
return
L_GET_C_LIST_FROM_CPP_LIST
(
GET_CPP_PTR
(
cr
)
->
getHistoryRange
(
startm
,
endm
)
,
LinphoneChatMessage
);
return
L_GET_C_LIST_FROM_CPP_LIST
(
GET_CPP_PTR
(
cr
)
->
getHistoryRange
(
startm
,
endm
));
}
bctbx_list_t
*
linphone_chat_room_get_history
(
LinphoneChatRoom
*
cr
,
int
nb_message
)
{
return
L_GET_C_LIST_FROM_CPP_LIST
(
GET_CPP_PTR
(
cr
)
->
getHistory
(
nb_message
)
,
LinphoneChatMessage
);
return
L_GET_C_LIST_FROM_CPP_LIST
(
GET_CPP_PTR
(
cr
)
->
getHistory
(
nb_message
));
}
LinphoneChatMessage
*
linphone_chat_room_find_message
(
LinphoneChatRoom
*
cr
,
const
char
*
message_id
)
{
...
...
src/c-wrapper/internal/c-tools.h
View file @
dd6db193
...
...
@@ -155,6 +155,10 @@ public:
return
cppPtr
;
}
// ---------------------------------------------------------------------------
// Get c back ptr helpers.
// ---------------------------------------------------------------------------
template
<
typename
CType
,
typename
CppType
>
static
inline
CType
*
getCBackPtr
(
const
std
::
shared_ptr
<
CppType
>
&
object
,
CType
*
(
*
cTypeAllocator
)())
{
Variant
v
=
object
->
getProperty
(
"LinphonePrivate::Wrapper::cBackPtr"
);
...
...
@@ -177,6 +181,8 @@ public:
return
reinterpret_cast
<
CType
*>
(
value
);
}
// ---------------------------------------------------------------------------
// Get/set user data.
// ---------------------------------------------------------------------------
template
<
typename
T
>
...
...
@@ -203,16 +209,26 @@ public:
object
->
setProperty
(
"LinphonePrivate::Wrapper::userData"
,
value
);
}
// ---------------------------------------------------------------------------
// List helpers.
// ---------------------------------------------------------------------------
template
<
typename
T
>
static
inline
bctbx_list_t
*
getCListFromCppList
(
const
std
::
list
<
T
>
cppList
)
{
static
inline
bctbx_list_t
*
getCListFromCppList
(
const
std
::
list
<
T
*
>
&
cppList
)
{
bctbx_list_t
*
result
=
nullptr
;
for
(
const
auto
&
value
:
cppList
)
result
=
bctbx_list_append
(
result
,
value
);
return
result
;
}
template
<
typename
T
>
static
inline
std
::
list
<
T
*>
getCppListFromCList
(
const
bctbx_list_t
*
cList
)
{
std
::
list
<
T
>
result
;
for
(
auto
it
=
cList
;
it
;
it
=
bctbx_list_next
(
it
))
result
.
push_back
(
static_cast
<
T
>
(
bctbx_list_get_data
(
it
)));
return
result
;
}
template
<
typename
CppType
,
typename
CType
>
static
inline
bctbx_list_t
*
getCListOfStructPtrFromCppListOfCppObj
(
const
std
::
list
<
std
::
shared_ptr
<
CppType
>>
cppList
,
CType
*
(
*
cTypeAllocator
)())
{
bctbx_list_t
*
result
=
nullptr
;
...
...
@@ -229,14 +245,6 @@ public:
return
result
;
}
template
<
typename
T
>
static
inline
std
::
list
<
T
>
getCppListFromCList
(
const
bctbx_list_t
*
cList
)
{
std
::
list
<
T
>
result
;
for
(
auto
it
=
cList
;
it
;
it
=
bctbx_list_next
(
it
))
result
.
push_back
(
static_cast
<
T
>
(
bctbx_list_get_data
(
it
)));
return
result
;
}
template
<
typename
CppType
,
typename
CType
,
...
...
@@ -432,10 +440,11 @@ LINPHONE_END_NAMESPACE
VALUE \
)
#define L_GET_C_LIST_FROM_CPP_LIST(LIST
, TYPE
) \
LINPHONE_NAMESPACE::Wrapper::getCListFromCppList
<TYPE *>
(LIST)
#define L_GET_C_LIST_FROM_CPP_LIST(LIST) \
LINPHONE_NAMESPACE::Wrapper::getCListFromCppList(LIST)
#define L_GET_CPP_LIST_FROM_C_LIST(LIST, TYPE) \
LINPHONE_NAMESPACE::Wrapper::getCppListFromCList<TYPE *>(LIST)
LINPHONE_NAMESPACE::Wrapper::getCppListFromCList<TYPE>(LIST)
#define L_GET_C_LIST_OF_STRUCT_PTR_FROM_CPP_LIST_OF_CPP_OBJ(LIST, CPP_TYPE, C_TYPE) \
LINPHONE_NAMESPACE::Wrapper::getCListOfStructPtrFromCppListOfCppObj<LINPHONE_NAMESPACE::CPP_TYPE, Linphone ## C_TYPE>(LIST, _linphone_ ## C_TYPE ## _init)
#define L_GET_CPP_LIST_OF_CPP_OBJ_FROM_C_LIST_OF_STRUCT_PTR(LIST, CPP_TYPE, C_TYPE) \
...
...
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