diff --git a/include/chaiscript/chaiscript.hpp b/include/chaiscript/chaiscript.hpp index 0d1e356..2dc53db 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_numeric.hpp" +#include "dispatchkit/boxed_number.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 5f62237..8d0fab1 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_numeric.hpp" +#include "boxed_number.hpp" #include namespace chaiscript @@ -21,15 +21,15 @@ namespace chaiscript { namespace detail { - /// \brief Constructs a new POD value object from a Boxed_Numeric - /// \param[in] v Boxed_Numeric to copy into the new object + /// \brief Constructs a new POD value object from a Boxed_Number + /// \param[in] v Boxed_Number to copy into the new object /// \returns The newly created object. template - boost::shared_ptr construct_pod(Boxed_Numeric v) + boost::shared_ptr construct_pod(Boxed_Number v) { boost::shared_ptr p(new P1()); Boxed_Value bv(p); - Boxed_Numeric nb(bv); + Boxed_Number nb(bv); nb = v; return p; } @@ -210,41 +210,41 @@ namespace chaiscript */ static void opers_arithmetic_pod(ModulePtr m = ModulePtr(new Module())) { - m->add(fun(&Boxed_Numeric::operator&=), "&="); - m->add(fun(&Boxed_Numeric::operator|=), "|="); - m->add(fun(&Boxed_Numeric::operator%=), "%="); - m->add(fun(&Boxed_Numeric::operator^=), "^="); - m->add(fun(&Boxed_Numeric::operator<<=), "<<="); - m->add(fun(&Boxed_Numeric::operator>>=), ">>="); + m->add(fun(&Boxed_Number::operator&=), "&="); + m->add(fun(&Boxed_Number::operator|=), "|="); + m->add(fun(&Boxed_Number::operator%=), "%="); + m->add(fun(&Boxed_Number::operator^=), "^="); + m->add(fun(&Boxed_Number::operator<<=), "<<="); + m->add(fun(&Boxed_Number::operator>>=), ">>="); - m->add(fun(&Boxed_Numeric::operator&), "&"); - m->add(fun(&Boxed_Numeric::operator~), "~"); - m->add(fun(&Boxed_Numeric::operator^), "^"); - m->add(fun(&Boxed_Numeric::operator|), "|"); - m->add(fun(&Boxed_Numeric::operator<<), "<<"); - m->add(fun(&Boxed_Numeric::operator%), "%"); - m->add(fun(&Boxed_Numeric::operator>>), ">>"); + m->add(fun(&Boxed_Number::operator&), "&"); + m->add(fun(&Boxed_Number::operator~), "~"); + m->add(fun(&Boxed_Number::operator^), "^"); + m->add(fun(&Boxed_Number::operator|), "|"); + m->add(fun(&Boxed_Number::operator<<), "<<"); + m->add(fun(&Boxed_Number::operator%), "%"); + m->add(fun(&Boxed_Number::operator>>), ">>"); - m->add(fun(&Boxed_Numeric::operator=), "="); - m->add(fun(&Boxed_Numeric::operator*=), "*="); - m->add(fun(&Boxed_Numeric::operator/=), "/="); - m->add(fun(&Boxed_Numeric::operator+=), "+="); - m->add(fun(&Boxed_Numeric::operator-=), "-="); - m->add(fun(&Boxed_Numeric::operator--), "--"); - m->add(fun(&Boxed_Numeric::operator++), "++"); - m->add(fun(&Boxed_Numeric::operator/), "/"); - m->add(fun(&Boxed_Numeric::operator*), "*"); - m->add(fun(&Boxed_Numeric::operator+), "+"); - m->add(fun(&Boxed_Numeric::operator-), "-"); - m->add(fun(&Boxed_Numeric::operator+), "+"); - m->add(fun(&Boxed_Numeric::operator-), "-"); + m->add(fun(&Boxed_Number::operator=), "="); + m->add(fun(&Boxed_Number::operator*=), "*="); + m->add(fun(&Boxed_Number::operator/=), "/="); + m->add(fun(&Boxed_Number::operator+=), "+="); + m->add(fun(&Boxed_Number::operator-=), "-="); + m->add(fun(&Boxed_Number::operator--), "--"); + m->add(fun(&Boxed_Number::operator++), "++"); + m->add(fun(&Boxed_Number::operator/), "/"); + m->add(fun(&Boxed_Number::operator*), "*"); + m->add(fun(&Boxed_Number::operator+), "+"); + m->add(fun(&Boxed_Number::operator-), "-"); + m->add(fun(&Boxed_Number::operator+), "+"); + m->add(fun(&Boxed_Number::operator-), "-"); - m->add(fun(&Boxed_Numeric::operator==), "=="); - m->add(fun(&Boxed_Numeric::operator>), ">"); - m->add(fun(&Boxed_Numeric::operator>=), ">="); - m->add(fun(&Boxed_Numeric::operator<), "<"); - m->add(fun(&Boxed_Numeric::operator<=), "<="); - m->add(fun(&Boxed_Numeric::operator!=), "!="); + m->add(fun(&Boxed_Number::operator==), "=="); + m->add(fun(&Boxed_Number::operator>), ">"); + m->add(fun(&Boxed_Number::operator>=), ">="); + m->add(fun(&Boxed_Number::operator<), "<"); + m->add(fun(&Boxed_Number::operator<=), "<="); + m->add(fun(&Boxed_Number::operator!=), "!="); } /** @@ -369,7 +369,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(), "Number"); m->add(user_type(), "Function"); m->add(user_type(), "exception"); diff --git a/include/chaiscript/dispatchkit/boxed_numeric.hpp b/include/chaiscript/dispatchkit/boxed_number.hpp similarity index 88% rename from include/chaiscript/dispatchkit/boxed_numeric.hpp rename to include/chaiscript/dispatchkit/boxed_number.hpp index 86b8a40..81b1f12 100644 --- a/include/chaiscript/dispatchkit/boxed_numeric.hpp +++ b/include/chaiscript/dispatchkit/boxed_number.hpp @@ -19,7 +19,7 @@ namespace chaiscript { /// \brief Represents any numeric type, generically. Used internally for generic operations between POD values - class Boxed_Numeric + class Boxed_Number { private: struct boolean @@ -301,7 +301,7 @@ namespace chaiscript public: - Boxed_Numeric(const Boxed_Value &v) + Boxed_Number(const Boxed_Value &v) : bv(v) { const Type_Info &inp_ = v.get_type_info(); @@ -317,32 +317,32 @@ namespace chaiscript } - bool operator==(const Boxed_Numeric &t_rhs) const + bool operator==(const Boxed_Number &t_rhs) const { return boxed_cast(oper(Operators::equals, this->bv, t_rhs.bv)); } - bool operator<(const Boxed_Numeric &t_rhs) const + bool operator<(const Boxed_Number &t_rhs) const { return boxed_cast(oper(Operators::less_than, this->bv, t_rhs.bv)); } - bool operator>(const Boxed_Numeric &t_rhs) const + bool operator>(const Boxed_Number &t_rhs) const { return boxed_cast(oper(Operators::greater_than, this->bv, t_rhs.bv)); } - bool operator>=(const Boxed_Numeric &t_rhs) const + bool operator>=(const Boxed_Number &t_rhs) const { return boxed_cast(oper(Operators::greater_than_equal, this->bv, t_rhs.bv)); } - bool operator<=(const Boxed_Numeric &t_rhs) const + bool operator<=(const Boxed_Number &t_rhs) const { return boxed_cast(oper(Operators::less_than_equal, this->bv, t_rhs.bv)); } - bool operator!=(const Boxed_Numeric &t_rhs) const + bool operator!=(const Boxed_Number &t_rhs) const { return boxed_cast(oper(Operators::not_equal, this->bv, t_rhs.bv)); } @@ -357,7 +357,7 @@ namespace chaiscript return oper(Operators::pre_increment, this->bv, var(0)); } - Boxed_Value operator+(const Boxed_Numeric &t_rhs) const + Boxed_Value operator+(const Boxed_Number &t_rhs) const { return oper(Operators::sum, this->bv, t_rhs.bv); } @@ -372,47 +372,47 @@ namespace chaiscript return oper(Operators::unary_minus, this->bv, Boxed_Value(0)); } - Boxed_Value operator-(const Boxed_Numeric &t_rhs) const + Boxed_Value operator-(const Boxed_Number &t_rhs) const { return oper(Operators::difference, this->bv, t_rhs.bv); } - Boxed_Value operator&=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator&=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_bitwise_and, this->bv, t_rhs.bv); } - Boxed_Value operator=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator=(const Boxed_Number &t_rhs) const { return oper(Operators::assign, this->bv, t_rhs.bv); } - Boxed_Value operator|=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator|=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_bitwise_or, this->bv, t_rhs.bv); } - Boxed_Value operator^=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator^=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_bitwise_xor, this->bv, t_rhs.bv); } - Boxed_Value operator%=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator%=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_remainder, this->bv, t_rhs.bv); } - Boxed_Value operator<<=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator<<=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_shift_left, this->bv, t_rhs.bv); } - Boxed_Value operator>>=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator>>=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_shift_right, this->bv, t_rhs.bv); } - Boxed_Value operator&(const Boxed_Numeric &t_rhs) const + Boxed_Value operator&(const Boxed_Number &t_rhs) const { return oper(Operators::bitwise_and, this->bv, t_rhs.bv); } @@ -422,54 +422,54 @@ namespace chaiscript return oper(Operators::bitwise_complement, this->bv, Boxed_Value(0)); } - Boxed_Value operator^(const Boxed_Numeric &t_rhs) const + Boxed_Value operator^(const Boxed_Number &t_rhs) const { return oper(Operators::bitwise_xor, this->bv, t_rhs.bv); } - Boxed_Value operator|(const Boxed_Numeric &t_rhs) const + Boxed_Value operator|(const Boxed_Number &t_rhs) const { return oper(Operators::bitwise_or, this->bv, t_rhs.bv); } - Boxed_Value operator*=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator*=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_product, this->bv, t_rhs.bv); } - Boxed_Value operator/=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator/=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_quotient, this->bv, t_rhs.bv); } - Boxed_Value operator+=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator+=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_sum, this->bv, t_rhs.bv); } - Boxed_Value operator-=(const Boxed_Numeric &t_rhs) const + Boxed_Value operator-=(const Boxed_Number &t_rhs) const { return oper(Operators::assign_difference, this->bv, t_rhs.bv); } - Boxed_Value operator/(const Boxed_Numeric &t_rhs) const + Boxed_Value operator/(const Boxed_Number &t_rhs) const { return oper(Operators::quotient, this->bv, t_rhs.bv); } - Boxed_Value operator<<(const Boxed_Numeric &t_rhs) const + Boxed_Value operator<<(const Boxed_Number &t_rhs) const { return oper(Operators::shift_left, this->bv, t_rhs.bv); } - Boxed_Value operator*(const Boxed_Numeric &t_rhs) const + Boxed_Value operator*(const Boxed_Number &t_rhs) const { return oper(Operators::product, this->bv, t_rhs.bv); } - Boxed_Value operator%(const Boxed_Numeric &t_rhs) const + Boxed_Value operator%(const Boxed_Number &t_rhs) const { return oper(Operators::remainder, this->bv, t_rhs.bv); } - Boxed_Value operator>>(const Boxed_Numeric &t_rhs) const + Boxed_Value operator>>(const Boxed_Number &t_rhs) const { return oper(Operators::shift_right, this->bv, t_rhs.bv); } @@ -490,32 +490,32 @@ namespace chaiscript namespace detail { /** - * Cast_Helper for converting from Boxed_Value to Boxed_Numeric + * Cast_Helper for converting from Boxed_Value to Boxed_Number */ template<> - struct Cast_Helper + struct Cast_Helper { - typedef Boxed_Numeric Result_Type; + typedef Boxed_Number Result_Type; static Result_Type cast(const Boxed_Value &ob) { - return Boxed_Numeric(ob); + return Boxed_Number(ob); } }; /** - * Cast_Helper for converting from Boxed_Value to Boxed_Numeric + * Cast_Helper for converting from Boxed_Value to Boxed_Number */ template<> - struct Cast_Helper : Cast_Helper + struct Cast_Helper : Cast_Helper { }; /** - * Cast_Helper for converting from Boxed_Value to Boxed_Numeric + * Cast_Helper for converting from Boxed_Value to Boxed_Number */ 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 c286149..550a9fb 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 fa0c89d..b6bb7e0 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -20,7 +20,7 @@ namespace chaiscript { - class Boxed_Numeric; + class Boxed_Number; 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/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 757d804..bd2ee1a 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -58,7 +58,7 @@ namespace chaiscript { // If it's an arithmetic operation we want to short circuit dispatch try{ - return Boxed_Numeric::do_oper(t_oper, t_lhs, t_rhs); + return Boxed_Number::do_oper(t_oper, t_lhs, t_rhs); } catch (...) { throw exception::eval_error("Error with numeric operator calling: " + t_oper_string); } @@ -288,7 +288,7 @@ namespace chaiscript retval.get_type_info().is_arithmetic()) { try { - retval = Boxed_Numeric::do_oper(oper, lhs, retval); + retval = Boxed_Number::do_oper(oper, lhs, retval); } catch (const std::exception &) { throw exception::eval_error("Error with unsupported arithmetic assignment operation"); } @@ -862,7 +862,7 @@ namespace chaiscript try { if (bv.get_type_info().is_arithmetic() && oper != Operators::invalid) { - return Boxed_Numeric::do_oper(oper, bv); + return Boxed_Number::do_oper(oper, bv); } else { return t_ss.call_function(this->children[0]->text, bv); } diff --git a/unittests/boxed_cast_test.cpp b/unittests/boxed_cast_test.cpp index 078ec97..2e6edd9 100644 --- a/unittests/boxed_cast_test.cpp +++ b/unittests/boxed_cast_test.cpp @@ -58,8 +58,8 @@ bool do_test(const Boxed_Value &bv, bool T, bool ConstT, bool TRef, bool ConstTR bool ConstTPtrConst, bool SharedPtrT, bool SharedConstPtrT, bool ConstSharedPtrT, bool ConstSharedConstPtrT, bool ConstSharedPtrTRef, bool ConstSharedPtrTConstRef, bool BoostRef, bool BoostConstRef, bool ConstBoostRef, bool ConstBoostConstRef, - bool ConstBoostRefRef, bool ConstBoostConstRefRef, bool PODValue, - bool ConstPODValue, bool ConstPODValueRef, bool TPtrConstRef, bool ConstTPtrConstRef) + bool ConstBoostRefRef, bool ConstBoostConstRefRef, bool Number, + bool ConstNumber, bool ConstNumberRef, bool TPtrConstRef, bool ConstTPtrConstRef) { bool passed = true; passed &= test_type_conversion(bv, T); @@ -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, Number); + passed &= test_type_conversion(bv, ConstNumber); + passed &= test_type_conversion(bv, false); + passed &= test_type_conversion(bv, ConstNumberRef); + 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); @@ -295,7 +295,7 @@ int main() bool ConstTPtr, bool TPtrConst, bool ConstTPtrConst, bool SharedPtrT, bool SharedConstPtrT, bool ConstSharedPtrT, bool ConstSharedConstPtrT, bool ConstSharedPtrTRef, bool ConstSharedPtrTConstRef, bool BoostRef, bool BoostConstRef, bool ConstBoostRef, bool ConstBoostConstRef, bool ConstBoostRefRef, bool ConstBoostConstRefRef, - bool PODValue, bool ConstPODValue, bool ConstPODValueRef + bool Number, bool ConstNumber, bool ConstNumberRef */ passed &= built_in_type_test(5, true);