diff --git a/tools/abstractapi.py b/tools/abstractapi.py index ab0573d964c270f705b41a8fb9e8acaf0e8e5483..35ec4ebeee40f278aef2625eee8f3e2a1fb47b49 100644 --- a/tools/abstractapi.py +++ b/tools/abstractapi.py @@ -366,6 +366,10 @@ class Method(DocumentableObject): def returnType(self, returnType): self._returnType = returnType returnType.parent = self + + @property + def returnAllocatedObject(self): + return self.name.words[0] in ['create', 'new', 'clone'] def translate_as_prototype(self, translator, **params): return translator.translate_method_as_prototype(self, **params) diff --git a/wrappers/cpp/genwrapper.py b/wrappers/cpp/genwrapper.py index 6a87658dbe8a3ffd712da317caf996c9620fa3b1..26f2af82668e847960db428fbacb2e86861198cd 100755 --- a/wrappers/cpp/genwrapper.py +++ b/wrappers/cpp/genwrapper.py @@ -307,7 +307,7 @@ class CppTranslator(object): if exprtype.desc.refcountable: cppReturnType = CppTranslator.sharedPtrTypeExtractor.match(cppReturnType).group(2) - if isinstance(exprtype.parent, AbsApi.Method) and len(exprtype.parent.name.words) >=1 and (exprtype.parent.name.words[0] == 'create' or exprtype.parent.name.words[0] == 'new'): + if isinstance(exprtype.parent, AbsApi.Method) and len(exprtype.parent.name.words) >=1 and exprtype.parent.returnAllocatedObject: return 'Object::cPtrToSharedPtr<{0}>({1}, false)'.format(cppReturnType, cExpr) else: return 'Object::cPtrToSharedPtr<{0}>({1})'.format(cppReturnType, cExpr)