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
ce0f9d1c
Commit
ce0f9d1c
authored
Sep 22, 2017
by
Ronan
Browse files
feat(c-wrapper): getCBackPtr is now more secure
parent
22214117
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/c-wrapper/internal/c-tools.h
View file @
ce0f9d1c
...
...
@@ -83,6 +83,7 @@ public:
// Get c/cpp ptr helpers.
// ---------------------------------------------------------------------------
// Get Object.
template
<
typename
CppType
,
typename
CType
,
...
...
@@ -103,6 +104,7 @@ public:
return
reinterpret_cast
<
const
WrappedObject
<
CppType
>
*>
(
cObject
)
->
cppPtr
;
}
// Get ClonableObject.
template
<
typename
CppType
,
typename
CType
,
...
...
@@ -123,6 +125,7 @@ public:
return
reinterpret_cast
<
const
WrappedClonableObject
<
CppType
>
*>
(
cObject
)
->
cppPtr
;
}
// Set Object.
template
<
typename
CppType
,
typename
=
typename
std
::
enable_if
<
std
::
is_base_of
<
Object
,
CppType
>
::
value
,
CppType
>::
type
...
...
@@ -133,6 +136,7 @@ public:
cppObject
->
setProperty
(
"LinphonePrivate::Wrapper::cBackPtr"
,
cObject
);
}
// Set ClonableObject.
template
<
typename
CppType
,
typename
=
typename
std
::
enable_if
<
std
::
is_base_of
<
ClonableObject
,
CppType
>
::
value
,
CppType
>::
type
...
...
@@ -148,6 +152,7 @@ public:
}
}
// Macro helpers.
template
<
typename
T
>
static
T
*
getCppPtr
(
const
std
::
shared_ptr
<
T
>
&
cppObject
)
{
return
cppObject
.
get
();
...
...
@@ -172,7 +177,10 @@ public:
// Get c back ptr helpers.
// ---------------------------------------------------------------------------
template
<
typename
CppType
>
template
<
typename
CppType
,
typename
=
typename
std
::
enable_if
<
std
::
is_base_of
<
Object
,
CppType
>
::
value
,
CppType
>::
type
>
static
inline
typename
CppTypeToCType
<
CppType
>::
type
*
getCBackPtr
(
const
std
::
shared_ptr
<
CppType
>
&
cppObject
)
{
typedef
typename
CppTypeToCType
<
CppType
>::
type
RetType
;
...
...
@@ -186,7 +194,10 @@ public:
return
reinterpret_cast
<
RetType
*>
(
value
);
}
template
<
typename
CppType
>
template
<
typename
CppType
,
typename
=
typename
std
::
enable_if
<
std
::
is_base_of
<
ClonableObject
,
CppType
>
::
value
,
CppType
>::
type
>
static
inline
typename
CppTypeToCType
<
CppType
>::
type
*
getCBackPtr
(
const
CppType
*
cppObject
)
{
typedef
typename
CppTypeToCType
<
CppType
>::
type
RetType
;
...
...
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