Add better namespaces to make documentation easier to handle

This commit is contained in:
Jason Turner 2011-03-05 22:50:38 -07:00
parent eee5c19b6e
commit 0b97fcb4df
23 changed files with 1398 additions and 1348 deletions

View File

@ -8,6 +8,8 @@
#endif
namespace chaiscript
{
namespace detail
{
namespace threading
{
@ -63,7 +65,7 @@ namespace chaiscript
};
#endif
}
}
}

View File

@ -11,7 +11,8 @@
namespace chaiscript
{
namespace exception
{
/**
* 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
@ -49,6 +50,7 @@ namespace chaiscript
std::string m_what;
};
}
}

View File

@ -31,6 +31,8 @@
namespace chaiscript
{
namespace detail
{
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))>
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, _));
}
}
}
#undef n

View File

@ -58,7 +58,7 @@ namespace chaiscript
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>
@ -69,7 +69,7 @@ namespace chaiscript
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>
@ -80,7 +80,7 @@ namespace chaiscript
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>
@ -102,7 +102,7 @@ namespace chaiscript
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);
}
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);
}
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));
return lhs;
} 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));
} 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)
{
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]);
@ -470,7 +470,7 @@ namespace chaiscript
{
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]);

View File

@ -19,6 +19,8 @@
namespace chaiscript
{
namespace bootstrap
{
namespace standard_library
{
/**
* Bidir_Range, based on the D concept of ranges.
@ -162,6 +164,43 @@ namespace detail {
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>
@ -185,9 +224,11 @@ namespace detail {
//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.
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(
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;
}
@ -229,41 +270,7 @@ namespace detail {
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
@ -280,8 +287,8 @@ namespace detail {
insert_name = "insert_at";
}
m->add(fun(&insert_at<ContainerType>), insert_name);
m->add(fun(&erase_at<ContainerType>), "erase_at");
m->add(fun(&detail::insert_at<ContainerType>), insert_name);
m->add(fun(&detail::erase_at<ContainerType>), "erase_at");
return m;
}
@ -520,6 +527,7 @@ namespace detail {
}
}
}
}
#endif

View File

@ -44,19 +44,19 @@ namespace chaiscript
#pragma warning(disable : 4127)
#endif
if (boost::is_polymorphic<typename Stripped_Type<Type>::type>::value)
if (boost::is_polymorphic<typename detail::Stripped_Type<Type>::type>::value)
{
try {
// 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
return detail::Cast_Helper<Type>::cast(boxed_dynamic_cast<Type>(bv));
} 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 {
// If it's not polymorphic, just throw the error, don't waste the time on the
// 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

View File

@ -128,7 +128,7 @@ namespace chaiscript
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
@ -138,7 +138,7 @@ namespace chaiscript
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
@ -148,7 +148,7 @@ namespace chaiscript
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
@ -168,7 +168,7 @@ namespace chaiscript
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);
}
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
@ -200,7 +200,7 @@ namespace chaiscript
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

View File

@ -10,6 +10,7 @@
#include "type_info.hpp"
#include "../chaiscript_threading.hpp"
#include <map>
#include <boost/shared_ptr.hpp>
#include <boost/any.hpp>
@ -273,30 +274,40 @@ namespace chaiscript
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>
Boxed_Value var(T 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>
Boxed_Value const_var(T *t)
{
return Boxed_Value( const_cast<typename boost::add_const<T>::type *>(t) );
}
/// boost::shared_ptr<T> overload for const_var
template<typename 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) );
}
/// boost::reference_wrapper<T> overload for const_var
template<typename T>
Boxed_Value const_var(const boost::reference_wrapper<T> &t)
{
return Boxed_Value( boost::cref(t.get()) );
}
/// Generic overload for const_var
template<typename T>
Boxed_Value const_var(const T &t)
{

View File

@ -970,7 +970,7 @@ namespace chaiscript
};
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;

View File

@ -14,6 +14,8 @@
#endif
namespace chaiscript
{
namespace exception
{
class bad_boxed_dynamic_cast : public bad_boxed_cast
{
@ -34,7 +36,7 @@ namespace chaiscript
{
}
};
}
namespace detail
{
@ -114,9 +116,8 @@ namespace chaiscript
}
}
} 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 {
return detail::Dynamic_Conversions::get().get_conversion(user_type<Base>(), derived.get_type_info())->convert(derived);
} 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 &) {
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");
}
}

View File

@ -34,6 +34,8 @@ namespace chaiscript
std::map<std::string, Boxed_Value> m_attrs;
};
namespace detail
{
struct Dynamic_Object_Attribute
{
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)
{
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);
@ -116,7 +118,7 @@ namespace chaiscript
{
return (*m_func)(params);
} else {
throw guard_error();
throw exception::guard_error();
}
}
@ -268,5 +270,6 @@ namespace chaiscript
};
}
}
#endif

View File

@ -16,6 +16,8 @@
#include <vector>
namespace chaiscript
{
namespace detail
{
/**
* 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());
}
};
}
}
#endif

View File

@ -2,6 +2,8 @@
#define __CHAISCRIPT_OPERATORS_HPP__
namespace chaiscript
{
namespace bootstrap
{
namespace operators
{
@ -445,5 +447,6 @@ namespace chaiscript
}
}
}
}
#endif

View File

@ -175,6 +175,8 @@ namespace chaiscript
typedef boost::shared_ptr<Proxy_Function_Base> 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
*/
@ -188,6 +190,7 @@ namespace chaiscript
virtual ~guard_error() throw()
{ }
};
}
/**
* A Proxy_Function implementation that is not type safe, the called function
@ -251,11 +254,11 @@ namespace chaiscript
{
return m_f(params);
} else {
throw guard_error();
throw exception::guard_error();
}
} 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 {
return boxed_cast<bool>((*m_guard)(params));
} catch (const arity_error &) {
} catch (const exception::arity_error &) {
return false;
} catch (const bad_boxed_cast &) {
} catch (const exception::bad_boxed_cast &) {
return false;
}
} else {
@ -438,7 +441,7 @@ namespace chaiscript
{
public:
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)
{
}
@ -465,7 +468,7 @@ namespace chaiscript
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
@ -481,7 +484,7 @@ namespace chaiscript
protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params) 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:
@ -545,13 +548,13 @@ namespace chaiscript
if (bv.is_const())
{
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 {
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 {
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);
}
} catch (const bad_boxed_cast &) {
} catch (const exception::bad_boxed_cast &) {
//parameter failed to cast, try again
} catch (const arity_error &) {
} catch (const exception::arity_error &) {
//invalid num params, try again
} catch (const guard_error &) {
} catch (const exception::guard_error &) {
//guard failed to allow the function to execute,
//try again
}

View File

@ -27,6 +27,8 @@
#include <vector>
namespace chaiscript
{
namespace exception
{
/**
* Exception thrown when there is a mismatch in number of
@ -41,10 +43,14 @@ namespace chaiscript
}
virtual ~arity_error() throw() {}
int got;
int expected;
};
}
namespace detail
{
template<typename Ret>
struct Do_Call
{
@ -66,6 +72,7 @@ namespace chaiscript
};
};
}
}
#define BOOST_PP_ITERATION_LIMITS ( 0, 10 )
#define BOOST_PP_FILENAME_1 <chaiscript/dispatchkit/proxy_functions_detail.hpp>
@ -77,6 +84,8 @@ namespace chaiscript
# define n BOOST_PP_ITERATION()
namespace chaiscript
{
namespace detail
{
/**
* Used by Proxy_Function_Impl to return a list of all param types
@ -105,7 +114,7 @@ namespace chaiscript
{
if (params.size() != n)
{
throw arity_error(static_cast<int>(params.size()), n);
throw exception::arity_error(static_cast<int>(params.size()), n);
} else {
return f(BOOST_PP_REPEAT(n, casthelper, ~));
}
@ -122,13 +131,13 @@ namespace chaiscript
{
try {
BOOST_PP_REPEAT(n, trycast, ~);
} catch (const bad_boxed_cast &) {
} catch (const exception::bad_boxed_cast &) {
return false;
}
return true;
}
}
}
#undef n

View File

@ -78,13 +78,13 @@ namespace chaiscript
template<typename T, typename 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>
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));
}
}

View File

@ -204,13 +204,13 @@ namespace chaiscript
&typeid(typename Bare_Type<T>::type));
}
};
}
template<typename T>
struct Stripped_Type
{
typedef typename Bare_Type<typename detail::Get_Type_Info<T>::type>::type type;
};
}
template<typename T>
Type_Info user_type(T)

View File

@ -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_2>(&ChaiScript::load_module), this), "load_module");
add(vector_type<std::vector<Boxed_Value> >("Vector"));
add(string_type<std::string>("string"));
add(map_type<std::map<std::string, Boxed_Value> >("Map"));
add(pair_type<std::pair<Boxed_Value, Boxed_Value > >("Pair"));
add(standard_library::vector_type<std::vector<Boxed_Value> >("Vector"));
add(standard_library::string_type<std::string>("string"));
add(standard_library::map_type<std::map<std::string, Boxed_Value> >("Map"));
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::internal_eval, this), "eval");

View File

@ -662,7 +662,7 @@ namespace chaiscript
try {
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();
throw Eval_Error("While condition not boolean");
}
@ -684,7 +684,7 @@ namespace chaiscript
try {
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();
throw Eval_Error("While condition not boolean");
}
@ -714,7 +714,7 @@ namespace chaiscript
try {
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");
}
catch (Eval_Error &ee) {
@ -748,7 +748,7 @@ namespace chaiscript
try {
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");
}
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();
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();
throw Eval_Error("For condition not boolean");
}
@ -1120,7 +1120,7 @@ namespace chaiscript
bool guard;
try {
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) {
try {
this->children.back()->children[0]->eval(t_ss);
@ -1200,7 +1200,7 @@ namespace chaiscript
try {
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) {
try {
this->children.back()->children[0]->eval(t_ss);
@ -1339,7 +1339,7 @@ namespace chaiscript
const std::string & function_name = this->children[1]->text;
if (function_name == class_name) {
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>,
boost::ref(t_ss), 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
}
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>,
boost::ref(t_ss), 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 Boxed_Value eval(Dispatch_Engine &t_ss){
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);
}
@ -1445,7 +1445,7 @@ namespace chaiscript
try {
lhs = boxed_cast<bool>(retval);
}
catch (const bad_boxed_cast &) {
catch (const exception::bad_boxed_cast &) {
throw Eval_Error("Condition not boolean");
}
if (lhs) {
@ -1488,7 +1488,7 @@ namespace chaiscript
try {
lhs = boxed_cast<bool>(retval);
}
catch (const bad_boxed_cast &) {
catch (const exception::bad_boxed_cast &) {
throw Eval_Error("Condition not boolean");
}
if (lhs) {

View File

@ -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
//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
@ -163,9 +163,9 @@ int main(int /*argc*/, char * /*argv*/[]) {
chai.add(fun(&bound_log, std::string("Msg")), "BoundFun");
//Dynamic objects test
chai.add(chaiscript::Proxy_Function(new 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(fun(boost::function<Boxed_Value (Dynamic_Object &)>(boost::bind(&Dynamic_Object_Attribute::func, "TestType", "attr", _1))), "attr");
chai.add(chaiscript::Proxy_Function(new 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(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("x.attr = \"hi\"");

View File

@ -48,7 +48,7 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_reflect
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::File_Position,

View File

@ -12,7 +12,7 @@
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");
}

View File

@ -13,7 +13,7 @@ bool run_test_type_conversion(const Boxed_Value &bv, bool expectedpass)
try {
To ret = chaiscript::boxed_cast<To>(bv);
use(ret);
} catch (const chaiscript::bad_boxed_cast &/*e*/) {
} catch (const chaiscript::exception::bad_boxed_cast &/*e*/) {
if (expectedpass) {
// std::cerr << "Failure in run_test_type_conversion: " << e.what() << std::endl;
return false;
@ -274,7 +274,7 @@ bool pointer_test(const T& default_value, const T& new_value)
}
return true;
} catch (const bad_boxed_cast &) {
} catch (const exception::bad_boxed_cast &) {
std::cerr << "Bad boxed cast performing ** to ** test" << std::endl;
return false;
} catch (...) {