feat(c-wrapper): better code (reduce bin size)

This commit is contained in:
Ronan Abhamon 2017-09-22 16:59:33 +02:00
parent 3bcf6e3523
commit bd11c0980f

View file

@ -67,15 +67,13 @@ public:
template<typename T>
static inline decltype (std::declval<T>().getPrivate()) getPrivate (T *cppObject) {
if (!cppObject)
return nullptr;
L_ASSERT(cppObject);
return cppObject->getPrivate();
}
template<typename T>
static inline decltype (std::declval<T>().getPrivate()) getPrivate (const std::shared_ptr<T> &cppObject) {
if (!cppObject)
return nullptr;
L_ASSERT(cppObject);
return cppObject->getPrivate();
}
@ -143,13 +141,14 @@ public:
>
static inline void setCppPtrFromC (void *cObject, const CppType *cppObject) {
L_ASSERT(cObject);
CppType *oldPtr = reinterpret_cast<CppType *>(static_cast<WrappedClonableObject<CppType> *>(cObject)->cppPtr);
if (oldPtr != cppObject) {
delete oldPtr;
CppType **cppPtr = &static_cast<WrappedClonableObject<CppType> *>(cObject)->cppPtr;
*cppPtr = new CppType(*cppObject);
(*cppPtr)->setProperty("LinphonePrivate::Wrapper::cBackPtr", cObject);
}
CppType **cppObjectAddr = &static_cast<WrappedClonableObject<CppType> *>(cObject)->cppPtr;
if (*cppObjectAddr == cppObject)
return;
delete *cppObjectAddr;
*cppObjectAddr = new CppType(*cppObject);
(*cppObjectAddr)->setProperty("LinphonePrivate::Wrapper::cBackPtr", cObject);
}
// Macro helpers.