Better Documentation
parent
7362b4e393
commit
9bebedc684
|
@ -24,30 +24,39 @@ void ReturnType::wrap_result(const string& out, const string& result,
|
||||||
string cppType = qualifiedName("::"), matlabType = qualifiedName(".");
|
string cppType = qualifiedName("::"), matlabType = qualifiedName(".");
|
||||||
|
|
||||||
if (category == CLASS) {
|
if (category == CLASS) {
|
||||||
|
|
||||||
|
// Handle Classes
|
||||||
string objCopy, ptrType;
|
string objCopy, ptrType;
|
||||||
ptrType = "Shared" + name();
|
|
||||||
const bool isVirtual = typeAttributes.attributes(cppType).isVirtual;
|
const bool isVirtual = typeAttributes.attributes(cppType).isVirtual;
|
||||||
if (isVirtual) {
|
if (isPtr)
|
||||||
if (isPtr)
|
objCopy = result; // a shared pointer can always be passed as is
|
||||||
objCopy = result;
|
else {
|
||||||
else
|
// but if we want an actual new object, things get more complex
|
||||||
|
if (isVirtual)
|
||||||
|
// A virtual class needs to be cloned, so the whole hierarchy is returned
|
||||||
objCopy = result + ".clone()";
|
objCopy = result + ".clone()";
|
||||||
} else {
|
|
||||||
if (isPtr)
|
|
||||||
objCopy = result;
|
|
||||||
else
|
else
|
||||||
objCopy = ptrType + "(new " + cppType + "(" + result + "))";
|
// ...but a non-virtual class can just be copied
|
||||||
|
objCopy = "Shared" + name() + "(new " + cppType + "(" + result + "))";
|
||||||
}
|
}
|
||||||
|
// e.g. out[1] = wrap_shared_ptr(pairResult.second,"gtsam.Point3", false);
|
||||||
wrapperFile.oss << out << " = wrap_shared_ptr(" << objCopy << ",\""
|
wrapperFile.oss << out << " = wrap_shared_ptr(" << objCopy << ",\""
|
||||||
<< matlabType << "\", " << (isVirtual ? "true" : "false") << ");\n";
|
<< matlabType << "\", " << (isVirtual ? "true" : "false") << ");\n";
|
||||||
|
|
||||||
} else if (isPtr) {
|
} else if (isPtr) {
|
||||||
wrapperFile.oss << " Shared" << name() << "* ret = new Shared" << name() << "("
|
|
||||||
<< result << ");" << endl;
|
// Handle shared pointer case for BASIS/EIGEN/VOID
|
||||||
|
wrapperFile.oss << "{\n Shared" << name() << "* ret = new Shared" << name()
|
||||||
|
<< "(" << result << ");" << endl;
|
||||||
wrapperFile.oss << out << " = wrap_shared_ptr(ret,\"" << matlabType
|
wrapperFile.oss << out << " = wrap_shared_ptr(ret,\"" << matlabType
|
||||||
<< "\");\n";
|
<< "\");\n}\n";
|
||||||
|
|
||||||
} else if (matlabType != "void")
|
} else if (matlabType != "void")
|
||||||
|
|
||||||
|
// Handle normal case case for BASIS/EIGEN
|
||||||
wrapperFile.oss << out << " = wrap< " << str(false) << " >(" << result
|
wrapperFile.oss << out << " = wrap< " << str(false) << " >(" << result
|
||||||
<< ");\n";
|
<< ");\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
Loading…
Reference in New Issue