diff --git a/chaiscript/chaiscript_engine.hpp b/chaiscript/chaiscript_engine.hpp index 00e6bdf9..30f5fea6 100644 --- a/chaiscript/chaiscript_engine.hpp +++ b/chaiscript/chaiscript_engine.hpp @@ -70,6 +70,7 @@ namespace chaiscript void build_eval_system() { dispatchkit::Bootstrap::bootstrap(engine); dispatchkit::bootstrap_vector >(engine, "Vector"); + dispatchkit::bootstrap_string(engine, "string"); dispatchkit::bootstrap_map >(engine, "Map"); dispatchkit::bootstrap_pair >(engine, "Pair"); diff --git a/chaiscript/chaiscript_prelude.hpp b/chaiscript/chaiscript_prelude.hpp index 7e067b96..10178bb3 100644 --- a/chaiscript/chaiscript_prelude.hpp +++ b/chaiscript/chaiscript_prelude.hpp @@ -8,7 +8,7 @@ const char *chaiscript_prelude = " \ def to_string(x) : call_exists(first, x) && call_exists(second, x) { \n\ \"<\" + x.first.to_string() + \", \" + x.second.to_string() + \">\"\n\ }\n\ -def to_string(x) : call_exists(range, x) { \n\ +def to_string(x) : !is_type(\"string\", x) && call_exists(range, x) { \n\ \"[\" + x.join(\", \") + \"]\"\n\ }\n\ def to_string(x) { \n\ diff --git a/dispatchkit/bootstrap.hpp b/dispatchkit/bootstrap.hpp index cb3379e3..d80ff1b2 100644 --- a/dispatchkit/bootstrap.hpp +++ b/dispatchkit/bootstrap.hpp @@ -494,16 +494,12 @@ namespace dispatchkit static void bootstrap(Dispatch_Engine &s) { s.register_type("void"); - - s.register_type("string"); - + s.register_type("bool"); s.register_type("function"); add_basic_constructors(s, "bool"); - add_basic_constructors(s, "string"); add_oper_assign(s); - register_function(s, &to_string, "internal_to_string"); register_function(s, &to_string, "internal_to_string"); register_function(s, &unknown_assign, "="); @@ -518,16 +514,12 @@ namespace dispatchkit add_opers_comparison_pod(s); add_opers_arithmetic_pod(s); - add_oper_add(s); - add_oper_add_equals (s); - add_opers_comparison(s); - register_function(s, &print, "print_string"); register_function(s, &println, "println_string"); s.register_function(boost::function(boost::bind(&dump_system, boost::ref(s))), "dump_system"); s.register_function(boost::function(boost::bind(&dump_object, _1)), "dump_object"); - s.register_function(boost::function(boost::bind(&is_type, s, _1, _2)), + s.register_function(boost::function(boost::bind(&is_type, boost::ref(s), _1, _2)), "is_type"); s.add_object("_", Placeholder_Object()); diff --git a/dispatchkit/bootstrap_stl.hpp b/dispatchkit/bootstrap_stl.hpp index 02e77e49..3da67e6c 100644 --- a/dispatchkit/bootstrap_stl.hpp +++ b/dispatchkit/bootstrap_stl.hpp @@ -91,10 +91,8 @@ namespace dispatchkit template void bootstrap_assignable(Dispatch_Engine &system, const std::string &type) { - system.register_function( - boost::function(&Assignable::operator=), "="); - system.register_function(build_constructor(), type); - system.register_function(build_constructor(), "clone"); + add_basic_constructors(system, type); + add_oper_assign(system); } template @@ -209,6 +207,18 @@ namespace dispatchkit bootstrap_unique_sorted_associative_container(system, type); bootstrap_pair_associative_container(system, type); } + + template + void bootstrap_string(Dispatch_Engine &system, const std::string &type) + { + system.register_type(type); + add_oper_add(system); + add_oper_add_equals(system); + add_opers_comparison(system); + bootstrap_random_access_container(system, type); + bootstrap_sequence(system, type); + } + } #endif