Move around some namespaces for documentation purposes.

Fix problems with building on clang 2.8.
Remove unneeded function for get_engine() and fix functor<> calls that take a Boxed_Value
This commit is contained in:
Jason Turner
2011-03-15 17:35:14 -06:00
parent 9dd9ffec46
commit 637164e457
9 changed files with 1478 additions and 1437 deletions

View File

@@ -257,37 +257,48 @@ namespace chaiscript
};
/**
* Exception thrown in the case that a multi method dispatch fails
* because no matching function was found
* at runtime due to either an arity_error, a guard_error or a bad_boxed_cast
* exception
*/
struct reserved_word_error : std::runtime_error
namespace exception
{
reserved_word_error(const std::string &t_word) throw()
: std::runtime_error("Reserved word not allowed in object name: " + word), word(t_word)
/**
* Exception thrown in the case that a multi method dispatch fails
* because no matching function was found
* at runtime due to either an arity_error, a guard_error or a bad_boxed_cast
* exception
*/
class reserved_word_error : public std::runtime_error
{
}
public:
reserved_word_error(const std::string &t_word) throw()
: std::runtime_error("Reserved word not allowed in object name: " + t_word), m_word(t_word)
{
}
std::string word;
virtual ~reserved_word_error() throw() {}
virtual ~reserved_word_error() throw() {}
};
std::string word() const
{
return m_word;
}
/**
* Exception thrown in the case that a non-const object was added as a shared object
*/
struct global_non_const : std::runtime_error
{
global_non_const() throw()
: std::runtime_error("a global object must be const")
private:
std::string m_word;
};
/**
* Exception thrown in the case that a non-const object was added as a shared object
*/
class global_non_const : public std::runtime_error
{
}
virtual ~global_non_const() throw() {}
};
public:
global_non_const() throw()
: std::runtime_error("a global object must be const")
{
}
virtual ~global_non_const() throw() {}
};
}
/**
* Main class for the dispatchkit. Handles management
@@ -377,7 +388,7 @@ namespace chaiscript
validate_object_name(name);
if (!obj.is_const())
{
throw global_non_const();
throw exception::global_non_const();
}
#ifndef CHAISCRIPT_NO_THREADS
@@ -909,7 +920,7 @@ namespace chaiscript
if (m_state.m_reserved_words.find(name) != m_state.m_reserved_words.end())
{
throw reserved_word_error(name);
throw exception::reserved_word_error(name);
}
}

View File

@@ -6,7 +6,7 @@
#include <boost/preprocessor.hpp>
#define addparam(z,n,text) params.push_back(boost::is_reference<Param ## n>::value?Boxed_Value(boost::ref(BOOST_PP_CAT(p, n))):Boxed_Value(BOOST_PP_CAT(p, n) ));
#define addparam(z,n,text) params.push_back((boost::is_reference<Param ## n>::value&&!(boost::is_same<chaiscript::Boxed_Value, typename boost::remove_const<typename boost::remove_reference<Param ## n>::type>::type>::value))?Boxed_Value(boost::ref(BOOST_PP_CAT(p, n))):Boxed_Value(BOOST_PP_CAT(p, n) ));
#define curry(z,n,text) BOOST_PP_CAT(_, BOOST_PP_INC(n))
@@ -25,6 +25,7 @@ namespace chaiscript
{
namespace detail
{
/**
* Internal helper class for handling the return
* value of a build_function_caller

View File

@@ -324,7 +324,7 @@ namespace chaiscript
Bound_Function(const Const_Proxy_Function &t_f,
const std::vector<Boxed_Value> &t_args)
: Proxy_Function_Base(build_param_type_info(t_f, t_args)),
m_f(t_f), m_args(t_args), m_arity(t_f->get_arity()<0?-1:get_param_types().size()-1)
m_f(t_f), m_args(t_args), m_arity(t_f->get_arity()<0?-1:static_cast<int>(get_param_types().size())-1)
{
assert(m_f->get_arity() < 0 || m_f->get_arity() == static_cast<int>(m_args.size()));
}
@@ -569,26 +569,30 @@ namespace chaiscript
T Class::* m_attr;
};
/**
* Exception thrown in the case that a multi method dispatch fails
* because no matching function was found
* at runtime due to either an arity_error, a guard_error or a bad_boxed_cast
* exception
*/
struct dispatch_error : std::runtime_error
namespace exception
{
dispatch_error() throw()
: std::runtime_error("No matching function to dispatch to")
/**
* Exception thrown in the case that a multi method dispatch fails
* because no matching function was found
* at runtime due to either an arity_error, a guard_error or a bad_boxed_cast
* exception
*/
class dispatch_error : public std::runtime_error
{
}
public:
dispatch_error() throw()
: std::runtime_error("No matching function to dispatch to")
{
}
dispatch_error(bool is_const) throw()
: std::runtime_error(std::string("No matching function to dispatch to") + (is_const?", parameter is const":""))
{
}
dispatch_error(bool is_const) throw()
: std::runtime_error(std::string("No matching function to dispatch to") + (is_const?", parameter is const":""))
{
}
virtual ~dispatch_error() throw() {}
};
virtual ~dispatch_error() throw() {}
};
}
/**
* Take a vector of functions and a vector of parameters. Attempt to execute
@@ -617,7 +621,7 @@ namespace chaiscript
++begin;
}
throw dispatch_error(plist.empty()?false:plist[0].is_const());
throw exception::dispatch_error(plist.empty()?false:plist[0].is_const());
}
/**

View File

@@ -49,29 +49,6 @@ namespace chaiscript
};
}
namespace detail
{
template<typename Ret>
struct Do_Call
{
template<typename Fun>
static Boxed_Value go(const boost::function<Fun> &fun, const std::vector<Boxed_Value> &params)
{
return Handle_Return<Ret>::handle(call_func(fun, params));
}
};
template<>
struct Do_Call<void>
{
template<typename Fun>
static Boxed_Value go(const boost::function<Fun> &fun, const std::vector<Boxed_Value> &params)
{
call_func(fun, params);
return Handle_Return<void>::handle();
}
};
}
}
#define BOOST_PP_ITERATION_LIMITS ( 0, 10 )
@@ -143,3 +120,35 @@ namespace chaiscript
#undef n
#endif
#ifndef BOOST_PP_IS_ITERATING
namespace chaiscript
{
namespace detail
{
template<typename Ret>
struct Do_Call
{
template<typename Fun>
static Boxed_Value go(const boost::function<Fun> &fun, const std::vector<Boxed_Value> &params)
{
return Handle_Return<Ret>::handle(chaiscript::detail::call_func(fun, params));
}
};
template<>
struct Do_Call<void>
{
template<typename Fun>
static Boxed_Value go(const boost::function<Fun> &fun, const std::vector<Boxed_Value> &params)
{
chaiscript::detail::call_func(fun, params);
return Handle_Return<void>::handle();
}
};
}
}
#endif