diff --git a/wrap/GlobalFunction.h b/wrap/GlobalFunction.h index d26ec8ae3..b2a582654 100644 --- a/wrap/GlobalFunction.h +++ b/wrap/GlobalFunction.h @@ -66,10 +66,12 @@ typedef std::map GlobalFunctions; struct GlobalFunctionGrammar: public classic::grammar { GlobalFunctions& global_functions_; ///< successful parse will be placed in here + std::vector& namespaces_; /// Construct type grammar and specify where result is placed - GlobalFunctionGrammar(GlobalFunctions& global_functions) : - global_functions_(global_functions) { + GlobalFunctionGrammar(GlobalFunctions& global_functions, + std::vector& namespaces) : + global_functions_(global_functions), namespaces_(namespaces) { } /// Definition of type grammar @@ -102,7 +104,8 @@ struct GlobalFunctionGrammar: public classic::grammar { global_function_p = (returnValue_g >> globalFunctionName_p[assign_a(globalFunction.name_)] >> argumentList_g >> ';' >> *comments_p) // - [bl::bind(&GlobalFunction::addOverload, + [assign_a(globalFunction.namespaces_, self.namespaces_)][bl::bind( + &GlobalFunction::addOverload, bl::var(self.global_functions_)[bl::var(globalFunction.name_)], bl::var(globalFunction), bl::var(args), bl::var(retVal), boost::none, verbose)] // @@ -118,5 +121,5 @@ struct GlobalFunctionGrammar: public classic::grammar { }; // GlobalFunctionGrammar -} // \namespace wrap +}// \namespace wrap diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 907ad1472..55fd13715 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -126,30 +126,8 @@ void Module::parseMarkup(const std::string& data) { [push_back_a(templateInstantiationTypedefs, singleInstantiation)] [assign_a(singleInstantiation, singleInstantiation0)]; - // NOTE: allows for pointers to all types - ArgumentList args; - ArgumentListGrammar argumentList_g(args); - - vector namespaces_return; /// namespace for current return type - Rule namespace_ret_p = basic.namespace_p[push_back_a(namespaces_return)] >> str_p("::"); - - ReturnValue retVal0, retVal; - ReturnValueGrammar returnValue_g(retVal); - - Rule globalFunctionName_p = lexeme_d[(upper_p | lower_p) >> *(alnum_p | '_')]; - - // parse a global function - Qualified globalFunction; - Rule global_function_p = - (returnValue_g >> globalFunctionName_p[assign_a(globalFunction.name_)] >> - argumentList_g >> ';' >> *basic.comments_p) - [assign_a(globalFunction.namespaces_,namespaces)] - [bl::bind(&GlobalFunction::addOverload, - bl::var(global_functions)[bl::var(globalFunction.name_)], - bl::var(globalFunction), bl::var(args), bl::var(retVal), boost::none,verbose)] - [assign_a(retVal,retVal0)] - [clear_a(globalFunction)] - [clear_a(args)]; + // Create grammar for global functions + GlobalFunctionGrammar global_function_g(global_functions,namespaces); Rule include_p = str_p("#include") >> ch_p('<') >> (*(anychar_p - '>'))[push_back_a(includes)] >> ch_p('>'); @@ -162,7 +140,7 @@ void Module::parseMarkup(const std::string& data) { (str_p("namespace") >> basic.namespace_p[push_back_a(namespaces)] >> ch_p('{') - >> *(include_p | class_p | templateSingleInstantiation_p | global_function_p | namespace_def_p | basic.comments_p) + >> *(include_p | class_p | templateSingleInstantiation_p | global_function_g | namespace_def_p | basic.comments_p) >> ch_p('}')) [pop_a(namespaces)]; @@ -182,7 +160,7 @@ void Module::parseMarkup(const std::string& data) { Rule module_content_p = basic.comments_p | include_p | class_p | templateSingleInstantiation_p | forward_declaration_p - | global_function_p | namespace_def_p; + | global_function_g | namespace_def_p; Rule module_p = *module_content_p >> !end_p; diff --git a/wrap/tests/testGlobalFunction.cpp b/wrap/tests/testGlobalFunction.cpp index b8ed67a0f..32ab5dafb 100644 --- a/wrap/tests/testGlobalFunction.cpp +++ b/wrap/tests/testGlobalFunction.cpp @@ -36,7 +36,8 @@ TEST( GlobalFunction, Grammar ) { // Create type grammar that will place result in actual GlobalFunctions actual; - GlobalFunctionGrammar g(actual); + vector namespaces; + GlobalFunctionGrammar g(actual,namespaces); // a class type with namespaces EXPECT(parse("Vector aGlobalFunction();", g, space_p).full);