Better Documentation

release/4.3a0
dellaert 2014-12-01 10:21:23 +01:00
parent 7362b4e393
commit 9bebedc684
1 changed files with 21 additions and 12 deletions

View File

@ -24,30 +24,39 @@ void ReturnType::wrap_result(const string& out, const string& result,
string cppType = qualifiedName("::"), matlabType = qualifiedName(".");
if (category == CLASS) {
// Handle Classes
string objCopy, ptrType;
ptrType = "Shared" + name();
const bool isVirtual = typeAttributes.attributes(cppType).isVirtual;
if (isVirtual) {
if (isPtr)
objCopy = result;
else
if (isPtr)
objCopy = result; // a shared pointer can always be passed as is
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()";
} else {
if (isPtr)
objCopy = result;
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 << ",\""
<< matlabType << "\", " << (isVirtual ? "true" : "false") << ");\n";
} 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
<< "\");\n";
<< "\");\n}\n";
} else if (matlabType != "void")
// Handle normal case case for BASIS/EIGEN
wrapperFile.oss << out << " = wrap< " << str(false) << " >(" << result
<< ");\n";
}
/* ************************************************************************* */