virtual bool call_match(const std::vector<Boxed_Value> &vals) const { std::vector<Boxed_Value> new_vals; new_vals.push_back(Boxed_Value(Dynamic_Object(m_type_name))); new_vals.insert(new_vals.end(), vals.begin(), vals.end()); return m_func->call_match(new_vals); }
virtual Boxed_Value convert(const Boxed_Value &t_derived) const { if (t_derived.get_type_info().bare_equal(user_type<Derived>())) { if (t_derived.is_pointer()) { // Dynamic cast out the contained boxed value, which we know is the type we want if (t_derived.is_const()) { boost::shared_ptr<const Base> data = boost::dynamic_pointer_cast<const Base>(detail::Cast_Helper<boost::shared_ptr<const Derived> >::cast(t_derived, 0)); if (!data) { throw std::bad_cast(); } return Boxed_Value(data); } else { boost::shared_ptr<Base> data = boost::dynamic_pointer_cast<Base>(detail::Cast_Helper<boost::shared_ptr<Derived> >::cast(t_derived, 0)); if (!data) { throw std::bad_cast(); } return Boxed_Value(data); } } else { // Pull the reference out of the contained boxed value, which we know is the type we want if (t_derived.is_const()) { const Derived &d = detail::Cast_Helper<const Derived &>::cast(t_derived, 0); const Base &data = dynamic_cast<const Base &>(d); return Boxed_Value(boost::cref(data)); } else { Derived &d = detail::Cast_Helper<Derived &>::cast(t_derived, 0); Base &data = dynamic_cast<Base &>(d); return Boxed_Value(boost::ref(data)); } } } else { throw exception::bad_boxed_dynamic_cast(t_derived.get_type_info(), typeid(Base), "Unknown dynamic_cast_conversion"); } }
static Boxed_Value cast(const Boxed_Value &t_from) { if (t_from.get_type_info().bare_equal(user_type<From>())) { if (t_from.is_pointer()) { // Dynamic cast out the contained boxed value, which we know is the type we want if (t_from.is_const()) { std::shared_ptr<const To> data = std::dynamic_pointer_cast<const To>(detail::Cast_Helper<std::shared_ptr<const From> >::cast(t_from, nullptr)); if (!data) { throw std::bad_cast(); } return Boxed_Value(data); } else { std::shared_ptr<To> data = std::dynamic_pointer_cast<To>(detail::Cast_Helper<std::shared_ptr<From> >::cast(t_from, nullptr)); if (!data) { throw std::bad_cast(); } return Boxed_Value(data); } } else { // Pull the reference out of the contained boxed value, which we know is the type we want if (t_from.is_const()) { const From &d = detail::Cast_Helper<const From &>::cast(t_from, nullptr); const To &data = dynamic_cast<const To &>(d); return Boxed_Value(std::cref(data)); } else { From &d = detail::Cast_Helper<From &>::cast(t_from, nullptr); To &data = dynamic_cast<To &>(d); return Boxed_Value(std::ref(data)); } } } else { throw chaiscript::exception::bad_boxed_dynamic_cast(t_from.get_type_info(), typeid(To), "Unknown dynamic_cast_conversion"); } }
static Boxed_Value handle(const boost::shared_ptr<Ret> &r) { return Boxed_Value(r); }
static Boxed_Value handle(const Ret &r) { return Boxed_Value(r); }
static Boxed_Value handle() { return Boxed_Value(Boxed_Value::Void_Type()); }
static Boxed_Value handle(Ret *p) { return Boxed_Value(p, true); }
static Boxed_Value handle(const std::shared_ptr<Ret> &r) { return Boxed_Value(r, true); }
static Boxed_Value handle(std::function<Ret> &f) { return Boxed_Value( chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Assignable_Proxy_Function_Impl<Ret>>(std::ref(f), std::shared_ptr<std::function<Ret>>()) ); }
static Boxed_Value handle(T &&r) { return Boxed_Value(std::make_shared<T>(std::forward<T>(r)), true); }
static Boxed_Value handle(T r) { return Boxed_Value(std::move(r), true); }
static Boxed_Value handle(Ret &r) { return Boxed_Value(std::ref(r)); }
static Boxed_Value handle(const Ret &r) { return Boxed_Value(std::cref(r), true); }
static Boxed_Value handle(std::unique_ptr<Ret> &&r) { return Boxed_Value(std::move(r), true); }
static Boxed_Value handle(Ret &r) { return Boxed_Value(boost::ref(r)); }
static Boxed_Value handle(const Ret &r) { return Boxed_Value(boost::cref(r)); }
static Boxed_Value handle(const std::function<Ret> &f) { return Boxed_Value( chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Proxy_Function_Callable_Impl<Ret, std::function<Ret>>>(f) ); }