diff --git a/wrap/Function.cpp b/wrap/Function.cpp index 29165c64b..b939c3cee 100644 --- a/wrap/Function.cpp +++ b/wrap/Function.cpp @@ -55,10 +55,10 @@ bool Function::initializeOrCheck(const string& name, const Qualified& instName, /* ************************************************************************* */ void Function::emit_call(FileWriter& proxyFile, const ReturnValue& returnVal, - const string& wrapperName, int id, bool staticMethod) const { + const string& wrapperName, int id) const { returnVal.emit_matlab(proxyFile); proxyFile.oss << wrapperName << "(" << id; - if (!staticMethod) + if (!isStatic()) proxyFile.oss << ", this"; proxyFile.oss << ", varargin{:});\n"; } @@ -66,14 +66,14 @@ void Function::emit_call(FileWriter& proxyFile, const ReturnValue& returnVal, /* ************************************************************************* */ void Function::emit_conditional_call(FileWriter& proxyFile, const ReturnValue& returnVal, const ArgumentList& args, - const string& wrapperName, int id, bool staticMethod) const { + const string& wrapperName, int id) const { // Check all arguments args.proxy_check_arguments(proxyFile); // output call to C++ wrapper proxyFile.oss << " "; - emit_call(proxyFile, returnVal, wrapperName, id, staticMethod); + emit_call(proxyFile, returnVal, wrapperName, id); } /* ************************************************************************* */ diff --git a/wrap/Function.h b/wrap/Function.h index 388e6568b..249cd42a7 100644 --- a/wrap/Function.h +++ b/wrap/Function.h @@ -44,6 +44,11 @@ public: return name_; } + /// Only Methods are non-static + virtual bool isStatic() const { + return true; + } + std::string matlabName() const { if (templateArgValue_.empty()) return name_; @@ -53,12 +58,12 @@ public: /// Emit function call to MATLAB (no argument checking) void emit_call(FileWriter& proxyFile, const ReturnValue& returnVal, - const std::string& wrapperName, int id, bool staticMethod) const; + const std::string& wrapperName, int id) const; /// Emit checking arguments and function call to MATLAB void emit_conditional_call(FileWriter& proxyFile, const ReturnValue& returnVal, const ArgumentList& args, - const std::string& wrapperName, int id, bool staticMethod) const; + const std::string& wrapperName, int id) const; }; diff --git a/wrap/GlobalFunction.cpp b/wrap/GlobalFunction.cpp index 18f5c5f6c..dfeb46dce 100644 --- a/wrap/GlobalFunction.cpp +++ b/wrap/GlobalFunction.cpp @@ -80,8 +80,7 @@ void GlobalFunction::generateSingleFunction(const string& toolboxPath, // Output proxy matlab code mfunctionFile.oss << " " << (i == 0 ? "" : "else"); - emit_conditional_call(mfunctionFile, returnVal, args, wrapperName, id, - true); // true omits "this" + emit_conditional_call(mfunctionFile, returnVal, args, wrapperName, id); // Output C++ wrapper code diff --git a/wrap/MethodBase.cpp b/wrap/MethodBase.cpp index 124963d9a..643d8ceec 100644 --- a/wrap/MethodBase.cpp +++ b/wrap/MethodBase.cpp @@ -55,7 +55,7 @@ void MethodBase::proxy_wrapper_fragments(FileWriter& proxyFile, // TODO: document why is it OK to not check arguments in this case proxyFile.oss << " "; const int id = (int) functionNames.size(); - emit_call(proxyFile, returnValue(0), wrapperName, id, isStatic()); + emit_call(proxyFile, returnValue(0), wrapperName, id); // Output C++ wrapper code const string wrapFunctionName = wrapper_fragment(wrapperFile, cppClassName, @@ -71,7 +71,7 @@ void MethodBase::proxy_wrapper_fragments(FileWriter& proxyFile, proxyFile.oss << " " << (i == 0 ? "" : "else"); const int id = (int) functionNames.size(); emit_conditional_call(proxyFile, returnValue(i), argumentList(i), - wrapperName, id, isStatic()); + wrapperName, id); // Output C++ wrapper code const string wrapFunctionName = wrapper_fragment(wrapperFile, diff --git a/wrap/MethodBase.h b/wrap/MethodBase.h index da50b8124..0aabe819d 100644 --- a/wrap/MethodBase.h +++ b/wrap/MethodBase.h @@ -28,8 +28,6 @@ struct MethodBase: public FullyOverloadedFunction { typedef const std::string& Str; - virtual bool isStatic() const = 0; - // emit a list of comments, one for each overload void comment_fragment(FileWriter& proxyFile) const { SignatureOverloads::comment_fragment(proxyFile, matlabName()); diff --git a/wrap/StaticMethod.h b/wrap/StaticMethod.h index cc8401cad..c3bf526dd 100644 --- a/wrap/StaticMethod.h +++ b/wrap/StaticMethod.h @@ -28,10 +28,6 @@ struct StaticMethod: public MethodBase { typedef const std::string& Str; - virtual bool isStatic() const { - return true; - } - friend std::ostream& operator<<(std::ostream& os, const StaticMethod& m) { for (size_t i = 0; i < m.nrOverloads(); i++) os << "static " << m.returnVals_[i] << " " << m.name_ << m.argLists_[i];