Rename Boxed_POD_Value to Boxed_Numeric, which is more correct.

This commit is contained in:
Jason Turner 2011-05-24 12:39:39 -06:00
parent 18d4984258
commit bba1ffde38
6 changed files with 89 additions and 89 deletions

View File

@ -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)

View File

@ -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 <boost/function_types/result_type.hpp>
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<typename P1>
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<typename P1>
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<typename P1>
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<typename P1>
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<typename P1>
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<typename P1>
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<typename P1>
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<typename P1>
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<typename P1>
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<typename P1>
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<typename P1>
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<typename P1>
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<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), "+");
m->add(fun(&operators::subtraction<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), "-");
m->add(fun(&operators::bitwise_and<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), "&");
m->add(fun(&operators::bitwise_xor<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), "^");
m->add(fun(&operators::bitwise_or<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), "|");
m->add(fun(&operators::division<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), "/");
m->add(fun(&operators::left_shift<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), "<<");
m->add(fun(&operators::multiplication<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), "*");
m->add(fun(&operators::remainder<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), "%");
m->add(fun(&operators::right_shift<Boxed_Value, Boxed_POD_Value, Boxed_POD_Value>), ">>");
m->add(fun(&operators::addition<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), "+");
m->add(fun(&operators::subtraction<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), "-");
m->add(fun(&operators::bitwise_and<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), "&");
m->add(fun(&operators::bitwise_xor<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), "^");
m->add(fun(&operators::bitwise_or<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), "|");
m->add(fun(&operators::division<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), "/");
m->add(fun(&operators::left_shift<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), "<<");
m->add(fun(&operators::multiplication<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), "*");
m->add(fun(&operators::remainder<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), "%");
m->add(fun(&operators::right_shift<Boxed_Value, Boxed_Numeric, Boxed_Numeric>), ">>");
}
/**
@ -619,7 +619,7 @@ namespace chaiscript
m->add(user_type<void>(), "void");
m->add(user_type<bool>(), "bool");
m->add(user_type<Boxed_Value>(), "Object");
m->add(user_type<Boxed_POD_Value>(), "PODObject");
m->add(user_type<Boxed_Numeric>(), "PODObject");
m->add(user_type<Proxy_Function>(), "Function");
m->add(user_type<std::exception>(), "exception");
@ -694,7 +694,7 @@ namespace chaiscript
operators::logical_compliment<bool>(m);
opers_comparison<Boxed_POD_Value>(m);
opers_comparison<Boxed_Numeric>(m);
opers_arithmetic_pod(m);

View File

@ -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<Boxed_POD_Value>
struct Cast_Helper<Boxed_Numeric>
{
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<const Boxed_POD_Value &> : Cast_Helper<Boxed_POD_Value>
struct Cast_Helper<const Boxed_Numeric &> : Cast_Helper<Boxed_Numeric>
{
};
/**
* 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<const Boxed_POD_Value> : Cast_Helper<Boxed_POD_Value>
struct Cast_Helper<const Boxed_Numeric> : Cast_Helper<Boxed_Numeric>
{
};
}

View File

@ -811,7 +811,7 @@ namespace chaiscript
const size_t rhssize = rhsparamtypes.size();
const Type_Info boxed_type = user_type<Boxed_Value>();
const Type_Info boxed_pod_type = user_type<Boxed_POD_Value>();
const Type_Info boxed_pod_type = user_type<Boxed_Numeric>();
boost::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynamic_lhs(boost::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(lhs));
boost::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynamic_rhs(boost::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(rhs));

View File

@ -20,7 +20,7 @@
namespace chaiscript
{
class Boxed_POD_Value;
class Boxed_Numeric;
struct AST_Node;
typedef boost::shared_ptr<struct AST_Node> AST_NodePtr;
@ -139,7 +139,7 @@ namespace chaiscript
if (ti.is_undef()
|| ti.bare_equal(user_type<Boxed_Value>())
|| (!bv.get_type_info().is_undef()
&& (ti.bare_equal(user_type<Boxed_POD_Value>())
&& (ti.bare_equal(user_type<Boxed_Numeric>())
|| 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<boost::shared_ptr<const Proxy_Function_Base> >())

View File

@ -86,14 +86,14 @@ bool do_test(const Boxed_Value &bv, bool T, bool ConstT, bool TRef, bool ConstTR
passed &= test_type_conversion<const boost::reference_wrapper<const Type> >(bv, ConstBoostConstRef);
passed &= test_type_conversion<const boost::reference_wrapper<Type> &>(bv, ConstBoostRefRef);
passed &= test_type_conversion<const boost::reference_wrapper<const Type> &>(bv, ConstBoostConstRefRef);
passed &= test_type_conversion<Boxed_POD_Value>(bv, PODValue);
passed &= test_type_conversion<const Boxed_POD_Value>(bv, ConstPODValue);
passed &= test_type_conversion<Boxed_POD_Value &>(bv, false);
passed &= test_type_conversion<const Boxed_POD_Value &>(bv, ConstPODValueRef);
passed &= test_type_conversion<Boxed_POD_Value *>(bv, false);
passed &= test_type_conversion<const Boxed_POD_Value *>(bv, false);
passed &= test_type_conversion<Boxed_POD_Value * const>(bv, false);
passed &= test_type_conversion<const Boxed_POD_Value *const>(bv, false);
passed &= test_type_conversion<Boxed_Numeric>(bv, PODValue);
passed &= test_type_conversion<const Boxed_Numeric>(bv, ConstPODValue);
passed &= test_type_conversion<Boxed_Numeric &>(bv, false);
passed &= test_type_conversion<const Boxed_Numeric &>(bv, ConstPODValueRef);
passed &= test_type_conversion<Boxed_Numeric *>(bv, false);
passed &= test_type_conversion<const Boxed_Numeric *>(bv, false);
passed &= test_type_conversion<Boxed_Numeric * const>(bv, false);
passed &= test_type_conversion<const Boxed_Numeric *const>(bv, false);
passed &= test_type_conversion<Type *&>(bv, false);
passed &= test_type_conversion<const Type *&>(bv, false);
passed &= test_type_conversion<Type * const&>(bv, TPtrConstRef);