diff --git a/chaiscript/chaiscript.hpp b/chaiscript/chaiscript.hpp index 9d88a58..3ded5c4 100644 --- a/chaiscript/chaiscript.hpp +++ b/chaiscript/chaiscript.hpp @@ -9,10 +9,10 @@ #include #include -#include #include #include #include +#include #include "dispatchkit.hpp" #include "bootstrap.hpp" @@ -53,7 +53,7 @@ namespace chaiscript File_Position() : line(0), column(0) { } }; - typedef std::tr1::shared_ptr TokenPtr; + typedef boost::shared_ptr TokenPtr; /** * The struct that doubles as both a parser token and an AST node diff --git a/chaiscript/chaiscript_engine.hpp b/chaiscript/chaiscript_engine.hpp index fd8e881..0801c84 100644 --- a/chaiscript/chaiscript_engine.hpp +++ b/chaiscript/chaiscript_engine.hpp @@ -51,7 +51,7 @@ namespace chaiscript catch (Eval_Error &ee) { throw Eval_Error("Can not evaluate string: " + val + " reason: " + ee.reason, TokenPtr()); } - catch (std::exception &e) { + catch (std::exception &) { throw Eval_Error("Can not evaluate string: " + val, TokenPtr()); } return evaluate_string(val); diff --git a/chaiscript/chaiscript_eval.hpp b/chaiscript/chaiscript_eval.hpp index bb1b4b4..a8c4466 100644 --- a/chaiscript/chaiscript_eval.hpp +++ b/chaiscript/chaiscript_eval.hpp @@ -64,7 +64,7 @@ namespace chaiscript try { return ss.get_object(node->text); } - catch (std::exception &e) { + catch (std::exception &) { throw Eval_Error("Can not find object: " + node->text, node); } } @@ -74,7 +74,7 @@ namespace chaiscript * Evaluates a floating point number */ template - dispatchkit::Boxed_Value eval_float(Eval_System &ss, TokenPtr node) { + dispatchkit::Boxed_Value eval_float(Eval_System &, TokenPtr node) { return dispatchkit::Boxed_Value(double(atof(node->text.c_str()))); } @@ -82,7 +82,7 @@ namespace chaiscript * Evaluates an integer */ template - dispatchkit::Boxed_Value eval_int(Eval_System &ss, TokenPtr node) { + dispatchkit::Boxed_Value eval_int(Eval_System &, TokenPtr node) { return dispatchkit::Boxed_Value(atoi(node->text.c_str())); } @@ -90,7 +90,7 @@ namespace chaiscript * Evaluates a quoted string */ template - dispatchkit::Boxed_Value eval_quoted_string(Eval_System &ss, TokenPtr node) { + dispatchkit::Boxed_Value eval_quoted_string(Eval_System &, TokenPtr node) { return dispatchkit::Boxed_Value(node->text); } @@ -98,7 +98,7 @@ namespace chaiscript * Evaluates a char group */ template - dispatchkit::Boxed_Value eval_single_quoted_string(Eval_System &ss, TokenPtr node) { + dispatchkit::Boxed_Value eval_single_quoted_string(Eval_System &, TokenPtr node) { return dispatchkit::Boxed_Value(node->text); } @@ -125,11 +125,11 @@ namespace chaiscript try { retval = dispatch(ss.get_function(node->children[i+1]->text), plb); } - catch(const dispatchkit::dispatch_error &e){ + catch(const dispatchkit::dispatch_error &){ throw Eval_Error("Mismatched types in equation", node->children[i+1]); } } - catch(const dispatchkit::dispatch_error &e){ + catch(const dispatchkit::dispatch_error &){ throw Eval_Error("Can not clone right hand side of equation", node->children[i+1]); } } @@ -149,7 +149,7 @@ namespace chaiscript try { retval = dispatch(ss.get_function(node->children[i+1]->text), plb); } - catch(const dispatchkit::dispatch_error &e){ + catch(const dispatchkit::dispatch_error &){ throw Eval_Error("Can not find appropriate '" + node->children[i+1]->text + "'", node->children[i+1]); } } @@ -182,7 +182,7 @@ namespace chaiscript try { lhs = dispatchkit::boxed_cast(retval); } - catch (std::exception &e) { + catch (const dispatchkit::bad_boxed_cast &) { throw Eval_Error("Condition not boolean", node); } if (node->children[i]->text == "&&") { @@ -224,7 +224,7 @@ namespace chaiscript try { retval = dispatch(ss.get_function(node->children[i]->text), plb); } - catch(const dispatchkit::dispatch_error &e){ + catch(const dispatchkit::dispatch_error &){ throw Eval_Error("Can not find appropriate '" + node->children[i]->text + "'", node->children[i]); } } @@ -249,10 +249,10 @@ namespace chaiscript try { retval = dispatch(ss.get_function("[]"), plb); } - catch(std::out_of_range &oor) { + catch(std::out_of_range &) { throw Eval_Error("Out of bounds exception", node); } - catch(const dispatchkit::dispatch_error &e){ + catch(const dispatchkit::dispatch_error &){ throw Eval_Error("Can not find appropriate array lookup '[]' " + node->children[i]->text, node->children[i]); } } @@ -275,7 +275,7 @@ namespace chaiscript try { return dispatch(ss.get_function("*"), plb); } - catch(std::exception &e){ + catch(std::exception &){ throw Eval_Error("Can not find appropriate negation", node->children[0]); } } @@ -292,7 +292,7 @@ namespace chaiscript retval = eval_token(ss, node->children[0]); cond = dispatchkit::boxed_cast(retval); } - catch (std::exception) { + catch (const dispatchkit::bad_boxed_cast &) { throw Eval_Error("Boolean not('!') condition not boolean", node->children[0]); } return dispatchkit::Boxed_Value(!cond); @@ -312,7 +312,7 @@ namespace chaiscript try { return dispatch(ss.get_function(node->children[0]->text), plb); } - catch(std::exception &e){ + catch(std::exception &){ throw Eval_Error("Can not find appropriate prefix", node->children[0]); } } @@ -333,13 +333,13 @@ namespace chaiscript dispatchkit::Boxed_Value tmp = eval_token(ss, node->children[0]->children[i]); dispatch(ss.get_function("push_back"), dispatchkit::Param_List_Builder() << retval << tmp); } - catch (const dispatchkit::dispatch_error &inner_e) { + catch (const dispatchkit::dispatch_error &) { throw Eval_Error("Can not find appropriate 'push_back'", node->children[0]->children[i]); } } } } - catch (const dispatchkit::dispatch_error &e) { + catch (const dispatchkit::dispatch_error &) { throw Eval_Error("Can not find appropriate 'Vector()'", node); } @@ -356,7 +356,7 @@ namespace chaiscript << eval_token(ss, node->children[0]->children[0]->children[0]) << eval_token(ss, node->children[0]->children[0]->children[1])); } - catch (const dispatchkit::dispatch_error &e) { + catch (const dispatchkit::dispatch_error &) { throw Eval_Error("Unable to generate range vector", node); } } @@ -377,12 +377,12 @@ namespace chaiscript dispatchkit::Boxed_Value slot = dispatch(ss.get_function("[]"), dispatchkit::Param_List_Builder() << retval << key); dispatch(ss.get_function("="), dispatchkit::Param_List_Builder() << slot << eval_token(ss, node->children[0]->children[i]->children[1])); } - catch (const dispatchkit::dispatch_error &inner_e) { + catch (const dispatchkit::dispatch_error &) { throw Eval_Error("Can not find appropriate '=' for map init", node->children[0]->children[i]); } } } - catch (const dispatchkit::dispatch_error &e) { + catch (const dispatchkit::dispatch_error &) { throw Eval_Error("Can not find appropriate 'Map()'", node); } @@ -442,7 +442,7 @@ namespace chaiscript template dispatchkit::Boxed_Value eval_dot_access(Eval_System &ss, TokenPtr node) { dispatchkit::Boxed_Value retval; - std::vector > fn; + std::vector > > fn; dispatchkit::Dispatch_Engine::Stack prev_stack = ss.get_stack(); dispatchkit::Dispatch_Engine::Stack new_stack; unsigned int i, j; @@ -477,7 +477,7 @@ namespace chaiscript retval = dispatch(fn, plb); ss.set_stack(prev_stack); } - catch(const dispatchkit::dispatch_error &e){ + catch(const dispatchkit::dispatch_error &){ ss.set_stack(prev_stack); throw Eval_Error("Can not find appropriate '" + fun_name + "'", node); } @@ -508,7 +508,7 @@ namespace chaiscript try { cond = dispatchkit::boxed_cast(retval); } - catch (std::exception &e) { + catch (const dispatchkit::bad_boxed_cast &) { throw Eval_Error("If condition not boolean", node->children[0]); } if (cond) { @@ -527,7 +527,7 @@ namespace chaiscript try { cond = dispatchkit::boxed_cast(retval); } - catch (std::exception &e) { + catch (const dispatchkit::bad_boxed_cast &) { throw Eval_Error("Elseif condition not boolean", node->children[i+1]); } if (cond) { @@ -554,7 +554,7 @@ namespace chaiscript try { cond = dispatchkit::boxed_cast(retval); } - catch (std::exception) { + catch (const dispatchkit::bad_boxed_cast &) { throw Eval_Error("While condition not boolean", node->children[0]); } while (cond) { @@ -564,11 +564,11 @@ namespace chaiscript try { cond = dispatchkit::boxed_cast(retval); } - catch (std::exception) { + catch (const dispatchkit::bad_boxed_cast &) { throw Eval_Error("While condition not boolean", node->children[0]); } } - catch (Break_Loop &bl) { + catch (Break_Loop &) { cond = false; } } @@ -595,7 +595,7 @@ namespace chaiscript } cond = dispatchkit::boxed_cast(condition); } - catch (std::exception &e) { + catch (const dispatchkit::bad_boxed_cast &) { throw Eval_Error("For condition not boolean", node); } while (cond) { @@ -613,10 +613,10 @@ namespace chaiscript cond = dispatchkit::boxed_cast(condition); } - catch (std::exception &e) { + catch (const dispatchkit::bad_boxed_cast &) { throw Eval_Error("For condition not boolean", node); } - catch (Break_Loop &bl) { + catch (Break_Loop &) { cond = false; } } @@ -748,7 +748,7 @@ namespace chaiscript * Evaluates a break statement */ template - dispatchkit::Boxed_Value eval_break(Eval_System &ss, TokenPtr node) { + dispatchkit::Boxed_Value eval_break(Eval_System &, TokenPtr node) { throw Break_Loop(node); } diff --git a/chaiscript/main.cpp b/chaiscript/main.cpp index 9bf6feb..cde08f6 100644 --- a/chaiscript/main.cpp +++ b/chaiscript/main.cpp @@ -10,6 +10,8 @@ void print_help() { } int main(int argc, char *argv[]) { + + std::string input; chaiscript::ChaiScript_Engine chai; @@ -29,13 +31,11 @@ int main(int argc, char *argv[]) { val = chai.evaluate_string(input); if (val.get_type_info().m_bare_type_info && *(val.get_type_info().m_bare_type_info) != typeid(void)) { - try { dispatchkit::dispatch(chai.get_eval_engine().get_function("print"), dispatchkit::Param_List_Builder() << val); } catch (const std::runtime_error &e) { std::cout << e.what() << std::endl; } - } } @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) { try { dispatchkit::Boxed_Value val = chai.evaluate_file(argv[i]); } - catch (std::exception &e) { + catch (std::exception &) { std::cerr << "Could not open: " << argv[i] << std::endl; exit(1); } diff --git a/dispatchkit/bootstrap.hpp b/dispatchkit/bootstrap.hpp index 96f230c..c518333 100644 --- a/dispatchkit/bootstrap.hpp +++ b/dispatchkit/bootstrap.hpp @@ -152,9 +152,9 @@ namespace dispatchkit { if (v.m_isfloat) { - return (p1 = v.d); + return (p1 = P1(v.d)); } else { - return (p1 = v.i); + return (p1 = P1(v.i)); } } @@ -163,9 +163,9 @@ namespace dispatchkit { if (v.m_isfloat) { - return (v.d); + return P1(v.d); } else { - return (v.i); + return P1(v.i); } } @@ -174,9 +174,9 @@ namespace dispatchkit { if (r.m_isfloat) { - return (p1 *= r.d); + return p1 *= P1(r.d); } else { - return (p1 *= r.i); + return p1 *= P1(r.i); } } @@ -185,9 +185,9 @@ namespace dispatchkit { if (r.m_isfloat) { - return (p1 /= r.d); + return p1 /= P1(r.d); } else { - return (p1 /= r.i); + return p1 /= P1(r.i); } } @@ -196,9 +196,9 @@ namespace dispatchkit { if (r.m_isfloat) { - return (p1 += r.d); + return p1 += P1(r.d); } else { - return (p1 += r.i); + return p1 += P1(r.i); } } @@ -207,9 +207,9 @@ namespace dispatchkit { if (r.m_isfloat) { - return (p1 -= r.d); + return p1 -= P1(r.d); } else { - return (p1 -= r.i); + return p1 -= P1(r.i); } } @@ -548,7 +548,7 @@ namespace dispatchkit bootstrap_pod_type(s, "int"); bootstrap_pod_type(s, "size_t"); bootstrap_pod_type(s, "char"); - bootstrap_pod_type(s, "int64_t"); + bootstrap_pod_type(s, "int64_t"); add_opers_comparison_pod(s); add_opers_arithmetic_pod(s); diff --git a/dispatchkit/bootstrap_stl.hpp b/dispatchkit/bootstrap_stl.hpp index 7a86fde..cd225ce 100644 --- a/dispatchkit/bootstrap_stl.hpp +++ b/dispatchkit/bootstrap_stl.hpp @@ -76,7 +76,7 @@ namespace dispatchkit } template - void bootstrap_reversible_container(Dispatch_Engine &system, const std::string &type) + void bootstrap_reversible_container(Dispatch_Engine &/*system*/, const std::string &/*type*/) { } diff --git a/dispatchkit/boxed_value.hpp b/dispatchkit/boxed_value.hpp index c64c246..924216e 100644 --- a/dispatchkit/boxed_value.hpp +++ b/dispatchkit/boxed_value.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace dispatchkit @@ -436,20 +437,20 @@ namespace dispatchkit i = boxed_cast(v); } else if (inp_ == typeid(unsigned long)) { i = boxed_cast(v); - } else if (inp_ == typeid(int8_t)) { - i = boxed_cast(v); - } else if (inp_ == typeid(int16_t)) { - i = boxed_cast(v); - } else if (inp_ == typeid(int32_t)) { - i = boxed_cast(v); - } else if (inp_ == typeid(int64_t)) { - i = boxed_cast(v); - } else if (inp_ == typeid(uint8_t)) { - i = boxed_cast(v); - } else if (inp_ == typeid(uint16_t)) { - i = boxed_cast(v); - } else if (inp_ == typeid(uint32_t)) { - i = boxed_cast(v); + } else if (inp_ == typeid(boost::int8_t)) { + i = boxed_cast(v); + } else if (inp_ == typeid(boost::int16_t)) { + i = boxed_cast(v); + } else if (inp_ == typeid(boost::int32_t)) { + i = boxed_cast(v); + } else if (inp_ == typeid(boost::int64_t)) { + i = boxed_cast(v); + } else if (inp_ == typeid(boost::uint8_t)) { + i = boxed_cast(v); + } else if (inp_ == typeid(boost::uint16_t)) { + i = boxed_cast(v); + } else if (inp_ == typeid(boost::uint32_t)) { + i = boxed_cast(v); } else { throw boost::bad_any_cast(); } @@ -527,7 +528,7 @@ namespace dispatchkit } double d; - int64_t i; + boost::int64_t i; bool m_isfloat; }; diff --git a/dispatchkit/dispatchkit.hpp b/dispatchkit/dispatchkit.hpp index 7c19650..2741819 100644 --- a/dispatchkit/dispatchkit.hpp +++ b/dispatchkit/dispatchkit.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,7 @@ namespace dispatchkit { } - virtual bool operator==(const Proxy_Function &f) const + virtual bool operator==(const Proxy_Function &) const { return false; } @@ -76,8 +77,7 @@ namespace dispatchkit class Dispatch_Engine { public: - typedef std::multimap > Function_Map; - typedef std::map Type_Name_Map; + typedef std::map Type_Name_Map; typedef std::map Scope; typedef std::deque Stack; @@ -143,7 +143,7 @@ namespace dispatchkit Stack set_stack(Stack s) { - swap(s, m_scopes); + std::swap(s, m_scopes); return s; } @@ -164,7 +164,7 @@ namespace dispatchkit } } - std::vector > funcs = get_function_impl(name, false); + std::vector >::mapped_type> > funcs = get_function_impl(name, false); if (funcs.empty()) { @@ -180,15 +180,17 @@ namespace dispatchkit m_types.insert(std::make_pair(name, Get_Type_Info::get())); } + Type_Info get_type(const std::string &name) const { Type_Name_Map::const_iterator itr = m_types.find(name); + if (itr != m_types.end()) { return itr->second; - } else { - throw std::range_error("Type Not Known"); } + + throw std::range_error("Type Not Known"); } std::string get_type_name(const Type_Info &ti) const @@ -206,51 +208,51 @@ namespace dispatchkit return ti.m_bare_type_info->name(); } - std::vector get_types() const + std::vector > get_types() const { - return std::vector(m_types.begin(), m_types.end()); + return std::vector >(m_types.begin(), m_types.end()); } - std::vector > + std::vector >::mapped_type> > get_function_impl(const std::string &t_name, bool include_objects) const { - std::vector > funcs; + std::vector >::mapped_type> > funcs; if (include_objects) { try { funcs.insert(funcs.end(), - Function_Map::value_type( + std::make_pair( t_name, - boxed_cast(get_object(t_name))) + boxed_cast >::mapped_type>(get_object(t_name))) ); } catch (const bad_boxed_cast &) { } catch (const std::range_error &) { } } - std::pair range + std::pair >::const_iterator, std::multimap >::const_iterator> range = m_functions.equal_range(t_name); funcs.insert(funcs.end(), range.first, range.second); return funcs; } - std::vector > + std::vector >::mapped_type> > get_function(const std::string &t_name) const { return get_function_impl(t_name, true); } - std::vector get_functions() const + std::vector > > get_functions() const { - return std::vector(m_functions.begin(), m_functions.end()); + return std::vector > >(m_functions.begin(), m_functions.end()); } private: bool add_function(const boost::shared_ptr &f, const std::string &t_name) { - std::pair range + std::pair >::const_iterator, std::multimap >::const_iterator> range = m_functions.equal_range(t_name); while (range.first != range.second) @@ -268,7 +270,7 @@ namespace dispatchkit std::deque m_scopes; - Function_Map m_functions; + std::multimap > m_functions; Type_Name_Map m_types; Boxed_Value m_place_holder; }; @@ -283,7 +285,7 @@ namespace dispatchkit std::cout << e.get_type_name(type); } - void dump_function(const Dispatch_Engine::Function_Map::value_type &f, const Dispatch_Engine &e) + void dump_function(const std::pair > &f, const Dispatch_Engine &e) { std::vector params = f.second->get_param_types(); std::string annotation = f.second->annotation(); @@ -314,8 +316,8 @@ namespace dispatchkit void dump_system(const Dispatch_Engine &s) { std::cout << "Registered Types: " << std::endl; - std::vector types = s.get_types(); - for (std::vector::const_iterator itr = types.begin(); + std::vector > types = s.get_types(); + for (std::vector >::const_iterator itr = types.begin(); itr != types.end(); ++itr) { @@ -325,10 +327,11 @@ namespace dispatchkit } - std::cout << std::endl; std::vector funcs = s.get_functions(); + std::cout << std::endl; + std::vector > > funcs = s.get_functions(); std::cout << "Functions: " << std::endl; - for (std::vector::const_iterator itr = funcs.begin(); + for (std::vector > >::const_iterator itr = funcs.begin(); itr != funcs.end(); ++itr) { diff --git a/dispatchkit/proxy_functions.hpp b/dispatchkit/proxy_functions.hpp index cce4b4e..f087f2d 100644 --- a/dispatchkit/proxy_functions.hpp +++ b/dispatchkit/proxy_functions.hpp @@ -148,7 +148,7 @@ namespace dispatchkit { } - virtual bool operator==(const Proxy_Function &f) const + virtual bool operator==(const Proxy_Function &) const { return false; } @@ -238,7 +238,7 @@ namespace dispatchkit { } - virtual bool operator==(const Proxy_Function &f) const + virtual bool operator==(const Proxy_Function &) const { return false; } @@ -398,7 +398,7 @@ namespace dispatchkit { template - std::vector build_param_type_list(const boost::function &f) + std::vector build_param_type_list(const boost::function &) { std::vector ti; ti.push_back(Get_Type_Info::get()); diff --git a/dispatchkit/type_info.hpp b/dispatchkit/type_info.hpp index c3c5ef0..e47c025 100644 --- a/dispatchkit/type_info.hpp +++ b/dispatchkit/type_info.hpp @@ -17,6 +17,7 @@ namespace dispatchkit Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void, const std::type_info *t_ti, const std::type_info *t_bareti) : m_is_const(t_is_const), m_is_reference(t_is_reference), m_is_pointer(t_is_pointer), + m_is_void(t_is_void), m_type_info(t_ti), m_bare_type_info(t_bareti), m_is_unknown(false) { @@ -29,6 +30,14 @@ namespace dispatchkit { } + Type_Info(const Type_Info &ti) + : m_is_const(ti.m_is_const), m_is_reference(ti.m_is_reference), + m_is_pointer(ti.m_is_pointer), + m_is_void(ti.m_is_void), m_type_info(ti.m_type_info), + m_bare_type_info(ti.m_bare_type_info), + m_is_unknown(ti.m_is_unknown) + { + } Type_Info &operator=(const Type_Info &ti) { m_is_const = ti.m_is_const; @@ -40,6 +49,10 @@ namespace dispatchkit m_is_unknown = ti.m_is_unknown; return *this; } + bool operator<(const Type_Info &ti) const + { + return m_type_info < ti.m_type_info; + } bool operator==(const Type_Info &ti) const { diff --git a/msvc/chaiscript/Boost.vsprops b/msvc/chaiscript/Boost.vsprops new file mode 100644 index 0000000..a4a7ba4 --- /dev/null +++ b/msvc/chaiscript/Boost.vsprops @@ -0,0 +1,11 @@ + + + + diff --git a/msvc/chaiscript/chaiscript.sln b/msvc/chaiscript/chaiscript.sln new file mode 100644 index 0000000..a019b4e --- /dev/null +++ b/msvc/chaiscript/chaiscript.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chaiscript", "chaiscript.vcproj", "{46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}.Debug|Win32.ActiveCfg = Debug|Win32 + {46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}.Debug|Win32.Build.0 = Debug|Win32 + {46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}.Release|Win32.ActiveCfg = Release|Win32 + {46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/msvc/chaiscript/chaiscript.vcproj b/msvc/chaiscript/chaiscript.vcproj new file mode 100644 index 0000000..a4eab8a --- /dev/null +++ b/msvc/chaiscript/chaiscript.vcproj @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +