diff --git a/CMakeLists.txt b/CMakeLists.txt index c987a9d..586a772 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,5 +14,5 @@ if(Boost_FOUND) add_executable(langkit_test langkit/main.cpp langkit/langkit_lexer.cpp langkit/langkit_parser.cpp) target_link_libraries(langkit_test ${Boost_LIBRARIES}) - #add_executable(boxedcpp_test boxedcpp/test.cpp) + add_executable(boxedcpp_test boxedcpp/test.cpp) endif() diff --git a/boxedcpp/boxedcpp.hpp b/boxedcpp/boxedcpp.hpp index 8ae8543..ffb0d41 100644 --- a/boxedcpp/boxedcpp.hpp +++ b/boxedcpp/boxedcpp.hpp @@ -87,7 +87,7 @@ void dump_type(const Type_Info &type) void dump_function(const BoxedCPP_System::Function_Map::value_type &f) { std::vector params = f.second->get_param_types(); - + dump_type(params.front()); std::cout << " " << f.first << "("; @@ -97,7 +97,7 @@ void dump_function(const BoxedCPP_System::Function_Map::value_type &f) { dump_type(*itr); std::cout << ", "; - } + } std::cout << ")" << std::endl; } @@ -113,7 +113,7 @@ void dump_system(const BoxedCPP_System &s) std::cout << itr->first << ": "; dump_type(itr->second); std::cout << std::endl; - } + } std::cout << std::endl; std::vector funcs = s.get_functions(); @@ -124,7 +124,7 @@ void dump_system(const BoxedCPP_System &s) ++itr) { dump_function(*itr); - } + } std::cout << std::endl; } @@ -167,11 +167,12 @@ void bootstrap(BoxedCPP_System &s) s.register_function(boost::function(&multiply), "*"); s.register_function(boost::function(&to_string), "to_string"); - s.register_function(boost::function(&to_string), "to_string"); + //JDT: Was giving me compiler errors (not sure why) + //s.register_function(boost::function(&to_string), "to_string"); s.register_function(boost::function(&to_string), "to_string"); s.register_function(boost::function(&to_string), "to_string"); } -#endif +#endif diff --git a/boxedcpp/test.cpp b/boxedcpp/test.cpp index e5023fb..49dbe85 100644 --- a/boxedcpp/test.cpp +++ b/boxedcpp/test.cpp @@ -35,7 +35,7 @@ struct Test std::cout << "Method called " << md << std::endl; return int(md); } - + std::string message; double md; }; @@ -52,10 +52,10 @@ int main() BoxedCPP_System ss; bootstrap(ss); dump_system(ss); - + //Calling a function by name and allowing the built in dispatch mechanism to //choose the most appropriate version of the function - Boxed_Value addresult = dispatch(ss.get_function("+"), Param_List_Builder() << double(5.1) << double(10.3)); + Boxed_Value addresult = dispatch(ss.get_function("+"), Param_List_Builder() << double(5.1) << double(10.3)); //Using the Cast_Helper to unbox the resultant value and output it std::cout << Cast_Helper()(addresult) << std::endl; @@ -64,17 +64,18 @@ int main() //This time we will not bother saving the result and will instead send it straight out std::cout << Cast_Helper()( dispatch(ss.get_function("*"), Param_List_Builder() << 2 << addresult) - ) << std::endl; + ) << std::endl; //Register a new function, this one with typing for us, so we don't have to ubox anything //right here - ss.register_function(boost::function(&print), "print"); + //JDT: Was giving me compiler errors (not sure why) + //ss.register_function(boost::function(&print), "print"); //Now we have a print method, let's try to print out the earlier example: //so, we dispatch the to_string and pass its result as a param to "print" //In this example we don't bother with temporaries and we don't have to know //anything about types - dispatch(ss.get_function("print"), + dispatch(ss.get_function("print"), Param_List_Builder() << dispatch(ss.get_function("to_string"), Param_List_Builder() << addresult)); // @@ -96,14 +97,14 @@ int main() std::vector sos; - sos.push_back(ss.get_object("testobj")); + sos.push_back(ss.get_object("testobj")); sos.push_back(ss.get_object("d")); boost::shared_ptr method1(ss.get_function("method").front().second); (*method1)(sos); (*method1)(sos); Boxed_Value o = (*method1)(sos); - + dispatch(ss.get_function("print"), Param_List_Builder() << ss.get_object("str")); //Add new dynamically created object from registered "Test" constructor @@ -121,8 +122,8 @@ int main() std::string &sr = Cast_Helper()(stringref); sr = "Bob Updated The message"; - + dispatch(ss.get_function("show_message"), sos3); */ } - + diff --git a/langkit/langkit_parser.hpp b/langkit/langkit_parser.hpp index 454b7d0..640f37e 100644 --- a/langkit/langkit_parser.hpp +++ b/langkit/langkit_parser.hpp @@ -8,7 +8,6 @@ #include "langkit_lexer.hpp" - typedef std::vector::iterator Token_Iterator; struct Rule {