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

C++ wrapper: public structure support improvement

parent 64584409
...@@ -726,6 +726,7 @@ class CParser(object): ...@@ -726,6 +726,7 @@ class CParser(object):
elif cType.ctype in self.classesIndex or cType.ctype in self.interfacesIndex: elif cType.ctype in self.classesIndex or cType.ctype in self.interfacesIndex:
absType = ClassType(cType.ctype) absType = ClassType(cType.ctype)
absType.isconst = cType.completeType.startswith('const ') absType.isconst = cType.completeType.startswith('const ')
absType.isref = cType.completeType.endswith('*')
elif cType.ctype == self.cListType: elif cType.ctype == self.cListType:
absType = ListType(cType.containedType) absType = ListType(cType.containedType)
else: else:
......
...@@ -334,7 +334,13 @@ class CppTranslator(object): ...@@ -334,7 +334,13 @@ class CppTranslator(object):
else: else:
return 'Object::cPtrToSharedPtr<{0}>({1})'.format(cppReturnType, cExpr) return 'Object::cPtrToSharedPtr<{0}>({1})'.format(cppReturnType, cExpr)
else: 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: elif type(exprtype) is AbsApi.ListType:
if type(exprtype.containedTypeDesc) is AbsApi.BaseType and exprtype.containedTypeDesc.name == 'string': if type(exprtype.containedTypeDesc) is AbsApi.BaseType and exprtype.containedTypeDesc.name == 'string':
return 'StringBctbxListWrapper::bctbxListToCppList({0})'.format(cExpr) return 'StringBctbxListWrapper::bctbxListToCppList({0})'.format(cExpr)
......
...@@ -119,6 +119,20 @@ namespace linphone { ...@@ -119,6 +119,20 @@ namespace linphone {
static std::list<std::string> cStringArrayToCppList(const char **cArray); 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 #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