Only create typedef to SharedXXX where really needed.
parent
6b20b888a2
commit
98ed4d7850
|
@ -94,8 +94,6 @@ void GlobalFunction::generateSingleFunction(const string& toolboxPath,
|
|||
// start
|
||||
file.oss << "{\n";
|
||||
|
||||
returnVal.wrapTypeUnwrap(file);
|
||||
|
||||
// check arguments
|
||||
// NOTE: for static functions, there is no object passed
|
||||
file.oss << " checkArguments(\"" << matlabUniqueName
|
||||
|
|
|
@ -64,8 +64,8 @@ string Method::wrapper_call(FileWriter& wrapperFile, Str cppClassName,
|
|||
<< "\",nargout,nargin-1," << args.size() << ");\n";
|
||||
|
||||
// get class pointer
|
||||
// example: shared_ptr<Test> = unwrap_shared_ptr< Test >(in[0], "Test");
|
||||
wrapperFile.oss << " Shared obj = unwrap_shared_ptr<" << cppClassName
|
||||
// example: auto obj = unwrap_shared_ptr< Test >(in[0], "Test");
|
||||
wrapperFile.oss << " auto obj = unwrap_shared_ptr<" << cppClassName
|
||||
<< ">(in[0], \"ptr_" << matlabUniqueName << "\");" << endl;
|
||||
|
||||
// unwrap arguments, see Argument.cpp, we start at 1 as first is obj
|
||||
|
|
|
@ -108,11 +108,6 @@ string MethodBase::wrapper_fragment(
|
|||
// start
|
||||
wrapperFile.oss << "{\n";
|
||||
|
||||
returnVal.wrapTypeUnwrap(wrapperFile);
|
||||
|
||||
wrapperFile.oss << " typedef boost::shared_ptr<" << cppClassName
|
||||
<< "> Shared;" << endl;
|
||||
|
||||
// get call
|
||||
// for static methods: cppClassName::staticMethod<TemplateVal>
|
||||
// for instance methods: obj->instanceMethod<TemplateVal>
|
||||
|
|
|
@ -23,6 +23,7 @@ void ReturnType::wrap_result(const string& out, const string& result,
|
|||
const TypeAttributesTable& typeAttributes) const {
|
||||
string cppType = qualifiedName("::"), matlabType = qualifiedName(".");
|
||||
|
||||
const string sharedType = "Shared" + name();
|
||||
if (category == CLASS) {
|
||||
// Handle Classes
|
||||
string objCopy, ptrType;
|
||||
|
@ -35,9 +36,12 @@ void ReturnType::wrap_result(const string& out, const string& result,
|
|||
// A virtual class needs to be cloned, so the whole hierarchy is
|
||||
// returned
|
||||
objCopy = result + ".clone()";
|
||||
else
|
||||
else {
|
||||
// ...but a non-virtual class can just be copied
|
||||
objCopy = "Shared" + name() + "(new " + cppType + "(" + result + "))";
|
||||
wrapperFile.oss << " typedef boost::shared_ptr<" << qualifiedName("::")
|
||||
<< "> " << sharedType << ";" << endl;
|
||||
objCopy = sharedType + "(new " + cppType + "(" + result + "))";
|
||||
}
|
||||
}
|
||||
// e.g. out[1] = wrap_shared_ptr(pairResult.second,"gtsam.Point3", false);
|
||||
wrapperFile.oss << out << " = wrap_shared_ptr(" << objCopy << ",\""
|
||||
|
@ -46,8 +50,10 @@ void ReturnType::wrap_result(const string& out, const string& result,
|
|||
|
||||
} else if (isPtr) {
|
||||
// Handle shared pointer case for BASIS/EIGEN/VOID
|
||||
wrapperFile.oss << " {\n Shared" << name() << "* ret = new Shared"
|
||||
<< name() << "(" << result << ");" << endl;
|
||||
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
|
||||
<< "\");\n }\n";
|
||||
|
||||
|
@ -58,13 +64,6 @@ void ReturnType::wrap_result(const string& out, const string& result,
|
|||
<< ");\n";
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
void ReturnType::wrapTypeUnwrap(FileWriter& wrapperFile) const {
|
||||
if (category == CLASS)
|
||||
wrapperFile.oss << " typedef boost::shared_ptr<" << qualifiedName("::")
|
||||
<< "> Shared" << name() << ";" << endl;
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
void ReturnType::emit_cython_pxd(
|
||||
FileWriter& file, const std::string& className,
|
||||
|
|
|
@ -60,9 +60,6 @@ private:
|
|||
void wrap_result(const std::string& out, const std::string& result,
|
||||
FileWriter& wrapperFile,
|
||||
const TypeAttributesTable& typeAttributes) const;
|
||||
|
||||
/// Creates typedef
|
||||
void wrapTypeUnwrap(FileWriter& wrapperFile) const;
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
|
|
|
@ -40,7 +40,7 @@ void ReturnValue::wrap_result(const string& result, FileWriter& wrapperFile,
|
|||
if (isPair) {
|
||||
// For a pair, store the returned pair so we do not evaluate the function
|
||||
// twice
|
||||
wrapperFile.oss << " " << return_type(true) << " pairResult = " << result
|
||||
wrapperFile.oss << " auto pairResult = " << result
|
||||
<< ";\n";
|
||||
type1.wrap_result(" out[0]", "pairResult.first", wrapperFile,
|
||||
typeAttributes);
|
||||
|
@ -51,12 +51,6 @@ void ReturnValue::wrap_result(const string& result, FileWriter& wrapperFile,
|
|||
}
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
void ReturnValue::wrapTypeUnwrap(FileWriter& wrapperFile) const {
|
||||
type1.wrapTypeUnwrap(wrapperFile);
|
||||
if (isPair) type2.wrapTypeUnwrap(wrapperFile);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
void ReturnValue::emit_matlab(FileWriter& proxyFile) const {
|
||||
string output;
|
||||
|
|
|
@ -70,8 +70,6 @@ struct ReturnValue {
|
|||
void wrap_result(const std::string& result, FileWriter& wrapperFile,
|
||||
const TypeAttributesTable& typeAttributes) const;
|
||||
|
||||
void wrapTypeUnwrap(FileWriter& wrapperFile) const;
|
||||
|
||||
void emit_matlab(FileWriter& proxyFile) const;
|
||||
|
||||
/// @param className the actual class name to use when "This" is specified
|
||||
|
|
Loading…
Reference in New Issue