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
ec1c1dbb
Commit
ec1c1dbb
authored
Sep 25, 2017
by
Ronan
Browse files
feat(c-wrapper): provide better usage on list macros
parent
fd1385fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/c-wrapper/api/c-chat-room.cpp
View file @
ec1c1dbb
...
...
@@ -213,7 +213,7 @@ LinphoneParticipant *linphone_chat_room_add_participant (LinphoneChatRoom *cr, c
}
void
linphone_chat_room_add_participants
(
LinphoneChatRoom
*
cr
,
const
bctbx_list_t
*
addresses
)
{
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
addParticipants
(
L_GET_
CPP_LIST_OF_CPP_OBJ_FROM_C_LIST_OF_STRUCT_PTR
(
addresses
,
Addres
s
,
Address
),
nullptr
,
false
);
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
addParticipants
(
L_GET_
RESOLVED_CPP_LIST_FROM_C_LIST
(
addresse
s
,
Address
),
nullptr
,
false
);
}
bool_t
linphone_chat_room_can_handle_participants
(
const
LinphoneChatRoom
*
cr
)
{
...
...
@@ -230,7 +230,7 @@ int linphone_chat_room_get_nb_participants (const LinphoneChatRoom *cr) {
}
bctbx_list_t
*
linphone_chat_room_get_participants
(
const
LinphoneChatRoom
*
cr
)
{
return
L_GET_
C_LIST_OF_STRUCT_PTR
_FROM_CPP_LIST
_OF_CPP_OBJ
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getParticipants
()
,
Participant
,
Participant
);
return
L_GET_
RESOLVED_C_LIST
_FROM_CPP_LIST
(
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
getParticipants
());
}
void
linphone_chat_room_remove_participant
(
LinphoneChatRoom
*
cr
,
LinphoneParticipant
*
participant
)
{
...
...
@@ -238,7 +238,7 @@ void linphone_chat_room_remove_participant (LinphoneChatRoom *cr, LinphonePartic
}
void
linphone_chat_room_remove_participants
(
LinphoneChatRoom
*
cr
,
const
bctbx_list_t
*
participants
)
{
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
removeParticipants
(
L_GET_
CPP_LIST_OF_CPP_OBJ_FROM_C_LIST_OF_STRUCT_PTR
(
participants
,
Participant
,
Participant
));
L_GET_CPP_PTR_FROM_C_OBJECT
(
cr
)
->
removeParticipants
(
L_GET_
RESOLVED_CPP_LIST_FROM_C_LIST
(
participants
,
Participant
));
}
// =============================================================================
...
...
src/c-wrapper/internal/c-tools.h
View file @
ec1c1dbb
...
...
@@ -207,7 +207,7 @@ public:
}
// ---------------------------------------------------------------------------
// List
helper
s.
// List
conversion
s.
// ---------------------------------------------------------------------------
template
<
typename
T
>
...
...
@@ -226,16 +226,23 @@ public:
return
result
;
}
template
<
typename
CppType
,
typename
CType
>
static
inline
bctbx_list_t
*
getCListOfStructPtrFromCppListOfCppObj
(
const
std
::
list
<
std
::
shared_ptr
<
CppType
>>
cppList
,
CType
*
(
*
cTypeAllocator
)())
{
// ---------------------------------------------------------------------------
// Resolved list conversions.
// ---------------------------------------------------------------------------
template
<
typename
CppType
,
typename
=
typename
std
::
enable_if
<
IsCppObject
<
CppType
>
::
value
,
CppType
>::
type
>
static
inline
bctbx_list_t
*
getResolvedCListFromCppList
(
const
std
::
list
<
std
::
shared_ptr
<
CppType
>>
&
cppList
)
{
bctbx_list_t
*
result
=
nullptr
;
for
(
const
auto
&
value
:
cppList
)
result
=
bctbx_list_append
(
result
,
getCBackPtr
(
value
));
return
result
;
}
template
<
typename
CppType
,
typename
CType
>
static
inline
bctbx_list_t
*
get
CListOfStructPtr
FromCppList
OfCppObj
(
const
std
::
list
<
CppType
>
cppList
,
CType
*
(
*
cTypeAllocator
)()
)
{
template
<
typename
CppType
>
static
inline
bctbx_list_t
*
get
ResolvedCList
FromCppList
(
const
std
::
list
<
CppType
>
&
cppList
)
{
bctbx_list_t
*
result
=
nullptr
;
for
(
const
auto
&
value
:
cppList
)
result
=
bctbx_list_append
(
result
,
getCBackPtr
(
value
));
...
...
@@ -243,11 +250,11 @@ public:
}
template
<
typename
CppType
,
typename
CType
,
typename
CppType
=
typename
CTypeToCppType
<
CType
>
::
type
,
typename
=
typename
std
::
enable_if
<
std
::
is_base_of
<
Object
,
CppType
>::
value
,
CppType
>::
type
>
static
inline
std
::
list
<
std
::
shared_ptr
<
CppType
>>
get
CppListOfCppObjFromCListOfStructPtr
(
const
bctbx_list_t
*
cList
)
{
static
inline
std
::
list
<
std
::
shared_ptr
<
CppType
>>
get
ResolvedCppListFromCList
(
const
bctbx_list_t
*
cList
)
{
std
::
list
<
std
::
shared_ptr
<
CppType
>>
result
;
for
(
auto
it
=
cList
;
it
;
it
=
bctbx_list_next
(
it
))
result
.
push_back
(
getCppPtrFromC
(
reinterpret_cast
<
CType
*>
(
bctbx_list_get_data
(
it
))));
...
...
@@ -255,11 +262,11 @@ public:
}
template
<
typename
CppType
,
typename
CType
,
typename
CppType
=
typename
CTypeToCppType
<
CType
>
::
type
,
typename
=
typename
std
::
enable_if
<
std
::
is_base_of
<
ClonableObject
,
CppType
>::
value
,
CppType
>::
type
>
static
inline
std
::
list
<
CppType
>
get
CppListOfCppObjFromCListOfStructPtr
(
const
bctbx_list_t
*
cList
)
{
static
inline
std
::
list
<
CppType
>
get
ResolvedCppListFromCList
(
const
bctbx_list_t
*
cList
)
{
std
::
list
<
CppType
>
result
;
for
(
auto
it
=
cList
;
it
;
it
=
bctbx_list_next
(
it
))
result
.
push_back
(
*
getCppPtrFromC
(
reinterpret_cast
<
CType
*>
(
bctbx_list_get_data
(
it
))));
...
...
@@ -458,9 +465,10 @@ LINPHONE_END_NAMESPACE
#define L_GET_CPP_LIST_FROM_C_LIST(C_LIST, TYPE) \
LINPHONE_NAMESPACE::Wrapper::getCppListFromCList<TYPE>(C_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) \
LINPHONE_NAMESPACE::Wrapper::getCppListOfCppObjFromCListOfStructPtr<LINPHONE_NAMESPACE::CPP_TYPE, Linphone ## C_TYPE>(LIST)
// Transforms cpp list and c list and convert cpp object to c object.
#define L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(CPP_LIST) \
LINPHONE_NAMESPACE::Wrapper::getResolvedCListFromCppList(CPP_LIST)
#define L_GET_RESOLVED_CPP_LIST_FROM_C_LIST(C_LIST, C_TYPE) \
LINPHONE_NAMESPACE::Wrapper::getResolvedCppListFromCList<Linphone ## C_TYPE>(C_LIST)
#endif // ifndef _C_TOOLS_H_
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