ReturnValue now emits, eliminated some copy/paste. Also removed unused verbose field/argument in ReturnValue
parent
05008ecaa3
commit
52cd200718
|
@ -170,14 +170,9 @@ void ArgumentList::emit_conditional_call(FileWriter& file,
|
||||||
file.oss << "\n";
|
file.oss << "\n";
|
||||||
|
|
||||||
// output call to C++ wrapper
|
// output call to C++ wrapper
|
||||||
string output;
|
file.oss << " ";
|
||||||
if (returnVal.isPair)
|
returnVal.emit_matlab(file);
|
||||||
output = "[ varargout{1} varargout{2} ] = ";
|
file.oss << wrapperName << "(" << id;
|
||||||
else if (returnVal.category1 == ReturnValue::VOID)
|
|
||||||
output = "";
|
|
||||||
else
|
|
||||||
output = "varargout{1} = ";
|
|
||||||
file.oss << " " << output << wrapperName << "(" << id;
|
|
||||||
if (!staticMethod)
|
if (!staticMethod)
|
||||||
file.oss << ", this";
|
file.oss << ", this";
|
||||||
file.oss << ", varargin{:});\n";
|
file.oss << ", varargin{:});\n";
|
||||||
|
|
|
@ -103,14 +103,9 @@ void GlobalFunction::generateSingleFunction(const std::string& toolboxPath, cons
|
||||||
mfunctionFile.oss << "\n";
|
mfunctionFile.oss << "\n";
|
||||||
|
|
||||||
// output call to C++ wrapper
|
// output call to C++ wrapper
|
||||||
string output;
|
mfunctionFile.oss << " ";
|
||||||
if(returnVal.isPair)
|
returnVal.emit_matlab(mfunctionFile);
|
||||||
output = "[ varargout{1} varargout{2} ] = ";
|
mfunctionFile.oss << wrapperName << "(" << id << ", varargin{:});\n";
|
||||||
else if(returnVal.category1 == ReturnValue::VOID)
|
|
||||||
output = "";
|
|
||||||
else
|
|
||||||
output = "varargout{1} = ";
|
|
||||||
mfunctionFile.oss << " " << output << wrapperName << "(" << id << ", varargin{:});\n";
|
|
||||||
|
|
||||||
// Output C++ wrapper code
|
// Output C++ wrapper code
|
||||||
|
|
||||||
|
|
|
@ -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
|
// Check arguments for all overloads
|
||||||
for (size_t overload = 0; overload < argLists.size(); ++overload) {
|
for (size_t overload = 0; overload < argLists.size(); ++overload) {
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ void Module::parseMarkup(const std::string& data) {
|
||||||
// The one with postfix 0 are used to reset the variables after parse.
|
// The one with postfix 0 are used to reset the variables after parse.
|
||||||
string methodName, methodName0;
|
string methodName, methodName0;
|
||||||
bool isConst, isConst0 = false;
|
bool isConst, isConst0 = false;
|
||||||
ReturnValue retVal0(verbose), retVal(verbose);
|
ReturnValue retVal0, retVal;
|
||||||
Argument arg0, arg;
|
Argument arg0, arg;
|
||||||
ArgumentList args0, args;
|
ArgumentList args0, args;
|
||||||
vector<string> arg_dup; ///keep track of duplicates
|
vector<string> arg_dup; ///keep track of duplicates
|
||||||
|
|
|
@ -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} = ";
|
||||||
|
}
|
||||||
|
/* ************************************************************************* */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,15 @@ struct ReturnValue {
|
||||||
CLASS = 1, EIGEN = 2, BASIS = 3, VOID = 4
|
CLASS = 1, EIGEN = 2, BASIS = 3, VOID = 4
|
||||||
} return_category;
|
} return_category;
|
||||||
|
|
||||||
bool verbose;
|
|
||||||
bool isPtr1, isPtr2, isPair;
|
bool isPtr1, isPtr2, isPair;
|
||||||
return_category category1, category2;
|
return_category category1, category2;
|
||||||
std::string type1, type2;
|
std::string type1, type2;
|
||||||
std::vector<std::string> namespaces1, namespaces2;
|
std::vector<std::string> namespaces1, namespaces2;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ReturnValue(bool enable_verbosity = true) :
|
ReturnValue() :
|
||||||
verbose(enable_verbosity), isPtr1(false), isPtr2(false), isPair(false), category1(
|
isPtr1(false), isPtr2(false), isPair(false), category1(CLASS), category2(
|
||||||
CLASS), category2(CLASS) {
|
CLASS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -55,6 +54,7 @@ struct ReturnValue {
|
||||||
|
|
||||||
void wrapTypeUnwrap(FileWriter& wrapperFile) const;
|
void wrapTypeUnwrap(FileWriter& wrapperFile) const;
|
||||||
|
|
||||||
|
void emit_matlab(FileWriter& file) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // \namespace wrap
|
} // \namespace wrap
|
||||||
|
|
Loading…
Reference in New Issue