diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 21ad6e7..291a75f 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -10,14 +10,13 @@ #include #include #include -#include -#include #include #include #include #include #include #include +#include #include "bad_boxed_cast.hpp" #include "boxed_cast.hpp" @@ -53,7 +52,7 @@ namespace chaiscript } template::value>::type > - ModulePtr array(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr array(const std::string &type, ModulePtr m = std::make_shared()) { typedef typename std::remove_extent::type ReturnType; const auto extent = std::extent::value; @@ -95,7 +94,7 @@ namespace chaiscript /// \tparam T The type to add a copy constructor for /// \returns The passed in ModulePtr, or the newly constructed one if the default param is used template - ModulePtr copy_constructor(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr copy_constructor(const std::string &type, ModulePtr m = std::make_shared()) { m->add(constructor(), type); return m; @@ -106,7 +105,7 @@ namespace chaiscript /// \param[in,out] m module to add comparison operators to /// \returns the passed in ModulePtr or the newly constructed one if the default params are used. template - ModulePtr opers_comparison(ModulePtr m = ModulePtr(new Module())) + ModulePtr opers_comparison(ModulePtr m = std::make_shared()) { operators::equal(m); operators::greater_than(m); @@ -127,7 +126,7 @@ namespace chaiscript /// \sa copy_constructor /// \sa constructor template - ModulePtr basic_constructors(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr basic_constructors(const std::string &type, ModulePtr m = std::make_shared()) { m->add(constructor(), type); copy_constructor(type, m); @@ -139,7 +138,7 @@ namespace chaiscript /// \param[in] type The name of the type /// \param[in,out] m The Module to add the constructor to template - ModulePtr construct_pod(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr construct_pod(const std::string &type, ModulePtr m = std::make_shared()) { m->add(fun(&detail::construct_pod), type); return m; @@ -170,7 +169,7 @@ namespace chaiscript /// Add all common functions for a POD type. All operators, and /// common conversions template - ModulePtr bootstrap_pod_type(const std::string &name, ModulePtr m = ModulePtr(new Module())) + ModulePtr bootstrap_pod_type(const std::string &name, ModulePtr m = std::make_shared()) { m->add(user_type(), name); m->add(constructor(), name); @@ -251,7 +250,7 @@ namespace chaiscript /// Add all arithmetic operators for PODs - static void opers_arithmetic_pod(ModulePtr m = ModulePtr(new Module())) + static void opers_arithmetic_pod(ModulePtr m = std::make_shared()) { m->add(fun(&Boxed_Number::equals), "=="); m->add(fun(&Boxed_Number::less_than), "<"); @@ -309,16 +308,7 @@ namespace chaiscript static bool has_guard(const Const_Proxy_Function &t_pf) { auto pf = std::dynamic_pointer_cast(t_pf); - if (pf) - { - if (pf->get_guard()) { - return true; - } else { - return false; - } - } else { - return false; - } + return pf && pf->get_guard(); } static Const_Proxy_Function get_guard(const Const_Proxy_Function &t_pf) @@ -372,12 +362,7 @@ namespace chaiscript static bool has_parse_tree(const chaiscript::Const_Proxy_Function &t_pf) { const auto pf = std::dynamic_pointer_cast(t_pf); - if (pf && pf->get_parse_tree()) - { - return true; - } else { - return false; - } + return pf && pf->get_parse_tree(); } static chaiscript::AST_NodePtr get_parse_tree(const chaiscript::Const_Proxy_Function &t_pf) @@ -404,7 +389,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 ModulePtr, or newly created one if default argument is used - static ModulePtr bootstrap(ModulePtr m = ModulePtr(new Module())) + static ModulePtr bootstrap(ModulePtr m = std::make_shared()) { m->add(user_type(), "void"); m->add(user_type(), "bool"); @@ -512,7 +497,7 @@ namespace chaiscript m->add(fun(&print), "print_string"); m->add(fun(&println), "println_string"); - m->add(Proxy_Function(new dispatch::Dynamic_Proxy_Function(&bind_function)), "bind"); + m->add(chaiscript::make_shared(&bind_function), "bind"); m->add(fun(&shared_ptr_unconst_clone), "clone"); m->add(fun(&ptr_assign::type>), "="); diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index d686486..260dc99 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -14,10 +14,8 @@ #define CHAISCRIPT_BOOTSTRAP_STL_HPP_ #include -#include #include #include -#include #include #include @@ -179,7 +177,7 @@ namespace chaiscript /// Add Bidir_Range support for the given ContainerType template - ModulePtr input_range_type_impl(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr input_range_type_impl(const std::string &type, ModulePtr m = std::make_shared()) { m->add(user_type(), type + "_Range"); @@ -232,7 +230,7 @@ namespace chaiscript } template - ModulePtr input_range_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr input_range_type(const std::string &type, ModulePtr m = std::make_shared()) { detail::input_range_type_impl >(type,m); detail::input_range_type_impl >("Const_" + type, m); @@ -243,7 +241,7 @@ namespace chaiscript /// Add random_access_container concept to the given ContainerType /// http://www.sgi.com/tech/stl/RandomAccessContainer.html template - ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module())) + ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = std::make_shared()) { // cppcheck-suppress syntaxError typedef typename ContainerType::reference(ContainerType::*indexoper)(size_t); @@ -266,7 +264,7 @@ namespace chaiscript /// Add assignable concept to the given ContainerType /// http://www.sgi.com/tech/stl/Assignable.html template - ModulePtr assignable_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr assignable_type(const std::string &type, ModulePtr m = std::make_shared()) { copy_constructor(type, m); operators::assign(m); @@ -277,7 +275,7 @@ namespace chaiscript /// Add container concept to the given ContainerType /// http://www.sgi.com/tech/stl/Container.html template - ModulePtr container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module())) + ModulePtr container_type(const std::string &/*type*/, ModulePtr m = std::make_shared()) { m->add(fun([](const ContainerType *a) { return a->size(); } ), "size"); m->add(fun([](const ContainerType *a) { return a->empty(); } ), "empty"); @@ -289,7 +287,7 @@ namespace chaiscript /// Add default constructable concept to the given Type /// http://www.sgi.com/tech/stl/DefaultConstructible.html template - ModulePtr default_constructible_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr default_constructible_type(const std::string &type, ModulePtr m = std::make_shared()) { m->add(constructor(), type); return m; @@ -301,7 +299,7 @@ namespace chaiscript /// Add sequence concept to the given ContainerType /// http://www.sgi.com/tech/stl/Sequence.html template - ModulePtr sequence_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module())) + ModulePtr sequence_type(const std::string &/*type*/, ModulePtr m = std::make_shared()) { m->add(fun(&detail::insert_at), []()->std::string{ @@ -321,7 +319,7 @@ namespace chaiscript /// Add back insertion sequence concept to the given ContainerType /// http://www.sgi.com/tech/stl/BackInsertionSequence.html template - ModulePtr back_insertion_sequence_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module())) + ModulePtr back_insertion_sequence_type(const std::string &/*type*/, ModulePtr m = std::make_shared()) { typedef typename ContainerType::reference (ContainerType::*backptr)(); @@ -347,17 +345,17 @@ namespace chaiscript /// Front insertion sequence /// http://www.sgi.com/tech/stl/FrontInsertionSequence.html template - ModulePtr front_insertion_sequence_type(const std::string &, ModulePtr m = ModulePtr(new Module())) + ModulePtr front_insertion_sequence_type(const std::string &, ModulePtr m = std::make_shared()) { - typedef typename ContainerType::reference (ContainerType::*frontptr)(); - typedef typename ContainerType::const_reference (ContainerType::*constfrontptr)() const; - typedef void (ContainerType::*pushptr)(typename ContainerType::const_reference); - typedef void (ContainerType::*popptr)(); + typedef typename ContainerType::reference (ContainerType::*front_ptr)(); + typedef typename ContainerType::const_reference (ContainerType::*const_front_ptr)() const; + typedef void (ContainerType::*push_ptr)(typename ContainerType::const_reference); + typedef void (ContainerType::*pop_ptr)(); - m->add(fun(static_cast(&ContainerType::front)), "front"); - m->add(fun(static_cast(&ContainerType::front)), "front"); + m->add(fun(static_cast(&ContainerType::front)), "front"); + m->add(fun(static_cast(&ContainerType::front)), "front"); - m->add(fun(static_cast(&ContainerType::push_front)), + m->add(fun(static_cast(&ContainerType::push_front)), []()->std::string{ if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value)) { return "push_front_ref"; @@ -366,7 +364,7 @@ namespace chaiscript } }()); - m->add(fun(static_cast(&ContainerType::pop_front)), "pop_front"); + m->add(fun(static_cast(&ContainerType::pop_front)), "pop_front"); return m; } @@ -374,7 +372,7 @@ namespace chaiscript /// bootstrap a given PairType /// http://www.sgi.com/tech/stl/pair.html template - ModulePtr pair_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr pair_type(const std::string &type, ModulePtr m = std::make_shared()) { m->add(user_type(), type); @@ -397,7 +395,7 @@ namespace chaiscript /// http://www.sgi.com/tech/stl/PairAssociativeContainer.html template - ModulePtr pair_associative_container_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr pair_associative_container_type(const std::string &type, ModulePtr m = std::make_shared()) { pair_type(type + "_Pair", m); @@ -408,7 +406,7 @@ namespace chaiscript /// Add unique associative container concept to the given ContainerType /// http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html template - ModulePtr unique_associative_container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module())) + ModulePtr unique_associative_container_type(const std::string &/*type*/, ModulePtr m = std::make_shared()) { m->add(fun(detail::count), "count"); @@ -435,13 +433,13 @@ namespace chaiscript /// Add a MapType container /// http://www.sgi.com/tech/stl/Map.html template - ModulePtr map_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr map_type(const std::string &type, ModulePtr m = std::make_shared()) { m->add(user_type(), type); - typedef typename MapType::mapped_type &(MapType::*elemaccess)(const typename MapType::key_type &); + typedef typename MapType::mapped_type &(MapType::*elem_access)(const typename MapType::key_type &); - m->add(fun(static_cast(&MapType::operator[])), "[]"); + m->add(fun(static_cast(&MapType::operator[])), "[]"); container_type(type, m); default_constructible_type(type, m); @@ -457,7 +455,7 @@ namespace chaiscript /// hopefully working List type /// http://www.sgi.com/tech/stl/List.html template - ModulePtr list_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr list_type(const std::string &type, ModulePtr m = std::make_shared()) { m->add(user_type(), type); @@ -476,7 +474,7 @@ namespace chaiscript /// Create a vector type with associated concepts /// http://www.sgi.com/tech/stl/Vector.html template - ModulePtr vector_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr vector_type(const std::string &type, ModulePtr m = std::make_shared()) { m->add(user_type(), type); @@ -525,7 +523,7 @@ namespace chaiscript /// Add a String container /// http://www.sgi.com/tech/stl/basic_string.html template - ModulePtr string_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr string_type(const std::string &type, ModulePtr m = std::make_shared()) { m->add(user_type(), type); operators::addition(m); @@ -575,7 +573,7 @@ namespace chaiscript /// Add a MapType container /// http://www.sgi.com/tech/stl/Map.html template - ModulePtr future_type(const std::string &type, ModulePtr m = ModulePtr(new Module())) + ModulePtr future_type(const std::string &type, ModulePtr m = std::make_shared()) { m->add(user_type(), type); diff --git a/include/chaiscript/dispatchkit/boxed_cast.hpp b/include/chaiscript/dispatchkit/boxed_cast.hpp index d7ba410..106b9d8 100644 --- a/include/chaiscript/dispatchkit/boxed_cast.hpp +++ b/include/chaiscript/dispatchkit/boxed_cast.hpp @@ -7,10 +7,7 @@ #ifndef CHAISCRIPT_BOXED_CAST_HPP_ #define CHAISCRIPT_BOXED_CAST_HPP_ -#include - #include "../chaiscript_defines.hpp" -#include "../chaiscript_threading.hpp" #include "bad_boxed_cast.hpp" #include "boxed_cast_helper.hpp" #include "boxed_value.hpp" diff --git a/include/chaiscript/dispatchkit/boxed_cast_helper.hpp b/include/chaiscript/dispatchkit/boxed_cast_helper.hpp index a2a1331..3c96931 100644 --- a/include/chaiscript/dispatchkit/boxed_cast_helper.hpp +++ b/include/chaiscript/dispatchkit/boxed_cast_helper.hpp @@ -7,7 +7,6 @@ #ifndef CHAISCRIPT_BOXED_CAST_HELPER_HPP_ #define CHAISCRIPT_BOXED_CAST_HELPER_HPP_ -#include #include #include @@ -34,7 +33,7 @@ namespace chaiscript template struct Cast_Helper_Inner { - typedef typename std::reference_wrapper::type > Result_Type; + typedef std::reference_wrapper::type > Result_Type; static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *) { @@ -112,9 +111,9 @@ namespace chaiscript /// Cast_Helper_Inner for casting to a std::shared_ptr<> type template - struct Cast_Helper_Inner > + struct Cast_Helper_Inner > { - typedef typename std::shared_ptr Result_Type; + typedef std::shared_ptr Result_Type; static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *) { @@ -124,9 +123,9 @@ namespace chaiscript /// Cast_Helper_Inner for casting to a std::shared_ptr type template - struct Cast_Helper_Inner > + struct Cast_Helper_Inner > { - typedef typename std::shared_ptr Result_Type; + typedef std::shared_ptr Result_Type; static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *) { diff --git a/include/chaiscript/dispatchkit/boxed_number.hpp b/include/chaiscript/dispatchkit/boxed_number.hpp index 1d164e3..a57ed7a 100644 --- a/include/chaiscript/dispatchkit/boxed_number.hpp +++ b/include/chaiscript/dispatchkit/boxed_number.hpp @@ -26,7 +26,7 @@ namespace chaiscript { namespace exception { - struct arithmetic_error : public std::runtime_error + struct arithmetic_error : std::runtime_error { arithmetic_error(const std::string& reason) : std::runtime_error("Arithmetic error: " + reason) {} arithmetic_error(const arithmetic_error &) = default; @@ -60,7 +60,7 @@ namespace chaiscript { private: template - static void check_divide_by_zero(T t, typename std::enable_if::value>::type* = 0) + static void check_divide_by_zero(T t, typename std::enable_if::value>::type* = nullptr) { #ifndef CHAISCRIPT_NO_PROTECT_DIVIDEBYZERO if (t == 0) { @@ -70,7 +70,7 @@ namespace chaiscript } template - static void check_divide_by_zero(T, typename std::enable_if::value>::type* = 0) + static void check_divide_by_zero(T, typename std::enable_if::value>::type* = nullptr) { } diff --git a/include/chaiscript/dispatchkit/boxed_value.hpp b/include/chaiscript/dispatchkit/boxed_value.hpp index 9c50c6b..08a115c 100644 --- a/include/chaiscript/dispatchkit/boxed_value.hpp +++ b/include/chaiscript/dispatchkit/boxed_value.hpp @@ -7,12 +7,10 @@ #ifndef CHAISCRIPT_BOXED_VALUE_HPP_ #define CHAISCRIPT_BOXED_VALUE_HPP_ -#include #include #include #include -#include "../chaiscript_threading.hpp" #include "../chaiscript_defines.hpp" #include "any.hpp" #include "type_info.hpp" diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index 21e98ae..e1cb285 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -8,10 +8,8 @@ #define CHAISCRIPT_DISPATCHKIT_HPP_ #include -#include #include #include -#include #include #include #include @@ -280,8 +278,8 @@ namespace chaiscript virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE { try { - const auto &dispatchfun = dynamic_cast(rhs); - return m_funcs == dispatchfun.m_funcs; + const auto &dispatch_fun = dynamic_cast(rhs); + return m_funcs == dispatch_fun.m_funcs; } catch (const std::bad_cast &) { return false; } @@ -1138,12 +1136,7 @@ namespace chaiscript { if (dynamic_lhs->get_guard()) { - if (dynamic_rhs->get_guard()) - { - return false; - } else { - return true; - } + return dynamic_rhs->get_guard() ? false : true; } else { return false; } diff --git a/include/chaiscript/dispatchkit/dynamic_object.hpp b/include/chaiscript/dispatchkit/dynamic_object.hpp index bd6c843..5a9ccaa 100644 --- a/include/chaiscript/dispatchkit/dynamic_object.hpp +++ b/include/chaiscript/dispatchkit/dynamic_object.hpp @@ -7,19 +7,11 @@ #ifndef CHAISCRIPT_DYNAMIC_OBJECT_HPP_ #define CHAISCRIPT_DYNAMIC_OBJECT_HPP_ -#include #include -#include #include -#include #include -#include -#include "../chaiscript_defines.hpp" -#include "boxed_cast.hpp" -#include "boxed_cast_helper.hpp" #include "boxed_value.hpp" -#include "type_info.hpp" namespace chaiscript { class Type_Conversions; diff --git a/include/chaiscript/dispatchkit/dynamic_object_detail.hpp b/include/chaiscript/dispatchkit/dynamic_object_detail.hpp index b9ddda1..9d501ae 100644 --- a/include/chaiscript/dispatchkit/dynamic_object_detail.hpp +++ b/include/chaiscript/dispatchkit/dynamic_object_detail.hpp @@ -213,12 +213,7 @@ namespace chaiscript virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE { const Dynamic_Object_Constructor *dc = dynamic_cast(&f); - if (dc) - { - return dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func); - } else { - return false; - } + return dc && dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func); } virtual bool call_match(const std::vector &vals, const Type_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE diff --git a/include/chaiscript/dispatchkit/function_call.hpp b/include/chaiscript/dispatchkit/function_call.hpp index 578c4ce..3c8e3c5 100644 --- a/include/chaiscript/dispatchkit/function_call.hpp +++ b/include/chaiscript/dispatchkit/function_call.hpp @@ -8,7 +8,6 @@ #define CHAISCRIPT_FUNCTION_CALL_HPP_ #include -#include #include #include diff --git a/include/chaiscript/dispatchkit/function_call_detail.hpp b/include/chaiscript/dispatchkit/function_call_detail.hpp index 798053d..9410d15 100644 --- a/include/chaiscript/dispatchkit/function_call_detail.hpp +++ b/include/chaiscript/dispatchkit/function_call_detail.hpp @@ -7,7 +7,6 @@ #ifndef CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_ #define CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_ -#include #include #include #include diff --git a/include/chaiscript/dispatchkit/handle_return.hpp b/include/chaiscript/dispatchkit/handle_return.hpp index 335d02a..ed165e0 100644 --- a/include/chaiscript/dispatchkit/handle_return.hpp +++ b/include/chaiscript/dispatchkit/handle_return.hpp @@ -9,14 +9,11 @@ #include #include -#include #include -#include #include #include "boxed_number.hpp" #include "boxed_value.hpp" -#include "type_info.hpp" namespace chaiscript { class Boxed_Number; diff --git a/include/chaiscript/dispatchkit/operators.hpp b/include/chaiscript/dispatchkit/operators.hpp index ce1bd97..a04cba4 100644 --- a/include/chaiscript/dispatchkit/operators.hpp +++ b/include/chaiscript/dispatchkit/operators.hpp @@ -229,231 +229,231 @@ namespace chaiscript template - ModulePtr assign(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign), "="); return m; } template - ModulePtr assign_bitwise_and(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_bitwise_and(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_bitwise_and), "&="); return m; } template - ModulePtr assign_xor(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_xor(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_xor), "^="); return m; } template - ModulePtr assign_bitwise_or(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_bitwise_or(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_bitwise_or), "|="); return m; } template - ModulePtr assign_difference(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_difference(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_difference), "-="); return m; } template - ModulePtr assign_left_shift(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_left_shift(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_left_shift), "<<="); return m; } template - ModulePtr assign_product(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_product(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_product), "*="); return m; } template - ModulePtr assign_quotient(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_quotient(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_quotient), "/="); return m; } template - ModulePtr assign_remainder(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_remainder(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_remainder), "%="); return m; } template - ModulePtr assign_right_shift(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_right_shift(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_right_shift), ">>="); return m; } template - ModulePtr assign_sum(ModulePtr m = ModulePtr(new Module())) + ModulePtr assign_sum(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::assign_sum), "+="); return m; } template - ModulePtr prefix_decrement(ModulePtr m = ModulePtr(new Module())) + ModulePtr prefix_decrement(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::prefix_decrement), "--"); return m; } template - ModulePtr prefix_increment(ModulePtr m = ModulePtr(new Module())) + ModulePtr prefix_increment(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::prefix_increment), "++"); return m; } template - ModulePtr equal(ModulePtr m = ModulePtr(new Module())) + ModulePtr equal(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::equal), "=="); return m; } template - ModulePtr greater_than(ModulePtr m = ModulePtr(new Module())) + ModulePtr greater_than(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::greater_than), ">"); return m; } template - ModulePtr greater_than_equal(ModulePtr m = ModulePtr(new Module())) + ModulePtr greater_than_equal(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::greater_than_equal), ">="); return m; } template - ModulePtr less_than(ModulePtr m = ModulePtr(new Module())) + ModulePtr less_than(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::less_than), "<"); return m; } template - ModulePtr less_than_equal(ModulePtr m = ModulePtr(new Module())) + ModulePtr less_than_equal(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::less_than_equal), "<="); return m; } template - ModulePtr logical_compliment(ModulePtr m = ModulePtr(new Module())) + ModulePtr logical_compliment(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::logical_compliment), "!"); return m; } template - ModulePtr not_equal(ModulePtr m = ModulePtr(new Module())) + ModulePtr not_equal(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::not_equal), "!="); return m; } template - ModulePtr addition(ModulePtr m = ModulePtr(new Module())) + ModulePtr addition(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::addition), "+"); return m; } template - ModulePtr unary_plus(ModulePtr m = ModulePtr(new Module())) + ModulePtr unary_plus(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::unary_plus), "+"); return m; } template - ModulePtr subtraction(ModulePtr m = ModulePtr(new Module())) + ModulePtr subtraction(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::subtraction), "-"); return m; } template - ModulePtr unary_minus(ModulePtr m = ModulePtr(new Module())) + ModulePtr unary_minus(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::unary_minus), "-"); return m; } template - ModulePtr bitwise_and(ModulePtr m = ModulePtr(new Module())) + ModulePtr bitwise_and(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::bitwise_and), "&"); return m; } template - ModulePtr bitwise_compliment(ModulePtr m = ModulePtr(new Module())) + ModulePtr bitwise_compliment(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::bitwise_compliment), "~"); return m; } template - ModulePtr bitwise_xor(ModulePtr m = ModulePtr(new Module())) + ModulePtr bitwise_xor(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::bitwise_xor), "^"); return m; } template - ModulePtr bitwise_or(ModulePtr m = ModulePtr(new Module())) + ModulePtr bitwise_or(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::bitwise_or), "|"); return m; } template - ModulePtr division(ModulePtr m = ModulePtr(new Module())) + ModulePtr division(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::division), "/"); return m; } template - ModulePtr left_shift(ModulePtr m = ModulePtr(new Module())) + ModulePtr left_shift(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::left_shift), "<<"); return m; } template - ModulePtr multiplication(ModulePtr m = ModulePtr(new Module())) + ModulePtr multiplication(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::multiplication), "*"); return m; } template - ModulePtr remainder(ModulePtr m = ModulePtr(new Module())) + ModulePtr remainder(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::remainder), "%"); return m; } template - ModulePtr right_shift(ModulePtr m = ModulePtr(new Module())) + ModulePtr right_shift(ModulePtr m = std::make_shared()) { m->add(chaiscript::fun(&detail::right_shift), ">>"); return m; diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index 6f686f6..39011ca 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -9,7 +9,6 @@ #define CHAISCRIPT_PROXY_FUNCTIONS_HPP_ -#include #include #include #include @@ -20,7 +19,6 @@ #include "../chaiscript_defines.hpp" #include "boxed_cast.hpp" -#include "boxed_cast_helper.hpp" #include "boxed_value.hpp" #include "proxy_functions_detail.hpp" #include "type_info.hpp" @@ -582,7 +580,7 @@ namespace chaiscript } protected: - virtual Boxed_Value do_call(const std::vector ¶ms, const Type_Conversions &t_conversions) const + virtual Boxed_Value do_call(const std::vector ¶ms, const Type_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE { return detail::Do_Call::result_type>::go(m_f, params, t_conversions); } @@ -638,12 +636,12 @@ namespace chaiscript return m_f.get(); } - virtual void assign(const std::shared_ptr &t_rhs) { + virtual void assign(const std::shared_ptr &t_rhs) CHAISCRIPT_OVERRIDE { m_f.get() = dispatch::functor(t_rhs, nullptr); } protected: - virtual Boxed_Value do_call(const std::vector ¶ms, const Type_Conversions &t_conversions) const + virtual Boxed_Value do_call(const std::vector ¶ms, const Type_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE { return detail::Do_Call::result_type>::go(m_f.get(), params, t_conversions); } diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index 5cb1d82..b90c8d6 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -7,10 +7,8 @@ #ifndef CHAISCRIPT_PROXY_FUNCTIONS_DETAIL_HPP_ #define CHAISCRIPT_PROXY_FUNCTIONS_DETAIL_HPP_ -#include #include #include -#include #include #include "../chaiscript_defines.hpp" diff --git a/include/chaiscript/dispatchkit/register_function.hpp b/include/chaiscript/dispatchkit/register_function.hpp index ccec354..ccfdb49 100644 --- a/include/chaiscript/dispatchkit/register_function.hpp +++ b/include/chaiscript/dispatchkit/register_function.hpp @@ -11,7 +11,6 @@ #include #include "bind_first.hpp" -#include "dispatchkit.hpp" #include "proxy_functions.hpp" namespace chaiscript diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index 30a2853..7fb3036 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -7,9 +7,7 @@ #ifndef CHAISCRIPT_TYPE_INFO_HPP_ #define CHAISCRIPT_TYPE_INFO_HPP_ -#include #include -#include #include #include @@ -31,8 +29,8 @@ namespace chaiscript { public: CHAISCRIPT_CONSTEXPR Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void, - bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bareti) - : m_type_info(t_ti), m_bare_type_info(t_bareti), + bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti) + : m_type_info(t_ti), m_bare_type_info(t_bare_ti), m_is_const(t_is_const), m_is_reference(t_is_reference), m_is_pointer(t_is_pointer), m_is_void(t_is_void), m_is_arithmetic(t_is_arithmetic), m_is_undef(false) diff --git a/include/chaiscript/language/chaiscript_algebraic.hpp b/include/chaiscript/language/chaiscript_algebraic.hpp index aab4af7..151a94b 100644 --- a/include/chaiscript/language/chaiscript_algebraic.hpp +++ b/include/chaiscript/language/chaiscript_algebraic.hpp @@ -9,8 +9,6 @@ #include -#include "../dispatchkit/dispatchkit.hpp" - namespace chaiscript { diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index 7ea46f1..4f3e813 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -78,7 +78,7 @@ namespace chaiscript { /// Errors generated during parsing or evaluation - struct eval_error : public std::runtime_error { + struct eval_error : std::runtime_error { std::string reason; File_Position start_position; File_Position end_position; @@ -230,8 +230,7 @@ namespace chaiscript if (f) { - std::shared_ptr dynfunguard - = std::dynamic_pointer_cast(f); + auto dynfunguard = std::dynamic_pointer_cast(f); if (dynfunguard) { retval += " : " + format_guard(dynfunguard->get_parse_tree()); @@ -393,7 +392,7 @@ namespace chaiscript /// Errors generated when loading a file - struct file_not_found_error : public std::runtime_error { + struct file_not_found_error : std::runtime_error { file_not_found_error(const std::string &t_filename) CHAISCRIPT_NOEXCEPT : std::runtime_error("File Not Found: " + t_filename) { } @@ -488,8 +487,8 @@ namespace chaiscript private: // Copy and assignment explicitly unimplemented - AST_Node(const AST_Node &); - AST_Node& operator=(const AST_Node &); + AST_Node(const AST_Node &) = delete; + AST_Node& operator=(const AST_Node &) = delete; }; diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index 69eac31..e617562 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -8,8 +8,6 @@ #define CHAISCRIPT_ENGINE_HPP_ #include -#include -#include #include #include #include @@ -18,7 +16,6 @@ #include #include #include -#include #include #include "../chaiscript_defines.hpp" @@ -166,11 +163,11 @@ namespace chaiscript static std::string get_error_message(DWORD t_err) { + typedef LPTSTR StringType; + #if defined(_UNICODE) || defined(UNICODE) - typedef LPWSTR StringType; std::wstring retval = L"Unknown Error"; #else - typedef LPSTR StringType; std::string retval = "Unknown Error"; #endif StringType lpMsgBuf = nullptr; @@ -182,7 +179,7 @@ namespace chaiscript NULL, t_err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (StringType)&lpMsgBuf, + reinterpret_cast(&lpMsgBuf), 0, NULL ) != 0 && lpMsgBuf) { retval = lpMsgBuf; @@ -264,8 +261,8 @@ namespace chaiscript std::map m_loaded_modules; std::set m_active_loaded_modules; - std::vector m_modulepaths; - std::vector m_usepaths; + std::vector m_module_paths; + std::vector m_use_paths; chaiscript::detail::Dispatch_Engine m_engine; @@ -299,7 +296,7 @@ namespace chaiscript /// Evaluates the given file and looks in the 'use' paths const Boxed_Value internal_eval_file(const std::string &t_filename) { - for (const auto &path : m_usepaths) + for (const auto &path : m_use_paths) { try { const auto appendedpath = path + t_filename; @@ -363,10 +360,10 @@ namespace chaiscript m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::function_exists, std::ref(m_engine)), "function_exists"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::get_function_objects, std::ref(m_engine)), "get_functions"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::get_scripting_objects, std::ref(m_engine)), "get_objects"); - m_engine.add(Proxy_Function(new dispatch::Dynamic_Proxy_Function( + m_engine.add(chaiscript::make_shared( [this](const std::vector &t_params) { return m_engine.call_exists(t_params); - })), "call_exists"); + }), "call_exists"); // m_engine.add(fun &)>(std::bind(&chaiscript::dispatch::Proxy_Function_Base::operator(), std::placeholders::_1, std::placeholders::_2, std::ref(m_engine.conversions()))), "call"); // @@ -441,16 +438,16 @@ namespace chaiscript ChaiScript(const ModulePtr &t_lib, std::vector t_modulepaths = std::vector(), std::vector t_usepaths = std::vector()) - : m_modulepaths(std::move(t_modulepaths)), m_usepaths(std::move(t_usepaths)) + : m_module_paths(std::move(t_modulepaths)), m_use_paths(std::move(t_usepaths)) { - if (m_modulepaths.empty()) + if (m_module_paths.empty()) { - m_modulepaths.push_back(""); + m_module_paths.push_back(""); } - if (m_usepaths.empty()) + if (m_use_paths.empty()) { - m_usepaths.push_back(""); + m_use_paths.push_back(""); } build_eval_system(t_lib); @@ -465,16 +462,16 @@ namespace chaiscript /// \param[in] t_usepaths Vector of paths to search when attempting to "use" an included ChaiScript file ChaiScript( std::vector t_modulepaths = std::vector(), std::vector t_usepaths = std::vector()) - : m_modulepaths(std::move(t_modulepaths)), m_usepaths(std::move(t_usepaths)) + : m_module_paths(std::move(t_modulepaths)), m_use_paths(std::move(t_usepaths)) { - if (m_modulepaths.empty()) + if (m_module_paths.empty()) { - m_modulepaths.push_back(""); + m_module_paths.push_back(""); } - if (m_usepaths.empty()) + if (m_use_paths.empty()) { - m_usepaths.push_back(""); + m_use_paths.push_back(""); } #if defined(_POSIX_VERSION) && !defined(__CYGWIN__) @@ -507,7 +504,7 @@ namespace chaiscript dllpath = std::string(&buf.front(), pathlen); } - m_modulepaths.insert(m_modulepaths.begin(), dllpath+"/"); + m_module_paths.insert(m_module_paths.begin(), dllpath+"/"); } #endif @@ -559,7 +556,7 @@ namespace chaiscript /// \param[in] t_filename Filename to load and evaluate Boxed_Value use(const std::string &t_filename) { - for (const auto &path : m_usepaths) + for (const auto &path : m_use_paths) { try { const auto appendedpath = path + t_filename; @@ -758,7 +755,7 @@ namespace chaiscript std::vector postfixes{".dll", ".so", ".bundle", ""}; - for (auto & elem : m_modulepaths) + for (auto & elem : m_module_paths) { for (auto & prefix : prefixes) { diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 38c588b..04fbef2 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -7,8 +7,6 @@ #ifndef CHAISCRIPT_EVAL_HPP_ #define CHAISCRIPT_EVAL_HPP_ -#include -#include #include #include #include @@ -21,7 +19,6 @@ #include "../chaiscript_defines.hpp" #include "../dispatchkit/boxed_cast.hpp" -#include "../dispatchkit/boxed_cast_helper.hpp" #include "../dispatchkit/boxed_number.hpp" #include "../dispatchkit/boxed_value.hpp" #include "../dispatchkit/dispatchkit.hpp" @@ -821,12 +818,12 @@ namespace chaiscript const auto &lambda_node = this->children.back(); - return Boxed_Value(Proxy_Function(new dispatch::Dynamic_Proxy_Function( + return Boxed_Value(chaiscript::make_shared( [&t_ss, lambda_node, param_names, captures](const std::vector &t_params) { return detail::eval_function(t_ss, lambda_node, param_names, t_params, captures); }, - static_cast(numparams), lambda_node, param_types))); + static_cast(numparams), lambda_node, param_types)); } @@ -882,23 +879,23 @@ namespace chaiscript std::shared_ptr guard; if (guardnode) { - guard = std::shared_ptr - (new dispatch::Dynamic_Proxy_Function([&t_ss, guardnode, t_param_names](const std::vector &t_params) + guard = std::make_shared + ([&t_ss, guardnode, t_param_names](const std::vector &t_params) { return detail::eval_function(t_ss, guardnode, t_param_names, t_params); - }, static_cast(numparams), guardnode)); + }, static_cast(numparams), guardnode); } try { const std::string & l_function_name = this->children[0]->text; const std::string & l_annotation = this->annotation?this->annotation->text:""; const auto & func_node = this->children.back(); - t_ss.add(Proxy_Function - (new dispatch::Dynamic_Proxy_Function([&t_ss, guardnode, func_node, t_param_names](const std::vector &t_params) + t_ss.add(chaiscript::make_shared + ([&t_ss, guardnode, func_node, t_param_names](const std::vector &t_params) { return detail::eval_function(t_ss, func_node, t_param_names, t_params); }, static_cast(numparams), this->children.back(), - param_types, l_annotation, guard)), l_function_name); + param_types, l_annotation, guard), l_function_name); } catch (const exception::reserved_word_error &e) { throw exception::eval_error("Reserved word used as function name '" + e.word() + "'"); @@ -1330,7 +1327,7 @@ namespace chaiscript end_point = this->children.size() - 1; } for (size_t i = 1; i < end_point; ++i) { - chaiscript::eval::detail::Scope_Push_Pop catchscope(t_ss); + chaiscript::eval::detail::Scope_Push_Pop catch_scope(t_ss); AST_NodePtr catch_block = this->children[i]; if (catch_block->children.size() == 1) { diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index e362fd3..952aa30 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -257,12 +256,12 @@ namespace chaiscript for (auto &c : p->children) { if (c->identifier == AST_Node_Type::Def && c->children.size() > 0) { - auto &lastchild = c->children.back(); - if (lastchild->identifier == AST_Node_Type::Block) { - auto &blocklastchild = lastchild->children.back(); - if (blocklastchild->identifier == AST_Node_Type::Return) { - if (blocklastchild->children.size() == 1) { - blocklastchild = blocklastchild->children[0]; + auto &last_child = c->children.back(); + if (last_child->identifier == AST_Node_Type::Block) { + auto &block_last_child = last_child->children.back(); + if (block_last_child->identifier == AST_Node_Type::Return) { + if (block_last_child->children.size() == 1) { + block_last_child = block_last_child->children[0]; } } } @@ -789,30 +788,26 @@ namespace chaiscript } /// Reads (and potentially captures) an identifier from input - bool Id(const bool t_capture = false) { + bool Id() { SkipWS(); - if (!t_capture) { - return Id_(); + const auto start = m_input_pos; + const auto prev_col = m_col; + const auto prev_line = m_line; + if (Id_()) { + m_match_stack.push_back(chaiscript::make_shared( + [&]()->std::string{ + if (*start == '`') { + //Id Literal + return std::string(start+1, m_input_pos-1); + } else { + return std::string(start, m_input_pos); + } + }(), + m_filename, prev_line, prev_col, m_line, m_col)); + return true; } else { - const auto start = m_input_pos; - const auto prev_col = m_col; - const auto prev_line = m_line; - if (Id_()) { - m_match_stack.push_back(chaiscript::make_shared( - [&]()->std::string{ - if (*start == '`') { - //Id Literal - return std::string(start+1, m_input_pos-1); - } else { - return std::string(start, m_input_pos); - } - }(), - m_filename, prev_line, prev_col, m_line, m_col)); - return true; - } else { - return false; - } + return false; } } @@ -821,14 +816,14 @@ namespace chaiscript const auto prev_stack_top = m_match_stack.size(); SkipWS(); - if (!Id(true)) { + if (!Id()) { return false; } SkipWS(); if (t_type_allowed) { - Id(true); + Id(); } build_match(chaiscript::make_shared(), prev_stack_top); @@ -1426,7 +1421,7 @@ namespace chaiscript if (Keyword("def")) { retval = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Missing function name in definition", File_Position(m_line, m_col), *m_filename); } @@ -1436,7 +1431,7 @@ namespace chaiscript //We're now a method is_method = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Missing method name in definition", File_Position(m_line, m_col), *m_filename); } } @@ -1609,7 +1604,7 @@ namespace chaiscript if (Keyword("class")) { retval = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Missing class name in definition", File_Position(m_line, m_col), *m_filename); } @@ -1890,7 +1885,7 @@ namespace chaiscript const auto prev_stack_top = m_match_stack.size(); if (Lambda() || Num(true) || Quoted_String(true) || Single_Quoted_String(true) || - Paren_Expression() || Inline_Container() || Id(true)) + Paren_Expression() || Inline_Container() || Id()) { retval = true; bool has_more = true; @@ -1931,7 +1926,7 @@ namespace chaiscript } else if (Symbol(".", true)) { has_more = true; - if (!(Id(true))) { + if (!(Id())) { throw exception::eval_error("Incomplete array access", File_Position(m_line, m_col), *m_filename); } @@ -1952,7 +1947,7 @@ namespace chaiscript if (t_class_context && (Keyword("attr") || Keyword("auto") || Keyword("var"))) { retval = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename); } @@ -1960,7 +1955,7 @@ namespace chaiscript } else if (Keyword("auto") || Keyword("var")) { retval = true; - if (!(Reference() || Id(true))) { + if (!(Reference() || Id())) { throw exception::eval_error("Incomplete variable declaration", File_Position(m_line, m_col), *m_filename); } @@ -1968,13 +1963,13 @@ namespace chaiscript } else if (Keyword("attr")) { retval = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename); } if (!Symbol("::", false)) { throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename); } - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Missing attribute name in definition", File_Position(m_line, m_col), *m_filename); } @@ -2036,7 +2031,7 @@ namespace chaiscript const auto prev_stack_top = m_match_stack.size(); if (Symbol("&", false)) { - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Incomplete '&' expression", File_Position(m_line, m_col), *m_filename); } @@ -2071,11 +2066,7 @@ namespace chaiscript /// Parses any of a group of 'value' style ast_node groups from input bool Value() { - if (Var_Decl() || Dot_Fun_Array() || Prefix()) { - return true; - } else { - return false; - } + return Var_Decl() || Dot_Fun_Array() || Prefix(); } bool Operator_Helper(const size_t t_precedence) { diff --git a/include/chaiscript/language/chaiscript_prelude_docs.hpp b/include/chaiscript/language/chaiscript_prelude_docs.hpp index eb02f3b..7480858 100644 --- a/include/chaiscript/language/chaiscript_prelude_docs.hpp +++ b/include/chaiscript/language/chaiscript_prelude_docs.hpp @@ -309,7 +309,7 @@ class Range /// \brief Moves the front pointer forward one /// - /// \post front() returne the element at front() + 1; + /// \post front() returns the element at front() + 1; void pop_front(); }; @@ -340,7 +340,7 @@ class Const_Range /// \brief Moves the front pointer forward one /// - /// \post front() returne the element at front() + 1; + /// \post front() returns the element at front() + 1; void pop_front(); }; diff --git a/include/chaiscript/utility/utility.hpp b/include/chaiscript/utility/utility.hpp index 9c36b13..ecd5a3f 100644 --- a/include/chaiscript/utility/utility.hpp +++ b/include/chaiscript/utility/utility.hpp @@ -38,8 +38,8 @@ namespace chaiscript /// { {fun(&test::function), "function"}, /// {fun(&test::function2), "function2"}, /// {fun(&test::function3), "function3"}, - /// {fun(static_cast(&test::functionoverload)), "functionoverload" }, - /// {fun(static_cast(&test::functionoverload)), "functionoverload" }, + /// {fun(static_cast(&test::function_overload)), "function_overload" }, + /// {fun(static_cast(&test::function_overload)), "function_overload" }, /// {fun(static_cast(&test::operator=)), "=" } /// } /// ); diff --git a/src/test_module.cpp b/src/test_module.cpp index 1ed7182..c5da4c9 100644 --- a/src/test_module.cpp +++ b/src/test_module.cpp @@ -35,7 +35,7 @@ class TestBaseType std::function func_member; private: - TestBaseType &operator=(const TestBaseType &); + TestBaseType &operator=(const TestBaseType &) = delete; }; class Type2 @@ -82,7 +82,7 @@ class TestDerivedType : public TestBaseType int derived_only_func() { return 19; } private: - TestDerivedType &operator=(const TestDerivedType &); + TestDerivedType &operator=(const TestDerivedType &) = delete; }; class TestMoreDerivedType : public TestDerivedType diff --git a/unittests/multithreaded_test.cpp b/unittests/multithreaded_test.cpp index 2ca2d65..866a3ca 100644 --- a/unittests/multithreaded_test.cpp +++ b/unittests/multithreaded_test.cpp @@ -1,6 +1,5 @@ #include -#include #include #include @@ -25,7 +24,7 @@ void do_work(chaiscript::ChaiScript &c, int id) ss.str(""); ss << id; c.use("multithreaded_work.inc"); - c("do_chai_work(40000, " + ss.str() + ");"); + c("do_chai_work(4000, " + ss.str() + ");"); } catch (const std::exception &e) { std::cout << "exception: " << e.what() << " thread: " << id; } @@ -74,7 +73,7 @@ int main() for (int i = 0; i < num_threads; ++i) { - threads.push_back(std::shared_ptr(new std::thread(do_work, std::ref(chai), i))); + threads.push_back(std::make_shared(do_work, std::ref(chai), i)); } for (int i = 0; i < num_threads; ++i)