Even more reorganization of namespaces to help with documentation and

clarity.
This commit is contained in:
Jason Turner 2011-03-25 15:42:18 -06:00
parent 8bd512a0af
commit 58e5df0a9a
16 changed files with 1777 additions and 1749 deletions

View File

@ -31,7 +31,7 @@ namespace chaiscript
P1 &assign_pod(P1 &p1, Boxed_POD_Value v) P1 &assign_pod(P1 &p1, Boxed_POD_Value v)
{ {
if (v.m_isfloat) if (v.isfloat)
{ {
return (p1 = P1(v.d)); return (p1 = P1(v.d));
} else { } else {
@ -42,7 +42,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 construct_pod(Boxed_POD_Value v) P1 construct_pod(Boxed_POD_Value v)
{ {
if (v.m_isfloat) if (v.isfloat)
{ {
return P1(v.d); return P1(v.d);
} else { } else {
@ -53,7 +53,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_bitwise_and_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_bitwise_and_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (!r.m_isfloat) if (!r.isfloat)
{ {
return p1 &= P1(r.i); return p1 &= P1(r.i);
} }
@ -64,7 +64,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_xor_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_xor_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (!r.m_isfloat) if (!r.isfloat)
{ {
return p1 ^= P1(r.i); return p1 ^= P1(r.i);
} }
@ -75,7 +75,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_bitwise_or_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_bitwise_or_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (!r.m_isfloat) if (!r.isfloat)
{ {
return p1 |= P1(r.i); return p1 |= P1(r.i);
} }
@ -86,7 +86,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_difference_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_difference_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (r.m_isfloat) if (r.isfloat)
{ {
return p1 -= P1(r.d); return p1 -= P1(r.d);
} else { } else {
@ -97,7 +97,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_left_shift_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_left_shift_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (!r.m_isfloat) if (!r.isfloat)
{ {
return p1 <<= P1(r.i); return p1 <<= P1(r.i);
} }
@ -109,7 +109,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_product_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_product_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (r.m_isfloat) if (r.isfloat)
{ {
return p1 *= P1(r.d); return p1 *= P1(r.d);
} else { } else {
@ -120,7 +120,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_quotient_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_quotient_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (r.m_isfloat) if (r.isfloat)
{ {
return p1 /= P1(r.d); return p1 /= P1(r.d);
} else { } else {
@ -131,7 +131,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_remainder_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_remainder_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (!r.m_isfloat) if (!r.isfloat)
{ {
return p1 %= P1(r.i); return p1 %= P1(r.i);
} }
@ -143,7 +143,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_right_shift_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_right_shift_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (!r.m_isfloat) if (!r.isfloat)
{ {
return p1 >>= P1(r.i); return p1 >>= P1(r.i);
} }
@ -155,7 +155,7 @@ namespace chaiscript
template<typename P1> template<typename P1>
P1 &assign_sum_pod(P1 &p1, Boxed_POD_Value r) P1 &assign_sum_pod(P1 &p1, Boxed_POD_Value r)
{ {
if (r.m_isfloat) if (r.isfloat)
{ {
return p1 += P1(r.d); return p1 += P1(r.d);
} else { } else {
@ -458,7 +458,7 @@ namespace chaiscript
Const_Proxy_Function f = boxed_cast<Const_Proxy_Function>(params[0]); Const_Proxy_Function f = boxed_cast<Const_Proxy_Function>(params[0]);
return Boxed_Value(Const_Proxy_Function(new Bound_Function(f, return Boxed_Value(Const_Proxy_Function(new dispatch::Bound_Function(f,
std::vector<Boxed_Value>(params.begin() + 1, params.end())))); std::vector<Boxed_Value>(params.begin() + 1, params.end()))));
} }
@ -480,7 +480,7 @@ namespace chaiscript
static bool has_guard(const Const_Proxy_Function &t_pf) static bool has_guard(const Const_Proxy_Function &t_pf)
{ {
boost::shared_ptr<const Dynamic_Proxy_Function> pf = boost::dynamic_pointer_cast<const Dynamic_Proxy_Function>(t_pf); boost::shared_ptr<const dispatch::Dynamic_Proxy_Function> pf = boost::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_pf);
if (pf) if (pf)
{ {
return pf->get_guard(); return pf->get_guard();
@ -491,7 +491,7 @@ namespace chaiscript
static Const_Proxy_Function get_guard(const Const_Proxy_Function &t_pf) static Const_Proxy_Function get_guard(const Const_Proxy_Function &t_pf)
{ {
boost::shared_ptr<const Dynamic_Proxy_Function> pf = boost::dynamic_pointer_cast<const Dynamic_Proxy_Function>(t_pf); boost::shared_ptr<const dispatch::Dynamic_Proxy_Function> pf = boost::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_pf);
if (pf) if (pf)
{ {
if (pf->get_guard()) if (pf->get_guard())
@ -509,7 +509,7 @@ namespace chaiscript
throw bv; throw bv;
} }
static boost::shared_ptr<Dispatch_Engine> bootstrap2(boost::shared_ptr<Dispatch_Engine> e = boost::shared_ptr<Dispatch_Engine> (new Dispatch_Engine())) static boost::shared_ptr<chaiscript::detail::Dispatch_Engine> bootstrap2(boost::shared_ptr<chaiscript::detail::Dispatch_Engine> e = boost::shared_ptr<chaiscript::detail::Dispatch_Engine> (new chaiscript::detail::Dispatch_Engine()))
{ {
e->add(user_type<void>(), "void"); e->add(user_type<void>(), "void");
return e; return e;
@ -535,7 +535,7 @@ namespace chaiscript
template<typename FunctionType> template<typename FunctionType>
static std::vector<Boxed_Value> do_return_boxed_value_vector(FunctionType f, static std::vector<Boxed_Value> do_return_boxed_value_vector(FunctionType f,
const Proxy_Function_Base *b) const dispatch::Proxy_Function_Base *b)
{ {
typedef typename boost::function_types::result_type<FunctionType>::type Vector; typedef typename boost::function_types::result_type<FunctionType>::type Vector;
Vector v = (b->*f)(); Vector v = (b->*f)();
@ -552,7 +552,7 @@ namespace chaiscript
} }
template<typename Function> template<typename Function>
static boost::function<std::vector<Boxed_Value> (const Proxy_Function_Base*)> return_boxed_value_vector(const Function &f) static boost::function<std::vector<Boxed_Value> (const dispatch::Proxy_Function_Base*)> return_boxed_value_vector(const Function &f)
{ {
return boost::bind(&do_return_boxed_value_vector<Function>, f, _1); return boost::bind(&do_return_boxed_value_vector<Function>, f, _1);
} }
@ -570,14 +570,14 @@ namespace chaiscript
m->add(user_type<Proxy_Function>(), "function"); m->add(user_type<Proxy_Function>(), "function");
m->add(user_type<std::exception>(), "exception"); m->add(user_type<std::exception>(), "exception");
m->add(fun(&Proxy_Function_Base::get_arity), "get_arity"); m->add(fun(&dispatch::Proxy_Function_Base::get_arity), "get_arity");
m->add(fun(&Proxy_Function_Base::annotation), "get_annotation"); m->add(fun(&dispatch::Proxy_Function_Base::annotation), "get_annotation");
m->add(fun(&Proxy_Function_Base::operator()), "call"); m->add(fun(&dispatch::Proxy_Function_Base::operator()), "call");
m->add(fun(&Proxy_Function_Base::operator==), "=="); m->add(fun(&dispatch::Proxy_Function_Base::operator==), "==");
m->add(fun(return_boxed_value_vector(&Proxy_Function_Base::get_param_types)), "get_param_types"); m->add(fun(return_boxed_value_vector(&dispatch::Proxy_Function_Base::get_param_types)), "get_param_types");
m->add(fun(return_boxed_value_vector(&Proxy_Function_Base::get_contained_functions)), "get_contained_functions"); m->add(fun(return_boxed_value_vector(&dispatch::Proxy_Function_Base::get_contained_functions)), "get_contained_functions");
m->add(user_type<std::runtime_error>(), "runtime_error"); m->add(user_type<std::runtime_error>(), "runtime_error");
@ -587,11 +587,11 @@ namespace chaiscript
m->add(constructor<std::runtime_error (const std::string &)>(), "runtime_error"); m->add(constructor<std::runtime_error (const std::string &)>(), "runtime_error");
m->add(fun(boost::function<std::string (const std::runtime_error &)>(&what)), "what"); m->add(fun(boost::function<std::string (const std::runtime_error &)>(&what)), "what");
m->add(user_type<Dynamic_Object>(), "Dynamic_Object"); m->add(user_type<dispatch::Dynamic_Object>(), "Dynamic_Object");
m->add(constructor<Dynamic_Object (const std::string &)>(), "Dynamic_Object"); m->add(constructor<dispatch::Dynamic_Object (const std::string &)>(), "Dynamic_Object");
m->add(fun(&Dynamic_Object::get_type_name), "get_type_name"); m->add(fun(&dispatch::Dynamic_Object::get_type_name), "get_type_name");
m->add(fun(&Dynamic_Object::get_attrs), "get_attrs"); m->add(fun(&dispatch::Dynamic_Object::get_attrs), "get_attrs");
m->add(fun(&Dynamic_Object::get_attr), "get_attr"); m->add(fun(&dispatch::Dynamic_Object::get_attr), "get_attr");
m->eval("def Dynamic_Object::clone() { var new_o := Dynamic_Object(this.get_type_name()); for_each(this.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; }"); m->eval("def Dynamic_Object::clone() { var new_o := Dynamic_Object(this.get_type_name()); for_each(this.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; }");
@ -648,14 +648,14 @@ namespace chaiscript
m->add(fun(&print), "print_string"); m->add(fun(&print), "print_string");
m->add(fun(&println), "println_string"); m->add(fun(&println), "println_string");
m->add(Proxy_Function(new Dynamic_Proxy_Function(boost::bind(&bind_function, _1))), m->add(Proxy_Function(new dispatch::Dynamic_Proxy_Function(boost::bind(&bind_function, _1))),
"bind"); "bind");
m->add(fun(&shared_ptr_unconst_clone<Proxy_Function_Base>), "clone"); m->add(fun(&shared_ptr_unconst_clone<dispatch::Proxy_Function_Base>), "clone");
m->add(fun(&ptr_assign<boost::remove_const<Proxy_Function_Base>::type>), "="); m->add(fun(&ptr_assign<boost::remove_const<dispatch::Proxy_Function_Base>::type>), "=");
m->add(fun(&ptr_assign<boost::add_const<Proxy_Function_Base>::type>), "="); m->add(fun(&ptr_assign<boost::add_const<dispatch::Proxy_Function_Base>::type>), "=");
m->add(Proxy_Function(new Dynamic_Proxy_Function(boost::bind(&call_exists, _1))), m->add(Proxy_Function(new dispatch::Dynamic_Proxy_Function(boost::bind(&call_exists, _1))),
"call_exists"); "call_exists");
m->add(fun(&type_match), "type_match"); m->add(fun(&type_match), "type_match");

View File

@ -21,10 +21,11 @@ namespace chaiscript
* Object which attempts to convert a Boxed_Value into a generic * Object which attempts to convert a Boxed_Value into a generic
* POD type and provide generic POD type operations * POD type and provide generic POD type operations
*/ */
struct Boxed_POD_Value class Boxed_POD_Value
{ {
public:
Boxed_POD_Value(const Boxed_Value &v) Boxed_POD_Value(const Boxed_Value &v)
: d(0), i(0), m_isfloat(false) : d(0), i(0), isfloat(false)
{ {
if (v.get_type_info().is_undef()) if (v.get_type_info().is_undef())
{ {
@ -36,10 +37,10 @@ namespace chaiscript
if (inp_ == typeid(double)) if (inp_ == typeid(double))
{ {
d = boxed_cast<double>(v); d = boxed_cast<double>(v);
m_isfloat = true; isfloat = true;
} else if (inp_ == typeid(float)) { } else if (inp_ == typeid(float)) {
d = boxed_cast<float>(v); d = boxed_cast<float>(v);
m_isfloat = true; isfloat = true;
} else if (inp_ == typeid(bool)) { } else if (inp_ == typeid(bool)) {
i = boxed_cast<bool>(v); i = boxed_cast<bool>(v);
} else if (inp_ == typeid(char)) { } else if (inp_ == typeid(char)) {
@ -73,57 +74,57 @@ namespace chaiscript
bool operator==(const Boxed_POD_Value &r) const bool operator==(const Boxed_POD_Value &r) const
{ {
return ((m_isfloat)?d:i) == ((r.m_isfloat)?r.d:r.i); return ((isfloat)?d:i) == ((r.isfloat)?r.d:r.i);
} }
bool operator<(const Boxed_POD_Value &r) const bool operator<(const Boxed_POD_Value &r) const
{ {
return ((m_isfloat)?d:i) < ((r.m_isfloat)?r.d:r.i); return ((isfloat)?d:i) < ((r.isfloat)?r.d:r.i);
} }
bool operator>(const Boxed_POD_Value &r) const bool operator>(const Boxed_POD_Value &r) const
{ {
return ((m_isfloat)?d:i) > ((r.m_isfloat)?r.d:r.i); return ((isfloat)?d:i) > ((r.isfloat)?r.d:r.i);
} }
bool operator>=(const Boxed_POD_Value &r) const bool operator>=(const Boxed_POD_Value &r) const
{ {
return ((m_isfloat)?d:i) >= ((r.m_isfloat)?r.d:r.i); return ((isfloat)?d:i) >= ((r.isfloat)?r.d:r.i);
} }
bool operator<=(const Boxed_POD_Value &r) const bool operator<=(const Boxed_POD_Value &r) const
{ {
return ((m_isfloat)?d:i) <= ((r.m_isfloat)?r.d:r.i); return ((isfloat)?d:i) <= ((r.isfloat)?r.d:r.i);
} }
bool operator!=(const Boxed_POD_Value &r) const bool operator!=(const Boxed_POD_Value &r) const
{ {
return ((m_isfloat)?d:i) != ((r.m_isfloat)?r.d:r.i); return ((isfloat)?d:i) != ((r.isfloat)?r.d:r.i);
} }
Boxed_Value operator+(const Boxed_POD_Value &r) const Boxed_Value operator+(const Boxed_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return smart_size(i + r.i); return smart_size(i + r.i);
} }
return Boxed_Value(((m_isfloat)?d:i) + ((r.m_isfloat)?r.d:r.i)); 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_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return smart_size(i - r.i); return smart_size(i - r.i);
} }
return Boxed_Value(((m_isfloat)?d:i) - ((r.m_isfloat)?r.d:r.i)); 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_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return Boxed_Value(i & r.i); return Boxed_Value(i & r.i);
} }
@ -133,7 +134,7 @@ namespace chaiscript
Boxed_Value operator^(const Boxed_POD_Value &r) const Boxed_Value operator^(const Boxed_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return Boxed_Value(i ^ r.i); return Boxed_Value(i ^ r.i);
} }
@ -143,7 +144,7 @@ namespace chaiscript
Boxed_Value operator|(const Boxed_POD_Value &r) const Boxed_Value operator|(const Boxed_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return Boxed_Value(i | r.i); return Boxed_Value(i | r.i);
} }
@ -153,17 +154,17 @@ namespace chaiscript
Boxed_Value operator/(const Boxed_POD_Value &r) const Boxed_Value operator/(const Boxed_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return smart_size(i / r.i); return smart_size(i / r.i);
} }
return Boxed_Value(((m_isfloat)?d:i) / ((r.m_isfloat)?r.d:r.i)); 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_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return smart_size(i << r.i); return smart_size(i << r.i);
} }
@ -174,18 +175,18 @@ namespace chaiscript
Boxed_Value operator*(const Boxed_POD_Value &r) const Boxed_Value operator*(const Boxed_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return smart_size(i * r.i); return smart_size(i * r.i);
} }
return Boxed_Value(((m_isfloat)?d:i) * ((r.m_isfloat)?r.d:r.i)); 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_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return smart_size(i % r.i); return smart_size(i % r.i);
} }
@ -195,7 +196,7 @@ namespace chaiscript
Boxed_Value operator>>(const Boxed_POD_Value &r) const Boxed_Value operator>>(const Boxed_POD_Value &r) const
{ {
if (!m_isfloat && !r.m_isfloat) if (!isfloat && !r.isfloat)
{ {
return smart_size(i >> r.i); return smart_size(i >> r.i);
} }
@ -215,11 +216,10 @@ namespace chaiscript
} }
double d; double d;
boost::int64_t i; boost::int64_t i;
bool m_isfloat; bool isfloat;
}; };
namespace detail namespace detail

View File

@ -111,12 +111,14 @@ namespace chaiscript
typedef boost::shared_ptr<Module> ModulePtr; typedef boost::shared_ptr<Module> ModulePtr;
namespace detail
{
/** /**
* A Proxy_Function implementation that is able to take * A Proxy_Function implementation that is able to take
* a vector of Proxy_Functions and perform a dispatch on them. It is * a vector of Proxy_Functions and perform a dispatch on them. It is
* used specifically in the case of dealing with Function object variables * used specifically in the case of dealing with Function object variables
*/ */
class Dispatch_Function : public Proxy_Function_Base class Dispatch_Function : public dispatch::Proxy_Function_Base
{ {
public: public:
Dispatch_Function(const std::vector<Proxy_Function> &t_funcs) Dispatch_Function(const std::vector<Proxy_Function> &t_funcs)
@ -125,7 +127,7 @@ namespace chaiscript
{ {
} }
virtual bool operator==(const Proxy_Function_Base &rhs) const virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const
{ {
try { try {
const Dispatch_Function &dispatchfun = dynamic_cast<const Dispatch_Function &>(rhs); const Dispatch_Function &dispatchfun = dynamic_cast<const Dispatch_Function &>(rhs);
@ -201,7 +203,7 @@ namespace chaiscript
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params) const virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params) const
{ {
return detail::dispatch(m_funcs.begin(), m_funcs.end(), params); return dispatch::dispatch(m_funcs.begin(), m_funcs.end(), params);
} }
private: private:
@ -255,7 +257,7 @@ namespace chaiscript
return std::vector<Type_Info>(); return std::vector<Type_Info>();
} }
}; };
}
namespace exception namespace exception
{ {
@ -300,6 +302,8 @@ namespace chaiscript
}; };
} }
namespace detail
{
/** /**
* Main class for the dispatchkit. Handles management * Main class for the dispatchkit. Handles management
* of the object stack, functions and registered types. * of the object stack, functions and registered types.
@ -321,7 +325,7 @@ namespace chaiscript
}; };
Dispatch_Engine() Dispatch_Engine()
: m_place_holder(boost::shared_ptr<Placeholder_Object>(new Placeholder_Object())) : m_place_holder(boost::shared_ptr<dispatch::Placeholder_Object>(new dispatch::Placeholder_Object()))
{ {
} }
@ -647,7 +651,7 @@ namespace chaiscript
{ {
std::vector<Proxy_Function> functions = get_function(t_name); std::vector<Proxy_Function> functions = get_function(t_name);
return detail::dispatch(functions.begin(), functions.end(), params); return dispatch::dispatch(functions.begin(), functions.end(), params);
} }
Boxed_Value call_function(const std::string &t_name) const Boxed_Value call_function(const std::string &t_name) const
@ -760,7 +764,7 @@ namespace chaiscript
} }
try { try {
const Dynamic_Object &d = boxed_cast<const Dynamic_Object &>(r); const dispatch::Dynamic_Object &d = boxed_cast<const dispatch::Dynamic_Object &>(r);
return d.get_type_name() == user_typename; return d.get_type_name() == user_typename;
} catch (const std::bad_cast &) { } catch (const std::bad_cast &) {
} }
@ -825,8 +829,8 @@ namespace chaiscript
const Type_Info boxed_type = user_type<Boxed_Value>(); 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_POD_Value>();
boost::shared_ptr<const Dynamic_Proxy_Function> dynamic_lhs(boost::dynamic_pointer_cast<const Dynamic_Proxy_Function>(lhs)); boost::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynamic_lhs(boost::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(lhs));
boost::shared_ptr<const Dynamic_Proxy_Function> dynamic_rhs(boost::dynamic_pointer_cast<const Dynamic_Proxy_Function>(rhs)); boost::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynamic_rhs(boost::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(rhs));
if (dynamic_lhs && dynamic_rhs) if (dynamic_lhs && dynamic_rhs)
{ {
@ -988,7 +992,7 @@ namespace chaiscript
Boxed_Value m_place_holder; Boxed_Value m_place_holder;
}; };
}
} }
#endif #endif

View File

@ -11,6 +11,8 @@
namespace chaiscript namespace chaiscript
{ {
namespace dispatch
{
class Dynamic_Object class Dynamic_Object
{ {
public: public:
@ -276,6 +278,7 @@ namespace chaiscript
}; };
} }
}
} }
#endif #endif

View File

@ -20,6 +20,8 @@
namespace chaiscript namespace chaiscript
{ {
namespace dispatch
{
/** /**
* Build a function caller that knows how to dispatch on a set of functions * Build a function caller that knows how to dispatch on a set of functions
* example: * example:
@ -68,6 +70,7 @@ namespace chaiscript
{ {
return functor<FunctionType>(boxed_cast<Const_Proxy_Function >(bv)); return functor<FunctionType>(boxed_cast<Const_Proxy_Function >(bv));
} }
}
namespace detail{ namespace detail{
/** /**
@ -82,7 +85,7 @@ namespace chaiscript
{ {
if (ob.get_type_info().bare_equal(user_type<Const_Proxy_Function>())) if (ob.get_type_info().bare_equal(user_type<Const_Proxy_Function>()))
{ {
return functor<Signature>(ob); return dispatch::functor<Signature>(ob);
} else { } else {
return Cast_Helper_Inner<const boost::function<Signature> &>::cast(ob); return Cast_Helper_Inner<const boost::function<Signature> &>::cast(ob);
} }
@ -101,7 +104,7 @@ namespace chaiscript
{ {
if (ob.get_type_info().bare_equal(user_type<Const_Proxy_Function>())) if (ob.get_type_info().bare_equal(user_type<Const_Proxy_Function>()))
{ {
return functor<Signature>(ob); return dispatch::functor<Signature>(ob);
} else { } else {
return Cast_Helper_Inner<boost::function<Signature> >::cast(ob); return Cast_Helper_Inner<boost::function<Signature> >::cast(ob);
} }
@ -120,14 +123,13 @@ namespace chaiscript
{ {
if (ob.get_type_info().bare_equal(user_type<Const_Proxy_Function>())) if (ob.get_type_info().bare_equal(user_type<Const_Proxy_Function>()))
{ {
return functor<Signature>(ob); return dispatch::functor<Signature>(ob);
} else { } else {
return Cast_Helper_Inner<const boost::function<Signature> >::cast(ob); return Cast_Helper_Inner<const boost::function<Signature> >::cast(ob);
} }
} }
}; };
} }
} }
#endif #endif

View File

@ -23,6 +23,8 @@
namespace chaiscript namespace chaiscript
{ {
namespace dispatch
{
namespace detail namespace detail
{ {
@ -36,7 +38,7 @@ namespace chaiscript
static Ret call(const std::vector<Const_Proxy_Function> &t_funcs, static Ret call(const std::vector<Const_Proxy_Function> &t_funcs,
const std::vector<Boxed_Value> &params) const std::vector<Boxed_Value> &params)
{ {
return boxed_cast<Ret>(dispatch(t_funcs, params)); return boxed_cast<Ret>(dispatch::dispatch(t_funcs, params));
} }
}; };
@ -49,10 +51,11 @@ namespace chaiscript
static void call(const std::vector<Const_Proxy_Function> &t_funcs, static void call(const std::vector<Const_Proxy_Function> &t_funcs,
const std::vector<Boxed_Value> &params) const std::vector<Boxed_Value> &params)
{ {
dispatch(t_funcs, params); dispatch::dispatch(t_funcs, params);
} }
}; };
} }
}
} }
#define BOOST_PP_ITERATION_LIMITS ( 0, 9 ) #define BOOST_PP_ITERATION_LIMITS ( 0, 9 )
@ -65,6 +68,8 @@ namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
namespace dispatch
{
namespace detail namespace detail
{ {
/** /**
@ -105,7 +110,7 @@ namespace chaiscript
return boost::bind(&function_caller<Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param)>, funcs return boost::bind(&function_caller<Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param)>, funcs
BOOST_PP_ENUM_TRAILING(n, curry, ~)); BOOST_PP_ENUM_TRAILING(n, curry, ~));
} }
}
} }
} }
#undef n #undef n

View File

@ -26,7 +26,7 @@ namespace chaiscript
Proxy_Function constructor() Proxy_Function constructor()
{ {
T *f = 0; T *f = 0;
return (detail::build_constructor_(f)); return (dispatch::detail::build_constructor_(f));
} }
} }
@ -35,6 +35,8 @@ namespace chaiscript
namespace chaiscript namespace chaiscript
{ {
namespace dispatch
{
namespace detail namespace detail
{ {
/** /**
@ -60,6 +62,7 @@ namespace chaiscript
return Proxy_Function(new Proxy_Function_Impl<sig>(boost::function<sig>(&(constructor_<Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param)>)))); return Proxy_Function(new Proxy_Function_Impl<sig>(boost::function<sig>(&(constructor_<Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param)>))));
} }
} }
}
} }
#undef n #undef n

View File

@ -26,6 +26,8 @@ namespace chaiscript
typedef boost::shared_ptr<struct AST_Node> AST_NodePtr; typedef boost::shared_ptr<struct AST_Node> AST_NodePtr;
namespace dispatch
{
/** /**
* Helper for building a list of parameters for calling a Proxy_Function * Helper for building a list of parameters for calling a Proxy_Function
* it does automatic conversion to Boxed_Value types via operator<< * it does automatic conversion to Boxed_Value types via operator<<
@ -171,9 +173,10 @@ namespace chaiscript
std::vector<Type_Info> m_types; std::vector<Type_Info> m_types;
}; };
}
typedef boost::shared_ptr<Proxy_Function_Base> Proxy_Function; typedef boost::shared_ptr<dispatch::Proxy_Function_Base> Proxy_Function;
typedef boost::shared_ptr<const Proxy_Function_Base> Const_Proxy_Function; typedef boost::shared_ptr<const dispatch::Proxy_Function_Base> Const_Proxy_Function;
namespace exception namespace exception
{ {
@ -192,6 +195,8 @@ namespace chaiscript
}; };
} }
namespace dispatch
{
/** /**
* A Proxy_Function implementation that is not type safe, the called function * A Proxy_Function implementation that is not type safe, the called function
* is expecting a vector<Boxed_Value> that it works with how it chooses. * is expecting a vector<Boxed_Value> that it works with how it chooses.
@ -568,6 +573,7 @@ namespace chaiscript
} }
T Class::* m_attr; T Class::* m_attr;
}; };
}
namespace exception namespace exception
{ {
@ -594,8 +600,9 @@ namespace chaiscript
}; };
} }
namespace detail namespace dispatch
{ {
/** /**
* Take a vector of functions and a vector of parameters. Attempt to execute * Take a vector of functions and a vector of parameters. Attempt to execute
* each function against the set of parameters, in order, until a matching * each function against the set of parameters, in order, until a matching
@ -635,7 +642,7 @@ namespace chaiscript
Boxed_Value dispatch(const Funcs &funcs, Boxed_Value dispatch(const Funcs &funcs,
const std::vector<Boxed_Value> &plist) const std::vector<Boxed_Value> &plist)
{ {
return dispatch(funcs.begin(), funcs.end(), plist); return dispatch::dispatch(funcs.begin(), funcs.end(), plist);
} }
} }
} }

View File

@ -18,6 +18,8 @@
namespace chaiscript namespace chaiscript
{ {
namespace dispatch
{
namespace detail namespace detail
{ {
template<bool Object, bool MemFn> template<bool Object, bool MemFn>
@ -60,19 +62,19 @@ namespace chaiscript
return Proxy_Function(new Attribute_Access<T, Class>(m)); return Proxy_Function(new Attribute_Access<T, Class>(m));
} }
}; };
}
} }
template<typename T> template<typename T>
Proxy_Function fun(const boost::function<T> &f) Proxy_Function fun(const boost::function<T> &f)
{ {
return Proxy_Function(new Proxy_Function_Impl<T>(f)); return Proxy_Function(new dispatch::Proxy_Function_Impl<T>(f));
} }
template<typename T> template<typename T>
Proxy_Function fun(T t) Proxy_Function fun(T t)
{ {
return detail::Fun_Helper<boost::function_types::is_member_object_pointer<T>::value, boost::function_types::is_member_function_pointer<T>::value>::go(t); return dispatch::detail::Fun_Helper<boost::function_types::is_member_object_pointer<T>::value, boost::function_types::is_member_function_pointer<T>::value>::go(t);
} }
template<typename T, typename Q> template<typename T, typename Q>

View File

@ -99,7 +99,7 @@ namespace chaiscript
return to_string(); return to_string();
} }
virtual Boxed_Value eval(Dispatch_Engine &) { virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &) {
Boxed_Value bv; Boxed_Value bv;
throw std::runtime_error("Undispatched ast_node (internal error)"); throw std::runtime_error("Undispatched ast_node (internal error)");
} }

View File

@ -235,7 +235,7 @@ namespace chaiscript
std::vector<std::string> m_modulepaths; std::vector<std::string> m_modulepaths;
std::vector<std::string> m_usepaths; std::vector<std::string> m_usepaths;
Dispatch_Engine m_engine; chaiscript::detail::Dispatch_Engine m_engine;
/** /**
@ -307,7 +307,7 @@ namespace chaiscript
/** /**
* Returns the current evaluation m_engine * Returns the current evaluation m_engine
*/ */
Dispatch_Engine &get_eval_engine() { chaiscript::detail::Dispatch_Engine &get_eval_engine() {
return m_engine; return m_engine;
} }
@ -335,13 +335,13 @@ namespace chaiscript
add(Bootstrap::bootstrap()); add(Bootstrap::bootstrap());
m_engine.add(fun(&Dispatch_Engine::dump_system, boost::ref(m_engine)), "dump_system"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::dump_system, boost::ref(m_engine)), "dump_system");
m_engine.add(fun(&Dispatch_Engine::dump_object, boost::ref(m_engine)), "dump_object"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::dump_object, boost::ref(m_engine)), "dump_object");
m_engine.add(fun(&Dispatch_Engine::is_type, boost::ref(m_engine)), "is_type"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::is_type, boost::ref(m_engine)), "is_type");
m_engine.add(fun(&Dispatch_Engine::type_name, boost::ref(m_engine)), "type_name"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::type_name, boost::ref(m_engine)), "type_name");
m_engine.add(fun(&Dispatch_Engine::function_exists, boost::ref(m_engine)), "function_exists"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::function_exists, boost::ref(m_engine)), "function_exists");
m_engine.add(fun(&Dispatch_Engine::get_type_name, boost::ref(m_engine)), "name"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::get_type_name, boost::ref(m_engine)), "name");
typedef void (ChaiScript::*load_mod_1)(const std::string&); typedef void (ChaiScript::*load_mod_1)(const std::string&);
@ -392,7 +392,7 @@ namespace chaiscript
struct State struct State
{ {
std::set<std::string> used_files; std::set<std::string> used_files;
Dispatch_Engine::State engine_state; chaiscript::detail::Dispatch_Engine::State engine_state;
std::set<std::string> active_loaded_modules; std::set<std::string> active_loaded_modules;
}; };
@ -532,7 +532,7 @@ namespace chaiscript
template<typename FunctionType> template<typename FunctionType>
boost::function<FunctionType> functor(const std::string &t_script) boost::function<FunctionType> functor(const std::string &t_script)
{ {
return chaiscript::functor<FunctionType>(eval(t_script)); return chaiscript::dispatch::functor<FunctionType>(eval(t_script));
} }
/** /**

View File

@ -49,7 +49,7 @@ namespace chaiscript
Binary_Operator_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Bitwise_Xor, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Binary_Operator_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Bitwise_Xor, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Binary_Operator_AST_Node() {} virtual ~Binary_Operator_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
Boxed_Value retval; Boxed_Value retval;
try { try {
@ -91,7 +91,7 @@ namespace chaiscript
Int_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Int, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Int_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Int, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Int_AST_Node() {} virtual ~Int_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &){
return const_var(int(atoi(this->text.c_str()))); return const_var(int(atoi(this->text.c_str())));
} }
@ -102,7 +102,7 @@ namespace chaiscript
Float_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Float, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Float_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Float, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Float_AST_Node() {} virtual ~Float_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &){
return const_var(double(atof(this->text.c_str()))); return const_var(double(atof(this->text.c_str())));
} }
@ -113,7 +113,7 @@ namespace chaiscript
Id_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Id, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Id_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Id, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Id_AST_Node() {} virtual ~Id_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
if (this->text == "true") { if (this->text == "true") {
return const_var(true); return const_var(true);
} }
@ -163,8 +163,8 @@ namespace chaiscript
Fun_Call_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Fun_Call, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Fun_Call_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Fun_Call, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Fun_Call_AST_Node() {} virtual ~Fun_Call_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
Param_List_Builder plb; dispatch::Param_List_Builder plb;
if ((this->children.size() > 1) && (this->children[1]->identifier == AST_Node_Type::Arg_List)) { if ((this->children.size() > 1) && (this->children[1]->identifier == AST_Node_Type::Arg_List)) {
for (size_t i = 0; i < this->children[1]->children.size(); ++i) { for (size_t i = 0; i < this->children[1]->children.size(); ++i) {
@ -178,8 +178,8 @@ namespace chaiscript
} }
} }
Dispatch_Engine::Stack prev_stack = t_ss.get_stack(); chaiscript::detail::Dispatch_Engine::Stack prev_stack = t_ss.get_stack();
Dispatch_Engine::Stack new_stack = t_ss.new_stack(); chaiscript::detail::Dispatch_Engine::Stack new_stack = t_ss.new_stack();
try { try {
Boxed_Value fn = this->children[0]->eval(t_ss); Boxed_Value fn = this->children[0]->eval(t_ss);
@ -218,8 +218,8 @@ namespace chaiscript
Inplace_Fun_Call_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Inplace_Fun_Call, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Inplace_Fun_Call_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Inplace_Fun_Call, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Inplace_Fun_Call_AST_Node() {} virtual ~Inplace_Fun_Call_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
Param_List_Builder plb; dispatch::Param_List_Builder plb;
if ((this->children.size() > 1) && (this->children[1]->identifier == AST_Node_Type::Arg_List)) { if ((this->children.size() > 1) && (this->children[1]->identifier == AST_Node_Type::Arg_List)) {
for (size_t i = 0; i < this->children[1]->children.size(); ++i) { for (size_t i = 0; i < this->children[1]->children.size(); ++i) {
@ -277,7 +277,7 @@ namespace chaiscript
Equation_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Equation, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Equation_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Equation, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Equation_AST_Node() {} virtual ~Equation_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
Boxed_Value retval; Boxed_Value retval;
try { try {
retval = this->children.back()->eval(t_ss); retval = this->children.back()->eval(t_ss);
@ -353,7 +353,7 @@ namespace chaiscript
Var_Decl_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Var_Decl, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Var_Decl_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Var_Decl, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Var_Decl_AST_Node() {} virtual ~Var_Decl_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
try { try {
t_ss.add_object(this->children[0]->text, Boxed_Value()); t_ss.add_object(this->children[0]->text, Boxed_Value());
} }
@ -391,7 +391,7 @@ namespace chaiscript
Array_Call_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Array_Call, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Array_Call_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Array_Call, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Array_Call_AST_Node() {} virtual ~Array_Call_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
Boxed_Value retval; Boxed_Value retval;
try { try {
@ -427,7 +427,7 @@ namespace chaiscript
Dot_Access_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Dot_Access, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Dot_Access_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Dot_Access, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Dot_Access_AST_Node() {} virtual ~Dot_Access_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
Boxed_Value retval; Boxed_Value retval;
try { try {
retval = this->children[0]->eval(t_ss); retval = this->children[0]->eval(t_ss);
@ -439,7 +439,7 @@ namespace chaiscript
if (this->children.size() > 1) { if (this->children.size() > 1) {
for (size_t i = 2; i < this->children.size(); i+=2) { for (size_t i = 2; i < this->children.size(); i+=2) {
Param_List_Builder plb; dispatch::Param_List_Builder plb;
plb << retval; plb << retval;
if (this->children[i]->children.size() > 1) { if (this->children[i]->children.size() > 1) {
@ -462,8 +462,8 @@ namespace chaiscript
fun_name = this->children[i]->text; fun_name = this->children[i]->text;
} }
Dispatch_Engine::Stack prev_stack = t_ss.get_stack(); chaiscript::detail::Dispatch_Engine::Stack prev_stack = t_ss.get_stack();
Dispatch_Engine::Stack new_stack = t_ss.new_stack(); chaiscript::detail::Dispatch_Engine::Stack new_stack = t_ss.new_stack();
try { try {
t_ss.set_stack(new_stack); t_ss.set_stack(new_stack);
@ -512,7 +512,7 @@ namespace chaiscript
Quoted_String_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Quoted_String, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Quoted_String_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Quoted_String, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Quoted_String_AST_Node() {} virtual ~Quoted_String_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &){
return const_var(this->text); return const_var(this->text);
} }
@ -523,7 +523,7 @@ namespace chaiscript
Single_Quoted_String_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Single_Quoted_String, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Single_Quoted_String_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Single_Quoted_String, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Single_Quoted_String_AST_Node() {} virtual ~Single_Quoted_String_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &){
return const_var(char(this->text[0])); return const_var(char(this->text[0]));
} }
@ -534,7 +534,7 @@ namespace chaiscript
Lambda_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Lambda, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Lambda_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Lambda, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Lambda_AST_Node() {} virtual ~Lambda_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
std::vector<std::string> t_param_names; std::vector<std::string> t_param_names;
size_t numparams = 0; size_t numparams = 0;
@ -550,8 +550,8 @@ namespace chaiscript
numparams = 0; numparams = 0;
} }
return Boxed_Value(Proxy_Function(new Dynamic_Proxy_Function return Boxed_Value(Proxy_Function(new dispatch::Dynamic_Proxy_Function
(boost::bind(&eval_function<Dispatch_Engine>, boost::ref(t_ss), this->children.back(), t_param_names, _1), (boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>, boost::ref(t_ss), this->children.back(), t_param_names, _1),
static_cast<int>(numparams), this->children.back()))); static_cast<int>(numparams), this->children.back())));
} }
@ -562,7 +562,7 @@ namespace chaiscript
Block_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Block, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Block_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Block, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Block_AST_Node() {} virtual ~Block_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
size_t num_children = this->children.size(); size_t num_children = this->children.size();
t_ss.new_scope(); t_ss.new_scope();
@ -602,7 +602,7 @@ namespace chaiscript
Def_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Def, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Def_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Def, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Def_AST_Node() {} virtual ~Def_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
std::vector<std::string> t_param_names; std::vector<std::string> t_param_names;
size_t numparams = 0; size_t numparams = 0;
AST_NodePtr guardnode; AST_NodePtr guardnode;
@ -626,10 +626,10 @@ namespace chaiscript
} }
} }
boost::shared_ptr<Dynamic_Proxy_Function> guard; boost::shared_ptr<dispatch::Dynamic_Proxy_Function> guard;
if (guardnode) { if (guardnode) {
guard = boost::shared_ptr<Dynamic_Proxy_Function> guard = boost::shared_ptr<dispatch::Dynamic_Proxy_Function>
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
boost::ref(t_ss), guardnode, boost::ref(t_ss), guardnode,
t_param_names, _1), static_cast<int>(numparams), guardnode)); t_param_names, _1), static_cast<int>(numparams), guardnode));
} }
@ -638,7 +638,7 @@ namespace chaiscript
const std::string & l_function_name = this->children[0]->text; const std::string & l_function_name = this->children[0]->text;
const std::string & l_annotation = this->annotation?this->annotation->text:""; const std::string & l_annotation = this->annotation?this->annotation->text:"";
t_ss.add(Proxy_Function t_ss.add(Proxy_Function
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
boost::ref(t_ss), this->children.back(), boost::ref(t_ss), this->children.back(),
t_param_names, _1), static_cast<int>(numparams), this->children.back(), t_param_names, _1), static_cast<int>(numparams), this->children.back(),
l_annotation, guard)), l_function_name); l_annotation, guard)), l_function_name);
@ -656,7 +656,7 @@ namespace chaiscript
While_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::While, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : While_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::While, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~While_AST_Node() {} virtual ~While_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
bool cond; bool cond;
t_ss.new_scope(); t_ss.new_scope();
@ -711,7 +711,7 @@ namespace chaiscript
If_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::If, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : If_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::If, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~If_AST_Node() {} virtual ~If_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
bool cond; bool cond;
try { try {
cond = boxed_cast<bool>(this->children[0]->eval(t_ss)); cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
@ -782,7 +782,7 @@ namespace chaiscript
For_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::For, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : For_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::For, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~For_AST_Node() {} virtual ~For_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
bool cond; bool cond;
t_ss.new_scope(); t_ss.new_scope();
@ -893,7 +893,7 @@ namespace chaiscript
Inline_Array_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Inline_Array, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Inline_Array_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Inline_Array, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Inline_Array_AST_Node() {} virtual ~Inline_Array_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
std::vector<Boxed_Value> vec; std::vector<Boxed_Value> vec;
if (this->children.size() > 0) { if (this->children.size() > 0) {
for (size_t i = 0; i < this->children[0]->children.size(); ++i) { for (size_t i = 0; i < this->children[0]->children.size(); ++i) {
@ -917,7 +917,7 @@ namespace chaiscript
Inline_Map_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Inline_Map, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Inline_Map_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Inline_Map, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Inline_Map_AST_Node() {} virtual ~Inline_Map_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
try { try {
std::map<std::string, Boxed_Value> retval; std::map<std::string, Boxed_Value> retval;
for (size_t i = 0; i < this->children[0]->children.size(); ++i) { for (size_t i = 0; i < this->children[0]->children.size(); ++i) {
@ -944,7 +944,7 @@ namespace chaiscript
Return_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Return, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Return_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Return, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Return_AST_Node() {} virtual ~Return_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
if (this->children.size() > 0) { if (this->children.size() > 0) {
try { try {
throw detail::Return_Value(this->children[0]->eval(t_ss)); throw detail::Return_Value(this->children[0]->eval(t_ss));
@ -966,7 +966,7 @@ namespace chaiscript
File_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::File, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : File_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::File, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~File_AST_Node() {} virtual ~File_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss) { virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss) {
const size_t size = this->children.size(); const size_t size = this->children.size();
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
try { try {
@ -989,7 +989,7 @@ namespace chaiscript
Prefix_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Prefix, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Prefix_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Prefix, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Prefix_AST_Node() {} virtual ~Prefix_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
try { try {
return t_ss.call_function(this->children[0]->text, this->children[1]->eval(t_ss)); return t_ss.call_function(this->children[0]->text, this->children[1]->eval(t_ss));
} }
@ -1005,7 +1005,7 @@ namespace chaiscript
Break_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Break, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Break_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Break, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Break_AST_Node() {} virtual ~Break_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &){
throw detail::Break_Loop(); throw detail::Break_Loop();
} }
}; };
@ -1029,7 +1029,7 @@ namespace chaiscript
Inline_Range_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Inline_Range, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Inline_Range_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Inline_Range, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Inline_Range_AST_Node() {} virtual ~Inline_Range_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
try { try {
return t_ss.call_function("generate_range", return t_ss.call_function("generate_range",
this->children[0]->children[0]->children[0]->eval(t_ss), this->children[0]->children[0]->children[0]->eval(t_ss),
@ -1058,7 +1058,7 @@ namespace chaiscript
Try_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Try, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Try_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Try, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Try_AST_Node() {} virtual ~Try_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
Boxed_Value retval; Boxed_Value retval;
t_ss.new_scope(); t_ss.new_scope();
@ -1300,7 +1300,7 @@ namespace chaiscript
Method_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Method, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Method_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Method, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Method_AST_Node() {} virtual ~Method_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
std::vector<std::string> t_param_names; std::vector<std::string> t_param_names;
AST_NodePtr guardnode; AST_NodePtr guardnode;
@ -1327,10 +1327,10 @@ namespace chaiscript
size_t numparams = t_param_names.size(); size_t numparams = t_param_names.size();
boost::shared_ptr<Dynamic_Proxy_Function> guard; boost::shared_ptr<dispatch::Dynamic_Proxy_Function> guard;
if (guardnode) { if (guardnode) {
guard = boost::shared_ptr<Dynamic_Proxy_Function> guard = boost::shared_ptr<dispatch::Dynamic_Proxy_Function>
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
boost::ref(t_ss), guardnode, boost::ref(t_ss), guardnode,
t_param_names, _1), static_cast<int>(numparams), guardnode)); t_param_names, _1), static_cast<int>(numparams), guardnode));
} }
@ -1341,8 +1341,8 @@ namespace chaiscript
const std::string & function_name = this->children[1]->text; const std::string & function_name = this->children[1]->text;
if (function_name == class_name) { if (function_name == class_name) {
t_ss.add(Proxy_Function t_ss.add(Proxy_Function
(new detail::Dynamic_Object_Constructor(class_name, Proxy_Function (new dispatch::detail::Dynamic_Object_Constructor(class_name, Proxy_Function
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
boost::ref(t_ss), this->children.back(), boost::ref(t_ss), this->children.back(),
t_param_names, _1), static_cast<int>(numparams), this->children.back(), t_param_names, _1), static_cast<int>(numparams), this->children.back(),
l_annotation, guard)))), function_name); l_annotation, guard)))), function_name);
@ -1356,8 +1356,8 @@ namespace chaiscript
// No biggie, the type name is just not known // No biggie, the type name is just not known
} }
t_ss.add(Proxy_Function t_ss.add(Proxy_Function
(new detail::Dynamic_Object_Function(class_name, Proxy_Function (new dispatch::detail::Dynamic_Object_Function(class_name, Proxy_Function
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
boost::ref(t_ss), this->children.back(), boost::ref(t_ss), this->children.back(),
t_param_names, _1), static_cast<int>(numparams), this->children.back(), t_param_names, _1), static_cast<int>(numparams), this->children.back(),
l_annotation, guard)), ti)), function_name); l_annotation, guard)), ti)), function_name);
@ -1377,9 +1377,9 @@ namespace chaiscript
Attr_Decl_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Attr_Decl, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Attr_Decl_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Attr_Decl, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Attr_Decl_AST_Node() {} virtual ~Attr_Decl_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
try { try {
t_ss.add(fun(boost::function<Boxed_Value (Dynamic_Object &)>(boost::bind(&detail::Dynamic_Object_Attribute::func, this->children[0]->text, t_ss.add(fun(boost::function<Boxed_Value (dispatch::Dynamic_Object &)>(boost::bind(&dispatch::detail::Dynamic_Object_Attribute::func, this->children[0]->text,
this->children[1]->text, _1))), this->children[1]->text); this->children[1]->text, _1))), this->children[1]->text);
} }
@ -1431,7 +1431,7 @@ namespace chaiscript
Logical_And_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Logical_And, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Logical_And_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Logical_And, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Logical_And_AST_Node() {} virtual ~Logical_And_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
Boxed_Value retval; Boxed_Value retval;
try { try {
retval = this->children[0]->eval(t_ss); retval = this->children[0]->eval(t_ss);
@ -1473,7 +1473,7 @@ namespace chaiscript
Logical_Or_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Logical_Or, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : Logical_Or_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Logical_Or, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
virtual ~Logical_Or_AST_Node() {} virtual ~Logical_Or_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &t_ss){ virtual Boxed_Value eval(chaiscript::detail::Dispatch_Engine &t_ss){
Boxed_Value retval; Boxed_Value retval;
try { try {

View File

@ -45,7 +45,7 @@ struct System
void add_callback(const std::string &t_name, void add_callback(const std::string &t_name,
const chaiscript::Proxy_Function &t_func) const chaiscript::Proxy_Function &t_func)
{ {
m_callbacks[t_name] = chaiscript::functor<std::string (const std::string &)>(t_func); m_callbacks[t_name] = chaiscript::dispatch::functor<std::string (const std::string &)>(t_func);
} }
@ -163,9 +163,9 @@ int main(int /*argc*/, char * /*argv*/[]) {
chai.add(fun(&bound_log, std::string("Msg")), "BoundFun"); chai.add(fun(&bound_log, std::string("Msg")), "BoundFun");
//Dynamic objects test //Dynamic objects test
chai.add(chaiscript::Proxy_Function(new detail::Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world"); chai.add(chaiscript::Proxy_Function(new dispatch::detail::Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world");
chai.add(chaiscript::Proxy_Function(new detail::Dynamic_Object_Constructor("TestType", fun(&hello_constructor))), "TestType"); chai.add(chaiscript::Proxy_Function(new dispatch::detail::Dynamic_Object_Constructor("TestType", fun(&hello_constructor))), "TestType");
chai.add(fun(boost::function<Boxed_Value (Dynamic_Object &)>(boost::bind(&detail::Dynamic_Object_Attribute::func, "TestType", "attr", _1))), "attr"); chai.add(fun(boost::function<Boxed_Value (dispatch::Dynamic_Object &)>(boost::bind(&dispatch::detail::Dynamic_Object_Attribute::func, "TestType", "attr", _1))), "attr");
chai.eval("var x = TestType()"); chai.eval("var x = TestType()");
// chai.eval("x.attr = \"hi\""); // chai.eval("x.attr = \"hi\"");

View File

@ -55,7 +55,7 @@ void version(int){
bool throws_exception(const chaiscript::Proxy_Function &f) bool throws_exception(const chaiscript::Proxy_Function &f)
{ {
try { try {
chaiscript::functor<void ()>(f)(); chaiscript::dispatch::functor<void ()>(f)();
} catch (...) { } catch (...) {
return true; return true;
} }

View File

@ -14,7 +14,8 @@
bool has_parse_tree(const chaiscript::Const_Proxy_Function &t_pf) bool has_parse_tree(const chaiscript::Const_Proxy_Function &t_pf)
{ {
boost::shared_ptr<const chaiscript::Dynamic_Proxy_Function> pf = boost::dynamic_pointer_cast<const chaiscript::Dynamic_Proxy_Function>(t_pf); boost::shared_ptr<const chaiscript::dispatch::Dynamic_Proxy_Function> pf
= boost::dynamic_pointer_cast<const chaiscript::dispatch::Dynamic_Proxy_Function>(t_pf);
if (pf) if (pf)
{ {
return pf->get_parse_tree(); return pf->get_parse_tree();
@ -25,7 +26,8 @@ bool has_parse_tree(const chaiscript::Const_Proxy_Function &t_pf)
chaiscript::AST_NodePtr get_parse_tree(const chaiscript::Const_Proxy_Function &t_pf) chaiscript::AST_NodePtr get_parse_tree(const chaiscript::Const_Proxy_Function &t_pf)
{ {
boost::shared_ptr<const chaiscript::Dynamic_Proxy_Function> pf = boost::dynamic_pointer_cast<const chaiscript::Dynamic_Proxy_Function>(t_pf); boost::shared_ptr<const chaiscript::dispatch::Dynamic_Proxy_Function> pf
= boost::dynamic_pointer_cast<const chaiscript::dispatch::Dynamic_Proxy_Function>(t_pf);
if (pf) if (pf)
{ {
if (pf->get_parse_tree()) if (pf->get_parse_tree())

View File

@ -19,7 +19,7 @@ int main()
chai("attr bob::z; def bob::bob() { this.z = 10 }; var x = bob()"); chai("attr bob::z; def bob::bob() { this.z = 10 }; var x = bob()");
chaiscript::Dynamic_Object &mydo = chai.eval<chaiscript::Dynamic_Object &>("x"); chaiscript::dispatch::Dynamic_Object &mydo = chai.eval<chaiscript::dispatch::Dynamic_Object &>("x");
assert_equal(mydo.get_type_name(), "bob"); assert_equal(mydo.get_type_name(), "bob");