Fixed argument parse error. Somehow it could parse either refs or ptrs, but noth both, and it depended on the order in which the rules were given in the argList_p. I just combined ptr and ref in one and now it works. Go figure.

release/4.3a0
Frank Dellaert 2012-01-28 19:44:33 +00:00
parent c309047d7a
commit a1aba7d6ff
3 changed files with 16 additions and 20 deletions

View File

@ -26,11 +26,13 @@ using namespace std;
using namespace wrap; using namespace wrap;
/* ************************************************************************* */ /* ************************************************************************* */
string Argument::matlabClass() const { string Argument::matlabClass(const string& delim) const {
if (type=="string") return string("char"); 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") if (type=="bool" || type=="int" || type=="size_t" || type=="Vector" || type=="Matrix")
return string("double"); return result + "double";
return type; return result + type;
} }
/* ************************************************************************* */ /* ************************************************************************* */

View File

@ -36,7 +36,7 @@ struct Argument {
} }
/// return MATLAB class for use in isa(x,class) /// 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 /// adds namespaces to type
std::string qualifiedType(const std::string& delim = "") const; std::string qualifiedType(const std::string& delim = "") const;

View File

@ -65,13 +65,12 @@ Module::Module(const string& interfacePath,
// defined within the square brackets [] and are executed whenever a // defined within the square brackets [] and are executed whenever a
// rule is successfully parsed. Define BOOST_SPIRIT_DEBUG to debug. // rule is successfully parsed. Define BOOST_SPIRIT_DEBUG to debug.
// The grammar is allows a very restricted C++ header // 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); 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 = Rule basisType_p =
(str_p("string") | "bool" | "size_t" | "int" | "double" | "char"); (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 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 = Rule argEigenType_p =
eigenType_p[assign_a(arg.type)] >> eigenType_p[assign_a(arg.type)] >>
!ch_p('*')[assign_a(arg.is_ptr,true)]; !ch_p('*')[assign_a(arg.is_ptr,true)];
@ -107,10 +95,16 @@ Module::Module(const string& interfacePath,
eigenType_p [assign_a(arg.type)] >> eigenType_p [assign_a(arg.type)] >>
ch_p('&') [assign_a(arg.is_ref,true)]; 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 name_p = lexeme_d[alpha_p >> *(alnum_p | '_')];
Rule argument_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)]) >> name_p[assign_a(arg.name)])
[push_back_a(args, arg)] [push_back_a(args, arg)]
[assign_a(arg,arg0)]; [assign_a(arg,arg0)];