Add better namespaces to make documentation easier to handle
This commit is contained in:
parent
eee5c19b6e
commit
0b97fcb4df
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
namespace threading
|
namespace threading
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -63,7 +65,7 @@ namespace chaiscript
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
namespace exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* class that is thrown in the event of a bad_boxed_cast. That is,
|
* class that is thrown in the event of a bad_boxed_cast. That is,
|
||||||
* in the case that a Boxed_Value cannot be cast to the desired type
|
* in the case that a Boxed_Value cannot be cast to the desired type
|
||||||
@ -48,6 +49,7 @@ namespace chaiscript
|
|||||||
private:
|
private:
|
||||||
std::string m_what;
|
std::string m_what;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
template<typename Ret, typename O, typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
|
template<typename Ret, typename O, typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
|
||||||
boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))>
|
boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))>
|
||||||
bind_first(Ret (Class::*f)(BOOST_PP_ENUM_PARAMS(n, Param)), const O &o)
|
bind_first(Ret (Class::*f)(BOOST_PP_ENUM_PARAMS(n, Param)), const O &o)
|
||||||
@ -58,6 +60,8 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
return boost::bind(f, o BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, param, _));
|
return boost::bind(f, o BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, param, _));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef n
|
#undef n
|
||||||
|
@ -58,7 +58,7 @@ namespace chaiscript
|
|||||||
return p1 &= P1(r.i);
|
return p1 &= P1(r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("&= only valid for integer types");
|
throw exception::bad_boxed_cast("&= only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename P1>
|
template<typename P1>
|
||||||
@ -69,7 +69,7 @@ namespace chaiscript
|
|||||||
return p1 ^= P1(r.i);
|
return p1 ^= P1(r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("^= only valid for integer types");
|
throw exception::bad_boxed_cast("^= only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename P1>
|
template<typename P1>
|
||||||
@ -80,7 +80,7 @@ namespace chaiscript
|
|||||||
return p1 |= P1(r.i);
|
return p1 |= P1(r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("&= only valid for integer types");
|
throw exception::bad_boxed_cast("&= only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename P1>
|
template<typename P1>
|
||||||
@ -102,7 +102,7 @@ namespace chaiscript
|
|||||||
return p1 <<= P1(r.i);
|
return p1 <<= P1(r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("<<= only valid for integer types");
|
throw exception::bad_boxed_cast("<<= only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ namespace chaiscript
|
|||||||
return p1 %= P1(r.i);
|
return p1 %= P1(r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("%= only valid for integer types");
|
throw exception::bad_boxed_cast("%= only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ namespace chaiscript
|
|||||||
return p1 >>= P1(r.i);
|
return p1 >>= P1(r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast(">>= only valid for integer types");
|
throw exception::bad_boxed_cast(">>= only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ namespace chaiscript
|
|||||||
lhs.assign(Boxed_Value(rhs));
|
lhs.assign(Boxed_Value(rhs));
|
||||||
return lhs;
|
return lhs;
|
||||||
} else {
|
} else {
|
||||||
throw bad_boxed_cast("type mismatch in pointer assignment");
|
throw exception::bad_boxed_cast("type mismatch in pointer assignment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
return (lhs.assign(rhs));
|
return (lhs.assign(rhs));
|
||||||
} else {
|
} else {
|
||||||
throw bad_boxed_cast("boxed_value has a set type already");
|
throw exception::bad_boxed_cast("boxed_value has a set type already");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
if (params.size() < 2)
|
if (params.size() < 2)
|
||||||
{
|
{
|
||||||
throw arity_error(static_cast<int>(params.size()), 2);
|
throw exception::arity_error(static_cast<int>(params.size()), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Const_Proxy_Function f = boxed_cast<Const_Proxy_Function>(params[0]);
|
Const_Proxy_Function f = boxed_cast<Const_Proxy_Function>(params[0]);
|
||||||
@ -470,7 +470,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
if (params.size() < 1)
|
if (params.size() < 1)
|
||||||
{
|
{
|
||||||
throw arity_error(static_cast<int>(params.size()), 1);
|
throw exception::arity_error(static_cast<int>(params.size()), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Const_Proxy_Function f = boxed_cast<Const_Proxy_Function>(params[0]);
|
Const_Proxy_Function f = boxed_cast<Const_Proxy_Function>(params[0]);
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
namespace bootstrap
|
namespace bootstrap
|
||||||
|
{
|
||||||
|
namespace standard_library
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Bidir_Range, based on the D concept of ranges.
|
* Bidir_Range, based on the D concept of ranges.
|
||||||
@ -141,7 +143,7 @@ namespace chaiscript
|
|||||||
typename Container::const_iterator m_end;
|
typename Container::const_iterator m_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
/**
|
/**
|
||||||
* Add Bidir_Range support for the given ContainerType
|
* Add Bidir_Range support for the given ContainerType
|
||||||
*/
|
*/
|
||||||
@ -162,7 +164,44 @@ namespace detail {
|
|||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Algorithm for inserting at a specific position into a container
|
||||||
|
*/
|
||||||
|
template<typename Type>
|
||||||
|
void insert_at(Type &container, int pos, const typename Type::value_type &v)
|
||||||
|
{
|
||||||
|
typename Type::iterator itr = container.begin();
|
||||||
|
typename Type::iterator end = container.end();
|
||||||
|
|
||||||
|
if (pos < 0 || std::distance(itr, end) < pos)
|
||||||
|
{
|
||||||
|
throw std::range_error("Cannot insert past end of range");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::advance(itr, pos);
|
||||||
|
container.insert(itr, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Algorithm for erasing a specific position from a container
|
||||||
|
*/
|
||||||
|
template<typename Type>
|
||||||
|
void erase_at(Type &container, int pos)
|
||||||
|
{
|
||||||
|
typename Type::iterator itr = container.begin();
|
||||||
|
typename Type::iterator end = container.end();
|
||||||
|
|
||||||
|
if (pos < 0 || std::distance(itr, end) < (pos-1))
|
||||||
|
{
|
||||||
|
throw std::range_error("Cannot erase past end of range");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::advance(itr, pos);
|
||||||
|
container.erase(itr);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ContainerType>
|
template<typename ContainerType>
|
||||||
ModulePtr input_range_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
|
ModulePtr input_range_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
|
||||||
@ -185,9 +224,11 @@ namespace detail {
|
|||||||
//In the interest of runtime safety for the m, we prefer the at() method for [] access,
|
//In the interest of runtime safety for the m, we prefer the at() method for [] access,
|
||||||
//to throw an exception in an out of bounds condition.
|
//to throw an exception in an out of bounds condition.
|
||||||
m->add(
|
m->add(
|
||||||
fun(boost::function<typename ContainerType::reference (ContainerType *, int)>(boost::mem_fn(static_cast<indexoper>(&ContainerType::at)))), "[]");
|
fun(boost::function<typename ContainerType::reference (ContainerType *, int)>
|
||||||
|
(boost::mem_fn(static_cast<indexoper>(&ContainerType::at)))), "[]");
|
||||||
m->add(
|
m->add(
|
||||||
fun(boost::function<typename ContainerType::const_reference (const ContainerType *, int)>(boost::mem_fn(static_cast<constindexoper>(&ContainerType::at)))), "[]");
|
fun(boost::function<typename ContainerType::const_reference (const ContainerType *, int)>
|
||||||
|
(boost::mem_fn(static_cast<constindexoper>(&ContainerType::at)))), "[]");
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
@ -229,41 +270,7 @@ namespace detail {
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Algorithm for inserting at a specific position into a container
|
|
||||||
*/
|
|
||||||
template<typename Type>
|
|
||||||
void insert_at(Type &container, int pos, const typename Type::value_type &v)
|
|
||||||
{
|
|
||||||
typename Type::iterator itr = container.begin();
|
|
||||||
typename Type::iterator end = container.end();
|
|
||||||
|
|
||||||
if (pos < 0 || std::distance(itr, end) < pos)
|
|
||||||
{
|
|
||||||
throw std::range_error("Cannot insert past end of range");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::advance(itr, pos);
|
|
||||||
container.insert(itr, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Algorithm for erasing a specific position from a container
|
|
||||||
*/
|
|
||||||
template<typename Type>
|
|
||||||
void erase_at(Type &container, int pos)
|
|
||||||
{
|
|
||||||
typename Type::iterator itr = container.begin();
|
|
||||||
typename Type::iterator end = container.end();
|
|
||||||
|
|
||||||
if (pos < 0 || std::distance(itr, end) < (pos-1))
|
|
||||||
{
|
|
||||||
throw std::range_error("Cannot erase past end of range");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::advance(itr, pos);
|
|
||||||
container.erase(itr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add sequence concept to the given ContainerType
|
* Add sequence concept to the given ContainerType
|
||||||
@ -280,8 +287,8 @@ namespace detail {
|
|||||||
insert_name = "insert_at";
|
insert_name = "insert_at";
|
||||||
}
|
}
|
||||||
|
|
||||||
m->add(fun(&insert_at<ContainerType>), insert_name);
|
m->add(fun(&detail::insert_at<ContainerType>), insert_name);
|
||||||
m->add(fun(&erase_at<ContainerType>), "erase_at");
|
m->add(fun(&detail::erase_at<ContainerType>), "erase_at");
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
@ -519,6 +526,7 @@ namespace detail {
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,19 +44,19 @@ namespace chaiscript
|
|||||||
#pragma warning(disable : 4127)
|
#pragma warning(disable : 4127)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (boost::is_polymorphic<typename Stripped_Type<Type>::type>::value)
|
if (boost::is_polymorphic<typename detail::Stripped_Type<Type>::type>::value)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// We will not catch any bad_boxed_dynamic_cast that is thrown, let the user get it
|
// We will not catch any bad_boxed_dynamic_cast that is thrown, let the user get it
|
||||||
// either way, we are not responsible if it doesn't work
|
// either way, we are not responsible if it doesn't work
|
||||||
return detail::Cast_Helper<Type>::cast(boxed_dynamic_cast<Type>(bv));
|
return detail::Cast_Helper<Type>::cast(boxed_dynamic_cast<Type>(bv));
|
||||||
} catch (const boost::bad_any_cast &) {
|
} catch (const boost::bad_any_cast &) {
|
||||||
throw bad_boxed_cast(bv.get_type_info(), typeid(Type));
|
throw exception::bad_boxed_cast(bv.get_type_info(), typeid(Type));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If it's not polymorphic, just throw the error, don't waste the time on the
|
// If it's not polymorphic, just throw the error, don't waste the time on the
|
||||||
// attempted dynamic_cast
|
// attempted dynamic_cast
|
||||||
throw bad_boxed_cast(bv.get_type_info(), typeid(Type));
|
throw exception::bad_boxed_cast(bv.get_type_info(), typeid(Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
|
@ -128,7 +128,7 @@ namespace chaiscript
|
|||||||
return Boxed_Value(i & r.i);
|
return Boxed_Value(i & r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("& only valid for integer types");
|
throw exception::bad_boxed_cast("& only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
Boxed_Value operator^(const Boxed_POD_Value &r) const
|
Boxed_Value operator^(const Boxed_POD_Value &r) const
|
||||||
@ -138,7 +138,7 @@ namespace chaiscript
|
|||||||
return Boxed_Value(i ^ r.i);
|
return Boxed_Value(i ^ r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("^ only valid for integer types");
|
throw exception::bad_boxed_cast("^ only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
Boxed_Value operator|(const Boxed_POD_Value &r) const
|
Boxed_Value operator|(const Boxed_POD_Value &r) const
|
||||||
@ -148,7 +148,7 @@ namespace chaiscript
|
|||||||
return Boxed_Value(i | r.i);
|
return Boxed_Value(i | r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("| only valid for integer types");
|
throw exception::bad_boxed_cast("| only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
Boxed_Value operator/(const Boxed_POD_Value &r) const
|
Boxed_Value operator/(const Boxed_POD_Value &r) const
|
||||||
@ -168,7 +168,7 @@ namespace chaiscript
|
|||||||
return smart_size(i << r.i);
|
return smart_size(i << r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("<< only valid for integer types");
|
throw exception::bad_boxed_cast("<< only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ namespace chaiscript
|
|||||||
return smart_size(i % r.i);
|
return smart_size(i % r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast("% only valid for integer types");
|
throw exception::bad_boxed_cast("% only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
Boxed_Value operator>>(const Boxed_POD_Value &r) const
|
Boxed_Value operator>>(const Boxed_POD_Value &r) const
|
||||||
@ -200,7 +200,7 @@ namespace chaiscript
|
|||||||
return smart_size(i >> r.i);
|
return smart_size(i >> r.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw bad_boxed_cast(">> only valid for integer types");
|
throw exception::bad_boxed_cast(">> only valid for integer types");
|
||||||
}
|
}
|
||||||
|
|
||||||
Boxed_Value smart_size(boost::int64_t i) const
|
Boxed_Value smart_size(boost::int64_t i) const
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "type_info.hpp"
|
#include "type_info.hpp"
|
||||||
|
|
||||||
#include "../chaiscript_threading.hpp"
|
#include "../chaiscript_threading.hpp"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/any.hpp>
|
#include <boost/any.hpp>
|
||||||
@ -273,30 +274,40 @@ namespace chaiscript
|
|||||||
boost::shared_ptr<Data> m_data;
|
boost::shared_ptr<Data> m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Clean wrapper for providing the user with a Boxed_Value
|
||||||
|
/// Suggested use: chai.add(var(myvariable), "myvariable");
|
||||||
|
/// \param t The value to box
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Boxed_Value var(T t)
|
Boxed_Value var(T t)
|
||||||
{
|
{
|
||||||
return Boxed_Value(t);
|
return Boxed_Value(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Wrapper for providing the user with a Boxed_Value that is const inside
|
||||||
|
/// of the ChaiScript engine.
|
||||||
|
/// Suggested use: chai.add(const_var(myvariable), "myvariable");
|
||||||
|
/// \param t The value to box
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Boxed_Value const_var(T *t)
|
Boxed_Value const_var(T *t)
|
||||||
{
|
{
|
||||||
return Boxed_Value( const_cast<typename boost::add_const<T>::type *>(t) );
|
return Boxed_Value( const_cast<typename boost::add_const<T>::type *>(t) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// boost::shared_ptr<T> overload for const_var
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Boxed_Value const_var(const boost::shared_ptr<T> &t)
|
Boxed_Value const_var(const boost::shared_ptr<T> &t)
|
||||||
{
|
{
|
||||||
return Boxed_Value( boost::const_pointer_cast<typename boost::add_const<T>::type>(t) );
|
return Boxed_Value( boost::const_pointer_cast<typename boost::add_const<T>::type>(t) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// boost::reference_wrapper<T> overload for const_var
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Boxed_Value const_var(const boost::reference_wrapper<T> &t)
|
Boxed_Value const_var(const boost::reference_wrapper<T> &t)
|
||||||
{
|
{
|
||||||
return Boxed_Value( boost::cref(t.get()) );
|
return Boxed_Value( boost::cref(t.get()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generic overload for const_var
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Boxed_Value const_var(const T &t)
|
Boxed_Value const_var(const T &t)
|
||||||
{
|
{
|
||||||
|
@ -970,7 +970,7 @@ namespace chaiscript
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Dynamic_Cast_Conversion> m_conversions;
|
std::vector<Dynamic_Cast_Conversion> m_conversions;
|
||||||
chaiscript::threading::Thread_Storage<Stack_Holder> m_stack_holder;
|
chaiscript::detail::threading::Thread_Storage<Stack_Holder> m_stack_holder;
|
||||||
|
|
||||||
|
|
||||||
State m_state;
|
State m_state;
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
namespace exception
|
||||||
|
{
|
||||||
class bad_boxed_dynamic_cast : public bad_boxed_cast
|
class bad_boxed_dynamic_cast : public bad_boxed_cast
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -34,7 +36,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
@ -114,9 +116,8 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "Unknown dynamic_cast_conversion");
|
throw exception::bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "Unknown dynamic_cast_conversion");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -262,9 +263,9 @@ namespace chaiscript
|
|||||||
try {
|
try {
|
||||||
return detail::Dynamic_Conversions::get().get_conversion(user_type<Base>(), derived.get_type_info())->convert(derived);
|
return detail::Dynamic_Conversions::get().get_conversion(user_type<Base>(), derived.get_type_info())->convert(derived);
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
throw bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "No known conversion");
|
throw exception::bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "No known conversion");
|
||||||
} catch (const std::bad_cast &) {
|
} catch (const std::bad_cast &) {
|
||||||
throw bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "Unable to perform dynamic_cast operation");
|
throw exception::bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "Unable to perform dynamic_cast operation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ namespace chaiscript
|
|||||||
std::map<std::string, Boxed_Value> m_attrs;
|
std::map<std::string, Boxed_Value> m_attrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
struct Dynamic_Object_Attribute
|
struct Dynamic_Object_Attribute
|
||||||
{
|
{
|
||||||
static Boxed_Value func(const std::string &t_type_name, const std::string &t_attr_name,
|
static Boxed_Value func(const std::string &t_type_name, const std::string &t_attr_name,
|
||||||
@ -41,7 +43,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
if (t_do.get_type_name() != t_type_name)
|
if (t_do.get_type_name() != t_type_name)
|
||||||
{
|
{
|
||||||
throw bad_boxed_cast("Dynamic object type mismatch");
|
throw exception::bad_boxed_cast("Dynamic object type mismatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
return t_do.get_attr(t_attr_name);
|
return t_do.get_attr(t_attr_name);
|
||||||
@ -116,7 +118,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
return (*m_func)(params);
|
return (*m_func)(params);
|
||||||
} else {
|
} else {
|
||||||
throw guard_error();
|
throw exception::guard_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,6 +269,7 @@ namespace chaiscript
|
|||||||
Proxy_Function m_func;
|
Proxy_Function m_func;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Used internally for handling a return value from a Proxy_Function call
|
* Used internally for handling a return value from a Proxy_Function call
|
||||||
*/
|
*/
|
||||||
@ -122,6 +124,8 @@ namespace chaiscript
|
|||||||
return Boxed_Value(Boxed_Value::Void_Type());
|
return Boxed_Value(Boxed_Value::Void_Type());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
namespace bootstrap
|
||||||
|
{
|
||||||
namespace operators
|
namespace operators
|
||||||
{
|
{
|
||||||
template<typename Ret, typename L, typename R>
|
template<typename Ret, typename L, typename R>
|
||||||
@ -444,6 +446,7 @@ namespace chaiscript
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -175,6 +175,8 @@ namespace chaiscript
|
|||||||
typedef boost::shared_ptr<Proxy_Function_Base> Proxy_Function;
|
typedef boost::shared_ptr<Proxy_Function_Base> Proxy_Function;
|
||||||
typedef boost::shared_ptr<const Proxy_Function_Base> Const_Proxy_Function;
|
typedef boost::shared_ptr<const Proxy_Function_Base> Const_Proxy_Function;
|
||||||
|
|
||||||
|
namespace exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Exception thrown if a function's guard fails to execute
|
* Exception thrown if a function's guard fails to execute
|
||||||
*/
|
*/
|
||||||
@ -188,6 +190,7 @@ namespace chaiscript
|
|||||||
virtual ~guard_error() throw()
|
virtual ~guard_error() throw()
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Proxy_Function implementation that is not type safe, the called function
|
* A Proxy_Function implementation that is not type safe, the called function
|
||||||
@ -251,11 +254,11 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
return m_f(params);
|
return m_f(params);
|
||||||
} else {
|
} else {
|
||||||
throw guard_error();
|
throw exception::guard_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw arity_error(static_cast<int>(params.size()), m_arity);
|
throw exception::arity_error(static_cast<int>(params.size()), m_arity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,9 +269,9 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return boxed_cast<bool>((*m_guard)(params));
|
return boxed_cast<bool>((*m_guard)(params));
|
||||||
} catch (const arity_error &) {
|
} catch (const exception::arity_error &) {
|
||||||
return false;
|
return false;
|
||||||
} catch (const bad_boxed_cast &) {
|
} catch (const exception::bad_boxed_cast &) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -438,7 +441,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Proxy_Function_Impl(const boost::function<Func> &f)
|
Proxy_Function_Impl(const boost::function<Func> &f)
|
||||||
: Proxy_Function_Base(build_param_type_list(static_cast<Func *>(0))),
|
: Proxy_Function_Base(detail::build_param_type_list(static_cast<Func *>(0))),
|
||||||
m_f(f), m_dummy_func(0)
|
m_f(f), m_dummy_func(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -465,7 +468,7 @@ namespace chaiscript
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return compare_types(m_types, vals) || compare_types_cast(m_dummy_func, vals);
|
return compare_types(m_types, vals) || detail::compare_types_cast(m_dummy_func, vals);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string annotation() const
|
virtual std::string annotation() const
|
||||||
@ -481,7 +484,7 @@ namespace chaiscript
|
|||||||
protected:
|
protected:
|
||||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms) const
|
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms) const
|
||||||
{
|
{
|
||||||
return Do_Call<typename boost::function<Func>::result_type>::go(m_f, params);
|
return detail::Do_Call<typename boost::function<Func>::result_type>::go(m_f, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -545,13 +548,13 @@ namespace chaiscript
|
|||||||
if (bv.is_const())
|
if (bv.is_const())
|
||||||
{
|
{
|
||||||
const Class *o = boxed_cast<const Class *>(bv);
|
const Class *o = boxed_cast<const Class *>(bv);
|
||||||
return Handle_Return<typename boost::add_reference<T>::type>::handle(o->*m_attr);
|
return detail::Handle_Return<typename boost::add_reference<T>::type>::handle(o->*m_attr);
|
||||||
} else {
|
} else {
|
||||||
Class *o = boxed_cast<Class *>(bv);
|
Class *o = boxed_cast<Class *>(bv);
|
||||||
return Handle_Return<typename boost::add_reference<T>::type>::handle(o->*m_attr);
|
return detail::Handle_Return<typename boost::add_reference<T>::type>::handle(o->*m_attr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw arity_error(static_cast<int>(params.size()), 1);
|
throw exception::arity_error(static_cast<int>(params.size()), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,11 +606,11 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
return (*(*begin))(plist);
|
return (*(*begin))(plist);
|
||||||
}
|
}
|
||||||
} catch (const bad_boxed_cast &) {
|
} catch (const exception::bad_boxed_cast &) {
|
||||||
//parameter failed to cast, try again
|
//parameter failed to cast, try again
|
||||||
} catch (const arity_error &) {
|
} catch (const exception::arity_error &) {
|
||||||
//invalid num params, try again
|
//invalid num params, try again
|
||||||
} catch (const guard_error &) {
|
} catch (const exception::guard_error &) {
|
||||||
//guard failed to allow the function to execute,
|
//guard failed to allow the function to execute,
|
||||||
//try again
|
//try again
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
namespace exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Exception thrown when there is a mismatch in number of
|
* Exception thrown when there is a mismatch in number of
|
||||||
* parameters during Proxy_Function execution
|
* parameters during Proxy_Function execution
|
||||||
@ -41,10 +43,14 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual ~arity_error() throw() {}
|
virtual ~arity_error() throw() {}
|
||||||
|
|
||||||
int got;
|
int got;
|
||||||
int expected;
|
int expected;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
template<typename Ret>
|
template<typename Ret>
|
||||||
struct Do_Call
|
struct Do_Call
|
||||||
{
|
{
|
||||||
@ -65,6 +71,7 @@ namespace chaiscript
|
|||||||
return Handle_Return<void>::handle();
|
return Handle_Return<void>::handle();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BOOST_PP_ITERATION_LIMITS ( 0, 10 )
|
#define BOOST_PP_ITERATION_LIMITS ( 0, 10 )
|
||||||
@ -78,6 +85,8 @@ namespace chaiscript
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Used by Proxy_Function_Impl to return a list of all param types
|
* Used by Proxy_Function_Impl to return a list of all param types
|
||||||
* it contains.
|
* it contains.
|
||||||
@ -105,7 +114,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
if (params.size() != n)
|
if (params.size() != n)
|
||||||
{
|
{
|
||||||
throw arity_error(static_cast<int>(params.size()), n);
|
throw exception::arity_error(static_cast<int>(params.size()), n);
|
||||||
} else {
|
} else {
|
||||||
return f(BOOST_PP_REPEAT(n, casthelper, ~));
|
return f(BOOST_PP_REPEAT(n, casthelper, ~));
|
||||||
}
|
}
|
||||||
@ -122,13 +131,13 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
BOOST_PP_REPEAT(n, trycast, ~);
|
BOOST_PP_REPEAT(n, trycast, ~);
|
||||||
} catch (const bad_boxed_cast &) {
|
} catch (const exception::bad_boxed_cast &) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef n
|
#undef n
|
||||||
|
@ -78,13 +78,13 @@ namespace chaiscript
|
|||||||
template<typename T, typename Q>
|
template<typename T, typename Q>
|
||||||
Proxy_Function fun(T t, const Q &q)
|
Proxy_Function fun(T t, const Q &q)
|
||||||
{
|
{
|
||||||
return fun(bind_first(t, q));
|
return fun(detail::bind_first(t, q));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename Q, typename R>
|
template<typename T, typename Q, typename R>
|
||||||
Proxy_Function fun(T t, const Q &q, const R &r)
|
Proxy_Function fun(T t, const Q &q, const R &r)
|
||||||
{
|
{
|
||||||
return fun(bind_first(bind_first(t, q), r));
|
return fun(detail::bind_first(detail::bind_first(t, q), r));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -204,13 +204,13 @@ namespace chaiscript
|
|||||||
&typeid(typename Bare_Type<T>::type));
|
&typeid(typename Bare_Type<T>::type));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Stripped_Type
|
struct Stripped_Type
|
||||||
{
|
{
|
||||||
typedef typename Bare_Type<typename detail::Get_Type_Info<T>::type>::type type;
|
typedef typename Bare_Type<typename detail::Get_Type_Info<T>::type>::type type;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Type_Info user_type(T)
|
Type_Info user_type(T)
|
||||||
|
@ -552,10 +552,10 @@ namespace chaiscript
|
|||||||
m_engine.add(fun(static_cast<load_mod_1>(&ChaiScript::load_module), this), "load_module");
|
m_engine.add(fun(static_cast<load_mod_1>(&ChaiScript::load_module), this), "load_module");
|
||||||
m_engine.add(fun(static_cast<load_mod_2>(&ChaiScript::load_module), this), "load_module");
|
m_engine.add(fun(static_cast<load_mod_2>(&ChaiScript::load_module), this), "load_module");
|
||||||
|
|
||||||
add(vector_type<std::vector<Boxed_Value> >("Vector"));
|
add(standard_library::vector_type<std::vector<Boxed_Value> >("Vector"));
|
||||||
add(string_type<std::string>("string"));
|
add(standard_library::string_type<std::string>("string"));
|
||||||
add(map_type<std::map<std::string, Boxed_Value> >("Map"));
|
add(standard_library::map_type<std::map<std::string, Boxed_Value> >("Map"));
|
||||||
add(pair_type<std::pair<Boxed_Value, Boxed_Value > >("Pair"));
|
add(standard_library::pair_type<std::pair<Boxed_Value, Boxed_Value > >("Pair"));
|
||||||
|
|
||||||
m_engine.add(fun(&ChaiScript::use, this), "use");
|
m_engine.add(fun(&ChaiScript::use, this), "use");
|
||||||
m_engine.add(fun(&ChaiScript::internal_eval, this), "eval");
|
m_engine.add(fun(&ChaiScript::internal_eval, this), "eval");
|
||||||
|
@ -662,7 +662,7 @@ namespace chaiscript
|
|||||||
try {
|
try {
|
||||||
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
|
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
|
||||||
}
|
}
|
||||||
catch (const bad_boxed_cast &) {
|
catch (const exception::bad_boxed_cast &) {
|
||||||
t_ss.pop_scope();
|
t_ss.pop_scope();
|
||||||
throw Eval_Error("While condition not boolean");
|
throw Eval_Error("While condition not boolean");
|
||||||
}
|
}
|
||||||
@ -684,7 +684,7 @@ namespace chaiscript
|
|||||||
try {
|
try {
|
||||||
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
|
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
|
||||||
}
|
}
|
||||||
catch (const bad_boxed_cast &) {
|
catch (const exception::bad_boxed_cast &) {
|
||||||
t_ss.pop_scope();
|
t_ss.pop_scope();
|
||||||
throw Eval_Error("While condition not boolean");
|
throw Eval_Error("While condition not boolean");
|
||||||
}
|
}
|
||||||
@ -714,7 +714,7 @@ namespace chaiscript
|
|||||||
try {
|
try {
|
||||||
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
|
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
|
||||||
}
|
}
|
||||||
catch (const bad_boxed_cast &) {
|
catch (const exception::bad_boxed_cast &) {
|
||||||
throw Eval_Error("If condition not boolean");
|
throw Eval_Error("If condition not boolean");
|
||||||
}
|
}
|
||||||
catch (Eval_Error &ee) {
|
catch (Eval_Error &ee) {
|
||||||
@ -748,7 +748,7 @@ namespace chaiscript
|
|||||||
try {
|
try {
|
||||||
cond = boxed_cast<bool>(this->children[i+1]->eval(t_ss));
|
cond = boxed_cast<bool>(this->children[i+1]->eval(t_ss));
|
||||||
}
|
}
|
||||||
catch (const bad_boxed_cast &) {
|
catch (const exception::bad_boxed_cast &) {
|
||||||
throw Eval_Error("'else if' condition not boolean");
|
throw Eval_Error("'else if' condition not boolean");
|
||||||
}
|
}
|
||||||
catch (Eval_Error &ee) {
|
catch (Eval_Error &ee) {
|
||||||
@ -814,7 +814,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const bad_boxed_cast &) {
|
catch (const exception::bad_boxed_cast &) {
|
||||||
t_ss.pop_scope();
|
t_ss.pop_scope();
|
||||||
throw Eval_Error("For condition not boolean");
|
throw Eval_Error("For condition not boolean");
|
||||||
}
|
}
|
||||||
@ -872,7 +872,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const bad_boxed_cast &) {
|
catch (const exception::bad_boxed_cast &) {
|
||||||
t_ss.pop_scope();
|
t_ss.pop_scope();
|
||||||
throw Eval_Error("For condition not boolean");
|
throw Eval_Error("For condition not boolean");
|
||||||
}
|
}
|
||||||
@ -1120,7 +1120,7 @@ namespace chaiscript
|
|||||||
bool guard;
|
bool guard;
|
||||||
try {
|
try {
|
||||||
guard = boxed_cast<bool>(catch_block->children[1]->eval(t_ss));
|
guard = boxed_cast<bool>(catch_block->children[1]->eval(t_ss));
|
||||||
} catch (const bad_boxed_cast &) {
|
} catch (const exception::bad_boxed_cast &) {
|
||||||
if (this->children.back()->identifier == AST_Node_Type::Finally) {
|
if (this->children.back()->identifier == AST_Node_Type::Finally) {
|
||||||
try {
|
try {
|
||||||
this->children.back()->children[0]->eval(t_ss);
|
this->children.back()->children[0]->eval(t_ss);
|
||||||
@ -1200,7 +1200,7 @@ namespace chaiscript
|
|||||||
try {
|
try {
|
||||||
guard = boxed_cast<bool>(catch_block->children[1]->eval(t_ss));
|
guard = boxed_cast<bool>(catch_block->children[1]->eval(t_ss));
|
||||||
}
|
}
|
||||||
catch (const bad_boxed_cast &) {
|
catch (const exception::bad_boxed_cast &) {
|
||||||
if (this->children.back()->identifier == AST_Node_Type::Finally) {
|
if (this->children.back()->identifier == AST_Node_Type::Finally) {
|
||||||
try {
|
try {
|
||||||
this->children.back()->children[0]->eval(t_ss);
|
this->children.back()->children[0]->eval(t_ss);
|
||||||
@ -1339,7 +1339,7 @@ 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 Dynamic_Object_Constructor(class_name, Proxy_Function
|
(new detail::Dynamic_Object_Constructor(class_name, Proxy_Function
|
||||||
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
|
(new Dynamic_Proxy_Function(boost::bind(&eval_function<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(),
|
||||||
@ -1354,7 +1354,7 @@ 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 Dynamic_Object_Function(class_name, Proxy_Function
|
(new detail::Dynamic_Object_Function(class_name, Proxy_Function
|
||||||
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
|
(new Dynamic_Proxy_Function(boost::bind(&eval_function<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(),
|
||||||
@ -1377,7 +1377,7 @@ namespace chaiscript
|
|||||||
virtual ~Attr_Decl_AST_Node() {}
|
virtual ~Attr_Decl_AST_Node() {}
|
||||||
virtual Boxed_Value eval(Dispatch_Engine &t_ss){
|
virtual Boxed_Value eval(Dispatch_Engine &t_ss){
|
||||||
try {
|
try {
|
||||||
t_ss.add(fun(boost::function<Boxed_Value (Dynamic_Object &)>(boost::bind(&Dynamic_Object_Attribute::func, this->children[0]->text,
|
t_ss.add(fun(boost::function<Boxed_Value (Dynamic_Object &)>(boost::bind(&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);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1445,7 +1445,7 @@ namespace chaiscript
|
|||||||
try {
|
try {
|
||||||
lhs = boxed_cast<bool>(retval);
|
lhs = boxed_cast<bool>(retval);
|
||||||
}
|
}
|
||||||
catch (const bad_boxed_cast &) {
|
catch (const exception::bad_boxed_cast &) {
|
||||||
throw Eval_Error("Condition not boolean");
|
throw Eval_Error("Condition not boolean");
|
||||||
}
|
}
|
||||||
if (lhs) {
|
if (lhs) {
|
||||||
@ -1488,7 +1488,7 @@ namespace chaiscript
|
|||||||
try {
|
try {
|
||||||
lhs = boxed_cast<bool>(retval);
|
lhs = boxed_cast<bool>(retval);
|
||||||
}
|
}
|
||||||
catch (const bad_boxed_cast &) {
|
catch (const exception::bad_boxed_cast &) {
|
||||||
throw Eval_Error("Condition not boolean");
|
throw Eval_Error("Condition not boolean");
|
||||||
}
|
}
|
||||||
if (lhs) {
|
if (lhs) {
|
||||||
|
@ -154,7 +154,7 @@ int main(int /*argc*/, char * /*argv*/[]) {
|
|||||||
|
|
||||||
//Ability to create our own container types when needed. std::vector and std::map are
|
//Ability to create our own container types when needed. std::vector and std::map are
|
||||||
//mostly supported currently
|
//mostly supported currently
|
||||||
chai.add(bootstrap::vector_type<std::vector<int> >("IntVector"));
|
chai.add(bootstrap::standard_library::vector_type<std::vector<int> >("IntVector"));
|
||||||
|
|
||||||
|
|
||||||
// Test ability to register a function that excepts a shared_ptr version of a type
|
// Test ability to register a function that excepts a shared_ptr version of a type
|
||||||
@ -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 Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world");
|
chai.add(chaiscript::Proxy_Function(new detail::Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world");
|
||||||
chai.add(chaiscript::Proxy_Function(new Dynamic_Object_Constructor("TestType", fun(&hello_constructor))), "TestType");
|
chai.add(chaiscript::Proxy_Function(new detail::Dynamic_Object_Constructor("TestType", fun(&hello_constructor))), "TestType");
|
||||||
chai.add(fun(boost::function<Boxed_Value (Dynamic_Object &)>(boost::bind(&Dynamic_Object_Attribute::func, "TestType", "attr", _1))), "attr");
|
chai.add(fun(boost::function<Boxed_Value (Dynamic_Object &)>(boost::bind(&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\"");
|
||||||
|
@ -48,7 +48,7 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_reflect
|
|||||||
m->add(chaiscript::fun(&get_parse_tree), "get_parse_tree");
|
m->add(chaiscript::fun(&get_parse_tree), "get_parse_tree");
|
||||||
|
|
||||||
|
|
||||||
chaiscript::bootstrap::vector_type<std::vector<boost::shared_ptr<chaiscript::AST_Node> > >("AST_NodeVector", m);
|
chaiscript::bootstrap::standard_library::vector_type<std::vector<boost::shared_ptr<chaiscript::AST_Node> > >("AST_NodeVector", m);
|
||||||
|
|
||||||
CHAISCRIPT_CLASS( m,
|
CHAISCRIPT_CLASS( m,
|
||||||
chaiscript::File_Position,
|
chaiscript::File_Position,
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_stl_extra()
|
CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_stl_extra()
|
||||||
{
|
{
|
||||||
return chaiscript::bootstrap::list_type<std::list<chaiscript::Boxed_Value> >("List");
|
return chaiscript::bootstrap::standard_library::list_type<std::list<chaiscript::Boxed_Value> >("List");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ bool run_test_type_conversion(const Boxed_Value &bv, bool expectedpass)
|
|||||||
try {
|
try {
|
||||||
To ret = chaiscript::boxed_cast<To>(bv);
|
To ret = chaiscript::boxed_cast<To>(bv);
|
||||||
use(ret);
|
use(ret);
|
||||||
} catch (const chaiscript::bad_boxed_cast &/*e*/) {
|
} catch (const chaiscript::exception::bad_boxed_cast &/*e*/) {
|
||||||
if (expectedpass) {
|
if (expectedpass) {
|
||||||
// std::cerr << "Failure in run_test_type_conversion: " << e.what() << std::endl;
|
// std::cerr << "Failure in run_test_type_conversion: " << e.what() << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -274,7 +274,7 @@ bool pointer_test(const T& default_value, const T& new_value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (const bad_boxed_cast &) {
|
} catch (const exception::bad_boxed_cast &) {
|
||||||
std::cerr << "Bad boxed cast performing ** to ** test" << std::endl;
|
std::cerr << "Bad boxed cast performing ** to ** test" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user