diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 21ad6e7..1dc0c44 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -309,16 +309,7 @@ namespace chaiscript static bool has_guard(const Const_Proxy_Function &t_pf) { auto pf = std::dynamic_pointer_cast(t_pf); - if (pf) - { - if (pf->get_guard()) { - return true; - } else { - return false; - } - } else { - return false; - } + return pf && pf->get_guard(); } static Const_Proxy_Function get_guard(const Const_Proxy_Function &t_pf) @@ -372,12 +363,7 @@ namespace chaiscript static bool has_parse_tree(const chaiscript::Const_Proxy_Function &t_pf) { const auto pf = std::dynamic_pointer_cast(t_pf); - if (pf && pf->get_parse_tree()) - { - return true; - } else { - return false; - } + return pf && pf->get_parse_tree(); } static chaiscript::AST_NodePtr get_parse_tree(const chaiscript::Const_Proxy_Function &t_pf) diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index d686486..3eb7e9e 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -349,15 +349,15 @@ namespace chaiscript template ModulePtr front_insertion_sequence_type(const std::string &, ModulePtr m = ModulePtr(new Module())) { - typedef typename ContainerType::reference (ContainerType::*frontptr)(); - typedef typename ContainerType::const_reference (ContainerType::*constfrontptr)() const; - typedef void (ContainerType::*pushptr)(typename ContainerType::const_reference); - typedef void (ContainerType::*popptr)(); + typedef typename ContainerType::reference (ContainerType::*front_ptr)(); + typedef typename ContainerType::const_reference (ContainerType::*const_front_ptr)() const; + typedef void (ContainerType::*push_ptr)(typename ContainerType::const_reference); + typedef void (ContainerType::*pop_ptr)(); - m->add(fun(static_cast(&ContainerType::front)), "front"); - m->add(fun(static_cast(&ContainerType::front)), "front"); + m->add(fun(static_cast(&ContainerType::front)), "front"); + m->add(fun(static_cast(&ContainerType::front)), "front"); - m->add(fun(static_cast(&ContainerType::push_front)), + m->add(fun(static_cast(&ContainerType::push_front)), []()->std::string{ if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value)) { return "push_front_ref"; @@ -366,7 +366,7 @@ namespace chaiscript } }()); - m->add(fun(static_cast(&ContainerType::pop_front)), "pop_front"); + m->add(fun(static_cast(&ContainerType::pop_front)), "pop_front"); return m; } @@ -439,9 +439,9 @@ namespace chaiscript { m->add(user_type(), type); - typedef typename MapType::mapped_type &(MapType::*elemaccess)(const typename MapType::key_type &); + typedef typename MapType::mapped_type &(MapType::*elem_access)(const typename MapType::key_type &); - m->add(fun(static_cast(&MapType::operator[])), "[]"); + m->add(fun(static_cast(&MapType::operator[])), "[]"); container_type(type, m); default_constructible_type(type, m); diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index 21e98ae..2d1026e 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -280,8 +280,8 @@ namespace chaiscript virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE { try { - const auto &dispatchfun = dynamic_cast(rhs); - return m_funcs == dispatchfun.m_funcs; + const auto &dispatch_fun = dynamic_cast(rhs); + return m_funcs == dispatch_fun.m_funcs; } catch (const std::bad_cast &) { return false; } @@ -1138,12 +1138,7 @@ namespace chaiscript { if (dynamic_lhs->get_guard()) { - if (dynamic_rhs->get_guard()) - { - return false; - } else { - return true; - } + return dynamic_rhs->get_guard() ? false : true; } else { return false; } diff --git a/include/chaiscript/dispatchkit/dynamic_object_detail.hpp b/include/chaiscript/dispatchkit/dynamic_object_detail.hpp index b9ddda1..9d501ae 100644 --- a/include/chaiscript/dispatchkit/dynamic_object_detail.hpp +++ b/include/chaiscript/dispatchkit/dynamic_object_detail.hpp @@ -213,12 +213,7 @@ namespace chaiscript virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE { const Dynamic_Object_Constructor *dc = dynamic_cast(&f); - if (dc) - { - return dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func); - } else { - return false; - } + return dc && dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func); } virtual bool call_match(const std::vector &vals, const Type_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index 30a2853..cf038e2 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -31,8 +31,8 @@ namespace chaiscript { public: CHAISCRIPT_CONSTEXPR Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void, - bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bareti) - : m_type_info(t_ti), m_bare_type_info(t_bareti), + bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti) + : m_type_info(t_ti), m_bare_type_info(t_bare_ti), 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_is_arithmetic(t_is_arithmetic), m_is_undef(false) diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index 82f3a52..41470a0 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -229,8 +229,7 @@ namespace chaiscript if (f) { - std::shared_ptr dynfunguard - = std::dynamic_pointer_cast(f); + auto dynfunguard = std::dynamic_pointer_cast(f); if (dynfunguard) { retval += " : " + format_guard(dynfunguard->get_parse_tree()); @@ -486,8 +485,8 @@ namespace chaiscript private: // Copy and assignment explicitly unimplemented - AST_Node(const AST_Node &); - AST_Node& operator=(const AST_Node &); + AST_Node(const AST_Node &) = delete; + AST_Node& operator=(const AST_Node &) = delete; }; diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index 69eac31..675188c 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -166,11 +166,11 @@ namespace chaiscript static std::string get_error_message(DWORD t_err) { + typedef LPTSTR StringType; + #if defined(_UNICODE) || defined(UNICODE) - typedef LPWSTR StringType; std::wstring retval = L"Unknown Error"; #else - typedef LPSTR StringType; std::string retval = "Unknown Error"; #endif StringType lpMsgBuf = nullptr; @@ -182,7 +182,7 @@ namespace chaiscript NULL, t_err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (StringType)&lpMsgBuf, + reinterpret_cast(&lpMsgBuf), 0, NULL ) != 0 && lpMsgBuf) { retval = lpMsgBuf; @@ -264,8 +264,8 @@ namespace chaiscript std::map m_loaded_modules; std::set m_active_loaded_modules; - std::vector m_modulepaths; - std::vector m_usepaths; + std::vector m_module_paths; + std::vector m_use_paths; chaiscript::detail::Dispatch_Engine m_engine; @@ -299,7 +299,7 @@ namespace chaiscript /// Evaluates the given file and looks in the 'use' paths const Boxed_Value internal_eval_file(const std::string &t_filename) { - for (const auto &path : m_usepaths) + for (const auto &path : m_use_paths) { try { const auto appendedpath = path + t_filename; @@ -441,16 +441,16 @@ namespace chaiscript ChaiScript(const ModulePtr &t_lib, std::vector t_modulepaths = std::vector(), std::vector t_usepaths = std::vector()) - : m_modulepaths(std::move(t_modulepaths)), m_usepaths(std::move(t_usepaths)) + : m_module_paths(std::move(t_modulepaths)), m_use_paths(std::move(t_usepaths)) { - if (m_modulepaths.empty()) + if (m_module_paths.empty()) { - m_modulepaths.push_back(""); + m_module_paths.push_back(""); } - if (m_usepaths.empty()) + if (m_use_paths.empty()) { - m_usepaths.push_back(""); + m_use_paths.push_back(""); } build_eval_system(t_lib); @@ -465,16 +465,16 @@ namespace chaiscript /// \param[in] t_usepaths Vector of paths to search when attempting to "use" an included ChaiScript file ChaiScript( std::vector t_modulepaths = std::vector(), std::vector t_usepaths = std::vector()) - : m_modulepaths(std::move(t_modulepaths)), m_usepaths(std::move(t_usepaths)) + : m_module_paths(std::move(t_modulepaths)), m_use_paths(std::move(t_usepaths)) { - if (m_modulepaths.empty()) + if (m_module_paths.empty()) { - m_modulepaths.push_back(""); + m_module_paths.push_back(""); } - if (m_usepaths.empty()) + if (m_use_paths.empty()) { - m_usepaths.push_back(""); + m_use_paths.push_back(""); } #if defined(_POSIX_VERSION) && !defined(__CYGWIN__) @@ -507,7 +507,7 @@ namespace chaiscript dllpath = std::string(&buf.front(), pathlen); } - m_modulepaths.insert(m_modulepaths.begin(), dllpath+"/"); + m_module_paths.insert(m_module_paths.begin(), dllpath+"/"); } #endif @@ -559,7 +559,7 @@ namespace chaiscript /// \param[in] t_filename Filename to load and evaluate Boxed_Value use(const std::string &t_filename) { - for (const auto &path : m_usepaths) + for (const auto &path : m_use_paths) { try { const auto appendedpath = path + t_filename; @@ -758,7 +758,7 @@ namespace chaiscript std::vector postfixes{".dll", ".so", ".bundle", ""}; - for (auto & elem : m_modulepaths) + for (auto & elem : m_module_paths) { for (auto & prefix : prefixes) { diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 38c588b..6c9b6ae 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -1330,7 +1330,7 @@ namespace chaiscript end_point = this->children.size() - 1; } for (size_t i = 1; i < end_point; ++i) { - chaiscript::eval::detail::Scope_Push_Pop catchscope(t_ss); + chaiscript::eval::detail::Scope_Push_Pop catch_scope(t_ss); AST_NodePtr catch_block = this->children[i]; if (catch_block->children.size() == 1) { diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index a7c48e9..5245b20 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -257,12 +257,12 @@ namespace chaiscript for (auto &c : p->children) { if (c->identifier == AST_Node_Type::Def && c->children.size() > 0) { - auto &lastchild = c->children.back(); - if (lastchild->identifier == AST_Node_Type::Block) { - auto &blocklastchild = lastchild->children.back(); - if (blocklastchild->identifier == AST_Node_Type::Return) { - if (blocklastchild->children.size() == 1) { - blocklastchild = blocklastchild->children[0]; + auto &last_child = c->children.back(); + if (last_child->identifier == AST_Node_Type::Block) { + auto &block_last_child = last_child->children.back(); + if (block_last_child->identifier == AST_Node_Type::Return) { + if (block_last_child->children.size() == 1) { + block_last_child = block_last_child->children[0]; } } } @@ -789,30 +789,26 @@ namespace chaiscript } /// Reads (and potentially captures) an identifier from input - bool Id(const bool t_capture = false) { + bool Id() { SkipWS(); - if (!t_capture) { - return Id_(); + const auto start = m_input_pos; + const auto prev_col = m_col; + const auto prev_line = m_line; + if (Id_()) { + m_match_stack.push_back(std::make_shared( + [&]()->std::string{ + if (*start == '`') { + //Id Literal + return std::string(start+1, m_input_pos-1); + } else { + return std::string(start, m_input_pos); + } + }(), + m_filename, prev_line, prev_col, m_line, m_col)); + return true; } else { - const auto start = m_input_pos; - const auto prev_col = m_col; - const auto prev_line = m_line; - if (Id_()) { - m_match_stack.push_back(std::make_shared( - [&]()->std::string{ - if (*start == '`') { - //Id Literal - return std::string(start+1, m_input_pos-1); - } else { - return std::string(start, m_input_pos); - } - }(), - m_filename, prev_line, prev_col, m_line, m_col)); - return true; - } else { - return false; - } + return false; } } @@ -821,14 +817,14 @@ namespace chaiscript const auto prev_stack_top = m_match_stack.size(); SkipWS(); - if (!Id(true)) { + if (!Id()) { return false; } SkipWS(); if (t_type_allowed) { - Id(true); + Id(); } build_match(std::make_shared(), prev_stack_top); @@ -1426,7 +1422,7 @@ namespace chaiscript if (Keyword("def")) { retval = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Missing function name in definition", File_Position(m_line, m_col), *m_filename); } @@ -1436,7 +1432,7 @@ namespace chaiscript //We're now a method is_method = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Missing method name in definition", File_Position(m_line, m_col), *m_filename); } } @@ -1609,7 +1605,7 @@ namespace chaiscript if (Keyword("class")) { retval = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Missing class name in definition", File_Position(m_line, m_col), *m_filename); } @@ -1890,7 +1886,7 @@ namespace chaiscript const auto prev_stack_top = m_match_stack.size(); if (Lambda() || Num(true) || Quoted_String(true) || Single_Quoted_String(true) || - Paren_Expression() || Inline_Container() || Id(true)) + Paren_Expression() || Inline_Container() || Id()) { retval = true; bool has_more = true; @@ -1931,7 +1927,7 @@ namespace chaiscript } else if (Symbol(".", true)) { has_more = true; - if (!(Id(true))) { + if (!(Id())) { throw exception::eval_error("Incomplete array access", File_Position(m_line, m_col), *m_filename); } @@ -1952,7 +1948,7 @@ namespace chaiscript if (t_class_context && (Keyword("attr") || Keyword("auto") || Keyword("var"))) { retval = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename); } @@ -1960,7 +1956,7 @@ namespace chaiscript } else if (Keyword("auto") || Keyword("var")) { retval = true; - if (!(Reference() || Id(true))) { + if (!(Reference() || Id())) { throw exception::eval_error("Incomplete variable declaration", File_Position(m_line, m_col), *m_filename); } @@ -1968,13 +1964,13 @@ namespace chaiscript } else if (Keyword("attr")) { retval = true; - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename); } if (!Symbol("::", false)) { throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename); } - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Missing attribute name in definition", File_Position(m_line, m_col), *m_filename); } @@ -2036,7 +2032,7 @@ namespace chaiscript const auto prev_stack_top = m_match_stack.size(); if (Symbol("&", false)) { - if (!Id(true)) { + if (!Id()) { throw exception::eval_error("Incomplete '&' expression", File_Position(m_line, m_col), *m_filename); } @@ -2071,11 +2067,7 @@ namespace chaiscript /// Parses any of a group of 'value' style ast_node groups from input bool Value() { - if (Var_Decl() || Dot_Fun_Array() || Prefix()) { - return true; - } else { - return false; - } + return Var_Decl() || Dot_Fun_Array() || Prefix(); } bool Operator_Helper(const size_t t_precedence) { diff --git a/include/chaiscript/language/chaiscript_prelude_docs.hpp b/include/chaiscript/language/chaiscript_prelude_docs.hpp index eb02f3b..7480858 100644 --- a/include/chaiscript/language/chaiscript_prelude_docs.hpp +++ b/include/chaiscript/language/chaiscript_prelude_docs.hpp @@ -309,7 +309,7 @@ class Range /// \brief Moves the front pointer forward one /// - /// \post front() returne the element at front() + 1; + /// \post front() returns the element at front() + 1; void pop_front(); }; @@ -340,7 +340,7 @@ class Const_Range /// \brief Moves the front pointer forward one /// - /// \post front() returne the element at front() + 1; + /// \post front() returns the element at front() + 1; void pop_front(); }; diff --git a/include/chaiscript/utility/utility.hpp b/include/chaiscript/utility/utility.hpp index 9c36b13..ecd5a3f 100644 --- a/include/chaiscript/utility/utility.hpp +++ b/include/chaiscript/utility/utility.hpp @@ -38,8 +38,8 @@ namespace chaiscript /// { {fun(&test::function), "function"}, /// {fun(&test::function2), "function2"}, /// {fun(&test::function3), "function3"}, - /// {fun(static_cast(&test::functionoverload)), "functionoverload" }, - /// {fun(static_cast(&test::functionoverload)), "functionoverload" }, + /// {fun(static_cast(&test::function_overload)), "function_overload" }, + /// {fun(static_cast(&test::function_overload)), "function_overload" }, /// {fun(static_cast(&test::operator=)), "=" } /// } /// ); diff --git a/src/test_module.cpp b/src/test_module.cpp index 1ed7182..c5da4c9 100644 --- a/src/test_module.cpp +++ b/src/test_module.cpp @@ -35,7 +35,7 @@ class TestBaseType std::function func_member; private: - TestBaseType &operator=(const TestBaseType &); + TestBaseType &operator=(const TestBaseType &) = delete; }; class Type2 @@ -82,7 +82,7 @@ class TestDerivedType : public TestBaseType int derived_only_func() { return 19; } private: - TestDerivedType &operator=(const TestDerivedType &); + TestDerivedType &operator=(const TestDerivedType &) = delete; }; class TestMoreDerivedType : public TestDerivedType