From dde7d27b96a8a1945db991d8afe1e71cb936596d Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 24 Apr 2015 21:35:56 -0600 Subject: [PATCH 1/2] A smaller make_shared derived types --- CMakeLists.txt | 9 +- include/chaiscript/chaiscript_defines.hpp | 14 +- .../dispatchkit/register_function.hpp | 10 +- .../dispatchkit/type_conversions.hpp | 11 +- .../chaiscript/language/chaiscript_common.hpp | 4 +- .../chaiscript/language/chaiscript_parser.hpp | 160 +++++++++--------- unittests/multithreaded_test.cpp | 2 +- 7 files changed, 114 insertions(+), 96 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb483c0..3108d94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,13 @@ endif() option(BUILD_MODULES "Build Extra Modules (stl)" TRUE) option(BUILD_SAMPLES "Build Samples Folder" FALSE) +option(USE_STD_MAKE_SHARED "Use std::make_shared instead of chaiscript::make_shared" FALSE) +mark_as_advanced(USE_STD_MAKE_SHARED) + +if(USE_STD_MAKE_SHARED) + add_definitions(-DCHAISCRIPT_USE_STD_MAKE_SHARED) +endif() if(CMAKE_COMPILER_IS_GNUCC) option(ENABLE_COVERAGE "Enable Coverage Reporting in GCC" FALSE) @@ -278,8 +284,6 @@ if(BUILD_TESTING) get_target_property(target_files ${executable} SOURCES) - message("Files: ${target_files}") - foreach(source ${target_files}) if(NOT "${source}" MATCHES "/moc_.*cxx") string(REGEX MATCH .*cpp source "${source}") @@ -287,7 +291,6 @@ if(BUILD_TESTING) file(READ "${source}" contents) string(REGEX MATCHALL "TEST_CASE\\([ ]*\"[^\"]+\"" found_tests ${contents}) foreach(hit ${found_tests}) - message("Found Test: ${hit}") string(REGEX REPLACE "TEST_CASE\\([ ]*(\"[^\"]+\").*" "\\1" test_name ${hit}) add_test(${test_name} "${executable}" ${test_name}) set_tests_properties(${test_name} PROPERTIES TIMEOUT 660 ENVIRONMENT "PATH=${NEWPATH}") diff --git a/include/chaiscript/chaiscript_defines.hpp b/include/chaiscript/chaiscript_defines.hpp index 09930c5..38952e5 100644 --- a/include/chaiscript/chaiscript_defines.hpp +++ b/include/chaiscript/chaiscript_defines.hpp @@ -52,11 +52,23 @@ #define CHAISCRIPT_CONSTEXPR constexpr #endif +#include + namespace chaiscript { static const int version_major = 5; static const int version_minor = 7; static const int version_patch = 0; -} + template + inline std::shared_ptr make_shared(Arg && ... arg) + { +#ifdef CHAISCRIPT_USE_STD_MAKE_SHARED + return std::make_shared(std::forward(arg)...); +#else + return std::shared_ptr(static_cast(new D(std::forward(arg)...))); +#endif + } + +} #endif diff --git a/include/chaiscript/dispatchkit/register_function.hpp b/include/chaiscript/dispatchkit/register_function.hpp index 8dd51f6..ccec354 100644 --- a/include/chaiscript/dispatchkit/register_function.hpp +++ b/include/chaiscript/dispatchkit/register_function.hpp @@ -90,28 +90,28 @@ namespace chaiscript Proxy_Function fun(const T &t) { return Proxy_Function( - static_cast(new dispatch::Proxy_Function_Impl::Signature>(dispatch::detail::to_function(t)))); + chaiscript::make_shared::Signature>>(dispatch::detail::to_function(t))); } template Proxy_Function fun(Ret (Class::*func)(Param...) const) { return Proxy_Function( - static_cast(new dispatch::Proxy_Function_Impl::Signature>(dispatch::detail::to_function(func)))); + chaiscript::make_shared::Signature>>(dispatch::detail::to_function(func))); } template Proxy_Function fun(Ret (Class::*func)(Param...)) { return Proxy_Function( - static_cast(new dispatch::Proxy_Function_Impl::Signature>(dispatch::detail::to_function(func)))); + chaiscript::make_shared::Signature>>(dispatch::detail::to_function(func))); } template::value>::type*/> Proxy_Function fun(T Class::* m /*, typename std::enable_if::value>::type* = 0*/ ) { - return Proxy_Function(new dispatch::Attribute_Access(m)); + return Proxy_Function(chaiscript::make_shared>(m)); } @@ -129,7 +129,7 @@ namespace chaiscript template Proxy_Function fun(const std::function &f) { - return Proxy_Function(static_cast(new dispatch::Proxy_Function_Impl(f))); + return Proxy_Function(chaiscript::make_shared>(f)); } diff --git a/include/chaiscript/dispatchkit/type_conversions.hpp b/include/chaiscript/dispatchkit/type_conversions.hpp index dc29efe..ee2184f 100644 --- a/include/chaiscript/dispatchkit/type_conversions.hpp +++ b/include/chaiscript/dispatchkit/type_conversions.hpp @@ -92,13 +92,14 @@ namespace chaiscript return m_from; } + virtual ~Type_Conversion_Base() {} + protected: Type_Conversion_Base(const Type_Info &t_to, const Type_Info &t_from) : m_to(t_to), m_from(t_from) { } - virtual ~Type_Conversion_Base() {} private: Type_Info m_to; @@ -415,14 +416,14 @@ namespace chaiscript static_assert(std::is_polymorphic::value, "Base class must be polymorphic"); static_assert(std::is_polymorphic::value, "Derived class must be polymorphic"); - return std::make_shared>(); + return chaiscript::make_shared>(); } template Type_Conversion type_conversion(const Type_Info &t_from, const Type_Info &t_to, const Callable &t_func) { - return std::make_shared>(t_from, t_to, t_func); + return chaiscript::make_shared>(t_from, t_to, t_func); } template @@ -433,7 +434,7 @@ namespace chaiscript return chaiscript::Boxed_Value(t_function(detail::Cast_Helper::cast(t_bv, nullptr))); }; - return std::make_shared>(user_type(), user_type(), func); + return chaiscript::make_shared>(user_type(), user_type(), func); } template @@ -445,7 +446,7 @@ namespace chaiscript return chaiscript::Boxed_Value(To(detail::Cast_Helper::cast(t_bv, nullptr))); }; - return std::make_shared>(user_type(), user_type(), func); + return chaiscript::make_shared>(user_type(), user_type(), func); } } diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index 82f3a52..7ea46f1 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -26,6 +26,7 @@ struct AST_Node; namespace chaiscript { + /// Signature of module entry point that all binary loadable modules must implement. typedef ModulePtr (*Create_Module_Func)(); @@ -466,6 +467,8 @@ namespace chaiscript std::replace(children.begin(), children.end(), t_child, t_new_child); } + virtual ~AST_Node() {} + protected: AST_Node(std::string t_ast_node_text, int t_id, const std::shared_ptr &t_fname, int t_start_line, int t_start_col, int t_end_line, int t_end_col) : @@ -477,7 +480,6 @@ namespace chaiscript AST_Node(std::string t_ast_node_text, int t_id, const std::shared_ptr &t_fname) : text(std::move(t_ast_node_text)), identifier(t_id), filename(t_fname) {} - virtual ~AST_Node() {} virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) const { diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index a7c48e9..e362fd3 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -228,7 +228,7 @@ namespace chaiscript for (const auto &count : counts) { // std::cout << " Fun Call Count: " << count.first << " " << count.second << '\n'; if (count.second > 1) { - children_to_add.push_back(std::make_shared(count.first)); + children_to_add.push_back(chaiscript::make_shared(count.first)); } } c->children.back()->children.insert(c->children.back()->children.begin(), children_to_add.begin(), children_to_add.end()); @@ -276,7 +276,7 @@ namespace chaiscript for (auto &c : p->children) { if (c->identifier == AST_Node_Type::Fun_Call && c->children.size() == 2 && c->children[1]->children.size() == 1) { - c = std::make_shared(dynamic_cast(*c)); + c = chaiscript::make_shared(dynamic_cast(*c)); // std::cout << "optimized unary fun call\n"; } optimize_fun_calls(c); @@ -697,7 +697,7 @@ namespace chaiscript if (has_more_input() && char_in_alphabet(*m_input_pos, detail::float_alphabet) ) { if (Hex_()) { std::string match(start, m_input_pos); - m_match_stack.emplace_back(std::make_shared(std::move(match), buildInt(std::hex, match), m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.emplace_back(chaiscript::make_shared(std::move(match), buildInt(std::hex, match), m_filename, prev_line, prev_col, m_line, m_col)); return true; } @@ -723,22 +723,22 @@ namespace chaiscript i = const_var(temp_int); } - m_match_stack.push_back(std::make_shared(std::move(match), std::move(i), m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(std::move(match), std::move(i), m_filename, prev_line, prev_col, m_line, m_col)); return true; } if (Float_()) { std::string match(start, m_input_pos); - m_match_stack.push_back(std::make_shared(std::move(match), buildFloat(match), m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(std::move(match), buildFloat(match), m_filename, prev_line, prev_col, m_line, m_col)); return true; } else { IntSuffix_(); std::string match(start, m_input_pos); if (!match.empty() && (match[0] == '0')) { - m_match_stack.push_back(std::make_shared(std::move(match), buildInt(std::oct, match), m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(std::move(match), buildInt(std::oct, match), m_filename, prev_line, prev_col, m_line, m_col)); } else { - m_match_stack.push_back(std::make_shared(std::move(match), buildInt(std::dec, match), m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(std::move(match), buildInt(std::dec, match), m_filename, prev_line, prev_col, m_line, m_col)); } return true; } @@ -799,7 +799,7 @@ namespace chaiscript const auto prev_col = m_col; const auto prev_line = m_line; if (Id_()) { - m_match_stack.push_back(std::make_shared( + m_match_stack.push_back(chaiscript::make_shared( [&]()->std::string{ if (*start == '`') { //Id Literal @@ -831,7 +831,7 @@ namespace chaiscript Id(true); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); return true; } @@ -858,7 +858,7 @@ namespace chaiscript } while (Symbol("#")); std::string match(start, m_input_pos); - m_match_stack.push_back(std::make_shared(std::move(match), m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(std::move(match), m_filename, prev_line, prev_col, m_line, m_col)); return true; } else { @@ -924,11 +924,11 @@ namespace chaiscript if (is_interpolated) { //If we've seen previous interpolation, add on instead of making a new one - m_match_stack.push_back(std::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); - build_match(std::make_shared("+"), prev_stack_top); + build_match(chaiscript::make_shared("+"), prev_stack_top); } else { - m_match_stack.push_back(std::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); } //We've finished with the part of the string up to this point, so clear it @@ -948,22 +948,22 @@ namespace chaiscript const auto tostr_stack_top = m_match_stack.size(); - m_match_stack.push_back(std::make_shared("to_string", m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared("to_string", m_filename, prev_line, prev_col, m_line, m_col)); const auto ev_stack_top = m_match_stack.size(); /// \todo can we evaluate this in place and save the runtime cost of evaluating with each execution of the node? - m_match_stack.push_back(std::make_shared("eval", m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared("eval", m_filename, prev_line, prev_col, m_line, m_col)); const auto arg_stack_top = m_match_stack.size(); - m_match_stack.push_back(std::make_shared(eval_match, m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(eval_match, m_filename, prev_line, prev_col, m_line, m_col)); - build_match(std::make_shared(), arg_stack_top); - build_match(std::make_shared(), ev_stack_top); - build_match(std::make_shared(), ev_stack_top); - build_match(std::make_shared(), tostr_stack_top); - build_match(std::make_shared("+"), prev_stack_top); + build_match(chaiscript::make_shared(), arg_stack_top); + build_match(chaiscript::make_shared(), ev_stack_top); + build_match(chaiscript::make_shared(), ev_stack_top); + build_match(chaiscript::make_shared(), tostr_stack_top); + build_match(chaiscript::make_shared("+"), prev_stack_top); } else { throw exception::eval_error("Unclosed in-string eval", File_Position(prev_line, prev_col), *m_filename); } @@ -1004,11 +1004,11 @@ namespace chaiscript } if (is_interpolated) { - m_match_stack.push_back(std::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); - build_match(std::make_shared("+"), prev_stack_top); + build_match(chaiscript::make_shared("+"), prev_stack_top); } else { - m_match_stack.push_back(std::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); } return true; } else { @@ -1087,7 +1087,7 @@ namespace chaiscript is_escaped = false; } } - m_match_stack.push_back(std::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); + m_match_stack.push_back(chaiscript::make_shared(match, m_filename, prev_line, prev_col, m_line, m_col)); return true; } else { @@ -1119,7 +1119,7 @@ namespace chaiscript const auto prev_line = m_line; if (Char_(t_c)) { m_match_stack.push_back( - std::make_shared(std::string(start, m_input_pos), m_filename, prev_line, prev_col, m_line, m_col)); + chaiscript::make_shared(std::string(start, m_input_pos), m_filename, prev_line, prev_col, m_line, m_col)); return true; } else { return false; @@ -1163,7 +1163,7 @@ namespace chaiscript } if ( t_capture && retval ) { - m_match_stack.push_back(std::make_shared( + m_match_stack.push_back(chaiscript::make_shared( std::string(start, m_input_pos), m_filename, prev_line, prev_col, m_line, m_col)); } return retval; @@ -1206,7 +1206,7 @@ namespace chaiscript } if ( t_capture && retval ) { - m_match_stack.push_back(std::make_shared( + m_match_stack.push_back(chaiscript::make_shared( std::string(start, m_input_pos), m_filename, prev_line, prev_col, m_line, m_col)); } @@ -1239,7 +1239,7 @@ namespace chaiscript const auto prev_col = m_col; const auto prev_line = m_line; if (Eol_()) { - m_match_stack.push_back(std::make_shared( + m_match_stack.push_back(chaiscript::make_shared( std::string(start, m_input_pos), m_filename, prev_line, prev_col, m_line, m_col)); return true; } else { @@ -1267,7 +1267,7 @@ namespace chaiscript } while (Char(',')); } } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); SkipWS(true); @@ -1293,7 +1293,7 @@ namespace chaiscript } while (Char(',')); } } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); SkipWS(true); @@ -1321,7 +1321,7 @@ namespace chaiscript } } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); SkipWS(true); @@ -1337,7 +1337,7 @@ namespace chaiscript if (Value_Range()) { retval = true; - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else if (Map_Pair()) { retval = true; while (Eol()) {} @@ -1349,7 +1349,7 @@ namespace chaiscript } } while (Char(',')); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else if (Operator()) { retval = true; while (Eol()) {} @@ -1361,7 +1361,7 @@ namespace chaiscript } } while (Char(',')); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } SkipWS(true); @@ -1385,7 +1385,7 @@ namespace chaiscript } } else { // make sure we always have the same number of nodes - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } if (Char('(')) { @@ -1404,7 +1404,7 @@ namespace chaiscript throw exception::eval_error("Incomplete anonymous function", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -1462,9 +1462,9 @@ namespace chaiscript } if (is_method || t_class_context) { - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else { - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } if (annotation) { @@ -1512,7 +1512,7 @@ namespace chaiscript if (!Block()) { throw exception::eval_error("Incomplete 'catch' block", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), catch_stack_top); + build_match(chaiscript::make_shared(), catch_stack_top); has_matches = true; } } @@ -1525,10 +1525,10 @@ namespace chaiscript if (!Block()) { throw exception::eval_error("Incomplete 'finally' block", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), finally_stack_top); + build_match(chaiscript::make_shared(), finally_stack_top); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -1564,7 +1564,7 @@ namespace chaiscript if (Keyword("else", true)) { if (Keyword("if")) { const AST_NodePtr back(m_match_stack.back()); - m_match_stack.back() = std::make_shared("else if"); + m_match_stack.back() = chaiscript::make_shared("else if"); m_match_stack.back()->start = back->start; m_match_stack.back()->end = back->end; m_match_stack.back()->children = back->children; @@ -1594,7 +1594,7 @@ namespace chaiscript } } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -1620,7 +1620,7 @@ namespace chaiscript throw exception::eval_error("Incomplete 'class' block", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -1650,7 +1650,7 @@ namespace chaiscript throw exception::eval_error("Incomplete 'while' block", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -1665,7 +1665,7 @@ namespace chaiscript { throw exception::eval_error("'for' loop initial statment missing", File_Position(m_line, m_col), *m_filename); } else { - m_match_stack.push_back(std::make_shared()); + m_match_stack.push_back(chaiscript::make_shared()); } } @@ -1675,13 +1675,13 @@ namespace chaiscript { throw exception::eval_error("'for' loop condition missing", File_Position(m_line, m_col), *m_filename); } else { - m_match_stack.push_back(std::make_shared()); + m_match_stack.push_back(chaiscript::make_shared()); } } if (!Equation()) { - m_match_stack.push_back(std::make_shared()); + m_match_stack.push_back(chaiscript::make_shared()); } return true; @@ -1712,7 +1712,7 @@ namespace chaiscript throw exception::eval_error("Incomplete 'for' block", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -1741,7 +1741,7 @@ namespace chaiscript throw exception::eval_error("Incomplete 'case' block", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else if (Keyword("default")) { while (Eol()) {} @@ -1749,7 +1749,7 @@ namespace chaiscript throw exception::eval_error("Incomplete 'default' block", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -1789,7 +1789,7 @@ namespace chaiscript throw exception::eval_error("Incomplete block", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); return true; } else { @@ -1814,10 +1814,10 @@ namespace chaiscript } if (m_match_stack.size() == prev_stack_top) { - m_match_stack.push_back(std::make_shared()); + m_match_stack.push_back(chaiscript::make_shared()); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -1838,10 +1838,10 @@ namespace chaiscript } if (m_match_stack.size() == prev_stack_top) { - m_match_stack.push_back(std::make_shared()); + m_match_stack.push_back(chaiscript::make_shared()); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -1853,7 +1853,7 @@ namespace chaiscript if (Keyword("return")) { Operator(); - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); return true; } else { return false; @@ -1865,7 +1865,7 @@ namespace chaiscript const auto prev_stack_top = m_match_stack.size(); if (Keyword("break")) { - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); return true; } else { return false; @@ -1877,7 +1877,7 @@ namespace chaiscript const auto prev_stack_top = m_match_stack.size(); if (Keyword("continue")) { - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); return true; } else { return false; @@ -1906,7 +1906,7 @@ namespace chaiscript throw exception::eval_error("Incomplete function call", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); /// \todo Work around for method calls until we have a better solution if (!m_match_stack.back()->children.empty()) { if (m_match_stack.back()->children[0]->identifier == AST_Node_Type::Dot_Access) { @@ -1927,7 +1927,7 @@ namespace chaiscript throw exception::eval_error("Incomplete array access", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else if (Symbol(".", true)) { has_more = true; @@ -1935,7 +1935,7 @@ namespace chaiscript throw exception::eval_error("Incomplete array access", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } } } @@ -1956,7 +1956,7 @@ namespace chaiscript throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else if (Keyword("auto") || Keyword("var")) { retval = true; @@ -1964,7 +1964,7 @@ namespace chaiscript throw exception::eval_error("Incomplete variable declaration", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else if (Keyword("attr")) { retval = true; @@ -1979,7 +1979,7 @@ namespace chaiscript } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return retval; @@ -2012,17 +2012,17 @@ namespace chaiscript } if ((prev_stack_top != m_match_stack.size()) && (m_match_stack.back()->children.size() > 0)) { if (m_match_stack.back()->children[0]->identifier == AST_Node_Type::Value_Range) { - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else if (m_match_stack.back()->children[0]->identifier == AST_Node_Type::Map_Pair) { - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else { - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } } else { - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } return true; @@ -2040,7 +2040,7 @@ namespace chaiscript throw exception::eval_error("Incomplete '&' expression", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); return true; } else { return false; @@ -2061,7 +2061,7 @@ namespace chaiscript throw exception::eval_error("Incomplete prefix '" + oper + "' expression", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(Operators::to_operator(oper, true)), prev_stack_top); + build_match(chaiscript::make_shared(Operators::to_operator(oper, true)), prev_stack_top); return true; } } @@ -2115,7 +2115,7 @@ namespace chaiscript + std::string(ast_node_type_to_string(m_operators[t_precedence])) + " expression", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else { throw exception::eval_error("Incomplete " @@ -2134,14 +2134,14 @@ namespace chaiscript case(AST_Node_Type::Comparison) : assert(m_match_stack.size() > 1); m_match_stack.erase(m_match_stack.begin() + m_match_stack.size() - 2, m_match_stack.begin() + m_match_stack.size() - 1); - build_match(std::make_shared(oper->text), prev_stack_top); + build_match(chaiscript::make_shared(oper->text), prev_stack_top); break; case(AST_Node_Type::Logical_And) : - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); break; case(AST_Node_Type::Logical_Or) : - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); break; default: @@ -2173,7 +2173,7 @@ namespace chaiscript throw exception::eval_error("Incomplete map pair", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else { m_input_pos = prev_pos; @@ -2202,7 +2202,7 @@ namespace chaiscript throw exception::eval_error("Incomplete value range", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } else { m_input_pos = prev_pos; @@ -2233,7 +2233,7 @@ namespace chaiscript throw exception::eval_error("Incomplete equation", File_Position(m_line, m_col), *m_filename); } - build_match(std::make_shared(), prev_stack_top); + build_match(chaiscript::make_shared(), prev_stack_top); } } @@ -2327,7 +2327,7 @@ namespace chaiscript if (m_input_pos != m_input_end) { throw exception::eval_error("Unparsed input", File_Position(m_line, m_col), t_fname); } else { - build_match(std::make_shared(), 0); + build_match(chaiscript::make_shared(), 0); return true; } } else { diff --git a/unittests/multithreaded_test.cpp b/unittests/multithreaded_test.cpp index 9b4d6a5..2ca2d65 100644 --- a/unittests/multithreaded_test.cpp +++ b/unittests/multithreaded_test.cpp @@ -25,7 +25,7 @@ void do_work(chaiscript::ChaiScript &c, int id) ss.str(""); ss << id; c.use("multithreaded_work.inc"); - c("do_chai_work(4000, " + ss.str() + ");"); + c("do_chai_work(40000, " + ss.str() + ");"); } catch (const std::exception &e) { std::cout << "exception: " << e.what() << " thread: " << id; } From 50e0ce36be11921c66956b9cdf1eb4454fa641e6 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 27 Apr 2015 14:12:23 -0600 Subject: [PATCH 2/2] Clean up missing include --- include/chaiscript/dispatchkit/type_info.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index 7fb3036..de61ab6 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace chaiscript {