diff --git a/include/chaiscript/dispatchkit/boxed_value.hpp b/include/chaiscript/dispatchkit/boxed_value.hpp index 53c58678..4d017a4f 100644 --- a/include/chaiscript/dispatchkit/boxed_value.hpp +++ b/include/chaiscript/dispatchkit/boxed_value.hpp @@ -231,8 +231,8 @@ namespace chaiscript auto pointer_sentinel(std::shared_ptr &ptr) const { struct Sentinel { - Sentinel(std::shared_ptr &ptr, Data &data) - : m_ptr(ptr), m_data(data) + Sentinel(std::shared_ptr &t_ptr, Data &data) + : m_ptr(t_ptr), m_data(data) { } diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index 2bed224e..2ce9dbad 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -1404,7 +1404,7 @@ namespace chaiscript static typename Container::const_iterator find_keyed_value(const Container &t_c, const Key &t_key, const size_t t_hint) { if (t_c.size() > t_hint && t_c[t_hint].first == t_key) { - return std::next(t_c.begin(), t_hint); + return std::next(t_c.begin(), static_cast::difference_type>(t_hint)); } else { return find_keyed_value(t_c, t_key); } diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index 59db2e5f..fb850c83 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -26,30 +26,31 @@ struct AST_Node; namespace chaiscript { - static bool is_reserved_word(const std::string &name) - { - static const std::set m_reserved_words - = {"def", "fun", "while", "for", "if", "else", "&&", "||", ",", "auto", - "return", "break", "true", "false", "class", "attr", "var", "global", "GLOBAL", "_"}; - return m_reserved_words.count(name) > 0; - } - - static bool valid_object_name(const std::string &name) - { - return name.find("::") == std::string::npos && !is_reserved_word(name); - } - - static void validate_object_name(const std::string &name) - { - if (is_reserved_word(name)) { - throw exception::reserved_word_error(name); + struct Name_Validator { + static bool is_reserved_word(const std::string &name) + { + static const std::set m_reserved_words + = {"def", "fun", "while", "for", "if", "else", "&&", "||", ",", "auto", + "return", "break", "true", "false", "class", "attr", "var", "global", "GLOBAL", "_"}; + return m_reserved_words.count(name) > 0; } - if (name.find("::") != std::string::npos) { - throw exception::illegal_name_error(name); + static bool valid_object_name(const std::string &name) + { + return name.find("::") == std::string::npos && !is_reserved_word(name); } - } + static void validate_object_name(const std::string &name) + { + if (is_reserved_word(name)) { + throw exception::reserved_word_error(name); + } + + if (name.find("::") != std::string::npos) { + throw exception::illegal_name_error(name); + } + } + }; /// Signature of module entry point that all binary loadable modules must implement. typedef ModulePtr (*Create_Module_Func)(); @@ -577,7 +578,7 @@ namespace chaiscript T &get_tracer() { // to do type check this somehow? - return static_cast(*get_tracer_ptr()); + return *static_cast(get_tracer_ptr()); } protected: diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index 7429746c..25413951 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -387,7 +387,7 @@ namespace chaiscript /// \sa Boxed_Value::is_const ChaiScript &add_global_const(const Boxed_Value &t_bv, const std::string &t_name) { - validate_object_name(t_name); + Name_Validator::validate_object_name(t_name); m_engine.add_global_const(t_bv, t_name); return *this; } @@ -399,14 +399,14 @@ namespace chaiscript /// ChaiScript is thread-safe but provides no threading locking mechanism to the script ChaiScript &add_global(const Boxed_Value &t_bv, const std::string &t_name) { - validate_object_name(t_name); + Name_Validator::validate_object_name(t_name); m_engine.add_global(t_bv, t_name); return *this; } ChaiScript &set_global(const Boxed_Value &t_bv, const std::string &t_name) { - validate_object_name(t_name); + Name_Validator::validate_object_name(t_name); m_engine.set_global(t_bv, t_name); return *this; } @@ -506,7 +506,7 @@ namespace chaiscript template ChaiScript &add(const T &t_t, const std::string &t_name) { - validate_object_name(t_name); + Name_Validator::validate_object_name(t_name); m_engine.add(t_t, t_name); return *this; } diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 85352f99..b3c92806 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -436,7 +436,7 @@ namespace chaiscript Equation_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector> t_children) : AST_Node_Impl(std::move(t_ast_node_text), AST_Node_Type::Equation, std::move(t_loc), std::move(t_children)), m_oper(Operators::to_operator(this->text)) - { assert(children.size() == 2); } + { assert(this->children.size() == 2); } Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override { @@ -1011,7 +1011,7 @@ private: struct Case_AST_Node final : AST_Node_Impl { Case_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector> t_children) : AST_Node_Impl(std::move(t_ast_node_text), AST_Node_Type::Case, std::move(t_loc), std::move(t_children)) - { assert(children.size() == 2); /* how many children does it have? */ } + { assert(this->children.size() == 2); /* how many children does it have? */ } Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override { chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); @@ -1026,7 +1026,7 @@ private: struct Default_AST_Node final : AST_Node_Impl { Default_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector> t_children) : AST_Node_Impl(std::move(t_ast_node_text), AST_Node_Type::Default, std::move(t_loc), std::move(t_children)) - { assert(children.size() == 1); } + { assert(this->children.size() == 1); } Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override { chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); @@ -1141,7 +1141,7 @@ private: struct Reference_AST_Node final : AST_Node_Impl { Reference_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector> t_children) : AST_Node_Impl(std::move(t_ast_node_text), AST_Node_Type::Reference, std::move(t_loc), std::move(t_children)) - { assert(children.size() == 1); } + { assert(this->children.size() == 1); } Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{ Boxed_Value bv; diff --git a/include/chaiscript/language/chaiscript_optimizer.hpp b/include/chaiscript/language/chaiscript_optimizer.hpp index be58157f..f892f567 100644 --- a/include/chaiscript/language/chaiscript_optimizer.hpp +++ b/include/chaiscript/language/chaiscript_optimizer.hpp @@ -262,7 +262,7 @@ namespace chaiscript { } else if (lhs.get_type_info().bare_equal_type_info(typeid(bool)) && oper == "!") { return chaiscript::make_shared, eval::Constant_AST_Node>(std::move(match), node->location, Boxed_Value(!boxed_cast(lhs))); } - } catch (const std::exception &e) { + } catch (const std::exception &) { //failure to fold, that's OK } } else if ((node->identifier == AST_Node_Type::Logical_And || node->identifier == AST_Node_Type::Logical_Or) diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index 8da5c702..3cbd2cd4 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -113,7 +113,7 @@ namespace chaiscript template class ChaiScript_Parser final : public ChaiScript_Parser_Base { - void *get_tracer_ptr() { + void *get_tracer_ptr() override { return &m_tracer; } @@ -339,7 +339,7 @@ namespace chaiscript void validate_object_name(const std::string &name) const { - if (!valid_object_name(name)) { + if (!Name_Validator::valid_object_name(name)) { throw exception::eval_error("Invalid Object Name: " + name, File_Position(m_position.line, m_position.col), *m_filename); } } @@ -2256,8 +2256,8 @@ namespace chaiscript build_match>(prev_stack_top, oper); break; - default: - throw exception::eval_error("Internal error: unhandled ast_node", File_Position(m_position.line, m_position.col), *m_filename); +// default: +// throw exception::eval_error("Internal error: unhandled ast_node", File_Position(m_position.line, m_position.col), *m_filename); } } }