From f82f6c2068b2ce9be2ae00a3e1474a869016c457 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 25 Jan 2016 16:41:11 -0700 Subject: [PATCH] Some fixes found by resharper c++ --- include/chaiscript/dispatchkit/dispatchkit.hpp | 14 +++++++------- .../dispatchkit/exception_specification.hpp | 2 +- include/chaiscript/language/chaiscript_engine.hpp | 4 ++-- include/chaiscript/language/chaiscript_parser.hpp | 2 +- src/main.cpp | 7 +++---- unittests/compiled_tests.cpp | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index aa09486..9274b65 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -596,13 +596,13 @@ namespace chaiscript /// Pushes a new stack on to the list of stacks - void new_stack(Stack_Holder &t_holder) + static void new_stack(Stack_Holder &t_holder) { // add a new Stack with 1 element t_holder.stacks.emplace_back(1); } - void pop_stack(Stack_Holder &t_holder) + static void pop_stack(Stack_Holder &t_holder) { t_holder.stacks.pop_back(); } @@ -1082,7 +1082,7 @@ namespace chaiscript /// Returns true if a call can be made that consists of the first parameter /// (the function) with the remaining parameters as its arguments. - Boxed_Value call_exists(const std::vector ¶ms) + Boxed_Value call_exists(const std::vector ¶ms) const { if (params.empty()) { @@ -1160,12 +1160,12 @@ namespace chaiscript m_state = t_state; } - void save_function_params(Stack_Holder &t_s, std::initializer_list t_params) + static void save_function_params(Stack_Holder &t_s, std::initializer_list t_params) { t_s.call_params.back().insert(t_s.call_params.back().begin(), std::move(t_params)); } - void save_function_params(Stack_Holder &t_s, std::vector &&t_params) + static void save_function_params(Stack_Holder &t_s, std::vector &&t_params) { for (auto &¶m : t_params) { @@ -1173,7 +1173,7 @@ namespace chaiscript } } - void save_function_params(Stack_Holder &t_s, const std::vector &t_params) + static void save_function_params(Stack_Holder &t_s, const std::vector &t_params) { t_s.call_params.back().insert(t_s.call_params.back().begin(), t_params.begin(), t_params.end()); } @@ -1240,7 +1240,7 @@ namespace chaiscript return m_stack_holder->stacks.back(); } - StackData &get_stack_data(Stack_Holder &t_holder) + static StackData &get_stack_data(Stack_Holder &t_holder) { return t_holder.stacks.back(); } diff --git a/include/chaiscript/dispatchkit/exception_specification.hpp b/include/chaiscript/dispatchkit/exception_specification.hpp index 54f19c4..2a9f0b6 100644 --- a/include/chaiscript/dispatchkit/exception_specification.hpp +++ b/include/chaiscript/dispatchkit/exception_specification.hpp @@ -32,7 +32,7 @@ namespace chaiscript protected: template - void throw_type(const Boxed_Value &bv, const Dispatch_Engine &t_engine) + static void throw_type(const Boxed_Value &bv, const Dispatch_Engine &t_engine) { try { T t = t_engine.boxed_cast(bv); throw t; } catch (const chaiscript::exception::bad_boxed_cast &) {} } diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index 4764c67..776569b 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -177,11 +177,11 @@ namespace chaiscript FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, t_err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&lpMsgBuf), - 0, NULL ) != 0 && lpMsgBuf) + 0, nullptr ) != 0 && lpMsgBuf) { retval = lpMsgBuf; LocalFree(lpMsgBuf); diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index 6548521..dfbbde2 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -278,7 +278,7 @@ namespace chaiscript bool char_in_alphabet(char c, detail::Alphabet a) const { return m_alphabet[a][static_cast(c)]; } /// Prints the parsed ast_nodes as a tree - void debug_print(AST_NodePtr t, std::string prepend = "") { + void debug_print(AST_NodePtr t, std::string prepend = "") const { std::cout << prepend << "(" << ast_node_type_to_string(t->identifier) << ") " << t->text << " : " << t->start().line << ", " << t->start().column << '\n'; for (unsigned int j = 0; j < t->children.size(); ++j) { debug_print(t->children[j], prepend + " "); diff --git a/src/main.cpp b/src/main.cpp index 372adf7..6fe1bc2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -66,7 +66,7 @@ std::vector default_search_paths() #ifdef CHAISCRIPT_WINDOWS // force no unicode CHAR path[4096]; - int size = GetModuleFileNameA(0, path, sizeof(path)-1); + int size = GetModuleFileNameA(nullptr, path, sizeof(path)-1); std::string exepath(path, size); @@ -344,17 +344,16 @@ int main(int argc, char *argv[]) mode = eFile; } - chaiscript::Boxed_Value val ; try { switch ( mode ) { case eInteractive: interactive(chai); break; case eCommand: - val = chai.eval(arg); + chai.eval(arg); break; case eFile: - val = chai.eval_file(arg); + chai.eval_file(arg); } } catch (const chaiscript::exception::eval_error &ee) { diff --git a/unittests/compiled_tests.cpp b/unittests/compiled_tests.cpp index 9a9a4a5..d4d429e 100644 --- a/unittests/compiled_tests.cpp +++ b/unittests/compiled_tests.cpp @@ -397,7 +397,7 @@ class Short_Comparison_Test { public: Short_Comparison_Test() : value_(5) {} - short get_value() { return value_; } + short get_value() const { return value_; } short value_; };