From 52cd2007181d2561abefd6d4e4e95db5a9e5d6ad Mon Sep 17 00:00:00 2001 From: dellaert Date: Sun, 25 May 2014 14:52:49 -0400 Subject: [PATCH] ReturnValue now emits, eliminated some copy/paste. Also removed unused verbose field/argument in ReturnValue --- wrap/Argument.cpp | 11 +++-------- wrap/GlobalFunction.cpp | 11 +++-------- wrap/Method.cpp | 2 ++ wrap/Module.cpp | 2 +- wrap/ReturnValue.cpp | 8 ++++++++ wrap/ReturnValue.h | 8 ++++---- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/wrap/Argument.cpp b/wrap/Argument.cpp index 2ee705c5b..1d7c43809 100644 --- a/wrap/Argument.cpp +++ b/wrap/Argument.cpp @@ -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"; diff --git a/wrap/GlobalFunction.cpp b/wrap/GlobalFunction.cpp index 16f6d48f1..588cbf7c8 100644 --- a/wrap/GlobalFunction.cpp +++ b/wrap/GlobalFunction.cpp @@ -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 diff --git a/wrap/Method.cpp b/wrap/Method.cpp index 7018ad138..c0ec79e91 100644 --- a/wrap/Method.cpp +++ b/wrap/Method.cpp @@ -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) { diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 6870d5178..2cb5ea7ed 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -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 arg_dup; ///keep track of duplicates diff --git a/wrap/ReturnValue.cpp b/wrap/ReturnValue.cpp index 3cb68181b..78e36d4da 100644 --- a/wrap/ReturnValue.cpp +++ b/wrap/ReturnValue.cpp @@ -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} = "; +} +/* ************************************************************************* */ diff --git a/wrap/ReturnValue.h b/wrap/ReturnValue.h index 2bc5aa82b..989f81109 100644 --- a/wrap/ReturnValue.h +++ b/wrap/ReturnValue.h @@ -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 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