diff --git a/wrappers/cpp/abstractapi.py b/wrappers/cpp/abstractapi.py index c5fcc8066..01489ba41 100644 --- a/wrappers/cpp/abstractapi.py +++ b/wrappers/cpp/abstractapi.py @@ -726,6 +726,7 @@ class CParser(object): elif cType.ctype in self.classesIndex or cType.ctype in self.interfacesIndex: absType = ClassType(cType.ctype) absType.isconst = cType.completeType.startswith('const ') + absType.isref = cType.completeType.endswith('*') elif cType.ctype == self.cListType: absType = ListType(cType.containedType) else: diff --git a/wrappers/cpp/genwrapper.py b/wrappers/cpp/genwrapper.py index 8948432e8..d8e5d5fde 100755 --- a/wrappers/cpp/genwrapper.py +++ b/wrappers/cpp/genwrapper.py @@ -334,7 +334,13 @@ class CppTranslator(object): else: return 'Object::cPtrToSharedPtr<{0}>({1})'.format(cppReturnType, cExpr) else: - return '{0}({1})'.format(exprtype.desc.name.to_camel_case(), cExpr); + if exprtype.isref: + return '{0}({1})'.format(exprtype.desc.name.to_camel_case(), cExpr) + else: + return '{0}(StructWrapper<::{1}>({2}).ptr())'.format( + exprtype.desc.name.to_camel_case(), + exprtype.desc.name.to_c(), + cExpr) elif type(exprtype) is AbsApi.ListType: if type(exprtype.containedTypeDesc) is AbsApi.BaseType and exprtype.containedTypeDesc.name == 'string': return 'StringBctbxListWrapper::bctbxListToCppList({0})'.format(cExpr) diff --git a/wrappers/cpp/tools.hh b/wrappers/cpp/tools.hh index 5d2fae0da..4ef512992 100644 --- a/wrappers/cpp/tools.hh +++ b/wrappers/cpp/tools.hh @@ -119,6 +119,20 @@ namespace linphone { static std::list cStringArrayToCppList(const char **cArray); }; + template + class StructWrapper { + public: + StructWrapper(const T &s) { + mStruct = s; + } + const void *ptr() const { + return &mStruct; + } + + private: + T mStruct; + }; + }; #endif // _TOOLS_HH