Commit d410536b authored by François Grisez's avatar François Grisez

C++ wrapper: public structure support improvement

parent 64584409
......@@ -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:
......
......@@ -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)
......
......@@ -119,6 +119,20 @@ namespace linphone {
static std::list<std::string> cStringArrayToCppList(const char **cArray);
};
template <class T>
class StructWrapper {
public:
StructWrapper(const T &s) {
mStruct = s;
}
const void *ptr() const {
return &mStruct;
}
private:
T mStruct;
};
};
#endif // _TOOLS_HH
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment