diff --git a/wrap/Argument.cpp b/wrap/Argument.cpp index 339fc4a97..6fe26834e 100644 --- a/wrap/Argument.cpp +++ b/wrap/Argument.cpp @@ -26,11 +26,13 @@ using namespace std; using namespace wrap; /* ************************************************************************* */ -string Argument::matlabClass() const { - if (type=="string") return string("char"); +string Argument::matlabClass(const string& delim) const { + string result; + BOOST_FOREACH(const string& ns, namespaces) result += ns + delim; + if (type=="string") return result + "char"; if (type=="bool" || type=="int" || type=="size_t" || type=="Vector" || type=="Matrix") - return string("double"); - return type; + return result + "double"; + return result + type; } /* ************************************************************************* */ diff --git a/wrap/Argument.h b/wrap/Argument.h index 2c71eed2b..000e3079a 100644 --- a/wrap/Argument.h +++ b/wrap/Argument.h @@ -36,7 +36,7 @@ struct Argument { } /// return MATLAB class for use in isa(x,class) - std::string matlabClass() const; + std::string matlabClass(const std::string& delim = "") const; /// adds namespaces to type std::string qualifiedType(const std::string& delim = "") const; diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 499be6635..bf029fda0 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -65,13 +65,12 @@ Module::Module(const string& interfacePath, // defined within the square brackets [] and are executed whenever a // rule is successfully parsed. Define BOOST_SPIRIT_DEBUG to debug. // The grammar is allows a very restricted C++ header + // lexeme_d turns off white space skipping + // http://www.boost.org/doc/libs/1_37_0/libs/spirit/classic/doc/directives.html // ---------------------------------------------------------------------------- Rule comments_p = comment_p("/*", "*/") | comment_p("//", eol_p); - // lexeme_d turns off white space skipping - // http://www.boost.org/doc/libs/1_37_0/libs/spirit/classic/doc/directives.html - Rule basisType_p = (str_p("string") | "bool" | "size_t" | "int" | "double" | "char"); @@ -87,17 +86,6 @@ Module::Module(const string& interfacePath, Rule namespace_arg_p = namespace_name_p[push_back_a(arg.namespaces)] >> str_p("::"); - Rule classPtr_p = - *namespace_arg_p >> - className_p [assign_a(arg.type)] >> - ch_p('*') [assign_a(arg.is_ptr,true)]; - - Rule classRef_p = - !str_p("const") [assign_a(arg.is_const,true)] >> - *namespace_arg_p >> - className_p [assign_a(arg.type)] >> - ch_p('&') [assign_a(arg.is_ref,true)]; - Rule argEigenType_p = eigenType_p[assign_a(arg.type)] >> !ch_p('*')[assign_a(arg.is_ptr,true)]; @@ -107,10 +95,16 @@ Module::Module(const string& interfacePath, eigenType_p [assign_a(arg.type)] >> ch_p('&') [assign_a(arg.is_ref,true)]; + Rule classArg_p = + !str_p("const") [assign_a(arg.is_const,true)] >> + *namespace_arg_p >> + className_p [assign_a(arg.type)] >> + (ch_p('*')[assign_a(arg.is_ptr,true)] | ch_p('&')[assign_a(arg.is_ref,true)]); + Rule name_p = lexeme_d[alpha_p >> *(alnum_p | '_')]; Rule argument_p = - ((basisType_p[assign_a(arg.type)] | argEigenType_p | classRef_p | eigenRef_p | classPtr_p) + ((basisType_p[assign_a(arg.type)] | argEigenType_p | eigenRef_p | classArg_p) >> name_p[assign_a(arg.name)]) [push_back_a(args, arg)] [assign_a(arg,arg0)];