diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 1eab977..4bee74d 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -52,7 +52,7 @@ namespace chaiscript } template::value>::type > - Module& array(const std::string &type, Module& m) + void array(const std::string &type, Module& m) { typedef typename std::remove_extent::type ReturnType; const auto extent = std::extent::value; @@ -83,9 +83,6 @@ namespace chaiscript [extent](const T &) { return extent; }), "size"); - - - return m; } /// \brief Adds a copy constructor for the given type to the given Model @@ -94,9 +91,9 @@ namespace chaiscript /// \tparam T The type to add a copy constructor for /// \returns The passed in Module template - Module& copy_constructor(const std::string &type, Module& m) + void copy_constructor(const std::string &type, Module& m) { - return m.add(constructor(), type); + m.add(constructor(), type); } /// \brief Add all comparison operators for the templated type. Used during bootstrap, also available to users. @@ -104,7 +101,7 @@ namespace chaiscript /// \param[in,out] m module to add comparison operators to /// \returns the passed in Module. template - Module& opers_comparison(Module& m) + void opers_comparison(Module& m) { operators::equal(m); operators::greater_than(m); @@ -112,7 +109,6 @@ namespace chaiscript operators::less_than(m); operators::less_than_equal(m); operators::not_equal(m); - return m; } @@ -125,11 +121,10 @@ namespace chaiscript /// \sa copy_constructor /// \sa constructor template - Module& basic_constructors(const std::string &type, Module& m) + void basic_constructors(const std::string &type, Module& m) { m.add(constructor(), type); copy_constructor(type, m); - return m; } /// \brief Adds a constructor for a POD type @@ -137,9 +132,9 @@ namespace chaiscript /// \param[in] type The name of the type /// \param[in,out] m The Module to add the constructor to template - Module& construct_pod(const std::string &type, Module& m) + void construct_pod(const std::string &type, Module& m) { - return m.add(fun(&detail::construct_pod), type); + m.add(fun(&detail::construct_pod), type); } @@ -183,14 +178,13 @@ namespace chaiscript /// Add all common functions for a POD type. All operators, and /// common conversions template - Module& bootstrap_pod_type(const std::string &name, Module& m) + void bootstrap_pod_type(const std::string &name, Module& m) { m.add(user_type(), name); m.add(constructor(), name); construct_pod(name, m); m.add(fun(&parse_string), "to_" + name); - return m; } @@ -402,7 +396,7 @@ namespace chaiscript /// \brief perform all common bootstrap functions for std::string, void and POD types /// \param[in,out] m Module to add bootstrapped functions to /// \returns passed in Module - static Module& bootstrap(Module& m) + static void bootstrap(Module& m) { m.add(user_type(), "void"); m.add(user_type(), "bool"); @@ -645,10 +639,6 @@ namespace chaiscript { {fun(&parser::ChaiScript_Parser::parse), "parse"}, {fun(&parser::ChaiScript_Parser::ast), "ast"} } ); - - - - return m; } }; } diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index 3c5f52b..7ba588b 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -177,7 +177,7 @@ namespace chaiscript /// Add Bidir_Range support for the given ContainerType template - Module& input_range_type_impl(const std::string &type, Module& m) + void input_range_type_impl(const std::string &type, Module& m) { m.add(user_type(), type + "_Range"); @@ -190,9 +190,7 @@ namespace chaiscript m.add(fun(&Bidir_Type::front), "front"); m.add(fun(&Bidir_Type::pop_back), "pop_back"); m.add(fun(&Bidir_Type::back), "back"); - - return m; - } + } /// Algorithm for inserting at a specific position into a container @@ -230,11 +228,10 @@ namespace chaiscript } template - Module& input_range_type(const std::string &type, Module& m) + void input_range_type(const std::string &type, Module& m) { detail::input_range_type_impl >(type,m); detail::input_range_type_impl >("Const_" + type, m); - return m; } template ModulePtr input_range_type(const std::string &type) @@ -248,7 +245,7 @@ namespace chaiscript /// Add random_access_container concept to the given ContainerType /// http://www.sgi.com/tech/stl/RandomAccessContainer.html template - Module& random_access_container_type(const std::string &/*type*/, Module& m) + void random_access_container_type(const std::string &/*type*/, Module& m) { //In the interest of runtime safety for the m, we prefer the at() method for [] access, //to throw an exception in an out of bounds condition. @@ -267,8 +264,6 @@ namespace chaiscript /// during dispatch. reevaluate return c.at(static_cast(index)); }), "[]"); - - return m; } template ModulePtr random_access_container_type(const std::string &type) @@ -283,11 +278,10 @@ namespace chaiscript /// Add assignable concept to the given ContainerType /// http://www.sgi.com/tech/stl/Assignable.html template - Module& assignable_type(const std::string &type, Module& m) + void assignable_type(const std::string &type, Module& m) { copy_constructor(type, m); operators::assign(m); - return m; } template ModulePtr assignable_type(const std::string &type) @@ -301,12 +295,11 @@ namespace chaiscript /// Add container concept to the given ContainerType /// http://www.sgi.com/tech/stl/Container.html template - Module& container_type(const std::string &/*type*/, Module& m) + void container_type(const std::string &/*type*/, Module& m) { m.add(fun([](const ContainerType *a) { return a->size(); } ), "size"); m.add(fun([](const ContainerType *a) { return a->empty(); } ), "empty"); m.add(fun([](ContainerType *a) { a->clear(); } ), "clear"); - return m; } template ModulePtr container_type(const std::string& type) @@ -320,10 +313,9 @@ namespace chaiscript /// Add default constructable concept to the given Type /// http://www.sgi.com/tech/stl/DefaultConstructible.html template - Module& default_constructible_type(const std::string &type, Module& m) + void default_constructible_type(const std::string &type, Module& m) { m.add(constructor(), type); - return m; } template ModulePtr default_constructible_type(const std::string& type) @@ -338,7 +330,7 @@ namespace chaiscript /// Add sequence concept to the given ContainerType /// http://www.sgi.com/tech/stl/Sequence.html template - Module& sequence_type(const std::string &/*type*/, Module& m) + void sequence_type(const std::string &/*type*/, Module& m) { m.add(fun(&detail::insert_at), []()->std::string{ @@ -350,8 +342,6 @@ namespace chaiscript }()); m.add(fun(&detail::erase_at), "erase_at"); - - return m; } template ModulePtr sequence_type(const std::string &type) @@ -364,7 +354,7 @@ namespace chaiscript /// Add back insertion sequence concept to the given ContainerType /// http://www.sgi.com/tech/stl/BackInsertionSequence.html template - Module& back_insertion_sequence_type(const std::string &type, Module& m) + void back_insertion_sequence_type(const std::string &type, Module& m) { typedef typename ContainerType::reference (ContainerType::*backptr)(); @@ -395,7 +385,6 @@ namespace chaiscript }()); m.add(fun(&ContainerType::pop_back), "pop_back"); - return m; } template ModulePtr back_insertion_sequence_type(const std::string &type) @@ -410,7 +399,7 @@ namespace chaiscript /// Front insertion sequence /// http://www.sgi.com/tech/stl/FrontInsertionSequence.html template - Module& front_insertion_sequence_type(const std::string &type, Module& m) + void front_insertion_sequence_type(const std::string &type, Module& m) { typedef typename ContainerType::reference (ContainerType::*front_ptr)(); typedef typename ContainerType::const_reference (ContainerType::*const_front_ptr)() const; @@ -442,7 +431,6 @@ namespace chaiscript }()); m.add(fun(static_cast(&ContainerType::pop_front)), "pop_front"); - return m; } template ModulePtr front_insertion_sequence_type(const std::string &type) @@ -456,7 +444,7 @@ namespace chaiscript /// bootstrap a given PairType /// http://www.sgi.com/tech/stl/pair.html template - Module& pair_type(const std::string &type, Module& m) + void pair_type(const std::string &type, Module& m) { m.add(user_type(), type); @@ -469,8 +457,6 @@ namespace chaiscript basic_constructors(type, m); m.add(constructor(), type); - - return m; } template ModulePtr pair_type(const std::string &type) @@ -486,11 +472,9 @@ namespace chaiscript /// http://www.sgi.com/tech/stl/PairAssociativeContainer.html template - Module& pair_associative_container_type(const std::string &type, Module& m) + void pair_associative_container_type(const std::string &type, Module& m) { pair_type(type + "_Pair", m); - - return m; } template ModulePtr pair_associative_container_type(const std::string &type) @@ -504,7 +488,7 @@ namespace chaiscript /// Add unique associative container concept to the given ContainerType /// http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html template - Module& unique_associative_container_type(const std::string &/*type*/, Module& m) + void unique_associative_container_type(const std::string &/*type*/, Module& m) { m.add(fun(detail::count), "count"); @@ -522,9 +506,6 @@ namespace chaiscript return "insert"; } }()); - - - return m; } template ModulePtr unique_associative_container_type(const std::string &type) @@ -538,7 +519,7 @@ namespace chaiscript /// Add a MapType container /// http://www.sgi.com/tech/stl/Map.html template - Module& map_type(const std::string &type, Module& m) + void map_type(const std::string &type, Module& m) { m.add(user_type(), type); @@ -580,8 +561,6 @@ namespace chaiscript unique_associative_container_type(type, m); pair_associative_container_type(type, m); input_range_type(type, m); - - return m; } template ModulePtr map_type(const std::string &type) @@ -595,7 +574,7 @@ namespace chaiscript /// hopefully working List type /// http://www.sgi.com/tech/stl/List.html template - Module& list_type(const std::string &type, Module& m) + void list_type(const std::string &type, Module& m) { m.add(user_type(), type); @@ -606,8 +585,6 @@ namespace chaiscript default_constructible_type(type, m); assignable_type(type, m); input_range_type(type, m); - - return m; } template ModulePtr list_type(const std::string &type) @@ -621,7 +598,7 @@ namespace chaiscript /// Create a vector type with associated concepts /// http://www.sgi.com/tech/stl/Vector.html template - Module& vector_type(const std::string &type, Module& m) + void vector_type(const std::string &type, Module& m) { m.add(user_type(), type); @@ -663,8 +640,6 @@ namespace chaiscript } )" ); } - - return m; } template ModulePtr vector_type(const std::string &type) @@ -677,7 +652,7 @@ namespace chaiscript /// Add a String container /// http://www.sgi.com/tech/stl/basic_string.html template - Module& string_type(const std::string &type, Module& m) + void string_type(const std::string &type, Module& m) { m.add(user_type(), type); operators::addition(m); @@ -715,8 +690,6 @@ namespace chaiscript m.add(fun([](const String *s) { return s->c_str(); } ), "c_str"); m.add(fun([](const String *s) { return s->data(); } ), "data"); m.add(fun([](const String *s, size_t pos, size_t len) { return s->substr(pos, len); } ), "substr"); - - return m; } template ModulePtr string_type(const std::string &type) @@ -731,15 +704,13 @@ namespace chaiscript /// Add a MapType container /// http://www.sgi.com/tech/stl/Map.html template - Module& future_type(const std::string &type, Module& m) + void future_type(const std::string &type, Module& m) { m.add(user_type(), type); m.add(fun([](const FutureType &t) { return t.valid(); }), "valid"); m.add(fun(&FutureType::get), "get"); m.add(fun(&FutureType::wait), "wait"); - - return m; } template ModulePtr future_type(const std::string &type) diff --git a/include/chaiscript/dispatchkit/operators.hpp b/include/chaiscript/dispatchkit/operators.hpp index 25094cb..8dc54ba 100644 --- a/include/chaiscript/dispatchkit/operators.hpp +++ b/include/chaiscript/dispatchkit/operators.hpp @@ -229,201 +229,201 @@ namespace chaiscript template - Module& assign(Module& m) + void assign(Module& m) { - return m.add(chaiscript::fun(&detail::assign), "="); + m.add(chaiscript::fun(&detail::assign), "="); } template - Module& assign_bitwise_and(Module& m) + void assign_bitwise_and(Module& m) { - return m.add(chaiscript::fun(&detail::assign_bitwise_and), "&="); + m.add(chaiscript::fun(&detail::assign_bitwise_and), "&="); } template - Module& assign_xor(Module& m) + void assign_xor(Module& m) { - return m.add(chaiscript::fun(&detail::assign_xor), "^="); + m.add(chaiscript::fun(&detail::assign_xor), "^="); } template - Module& assign_bitwise_or(Module& m) + void assign_bitwise_or(Module& m) { - return m.add(chaiscript::fun(&detail::assign_bitwise_or), "|="); + m.add(chaiscript::fun(&detail::assign_bitwise_or), "|="); } template - Module& assign_difference(Module& m) + void assign_difference(Module& m) { - return m.add(chaiscript::fun(&detail::assign_difference), "-="); + m.add(chaiscript::fun(&detail::assign_difference), "-="); } template - Module& assign_left_shift(Module& m) + void assign_left_shift(Module& m) { - return m.add(chaiscript::fun(&detail::assign_left_shift), "<<="); + m.add(chaiscript::fun(&detail::assign_left_shift), "<<="); } template - Module& assign_product(Module& m) + void assign_product(Module& m) { - return m.add(chaiscript::fun(&detail::assign_product), "*="); + m.add(chaiscript::fun(&detail::assign_product), "*="); } template - Module& assign_quotient(Module& m) + void assign_quotient(Module& m) { - return m.add(chaiscript::fun(&detail::assign_quotient), "/="); + m.add(chaiscript::fun(&detail::assign_quotient), "/="); } template - Module& assign_remainder(Module& m) + void assign_remainder(Module& m) { - return m.add(chaiscript::fun(&detail::assign_remainder), "%="); + m.add(chaiscript::fun(&detail::assign_remainder), "%="); } template - Module& assign_right_shift(Module& m) + void assign_right_shift(Module& m) { - return m.add(chaiscript::fun(&detail::assign_right_shift), ">>="); + m.add(chaiscript::fun(&detail::assign_right_shift), ">>="); } template - Module& assign_sum(Module& m) + void assign_sum(Module& m) { - return m.add(chaiscript::fun(&detail::assign_sum), "+="); + m.add(chaiscript::fun(&detail::assign_sum), "+="); } template - Module& prefix_decrement(Module& m) + void prefix_decrement(Module& m) { - return m.add(chaiscript::fun(&detail::prefix_decrement), "--"); + m.add(chaiscript::fun(&detail::prefix_decrement), "--"); } template - Module& prefix_increment(Module& m) + void prefix_increment(Module& m) { - return m.add(chaiscript::fun(&detail::prefix_increment), "++"); + m.add(chaiscript::fun(&detail::prefix_increment), "++"); } template - Module& equal(Module& m) + void equal(Module& m) { - return m.add(chaiscript::fun(&detail::equal), "=="); + m.add(chaiscript::fun(&detail::equal), "=="); } template - Module& greater_than(Module& m) + void greater_than(Module& m) { - return m.add(chaiscript::fun(&detail::greater_than), ">"); + m.add(chaiscript::fun(&detail::greater_than), ">"); } template - Module& greater_than_equal(Module& m) + void greater_than_equal(Module& m) { - return m.add(chaiscript::fun(&detail::greater_than_equal), ">="); + m.add(chaiscript::fun(&detail::greater_than_equal), ">="); } template - Module& less_than(Module& m) + void less_than(Module& m) { - return m.add(chaiscript::fun(&detail::less_than), "<"); + m.add(chaiscript::fun(&detail::less_than), "<"); } template - Module& less_than_equal(Module& m) + void less_than_equal(Module& m) { - return m.add(chaiscript::fun(&detail::less_than_equal), "<="); + m.add(chaiscript::fun(&detail::less_than_equal), "<="); } template - Module& logical_compliment(Module& m) + void logical_compliment(Module& m) { - return m.add(chaiscript::fun(&detail::logical_compliment), "!"); + m.add(chaiscript::fun(&detail::logical_compliment), "!"); } template - Module& not_equal(Module& m) + void not_equal(Module& m) { - return m.add(chaiscript::fun(&detail::not_equal), "!="); + m.add(chaiscript::fun(&detail::not_equal), "!="); } template - Module& addition(Module& m) + void addition(Module& m) { - return m.add(chaiscript::fun(&detail::addition), "+"); + m.add(chaiscript::fun(&detail::addition), "+"); } template - Module& unary_plus(Module& m) + void unary_plus(Module& m) { - return m.add(chaiscript::fun(&detail::unary_plus), "+"); + m.add(chaiscript::fun(&detail::unary_plus), "+"); } template - Module& subtraction(Module& m) + void subtraction(Module& m) { - return m.add(chaiscript::fun(&detail::subtraction), "-"); + m.add(chaiscript::fun(&detail::subtraction), "-"); } template - Module& unary_minus(Module& m) + void unary_minus(Module& m) { - return m.add(chaiscript::fun(&detail::unary_minus), "-"); + m.add(chaiscript::fun(&detail::unary_minus), "-"); } template - Module& bitwise_and(Module& m) + void bitwise_and(Module& m) { - return m.add(chaiscript::fun(&detail::bitwise_and), "&"); + m.add(chaiscript::fun(&detail::bitwise_and), "&"); } template - Module& bitwise_compliment(Module& m) + void bitwise_compliment(Module& m) { - return m.add(chaiscript::fun(&detail::bitwise_compliment), "~"); + m.add(chaiscript::fun(&detail::bitwise_compliment), "~"); } template - Module& bitwise_xor(Module& m) + void bitwise_xor(Module& m) { - return m.add(chaiscript::fun(&detail::bitwise_xor), "^"); + m.add(chaiscript::fun(&detail::bitwise_xor), "^"); } template - Module& bitwise_or(Module& m) + void bitwise_or(Module& m) { - return m.add(chaiscript::fun(&detail::bitwise_or), "|"); + m.add(chaiscript::fun(&detail::bitwise_or), "|"); } template - Module& division(Module& m) + void division(Module& m) { - return m.add(chaiscript::fun(&detail::division), "/"); + m.add(chaiscript::fun(&detail::division), "/"); } template - Module& left_shift(Module& m) + void left_shift(Module& m) { - return m.add(chaiscript::fun(&detail::left_shift), "<<"); + m.add(chaiscript::fun(&detail::left_shift), "<<"); } template - Module& multiplication(Module& m) + void multiplication(Module& m) { - return m.add(chaiscript::fun(&detail::multiplication), "*"); + m.add(chaiscript::fun(&detail::multiplication), "*"); } template - Module& remainder(Module& m) + void remainder(Module& m) { - return m.add(chaiscript::fun(&detail::remainder), "%"); + m.add(chaiscript::fun(&detail::remainder), "%"); } template - Module& right_shift(Module& m) + void right_shift(Module& m) { - return m.add(chaiscript::fun(&detail::right_shift), ">>"); + m.add(chaiscript::fun(&detail::right_shift), ">>"); } } } diff --git a/include/chaiscript/utility/utility.hpp b/include/chaiscript/utility/utility.hpp index b68f8d5..1ca0dfb 100644 --- a/include/chaiscript/utility/utility.hpp +++ b/include/chaiscript/utility/utility.hpp @@ -78,7 +78,9 @@ namespace chaiscript t_module.add(chaiscript::constructor(), t_class_name); using namespace chaiscript::bootstrap::operators; - assign(not_equal(equal(t_module))); + equal(t_module); + not_equal(t_module); + assign(t_module); t_module.add(chaiscript::fun([](const Enum &e, const int &i) { return e == i; }), "=="); t_module.add(chaiscript::fun([](const int &i, const Enum &e) { return i == e; }), "==");