diff --git a/wrap/Argument.cpp b/wrap/Argument.cpp index a3c0987d8..d49e00d82 100644 --- a/wrap/Argument.cpp +++ b/wrap/Argument.cpp @@ -36,7 +36,8 @@ Argument Argument::expandTemplate(const TemplateSubstitution& ts) const { } /* ************************************************************************* */ -ArgumentList ArgumentList::expandTemplate(const TemplateSubstitution& ts) const { +ArgumentList ArgumentList::expandTemplate( + const TemplateSubstitution& ts) const { ArgumentList instArgList; BOOST_FOREACH(const Argument& arg, *this) { Argument instArg = arg.expandTemplate(ts); @@ -97,6 +98,12 @@ void Argument::matlab_unwrap(FileWriter& file, const string& matlabName) const { file.oss << ");" << endl; } +/* ************************************************************************* */ +void Argument::proxy_check(FileWriter& proxyFile, size_t sequenceNr) const { + proxyFile.oss << "isa(varargin{" << sequenceNr << "},'" << matlabClass(".") + << "')"; +} + /* ************************************************************************* */ string ArgumentList::types() const { string str; @@ -177,7 +184,7 @@ void ArgumentList::emit_prototype(FileWriter& file, const string& name) const { } /* ************************************************************************* */ -void ArgumentList::proxy_check_arguments(FileWriter& proxyFile) const { +void ArgumentList::proxy_check(FileWriter& proxyFile) const { // Check nr of arguments proxyFile.oss << "if length(varargin) == " << size(); if (size() > 0) @@ -187,11 +194,11 @@ void ArgumentList::proxy_check_arguments(FileWriter& proxyFile) const { for (size_t i = 0; i < size(); i++) { if (!first) proxyFile.oss << " && "; - proxyFile.oss << "isa(varargin{" << i + 1 << "},'" - << (*this)[i].matlabClass(".") << "')"; + (*this)[i].proxy_check(proxyFile, i + 1); first = false; } proxyFile.oss << "\n"; } + /* ************************************************************************* */ diff --git a/wrap/Argument.h b/wrap/Argument.h index f207e0766..b440e3941 100644 --- a/wrap/Argument.h +++ b/wrap/Argument.h @@ -46,6 +46,12 @@ struct Argument { /// MATLAB code generation, MATLAB to C++ void matlab_unwrap(FileWriter& file, const std::string& matlabName) const; + /** + * emit checking argument to MATLAB proxy + * @param proxyFile output stream + */ + void proxy_check(FileWriter& proxyFile, size_t sequenceNr) const; + friend std::ostream& operator<<(std::ostream& os, const Argument& arg) { os << (arg.is_const ? "const " : "") << arg.type << (arg.is_ptr ? "*" : "") << (arg.is_ref ? "&" : ""); @@ -91,7 +97,7 @@ struct ArgumentList: public std::vector { * emit checking arguments to MATLAB proxy * @param proxyFile output stream */ - void proxy_check_arguments(FileWriter& proxyFile) const; + void proxy_check(FileWriter& proxyFile) const; /// Output stream operator friend std::ostream& operator<<(std::ostream& os, @@ -106,7 +112,6 @@ struct ArgumentList: public std::vector { return os; } - }; } // \namespace wrap diff --git a/wrap/Function.cpp b/wrap/Function.cpp index b939c3cee..d045d2915 100644 --- a/wrap/Function.cpp +++ b/wrap/Function.cpp @@ -69,7 +69,7 @@ void Function::emit_conditional_call(FileWriter& proxyFile, const string& wrapperName, int id) const { // Check all arguments - args.proxy_check_arguments(proxyFile); + args.proxy_check(proxyFile); // output call to C++ wrapper proxyFile.oss << " ";