Add runtime_error support, for throwing a normal std::exception. Also, move bootstrap for Dynamic_Object into its proper place.

This commit is contained in:
Jason Turner 2009-09-19 12:15:17 +00:00
parent b0041217b0
commit 6a47846b84
4 changed files with 17 additions and 3 deletions

View File

@ -8,6 +8,7 @@
#define __bootstrap_hpp__ #define __bootstrap_hpp__
#include "dispatchkit.hpp" #include "dispatchkit.hpp"
#include "dynamic_object.hpp"
#include "register_function.hpp" #include "register_function.hpp"
namespace chaiscript namespace chaiscript
@ -666,6 +667,15 @@ 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(user_type<std::runtime_error>(), "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(user_type<Dynamic_Object>(), "Dynamic_Object");
copy_constructor<Dynamic_Object>("Dynamic_Object", m);
basic_constructors<bool>("bool", m); basic_constructors<bool>("bool", m);
oper_assign<std::string>(m); oper_assign<std::string>(m);
oper_assign<bool>(m); oper_assign<bool>(m);

View File

@ -465,9 +465,6 @@ namespace chaiscript
new Dynamic_Proxy_Function(boost::bind(&ChaiScript_System<Eval_Engine>::internal_eval, boost::ref(*this), _1), 1)), "eval"); new Dynamic_Proxy_Function(boost::bind(&ChaiScript_System<Eval_Engine>::internal_eval, boost::ref(*this), _1), 1)), "eval");
engine.add(user_type<Dynamic_Object>(), "Dynamic_Object");
engine.add(chaiscript::bootstrap::copy_constructor<Dynamic_Object>("Dynamic_Object"));

View File

@ -0,0 +1,6 @@
try {
throw(runtime_error("error"))
}
catch(e) {
print(e.what())
}

View File

@ -0,0 +1 @@
error