diff --git a/wrap/FullyOverloadedFunction.h b/wrap/FullyOverloadedFunction.h index 87c5169dd..bf7051662 100644 --- a/wrap/FullyOverloadedFunction.h +++ b/wrap/FullyOverloadedFunction.h @@ -79,8 +79,8 @@ public: if (argLCount != nrOverloads() - 1) proxyFile.oss << ", "; else - proxyFile.oss << " : returns " << returnValue(0).return_type(false) - << std::endl; + proxyFile.oss << " : returns " << returnValue(0).returnType() + << std::endl; argLCount++; } } @@ -91,8 +91,8 @@ public: for(ArgumentList argList: argLists_) { proxyFile.oss << "%"; argList.emit_prototype(proxyFile, name); - proxyFile.oss << " : returns " << returnVals_[i++].return_type(false) - << std::endl; + proxyFile.oss << " : returns " << returnVals_[i++].returnType() + << std::endl; } } diff --git a/wrap/ReturnType.cpp b/wrap/ReturnType.cpp index a97b1cf31..d308bc28a 100644 --- a/wrap/ReturnType.cpp +++ b/wrap/ReturnType.cpp @@ -12,18 +12,12 @@ using namespace std; using namespace wrap; -/* ************************************************************************* */ -string ReturnType::str(bool add_ptr) const { - return maybe_shared_ptr(add_ptr && isPtr, qualifiedName("::"), name()); -} - /* ************************************************************************* */ void ReturnType::wrap_result(const string& out, const string& result, FileWriter& wrapperFile, const TypeAttributesTable& typeAttributes) const { string cppType = qualifiedName("::"), matlabType = qualifiedName("."); - const string sharedType = "Shared" + name(); if (category == CLASS) { // Handle Classes string objCopy, ptrType; @@ -38,9 +32,7 @@ void ReturnType::wrap_result(const string& out, const string& result, objCopy = result + ".clone()"; else { // ...but a non-virtual class can just be copied - wrapperFile.oss << " typedef boost::shared_ptr<" << qualifiedName("::") - << "> " << sharedType << ";" << endl; - objCopy = sharedType + "(new " + cppType + "(" + result + "))"; + objCopy = "boost::make_shared<" + cppType + ">(" + result + ")"; } } // e.g. out[1] = wrap_shared_ptr(pairResult.second,"gtsam.Point3", false); @@ -50,17 +42,15 @@ void ReturnType::wrap_result(const string& out, const string& result, } else if (isPtr) { // Handle shared pointer case for BASIS/EIGEN/VOID - wrapperFile.oss << " typedef boost::shared_ptr<" << qualifiedName("::") - << "> " << sharedType << ";" << endl; - wrapperFile.oss << " {\n auto ret = new " << sharedType << "(" << result - << ");" << endl; - wrapperFile.oss << out << " = wrap_shared_ptr(ret,\"" << matlabType + // This case does not actually occur in GTSAM wrappers, so untested! + wrapperFile.oss << " {\n boost::shared_ptr<" << qualifiedName("::") + << "> shared(" << result << ");" << endl; + wrapperFile.oss << out << " = wrap_shared_ptr(shared,\"" << matlabType << "\");\n }\n"; } else if (matlabType != "void") - // Handle normal case case for BASIS/EIGEN - wrapperFile.oss << out << " = wrap< " << str(false) << " >(" << result + wrapperFile.oss << out << " = wrap< " << qualifiedName("::") << " >(" << result << ");\n"; } diff --git a/wrap/ReturnType.h b/wrap/ReturnType.h index e4b5b193f..ba5086507 100644 --- a/wrap/ReturnType.h +++ b/wrap/ReturnType.h @@ -54,8 +54,6 @@ struct ReturnType : public Qualified { private: friend struct ReturnValue; - std::string str(bool add_ptr) const; - /// Example: out[1] = wrap_shared_ptr(pairResult.second,"Test", false); void wrap_result(const std::string& out, const std::string& result, FileWriter& wrapperFile, diff --git a/wrap/ReturnValue.cpp b/wrap/ReturnValue.cpp index 9bdd9f5fb..e58e85602 100644 --- a/wrap/ReturnValue.cpp +++ b/wrap/ReturnValue.cpp @@ -22,11 +22,12 @@ ReturnValue ReturnValue::expandTemplate(const TemplateSubstitution& ts) const { } /* ************************************************************************* */ -string ReturnValue::return_type(bool add_ptr) const { +string ReturnValue::returnType() const { if (isPair) - return "pair< " + type1.str(add_ptr) + ", " + type2.str(add_ptr) + " >"; + return "pair< " + type1.qualifiedName("::") + ", " + + type2.qualifiedName("::") + " >"; else - return type1.str(add_ptr); + return type1.qualifiedName("::"); } /* ************************************************************************* */ diff --git a/wrap/ReturnValue.h b/wrap/ReturnValue.h index 3e3ca1cc7..721132797 100644 --- a/wrap/ReturnValue.h +++ b/wrap/ReturnValue.h @@ -63,7 +63,7 @@ struct ReturnValue { /// Substitute template argument ReturnValue expandTemplate(const TemplateSubstitution& ts) const; - std::string return_type(bool add_ptr) const; + std::string returnType() const; std::string matlab_returnType() const; @@ -82,7 +82,7 @@ struct ReturnValue { if (!r.isPair && r.type1.category == ReturnType::VOID) os << "void"; else - os << r.return_type(true); + os << r.returnType(); return os; }