ReturnValue now emits, eliminated some copy/paste. Also removed unused verbose field/argument in ReturnValue

release/4.3a0
dellaert 2014-05-25 14:52:49 -04:00
parent 05008ecaa3
commit 52cd200718
6 changed files with 21 additions and 21 deletions

View File

@ -170,14 +170,9 @@ void ArgumentList::emit_conditional_call(FileWriter& file,
file.oss << "\n";
// output call to C++ wrapper
string output;
if (returnVal.isPair)
output = "[ varargout{1} varargout{2} ] = ";
else if (returnVal.category1 == ReturnValue::VOID)
output = "";
else
output = "varargout{1} = ";
file.oss << " " << output << wrapperName << "(" << id;
file.oss << " ";
returnVal.emit_matlab(file);
file.oss << wrapperName << "(" << id;
if (!staticMethod)
file.oss << ", this";
file.oss << ", varargin{:});\n";

View File

@ -103,14 +103,9 @@ void GlobalFunction::generateSingleFunction(const std::string& toolboxPath, cons
mfunctionFile.oss << "\n";
// output call to C++ wrapper
string output;
if(returnVal.isPair)
output = "[ varargout{1} varargout{2} ] = ";
else if(returnVal.category1 == ReturnValue::VOID)
output = "";
else
output = "varargout{1} = ";
mfunctionFile.oss << " " << output << wrapperName << "(" << id << ", varargin{:});\n";
mfunctionFile.oss << " ";
returnVal.emit_matlab(mfunctionFile);
mfunctionFile.oss << wrapperName << "(" << id << ", varargin{:});\n";
// Output C++ wrapper code

View File

@ -78,6 +78,8 @@ void Method::proxy_wrapper_fragments(FileWriter& file, FileWriter& wrapperFile,
}
}
// Handle special case of single overload with numeric
// Check arguments for all overloads
for (size_t overload = 0; overload < argLists.size(); ++overload) {

View File

@ -98,7 +98,7 @@ void Module::parseMarkup(const std::string& data) {
// The one with postfix 0 are used to reset the variables after parse.
string methodName, methodName0;
bool isConst, isConst0 = false;
ReturnValue retVal0(verbose), retVal(verbose);
ReturnValue retVal0, retVal;
Argument arg0, arg;
ArgumentList args0, args;
vector<string> arg_dup; ///keep track of duplicates

View File

@ -141,5 +141,13 @@ void ReturnValue::wrapTypeUnwrap(FileWriter& wrapperFile) const {
}
}
/* ************************************************************************* */
void ReturnValue::emit_matlab(FileWriter& file) const {
string output;
if (isPair)
file.oss << "[ varargout{1} varargout{2} ] = ";
else if (category1 != ReturnValue::VOID)
file.oss << "varargout{1} = ";
}
/* ************************************************************************* */

View File

@ -27,16 +27,15 @@ struct ReturnValue {
CLASS = 1, EIGEN = 2, BASIS = 3, VOID = 4
} return_category;
bool verbose;
bool isPtr1, isPtr2, isPair;
return_category category1, category2;
std::string type1, type2;
std::vector<std::string> namespaces1, namespaces2;
/// Constructor
ReturnValue(bool enable_verbosity = true) :
verbose(enable_verbosity), isPtr1(false), isPtr2(false), isPair(false), category1(
CLASS), category2(CLASS) {
ReturnValue() :
isPtr1(false), isPtr2(false), isPair(false), category1(CLASS), category2(
CLASS) {
}
typedef enum {
@ -55,6 +54,7 @@ struct ReturnValue {
void wrapTypeUnwrap(FileWriter& wrapperFile) const;
void emit_matlab(FileWriter& file) const;
};
} // \namespace wrap