diff --git a/include/chaiscript/chaiscript.hpp b/include/chaiscript/chaiscript.hpp index 85d704f..0d1e356 100644 --- a/include/chaiscript/chaiscript.hpp +++ b/include/chaiscript/chaiscript.hpp @@ -563,7 +563,7 @@ #include "dispatchkit/bootstrap_stl.hpp" #include "dispatchkit/function_call.hpp" #include "dispatchkit/dynamic_object.hpp" -#include "dispatchkit/boxed_pod_value.hpp" +#include "dispatchkit/boxed_numeric.hpp" #ifdef BOOST_HAS_DECLSPEC #define CHAISCRIPT_MODULE_EXPORT extern "C" __declspec(dllexport) diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index d8f62ac..49a3aa7 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -11,7 +11,7 @@ #include "dynamic_object.hpp" #include "register_function.hpp" #include "operators.hpp" -#include "boxed_pod_value.hpp" +#include "boxed_numeric.hpp" #include namespace chaiscript @@ -22,13 +22,13 @@ namespace chaiscript namespace detail { - /// \brief Assigns a POD value from a Boxed_POD_Value. Helps support operators between + /// \brief Assigns a POD value from a Boxed_Numeric. Helps support operators between /// disparate POD types. /// \param[in,out] p1 object to assign to - /// \param[in] v Boxed_POD_Value to assign from + /// \param[in] v Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_pod(P1 &p1, const Boxed_POD_Value &v) + P1 &assign_pod(P1 &p1, const Boxed_Numeric &v) { if (v.isfloat) { @@ -38,11 +38,11 @@ namespace chaiscript } } - /// \brief Constructs a new POD value object from a Boxed_POD_Value - /// \param[in] v Boxed_POD_Value to copy into the new object + /// \brief Constructs a new POD value object from a Boxed_Numeric + /// \param[in] v Boxed_Numeric to copy into the new object /// \returns The newly created object. template - P1 construct_pod(Boxed_POD_Value v) + P1 construct_pod(Boxed_Numeric v) { if (v.isfloat) { @@ -52,12 +52,12 @@ namespace chaiscript } } - /// \brief Performs a bitwise and assignment (&=) on the given object with the given Boxed_POD_Value + /// \brief Performs a bitwise and assignment (&=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to bitwise and assign to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_bitwise_and_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_bitwise_and_pod(P1 &p1, Boxed_Numeric r) { if (!r.isfloat) { @@ -67,12 +67,12 @@ namespace chaiscript throw exception::bad_boxed_cast("&= only valid for integer types"); } - /// \brief Performs a xor assignment (^=) on the given object with the given Boxed_POD_Value + /// \brief Performs a xor assignment (^=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to xor assign to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_xor_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_xor_pod(P1 &p1, Boxed_Numeric r) { if (!r.isfloat) { @@ -82,12 +82,12 @@ namespace chaiscript throw exception::bad_boxed_cast("^= only valid for integer types"); } - /// \brief Performs a bitwise or assignment (|=) on the given object with the given Boxed_POD_Value + /// \brief Performs a bitwise or assignment (|=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to bitwise or assign to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_bitwise_or_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_bitwise_or_pod(P1 &p1, Boxed_Numeric r) { if (!r.isfloat) { @@ -97,12 +97,12 @@ namespace chaiscript throw exception::bad_boxed_cast("&= only valid for integer types"); } - /// \brief Performs an assign difference (-=) on the given object with the given Boxed_POD_Value + /// \brief Performs an assign difference (-=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to difference assign to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_difference_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_difference_pod(P1 &p1, Boxed_Numeric r) { if (r.isfloat) { @@ -112,12 +112,12 @@ namespace chaiscript } } - /// \brief Performs an assign shift left (<<=) on the given object with the given Boxed_POD_Value + /// \brief Performs an assign shift left (<<=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to assign shift left to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_left_shift_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_left_shift_pod(P1 &p1, Boxed_Numeric r) { if (!r.isfloat) { @@ -128,12 +128,12 @@ namespace chaiscript } - /// \brief Performs an assign product (*=) on the given object with the given Boxed_POD_Value + /// \brief Performs an assign product (*=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to assign product to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_product_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_product_pod(P1 &p1, Boxed_Numeric r) { if (r.isfloat) { @@ -143,12 +143,12 @@ namespace chaiscript } } - /// \brief Performs an assign quotient (/=) on the given object with the given Boxed_POD_Value + /// \brief Performs an assign quotient (/=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to assign quotient to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_quotient_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_quotient_pod(P1 &p1, Boxed_Numeric r) { if (r.isfloat) { @@ -158,12 +158,12 @@ namespace chaiscript } } - /// \brief Performs an assign remainder (%=) on the given object with the given Boxed_POD_Value + /// \brief Performs an assign remainder (%=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to assign remainder to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_remainder_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_remainder_pod(P1 &p1, Boxed_Numeric r) { if (!r.isfloat) { @@ -174,12 +174,12 @@ namespace chaiscript } - /// \brief Performs an assign shift right (>>=) on the given object with the given Boxed_POD_Value + /// \brief Performs an assign shift right (>>=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to assign shift right to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_right_shift_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_right_shift_pod(P1 &p1, Boxed_Numeric r) { if (!r.isfloat) { @@ -189,12 +189,12 @@ namespace chaiscript throw exception::bad_boxed_cast(">>= only valid for integer types"); } - /// \brief Performs an assign sum (+=) on the given object with the given Boxed_POD_Value + /// \brief Performs an assign sum (+=) on the given object with the given Boxed_Numeric /// \param[in,out] p1 object to sum assign to - /// \param[in] r Boxed_POD_Value to assign from + /// \param[in] r Boxed_Numeric to assign from /// \returns Reference to p1, to support normal C assignment semantics template - P1 &assign_sum_pod(P1 &p1, Boxed_POD_Value r) + P1 &assign_sum_pod(P1 &p1, Boxed_Numeric r) { if (r.isfloat) { @@ -485,16 +485,16 @@ namespace chaiscript */ static void opers_arithmetic_pod(ModulePtr m = ModulePtr(new Module())) { - m->add(fun(&operators::addition), "+"); - m->add(fun(&operators::subtraction), "-"); - m->add(fun(&operators::bitwise_and), "&"); - m->add(fun(&operators::bitwise_xor), "^"); - m->add(fun(&operators::bitwise_or), "|"); - m->add(fun(&operators::division), "/"); - m->add(fun(&operators::left_shift), "<<"); - m->add(fun(&operators::multiplication), "*"); - m->add(fun(&operators::remainder), "%"); - m->add(fun(&operators::right_shift), ">>"); + m->add(fun(&operators::addition), "+"); + m->add(fun(&operators::subtraction), "-"); + m->add(fun(&operators::bitwise_and), "&"); + m->add(fun(&operators::bitwise_xor), "^"); + m->add(fun(&operators::bitwise_or), "|"); + m->add(fun(&operators::division), "/"); + m->add(fun(&operators::left_shift), "<<"); + m->add(fun(&operators::multiplication), "*"); + m->add(fun(&operators::remainder), "%"); + m->add(fun(&operators::right_shift), ">>"); } /** @@ -619,7 +619,7 @@ namespace chaiscript m->add(user_type(), "void"); m->add(user_type(), "bool"); m->add(user_type(), "Object"); - m->add(user_type(), "PODObject"); + m->add(user_type(), "PODObject"); m->add(user_type(), "Function"); m->add(user_type(), "exception"); @@ -694,7 +694,7 @@ namespace chaiscript operators::logical_compliment(m); - opers_comparison(m); + opers_comparison(m); opers_arithmetic_pod(m); diff --git a/include/chaiscript/dispatchkit/boxed_pod_value.hpp b/include/chaiscript/dispatchkit/boxed_numeric.hpp similarity index 76% rename from include/chaiscript/dispatchkit/boxed_pod_value.hpp rename to include/chaiscript/dispatchkit/boxed_numeric.hpp index 215eba0..3dd826a 100644 --- a/include/chaiscript/dispatchkit/boxed_pod_value.hpp +++ b/include/chaiscript/dispatchkit/boxed_numeric.hpp @@ -4,8 +4,8 @@ // and Jason Turner (jason@emptycrate.com) // http://www.chaiscript.com -#ifndef CHAISCRIPT_BOXED_POD_VALUE_HPP_ -#define CHAISCRIPT_BOXED_POD_VALUE_HPP_ +#ifndef CHAISCRIPT_BOXED_NUMERIC_HPP_ +#define CHAISCRIPT_BOXED_NUMERIC_HPP_ #include "type_info.hpp" #include "boxed_value.hpp" @@ -18,10 +18,10 @@ namespace chaiscript { /// \brief Represents any numeric type, generically. Used internally for generic operations between POD values - class Boxed_POD_Value + class Boxed_Numeric { public: - Boxed_POD_Value(const Boxed_Value &v) + Boxed_Numeric(const Boxed_Value &v) : d(0), i(0), isfloat(false) { if (v.get_type_info().is_undef()) @@ -69,37 +69,37 @@ namespace chaiscript } } - bool operator==(const Boxed_POD_Value &r) const + bool operator==(const Boxed_Numeric &r) const { return ((isfloat)?d:i) == ((r.isfloat)?r.d:r.i); } - bool operator<(const Boxed_POD_Value &r) const + bool operator<(const Boxed_Numeric &r) const { return ((isfloat)?d:i) < ((r.isfloat)?r.d:r.i); } - bool operator>(const Boxed_POD_Value &r) const + bool operator>(const Boxed_Numeric &r) const { return ((isfloat)?d:i) > ((r.isfloat)?r.d:r.i); } - bool operator>=(const Boxed_POD_Value &r) const + bool operator>=(const Boxed_Numeric &r) const { return ((isfloat)?d:i) >= ((r.isfloat)?r.d:r.i); } - bool operator<=(const Boxed_POD_Value &r) const + bool operator<=(const Boxed_Numeric &r) const { return ((isfloat)?d:i) <= ((r.isfloat)?r.d:r.i); } - bool operator!=(const Boxed_POD_Value &r) const + bool operator!=(const Boxed_Numeric &r) const { return ((isfloat)?d:i) != ((r.isfloat)?r.d:r.i); } - Boxed_Value operator+(const Boxed_POD_Value &r) const + Boxed_Value operator+(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -109,7 +109,7 @@ namespace chaiscript return Boxed_Value(((isfloat)?d:i) + ((r.isfloat)?r.d:r.i)); } - Boxed_Value operator-(const Boxed_POD_Value &r) const + Boxed_Value operator-(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -119,7 +119,7 @@ namespace chaiscript return Boxed_Value(((isfloat)?d:i) - ((r.isfloat)?r.d:r.i)); } - Boxed_Value operator&(const Boxed_POD_Value &r) const + Boxed_Value operator&(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -129,7 +129,7 @@ namespace chaiscript throw exception::bad_boxed_cast("& only valid for integer types"); } - Boxed_Value operator^(const Boxed_POD_Value &r) const + Boxed_Value operator^(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -139,7 +139,7 @@ namespace chaiscript throw exception::bad_boxed_cast("^ only valid for integer types"); } - Boxed_Value operator|(const Boxed_POD_Value &r) const + Boxed_Value operator|(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -149,7 +149,7 @@ namespace chaiscript throw exception::bad_boxed_cast("| only valid for integer types"); } - Boxed_Value operator/(const Boxed_POD_Value &r) const + Boxed_Value operator/(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -159,7 +159,7 @@ namespace chaiscript return Boxed_Value(((isfloat)?d:i) / ((r.isfloat)?r.d:r.i)); } - Boxed_Value operator<<(const Boxed_POD_Value &r) const + Boxed_Value operator<<(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -170,7 +170,7 @@ namespace chaiscript } - Boxed_Value operator*(const Boxed_POD_Value &r) const + Boxed_Value operator*(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -181,7 +181,7 @@ namespace chaiscript } - Boxed_Value operator%(const Boxed_POD_Value &r) const + Boxed_Value operator%(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -191,7 +191,7 @@ namespace chaiscript throw exception::bad_boxed_cast("% only valid for integer types"); } - Boxed_Value operator>>(const Boxed_POD_Value &r) const + Boxed_Value operator>>(const Boxed_Numeric &r) const { if (!isfloat && !r.isfloat) { @@ -222,32 +222,32 @@ namespace chaiscript namespace detail { /** - * Cast_Helper for converting from Boxed_Value to Boxed_POD_Value + * Cast_Helper for converting from Boxed_Value to Boxed_Numeric */ template<> - struct Cast_Helper + struct Cast_Helper { - typedef Boxed_POD_Value Result_Type; + typedef Boxed_Numeric Result_Type; static Result_Type cast(const Boxed_Value &ob) { - return Boxed_POD_Value(ob); + return Boxed_Numeric(ob); } }; /** - * Cast_Helper for converting from Boxed_Value to Boxed_POD_Value + * Cast_Helper for converting from Boxed_Value to Boxed_Numeric */ template<> - struct Cast_Helper : Cast_Helper + struct Cast_Helper : Cast_Helper { }; /** - * Cast_Helper for converting from Boxed_Value to Boxed_POD_Value + * Cast_Helper for converting from Boxed_Value to Boxed_Numeric */ template<> - struct Cast_Helper : Cast_Helper + struct Cast_Helper : Cast_Helper { }; } diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index c87acd6..c286149 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -811,7 +811,7 @@ namespace chaiscript const size_t rhssize = rhsparamtypes.size(); const Type_Info boxed_type = user_type(); - const Type_Info boxed_pod_type = user_type(); + const Type_Info boxed_pod_type = user_type(); boost::shared_ptr dynamic_lhs(boost::dynamic_pointer_cast(lhs)); boost::shared_ptr dynamic_rhs(boost::dynamic_pointer_cast(rhs)); diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index a86a62c..fa0c89d 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -20,7 +20,7 @@ namespace chaiscript { - class Boxed_POD_Value; + class Boxed_Numeric; struct AST_Node; typedef boost::shared_ptr AST_NodePtr; @@ -139,7 +139,7 @@ namespace chaiscript if (ti.is_undef() || ti.bare_equal(user_type()) || (!bv.get_type_info().is_undef() - && (ti.bare_equal(user_type()) + && (ti.bare_equal(user_type()) || ti.bare_equal(bv.get_type_info()) || chaiscript::detail::dynamic_cast_converts(ti, bv.get_type_info()) || bv.get_type_info().bare_equal(user_type >()) diff --git a/unittests/boxed_cast_test.cpp b/unittests/boxed_cast_test.cpp index ab9b882..ca53707 100644 --- a/unittests/boxed_cast_test.cpp +++ b/unittests/boxed_cast_test.cpp @@ -86,14 +86,14 @@ bool do_test(const Boxed_Value &bv, bool T, bool ConstT, bool TRef, bool ConstTR passed &= test_type_conversion >(bv, ConstBoostConstRef); passed &= test_type_conversion &>(bv, ConstBoostRefRef); passed &= test_type_conversion &>(bv, ConstBoostConstRefRef); - passed &= test_type_conversion(bv, PODValue); - passed &= test_type_conversion(bv, ConstPODValue); - passed &= test_type_conversion(bv, false); - passed &= test_type_conversion(bv, ConstPODValueRef); - passed &= test_type_conversion(bv, false); - passed &= test_type_conversion(bv, false); - passed &= test_type_conversion(bv, false); - passed &= test_type_conversion(bv, false); + passed &= test_type_conversion(bv, PODValue); + passed &= test_type_conversion(bv, ConstPODValue); + passed &= test_type_conversion(bv, false); + passed &= test_type_conversion(bv, ConstPODValueRef); + passed &= test_type_conversion(bv, false); + passed &= test_type_conversion(bv, false); + passed &= test_type_conversion(bv, false); + passed &= test_type_conversion(bv, false); passed &= test_type_conversion(bv, false); passed &= test_type_conversion(bv, false); passed &= test_type_conversion(bv, TPtrConstRef);