MAde some method private, and renamed return_type -> str
parent
bad8e85c11
commit
2ad5a51e74
|
@ -16,13 +16,13 @@ using namespace std;
|
||||||
using namespace wrap;
|
using namespace wrap;
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
string ReturnType::return_type(bool add_ptr) const {
|
string ReturnType::str(bool add_ptr) const {
|
||||||
return maybe_shared_ptr(add_ptr || isPtr, qualifiedName("::"), name);
|
return maybe_shared_ptr(add_ptr && isPtr, qualifiedName("::"), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void ReturnType::wrap_result(const string& result, FileWriter& file,
|
void ReturnType::wrap_result(const string& out, const string& result,
|
||||||
const TypeAttributesTable& typeAttributes) const {
|
FileWriter& file, const TypeAttributesTable& typeAttributes) const {
|
||||||
|
|
||||||
string cppType = qualifiedName("::"), matlabType = qualifiedName(".");
|
string cppType = qualifiedName("::"), matlabType = qualifiedName(".");
|
||||||
|
|
||||||
|
@ -41,15 +41,14 @@ void ReturnType::wrap_result(const string& result, FileWriter& file,
|
||||||
else
|
else
|
||||||
objCopy = ptrType + "(new " + cppType + "(" + result + "))";
|
objCopy = ptrType + "(new " + cppType + "(" + result + "))";
|
||||||
}
|
}
|
||||||
file.oss << " out[0] = wrap_shared_ptr(" << objCopy << ",\"" << matlabType
|
file.oss << out << " = wrap_shared_ptr(" << objCopy << ",\"" << matlabType
|
||||||
<< "\", " << (isVirtual ? "true" : "false") << ");\n";
|
<< "\", " << (isVirtual ? "true" : "false") << ");\n";
|
||||||
} else if (isPtr) {
|
} else if (isPtr) {
|
||||||
file.oss << " Shared" << name << "* ret = new Shared" << name << "("
|
file.oss << " Shared" << name << "* ret = new Shared" << name << "("
|
||||||
<< result << ");" << endl;
|
<< result << ");" << endl;
|
||||||
file.oss << " out[0] = wrap_shared_ptr(ret,\"" << matlabType << "\");\n";
|
file.oss << out << " = wrap_shared_ptr(ret,\"" << matlabType << "\");\n";
|
||||||
} else if (matlabType != "void")
|
} else if (matlabType != "void")
|
||||||
file.oss << " out[0] = wrap< " << return_type(true) << " >(" << result
|
file.oss << out << " = wrap< " << str(false) << " >(" << result << ");\n";
|
||||||
<< ");\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
@ -61,8 +60,10 @@ void ReturnType::wrapTypeUnwrap(FileWriter& file) const {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
string ReturnValue::return_type(bool add_ptr) const {
|
string ReturnValue::return_type(bool add_ptr) const {
|
||||||
return "pair< " + type1.return_type(add_ptr) + ", "
|
if (isPair)
|
||||||
+ type2.return_type(add_ptr) + " >";
|
return "pair< " + type1.str(add_ptr) + ", " + type2.str(add_ptr) + " >";
|
||||||
|
else
|
||||||
|
return type1.str(add_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
@ -75,12 +76,12 @@ void ReturnValue::wrap_result(const string& result, FileWriter& file,
|
||||||
const TypeAttributesTable& typeAttributes) const {
|
const TypeAttributesTable& typeAttributes) const {
|
||||||
if (isPair) {
|
if (isPair) {
|
||||||
// For a pair, store the returned pair so we do not evaluate the function twice
|
// For a pair, store the returned pair so we do not evaluate the function twice
|
||||||
file.oss << " " << return_type(false) << " pairResult = " << result
|
file.oss << " " << return_type(true) << " pairResult = " << result
|
||||||
<< ";\n";
|
<< ";\n";
|
||||||
type1.wrap_result("pairResult.first", file, typeAttributes);
|
type1.wrap_result(" out[0]", "pairResult.first", file, typeAttributes);
|
||||||
type2.wrap_result("pairResult.second", file, typeAttributes);
|
type2.wrap_result(" out[1]", "pairResult.second", file, typeAttributes);
|
||||||
} else { // Not a pair
|
} else { // Not a pair
|
||||||
type1.wrap_result(result, file, typeAttributes);
|
type1.wrap_result(" out[0]", result, file, typeAttributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,19 +30,14 @@ struct ReturnType : Qualified {
|
||||||
bool isPtr;
|
bool isPtr;
|
||||||
return_category category;
|
return_category category;
|
||||||
|
|
||||||
ReturnType(): isPtr(false), category(CLASS) {
|
ReturnType() :
|
||||||
|
isPtr(false), category(CLASS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnType(const Qualified& q): Qualified(q), isPtr(false), category(CLASS) {
|
ReturnType(const Qualified& q) :
|
||||||
|
Qualified(q), isPtr(false), category(CLASS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string return_type(bool add_ptr) const;
|
|
||||||
|
|
||||||
void wrap_result(const std::string& result, FileWriter& file,
|
|
||||||
const TypeAttributesTable& typeAttributes) const;
|
|
||||||
|
|
||||||
void wrapTypeUnwrap(FileWriter& wrapperFile) const;
|
|
||||||
|
|
||||||
/// Check if this type is in a set of valid types
|
/// Check if this type is in a set of valid types
|
||||||
template<class TYPES>
|
template<class TYPES>
|
||||||
void verify(TYPES validtypes, const std::string& s) const {
|
void verify(TYPES validtypes, const std::string& s) const {
|
||||||
|
@ -51,6 +46,19 @@ struct ReturnType : Qualified {
|
||||||
throw DependencyMissing(key, s);
|
throw DependencyMissing(key, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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& file, const TypeAttributesTable& typeAttributes) const;
|
||||||
|
|
||||||
|
/// Creates typedef
|
||||||
|
void wrapTypeUnwrap(FileWriter& wrapperFile) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +70,8 @@ struct ReturnValue {
|
||||||
ReturnType type1, type2;
|
ReturnType type1, type2;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ReturnValue() : isPair(false) {
|
ReturnValue() :
|
||||||
|
isPair(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string return_type(bool add_ptr) const;
|
std::string return_type(bool add_ptr) const;
|
||||||
|
|
Loading…
Reference in New Issue