From c9312c0b7a751065c451a2cfcda729e0003f6003 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 29 May 2015 19:59:25 -0600 Subject: [PATCH 01/27] Enable coverity scan? hopefully --- .travis.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 210e29e..eb3d0ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,20 @@ notifications: on_start: false # default: false env: global: - secure: eiaR6pXiiEpyB8+LLQ1NvZdl0Yylru1BLy9lMoHl+IpUNGGQGywmW/2WAn77rFfmR1OPA2qWQLfgPwgK0HxUA9HHlot9tre5QhiN2Lw8NOT8tCZ6tTm2+QntDBjBGJyal/knRvQkn/6qs6GxlXRerz4ArnnuPL1vESt3zwB0YtU= + - secure: eiaR6pXiiEpyB8+LLQ1NvZdl0Yylru1BLy9lMoHl+IpUNGGQGywmW/2WAn77rFfmR1OPA2qWQLfgPwgK0HxUA9HHlot9tre5QhiN2Lw8NOT8tCZ6tTm2+QntDBjBGJyal/knRvQkn/6qs6GxlXRerz4ArnnuPL1vESt3zwB0YtU= + # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created + # via the "travis encrypt" command using the project repo's public key + - secure: "LfolGjP8tWm3yAwthfu3yp8Zn40aueFae580UUR34gusG87cyglq2tQDtxdy+63gWEeNfArbv9n5rZv+bDW3ggHyPjuCKKc1PlZAy07lfXUXf1uz+SFhNvNoYTn3mQG3VZ08o116p4Le2p8yqu4bylJ8wckEq7PrTwvSGVQWTWM=" + + +addons: + coverity_scan: + project: + name: "ChaiScript/ChaiScript" + description: "Build submitted via Travis CI" + notification_email: jason@emptycrate.com + build_command_prepend: "cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; make clean" + build_command: "make -j2" + branch_pattern: coverity_scan From 8ed4e6fad8c84c413ea50b9a3d7aba239241ed8f Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 29 May 2015 20:17:13 -0600 Subject: [PATCH 02/27] Fix coverity settings? --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb3d0ab..1f30e3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,9 +42,9 @@ addons: project: name: "ChaiScript/ChaiScript" description: "Build submitted via Travis CI" - notification_email: jason@emptycrate.com - build_command_prepend: "cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; make clean" - build_command: "make -j2" - branch_pattern: coverity_scan + notification_email: jason@emptycrate.com + build_command_prepend: "cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; make clean" + build_command: "make -j2" + branch_pattern: coverity_scan From f54bd484e6a1619ada0cbd6870bc7272c24f4710 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 29 May 2015 20:31:07 -0600 Subject: [PATCH 03/27] Attempt to fix build matrix and coverity --- .travis.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f30e3f..867351c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,20 @@ compiler: env: - GCC_VER=4.6 - GCC_VER=4.8 + + + global: + - secure: eiaR6pXiiEpyB8+LLQ1NvZdl0Yylru1BLy9lMoHl+IpUNGGQGywmW/2WAn77rFfmR1OPA2qWQLfgPwgK0HxUA9HHlot9tre5QhiN2Lw8NOT8tCZ6tTm2+QntDBjBGJyal/knRvQkn/6qs6GxlXRerz4ArnnuPL1vESt3zwB0YtU= + # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created + # via the "travis encrypt" command using the project repo's public key + - secure: "LfolGjP8tWm3yAwthfu3yp8Zn40aueFae580UUR34gusG87cyglq2tQDtxdy+63gWEeNfArbv9n5rZv+bDW3ggHyPjuCKKc1PlZAy07lfXUXf1uz+SFhNvNoYTn3mQG3VZ08o116p4Le2p8yqu4bylJ8wckEq7PrTwvSGVQWTWM=" + before_install: - sudo pip install cpp-coveralls - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - sudo apt-get install -qq g++-4.8 - - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"; else export CXX="g++-4.6" CC="gcc-4.6" GCOV="gcov-4.6"; fi + - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"; fi script: - cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . - make -j2 @@ -29,13 +37,6 @@ notifications: on_success: change # options: [always|never|change] default: always on_failure: always # options: [always|never|change] default: always on_start: false # default: false -env: - global: - - secure: eiaR6pXiiEpyB8+LLQ1NvZdl0Yylru1BLy9lMoHl+IpUNGGQGywmW/2WAn77rFfmR1OPA2qWQLfgPwgK0HxUA9HHlot9tre5QhiN2Lw8NOT8tCZ6tTm2+QntDBjBGJyal/knRvQkn/6qs6GxlXRerz4ArnnuPL1vESt3zwB0YtU= - # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created - # via the "travis encrypt" command using the project repo's public key - - secure: "LfolGjP8tWm3yAwthfu3yp8Zn40aueFae580UUR34gusG87cyglq2tQDtxdy+63gWEeNfArbv9n5rZv+bDW3ggHyPjuCKKc1PlZAy07lfXUXf1uz+SFhNvNoYTn3mQG3VZ08o116p4Le2p8yqu4bylJ8wckEq7PrTwvSGVQWTWM=" - addons: coverity_scan: From a04fe9d5a51310bba9e19556a3241c85eb26112b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 29 May 2015 22:19:59 -0600 Subject: [PATCH 04/27] Fix env variables layout? --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 867351c..6725e11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,9 @@ language: cpp compiler: - gcc env: - - GCC_VER=4.6 - - GCC_VER=4.8 + matrix: + - GCC_VER=4.6 + - GCC_VER=4.8 global: From f274d6beb38dcb60a632014f0015103e9b4e3370 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 29 May 2015 22:31:27 -0600 Subject: [PATCH 05/27] Another attempt at coverity --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6725e11..0da8ba3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ addons: name: "ChaiScript/ChaiScript" description: "Build submitted via Travis CI" notification_email: jason@emptycrate.com - build_command_prepend: "cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; make clean" + build_command_prepend: "cmake . ; make clean" build_command: "make -j2" branch_pattern: coverity_scan From 1a02903b99e906b5c2c0825bebd207c46b46690b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 29 May 2015 22:47:53 -0600 Subject: [PATCH 06/27] Another attempt with coverity support, add debugging --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0da8ba3..bec8b8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,8 +18,9 @@ before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - sudo apt-get install -qq g++-4.8 - - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"; fi + - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"; else export GCOV="gcov"; fi script: + - cat cov-int/build-log.txt - cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . - make -j2 - make test @@ -46,7 +47,7 @@ addons: description: "Build submitted via Travis CI" notification_email: jason@emptycrate.com build_command_prepend: "cmake . ; make clean" - build_command: "make -j2" + build_command: "make -j2 VERBOSE=1" branch_pattern: coverity_scan From cfc67f619a80633e0753caa365780c4d26a4c5b5 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 29 May 2015 23:08:27 -0600 Subject: [PATCH 07/27] Travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bec8b8b..8df43b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,8 +46,8 @@ addons: name: "ChaiScript/ChaiScript" description: "Build submitted via Travis CI" notification_email: jason@emptycrate.com - build_command_prepend: "cmake . ; make clean" - build_command: "make -j2 VERBOSE=1" + build_command_prepend: "cmake ." + build_command: "cmake --build ." branch_pattern: coverity_scan From 70326a5dfffeb1f1cb2457a14ed1545d4eff33ff Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 06:32:14 -0600 Subject: [PATCH 08/27] Try to distill travis / coverity settings --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8df43b5..91866bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,15 +18,15 @@ before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - sudo apt-get install -qq g++-4.8 - - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"; else export GCOV="gcov"; fi + - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8" COVERALLS="1" CPPCHECK="1"; else export GCOV="gcov"; fi script: - - cat cov-int/build-log.txt - - cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . - - make -j2 - - make test - - coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV + - if [ ${COVERITY_SCAN_BRANCH} = 1 ]; then cat cov-int/build-log.txt; fi + - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi + - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make -j2 ; fi + - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make test ; fi + - if [ ${COVERITY_SCAN_BRANCH} != 1 && ${COVERALLS} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi after_script: - - contrib/codeanalysis/runcppcheck.sh + - if [ ${COVERITY_SCAN_BRANCH} != 1 && ${COVERALLS} = 1 ]; then contrib/codeanalysis/runcppcheck.sh ; fi notifications: email: recipients: @@ -47,7 +47,7 @@ addons: description: "Build submitted via Travis CI" notification_email: jason@emptycrate.com build_command_prepend: "cmake ." - build_command: "cmake --build ." + build_command: "cmake --build . --target chai" branch_pattern: coverity_scan From bb0d1005138e53cb2d414401f0338f22fbbc636b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 07:33:34 -0600 Subject: [PATCH 09/27] Work around coverity crash I'm not 100% convinced on these changes, but they might be for the better. --- .../chaiscript/dispatchkit/dispatchkit.hpp | 9 ++- .../dispatchkit/type_conversions.hpp | 13 +-- include/chaiscript/dispatchkit/type_info.hpp | 79 ++++++++++--------- 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index 5e7d18d..be4d8a7 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -1175,8 +1175,13 @@ namespace chaiscript const auto lhssize = lhsparamtypes.size(); const auto rhssize = rhsparamtypes.size(); - CHAISCRIPT_CONSTEXPR auto boxed_type = user_type(); - CHAISCRIPT_CONSTEXPR auto boxed_pod_type = user_type(); +#ifdef CHAISCRIPT_HAS_MAGIC_STATICS + auto boxed_type = user_type(); + auto boxed_pod_type = user_type(); +#else + static auto boxed_type = user_type(); + static auto boxed_pod_type = user_type(); +#endif for (size_t i = 1; i < lhssize && i < rhssize; ++i) { diff --git a/include/chaiscript/dispatchkit/type_conversions.hpp b/include/chaiscript/dispatchkit/type_conversions.hpp index a5abed4..a08addd 100644 --- a/include/chaiscript/dispatchkit/type_conversions.hpp +++ b/include/chaiscript/dispatchkit/type_conversions.hpp @@ -300,13 +300,6 @@ namespace chaiscript class Type_Conversions { public: - struct Less_Than - { - bool operator()(const std::type_info *t_lhs, const std::type_info *t_rhs) const - { - return *t_lhs != *t_rhs && t_lhs->before(*t_rhs); - } - }; Type_Conversions() : m_mutex(), @@ -329,7 +322,7 @@ namespace chaiscript { } - const std::set &thread_cache() const + const std::set &thread_cache() const { auto &cache = *m_thread_cache; if (cache.size() != m_num_types) @@ -466,9 +459,9 @@ namespace chaiscript mutable chaiscript::detail::threading::shared_mutex m_mutex; std::set> m_conversions; - std::set m_convertableTypes; + std::set m_convertableTypes; std::atomic_size_t m_num_types; - mutable chaiscript::detail::threading::Thread_Storage> m_thread_cache; + mutable chaiscript::detail::threading::Thread_Storage> m_thread_cache; mutable chaiscript::detail::threading::Thread_Storage m_conversion_saves; }; diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index de61ab6..0bee9c6 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace chaiscript @@ -28,9 +29,12 @@ namespace chaiscript /// \brief Compile time deduced information about a type class Type_Info { + private: + class Undef {}; + 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_bare_ti) + 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_index &t_ti, const std::type_index &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), @@ -38,8 +42,8 @@ namespace chaiscript { } - CHAISCRIPT_CONSTEXPR Type_Info() - : m_type_info(nullptr), m_bare_type_info(nullptr), + Type_Info() + : m_type_info(typeid(Type_Info::Undef)), m_bare_type_info(typeid(Type_Info::Undef)), m_is_const(false), m_is_reference(false), m_is_pointer(false), m_is_void(false), m_is_arithmetic(false), m_is_undef(true) @@ -55,46 +59,43 @@ namespace chaiscript Type_Info& operator=(const Type_Info&) = default; - CHAISCRIPT_CONSTEXPR bool operator<(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT + bool operator<(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { return m_type_info < ti.m_type_info; } - CHAISCRIPT_CONSTEXPR bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT + bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { - return ti.m_type_info == m_type_info - || (ti.m_type_info && m_type_info && *ti.m_type_info == *m_type_info); + return ti.m_type_info == m_type_info; } - CHAISCRIPT_CONSTEXPR bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT + bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { - return m_type_info != nullptr && (*m_type_info) == ti; + return m_type_info == ti; } - CHAISCRIPT_CONSTEXPR bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT + bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { - return ti.m_bare_type_info == m_bare_type_info - || (ti.m_bare_type_info && m_bare_type_info && *ti.m_bare_type_info == *m_bare_type_info); + return ti.m_bare_type_info == m_bare_type_info; } - CHAISCRIPT_CONSTEXPR bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT + bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { - return m_bare_type_info != nullptr - && (*m_bare_type_info) == ti; + return m_bare_type_info == ti; } - CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return m_is_const; } - CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return m_is_reference; } - CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return m_is_void; } - CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return m_is_arithmetic; } - CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_is_undef || m_bare_type_info == nullptr; } - CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return m_is_pointer; } + bool is_const() const CHAISCRIPT_NOEXCEPT { return m_is_const; } + bool is_reference() const CHAISCRIPT_NOEXCEPT { return m_is_reference; } + bool is_void() const CHAISCRIPT_NOEXCEPT { return m_is_void; } + bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return m_is_arithmetic; } + bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_is_undef; } + bool is_pointer() const CHAISCRIPT_NOEXCEPT { return m_is_pointer; } std::string name() const { - if (m_type_info) + if (m_is_undef) { - return m_type_info->name(); + return m_type_info.name(); } else { return ""; } @@ -102,22 +103,22 @@ namespace chaiscript std::string bare_name() const { - if (m_bare_type_info) + if (m_is_undef) { - return m_bare_type_info->name(); + return m_bare_type_info.name(); } else { return ""; } } - CHAISCRIPT_CONSTEXPR const std::type_info *bare_type_info() const + const std::type_index &bare_type_info() const { return m_bare_type_info; } private: - const std::type_info *m_type_info; - const std::type_info *m_bare_type_info; + std::type_index m_type_info; + std::type_index m_bare_type_info; bool m_is_const; bool m_is_reference; bool m_is_pointer; @@ -139,8 +140,8 @@ namespace chaiscript return Type_Info(std::is_const::type>::type>::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - &typeid(T), - &typeid(typename Bare_Type::type)); + typeid(T), + typeid(typename Bare_Type::type)); } }; @@ -154,8 +155,8 @@ namespace chaiscript return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - &typeid(std::shared_ptr ), - &typeid(typename Bare_Type::type)); + typeid(std::shared_ptr ), + typeid(typename Bare_Type::type)); } }; @@ -169,8 +170,8 @@ namespace chaiscript return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - &typeid(const std::shared_ptr &), - &typeid(typename Bare_Type::type)); + typeid(const std::shared_ptr &), + typeid(typename Bare_Type::type)); } }; @@ -184,8 +185,8 @@ namespace chaiscript return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - &typeid(std::reference_wrapper ), - &typeid(typename Bare_Type::type)); + typeid(std::reference_wrapper ), + typeid(typename Bare_Type::type)); } }; @@ -199,8 +200,8 @@ namespace chaiscript return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - &typeid(const std::reference_wrapper &), - &typeid(typename Bare_Type::type)); + typeid(const std::reference_wrapper &), + typeid(typename Bare_Type::type)); } }; From aa60cffe852b02823f128b87368920aa8e8c8490 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 13:34:34 -0600 Subject: [PATCH 10/27] Add g++5.1 cleanup coverity use --- .travis.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91866bf..b3ba313 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ compiler: - gcc env: matrix: - - GCC_VER=4.6 - - GCC_VER=4.8 - + - CXX="g++-4.6" CC="gcc-4.6" GCOV="gcov-4.6" + - CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8" + - CXX="g++-5.1" CC="gcc-5.1" GCOV="gcov-5.1" COVERALLS=1 CPPCHECK=1 global: - secure: eiaR6pXiiEpyB8+LLQ1NvZdl0Yylru1BLy9lMoHl+IpUNGGQGywmW/2WAn77rFfmR1OPA2qWQLfgPwgK0HxUA9HHlot9tre5QhiN2Lw8NOT8tCZ6tTm2+QntDBjBGJyal/knRvQkn/6qs6GxlXRerz4ArnnuPL1vESt3zwB0YtU= @@ -17,16 +17,18 @@ before_install: - sudo pip install cpp-coveralls - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - sudo apt-get install -qq g++-4.8 - - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8" COVERALLS="1" CPPCHECK="1"; else export GCOV="gcov"; fi + - if [ "$CXX" = "g++-4.8" ]; then sudo apt-get install -qq g++-4.8; fi + - if [ "$CXX" = "g++-5.1" ]; then sudo apt-get install -qq g++-5.1; fi + script: - - if [ ${COVERITY_SCAN_BRANCH} = 1 ]; then cat cov-int/build-log.txt; fi - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make -j2 ; fi - - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make test ; fi - - if [ ${COVERITY_SCAN_BRANCH} != 1 && ${COVERALLS} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi + - make test + - if [ ${COVERALLS} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi + after_script: - - if [ ${COVERITY_SCAN_BRANCH} != 1 && ${COVERALLS} = 1 ]; then contrib/codeanalysis/runcppcheck.sh ; fi + - if [ ${CPPCHECK} = 1 ]; then contrib/codeanalysis/runcppcheck.sh ; fi + notifications: email: recipients: @@ -46,7 +48,7 @@ addons: name: "ChaiScript/ChaiScript" description: "Build submitted via Travis CI" notification_email: jason@emptycrate.com - build_command_prepend: "cmake ." + build_command_prepend: "cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . " build_command: "cmake --build . --target chai" branch_pattern: coverity_scan From ee672f5132c2404731a7045103375242ed00ec1b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 13:43:49 -0600 Subject: [PATCH 11/27] Further travis / coverity cleanups --- .travis.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b3ba313..1fdaf71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ compiler: - gcc env: matrix: - - CXX="g++-4.6" CC="gcc-4.6" GCOV="gcov-4.6" - - CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8" - - CXX="g++-5.1" CC="gcc-5.1" GCOV="gcov-5.1" COVERALLS=1 CPPCHECK=1 + - GCC_VER="4.8" + - GCC_VER="4.6" + - GCC_VER="5.1" global: - secure: eiaR6pXiiEpyB8+LLQ1NvZdl0Yylru1BLy9lMoHl+IpUNGGQGywmW/2WAn77rFfmR1OPA2qWQLfgPwgK0HxUA9HHlot9tre5QhiN2Lw8NOT8tCZ6tTm2+QntDBjBGJyal/knRvQkn/6qs6GxlXRerz4ArnnuPL1vESt3zwB0YtU= @@ -14,11 +14,14 @@ env: - secure: "LfolGjP8tWm3yAwthfu3yp8Zn40aueFae580UUR34gusG87cyglq2tQDtxdy+63gWEeNfArbv9n5rZv+bDW3ggHyPjuCKKc1PlZAy07lfXUXf1uz+SFhNvNoYTn3mQG3VZ08o116p4Le2p8yqu4bylJ8wckEq7PrTwvSGVQWTWM=" before_install: + - if [ "$GCC_VER" = "4.6" ]; export CXX="g++-4.6" CC="gcc-4.6" GCOV="gcov-4.6"; fi + - if [ "$GCC_VER" = "4.8" ]; export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"; fi + - if [ "$GCC_VER" = "5.1" ]; export CXX="g++-5.1" CC="gcc-5.1" GCOV="gcov-5.1" COVERALLS=1 CPPCHECK=1; fi - sudo pip install cpp-coveralls - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - if [ "$CXX" = "g++-4.8" ]; then sudo apt-get install -qq g++-4.8; fi - - if [ "$CXX" = "g++-5.1" ]; then sudo apt-get install -qq g++-5.1; fi + - if [ "$GCC_VER" = "4.8" ]; then sudo apt-get install -qq g++-4.8; fi + - if [ "$GCC_VER" = "5.1" ]; then sudo apt-get install -qq g++-5.1; fi script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi @@ -49,7 +52,7 @@ addons: description: "Build submitted via Travis CI" notification_email: jason@emptycrate.com build_command_prepend: "cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . " - build_command: "cmake --build . --target chai" + build_command: "cmake --build . -- -j2" branch_pattern: coverity_scan From 114e3939f69bbff1b77d5f8992a204d843489775 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 13:55:34 -0600 Subject: [PATCH 12/27] Fix shell if command in travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1fdaf71..cdd8245 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,9 @@ env: - secure: "LfolGjP8tWm3yAwthfu3yp8Zn40aueFae580UUR34gusG87cyglq2tQDtxdy+63gWEeNfArbv9n5rZv+bDW3ggHyPjuCKKc1PlZAy07lfXUXf1uz+SFhNvNoYTn3mQG3VZ08o116p4Le2p8yqu4bylJ8wckEq7PrTwvSGVQWTWM=" before_install: - - if [ "$GCC_VER" = "4.6" ]; export CXX="g++-4.6" CC="gcc-4.6" GCOV="gcov-4.6"; fi - - if [ "$GCC_VER" = "4.8" ]; export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"; fi - - if [ "$GCC_VER" = "5.1" ]; export CXX="g++-5.1" CC="gcc-5.1" GCOV="gcov-5.1" COVERALLS=1 CPPCHECK=1; fi + - if [ "$GCC_VER" = "4.6" ]; then export CXX="g++-4.6" CC="gcc-4.6" GCOV="gcov-4.6"; fi + - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"; fi + - if [ "$GCC_VER" = "5.1" ]; then export CXX="g++-5.1" CC="gcc-5.1" GCOV="gcov-5.1" COVERALLS=1 CPPCHECK=1; fi - sudo pip install cpp-coveralls - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update From d2f855e3f9ac119b94206f11063f23a5254a3a79 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 14:07:29 -0600 Subject: [PATCH 13/27] Cleanup g++-5 support for travis --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index cdd8245..2f8a07d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ compiler: - gcc env: matrix: - - GCC_VER="4.8" - GCC_VER="4.6" - - GCC_VER="5.1" + - GCC_VER="4.8" + - GCC_VER="5" global: - secure: eiaR6pXiiEpyB8+LLQ1NvZdl0Yylru1BLy9lMoHl+IpUNGGQGywmW/2WAn77rFfmR1OPA2qWQLfgPwgK0HxUA9HHlot9tre5QhiN2Lw8NOT8tCZ6tTm2+QntDBjBGJyal/knRvQkn/6qs6GxlXRerz4ArnnuPL1vESt3zwB0YtU= @@ -15,13 +15,13 @@ env: before_install: - if [ "$GCC_VER" = "4.6" ]; then export CXX="g++-4.6" CC="gcc-4.6" GCOV="gcov-4.6"; fi - - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"; fi - - if [ "$GCC_VER" = "5.1" ]; then export CXX="g++-5.1" CC="gcc-5.1" GCOV="gcov-5.1" COVERALLS=1 CPPCHECK=1; fi + - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8" COVERALLS=1 CPPCHECK=1; fi + - if [ "$GCC_VER" = "5" ]; then export CXX="g++-5" CC="gcc-5" GCOV="gcov-5"; fi - sudo pip install cpp-coveralls - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - if [ "$GCC_VER" = "4.8" ]; then sudo apt-get install -qq g++-4.8; fi - - if [ "$GCC_VER" = "5.1" ]; then sudo apt-get install -qq g++-5.1; fi + - if [ "$GCC_VER" = "5" ]; then sudo apt-get install -qq g++-5; fi script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi From ac280a69712c83bbc0583997f19a16e8ba062d9b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 14:14:48 -0600 Subject: [PATCH 14/27] Fix name() lookups --- include/chaiscript/dispatchkit/type_info.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index 0bee9c6..e92fe23 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -93,7 +93,7 @@ namespace chaiscript std::string name() const { - if (m_is_undef) + if (!m_is_undef) { return m_type_info.name(); } else { @@ -103,7 +103,7 @@ namespace chaiscript std::string bare_name() const { - if (m_is_undef) + if (!m_is_undef) { return m_bare_type_info.name(); } else { From 4b577f1f2ac0fa89b6d71031ade1f1484bf1e46f Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 15:15:08 -0600 Subject: [PATCH 15/27] Undefined types are never equal --- include/chaiscript/dispatchkit/type_info.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index e92fe23..a15c245 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -71,7 +71,8 @@ namespace chaiscript bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { - return m_type_info == ti; + return !m_is_undef + && m_type_info == ti; } bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT @@ -81,7 +82,8 @@ namespace chaiscript bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { - return m_bare_type_info == ti; + return !m_is_undef + && m_bare_type_info == ti; } bool is_const() const CHAISCRIPT_NOEXCEPT { return m_is_const; } From 023a3edf40ff5405ac47df55415d2a5b01b0f801 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 15:36:25 -0600 Subject: [PATCH 16/27] Fix static usage of Type_Info objects --- include/chaiscript/dispatchkit/dispatchkit.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index be4d8a7..02822b1 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -1176,11 +1176,11 @@ namespace chaiscript const auto rhssize = rhsparamtypes.size(); #ifdef CHAISCRIPT_HAS_MAGIC_STATICS - auto boxed_type = user_type(); - auto boxed_pod_type = user_type(); -#else static auto boxed_type = user_type(); static auto boxed_pod_type = user_type(); +#else + auto boxed_type = user_type(); + auto boxed_pod_type = user_type(); #endif for (size_t i = 1; i < lhssize && i < rhssize; ++i) From 61d5e2ad85c2d81a74bc2dc94d0a52e917eb5477 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 15:47:22 -0600 Subject: [PATCH 17/27] Revert "Work around coverity crash" This reverts commit bb0d1005138e53cb2d414401f0338f22fbbc636b. Conflicts: include/chaiscript/dispatchkit/dispatchkit.hpp include/chaiscript/dispatchkit/type_info.hpp --- .../dispatchkit/type_conversions.hpp | 13 ++- include/chaiscript/dispatchkit/type_info.hpp | 81 +++++++++---------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/include/chaiscript/dispatchkit/type_conversions.hpp b/include/chaiscript/dispatchkit/type_conversions.hpp index a08addd..a5abed4 100644 --- a/include/chaiscript/dispatchkit/type_conversions.hpp +++ b/include/chaiscript/dispatchkit/type_conversions.hpp @@ -300,6 +300,13 @@ namespace chaiscript class Type_Conversions { public: + struct Less_Than + { + bool operator()(const std::type_info *t_lhs, const std::type_info *t_rhs) const + { + return *t_lhs != *t_rhs && t_lhs->before(*t_rhs); + } + }; Type_Conversions() : m_mutex(), @@ -322,7 +329,7 @@ namespace chaiscript { } - const std::set &thread_cache() const + const std::set &thread_cache() const { auto &cache = *m_thread_cache; if (cache.size() != m_num_types) @@ -459,9 +466,9 @@ namespace chaiscript mutable chaiscript::detail::threading::shared_mutex m_mutex; std::set> m_conversions; - std::set m_convertableTypes; + std::set m_convertableTypes; std::atomic_size_t m_num_types; - mutable chaiscript::detail::threading::Thread_Storage> m_thread_cache; + mutable chaiscript::detail::threading::Thread_Storage> m_thread_cache; mutable chaiscript::detail::threading::Thread_Storage m_conversion_saves; }; diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index a15c245..de61ab6 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include namespace chaiscript @@ -29,12 +28,9 @@ namespace chaiscript /// \brief Compile time deduced information about a type class Type_Info { - private: - class Undef {}; - public: - 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_index &t_ti, const std::type_index &t_bare_ti) + 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_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), @@ -42,8 +38,8 @@ namespace chaiscript { } - Type_Info() - : m_type_info(typeid(Type_Info::Undef)), m_bare_type_info(typeid(Type_Info::Undef)), + CHAISCRIPT_CONSTEXPR Type_Info() + : m_type_info(nullptr), m_bare_type_info(nullptr), m_is_const(false), m_is_reference(false), m_is_pointer(false), m_is_void(false), m_is_arithmetic(false), m_is_undef(true) @@ -59,45 +55,46 @@ namespace chaiscript Type_Info& operator=(const Type_Info&) = default; - bool operator<(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT + CHAISCRIPT_CONSTEXPR bool operator<(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { return m_type_info < ti.m_type_info; } - bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT + CHAISCRIPT_CONSTEXPR bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { - return ti.m_type_info == m_type_info; + return ti.m_type_info == m_type_info + || (ti.m_type_info && m_type_info && *ti.m_type_info == *m_type_info); } - bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT + CHAISCRIPT_CONSTEXPR bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { - return !m_is_undef - && m_type_info == ti; + return m_type_info != nullptr && (*m_type_info) == ti; } - bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT + CHAISCRIPT_CONSTEXPR bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { - return ti.m_bare_type_info == m_bare_type_info; + return ti.m_bare_type_info == m_bare_type_info + || (ti.m_bare_type_info && m_bare_type_info && *ti.m_bare_type_info == *m_bare_type_info); } - bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT + CHAISCRIPT_CONSTEXPR bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { - return !m_is_undef - && m_bare_type_info == ti; + return m_bare_type_info != nullptr + && (*m_bare_type_info) == ti; } - bool is_const() const CHAISCRIPT_NOEXCEPT { return m_is_const; } - bool is_reference() const CHAISCRIPT_NOEXCEPT { return m_is_reference; } - bool is_void() const CHAISCRIPT_NOEXCEPT { return m_is_void; } - bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return m_is_arithmetic; } - bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_is_undef; } - bool is_pointer() const CHAISCRIPT_NOEXCEPT { return m_is_pointer; } + CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return m_is_const; } + CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return m_is_reference; } + CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return m_is_void; } + CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return m_is_arithmetic; } + CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_is_undef || m_bare_type_info == nullptr; } + CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return m_is_pointer; } std::string name() const { - if (!m_is_undef) + if (m_type_info) { - return m_type_info.name(); + return m_type_info->name(); } else { return ""; } @@ -105,22 +102,22 @@ namespace chaiscript std::string bare_name() const { - if (!m_is_undef) + if (m_bare_type_info) { - return m_bare_type_info.name(); + return m_bare_type_info->name(); } else { return ""; } } - const std::type_index &bare_type_info() const + CHAISCRIPT_CONSTEXPR const std::type_info *bare_type_info() const { return m_bare_type_info; } private: - std::type_index m_type_info; - std::type_index m_bare_type_info; + const std::type_info *m_type_info; + const std::type_info *m_bare_type_info; bool m_is_const; bool m_is_reference; bool m_is_pointer; @@ -142,8 +139,8 @@ namespace chaiscript return Type_Info(std::is_const::type>::type>::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - typeid(T), - typeid(typename Bare_Type::type)); + &typeid(T), + &typeid(typename Bare_Type::type)); } }; @@ -157,8 +154,8 @@ namespace chaiscript return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - typeid(std::shared_ptr ), - typeid(typename Bare_Type::type)); + &typeid(std::shared_ptr ), + &typeid(typename Bare_Type::type)); } }; @@ -172,8 +169,8 @@ namespace chaiscript return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - typeid(const std::shared_ptr &), - typeid(typename Bare_Type::type)); + &typeid(const std::shared_ptr &), + &typeid(typename Bare_Type::type)); } }; @@ -187,8 +184,8 @@ namespace chaiscript return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - typeid(std::reference_wrapper ), - typeid(typename Bare_Type::type)); + &typeid(std::reference_wrapper ), + &typeid(typename Bare_Type::type)); } }; @@ -202,8 +199,8 @@ namespace chaiscript return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, std::is_arithmetic::value && !std::is_same::type, bool>::value, - typeid(const std::reference_wrapper &), - typeid(typename Bare_Type::type)); + &typeid(const std::reference_wrapper &), + &typeid(typename Bare_Type::type)); } }; From d13d080dee7ae7ae8ba3c85e294ec0cd9687fc14 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 15:50:21 -0600 Subject: [PATCH 18/27] Remove constexpr from type_info --- include/chaiscript/dispatchkit/type_info.hpp | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index de61ab6..1db31be 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -29,7 +29,7 @@ namespace chaiscript class Type_Info { public: - CHAISCRIPT_CONSTEXPR Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void, + 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_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), @@ -38,7 +38,7 @@ namespace chaiscript { } - CHAISCRIPT_CONSTEXPR Type_Info() + Type_Info() : m_type_info(nullptr), m_bare_type_info(nullptr), m_is_const(false), m_is_reference(false), m_is_pointer(false), m_is_void(false), m_is_arithmetic(false), @@ -55,40 +55,40 @@ namespace chaiscript Type_Info& operator=(const Type_Info&) = default; - CHAISCRIPT_CONSTEXPR bool operator<(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT + bool operator<(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { return m_type_info < ti.m_type_info; } - CHAISCRIPT_CONSTEXPR bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT + bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { return ti.m_type_info == m_type_info || (ti.m_type_info && m_type_info && *ti.m_type_info == *m_type_info); } - CHAISCRIPT_CONSTEXPR bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT + bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { return m_type_info != nullptr && (*m_type_info) == ti; } - CHAISCRIPT_CONSTEXPR bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT + bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { return ti.m_bare_type_info == m_bare_type_info || (ti.m_bare_type_info && m_bare_type_info && *ti.m_bare_type_info == *m_bare_type_info); } - CHAISCRIPT_CONSTEXPR bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT + bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { return m_bare_type_info != nullptr && (*m_bare_type_info) == ti; } - CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return m_is_const; } - CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return m_is_reference; } - CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return m_is_void; } - CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return m_is_arithmetic; } - CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_is_undef || m_bare_type_info == nullptr; } - CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return m_is_pointer; } + bool is_const() const CHAISCRIPT_NOEXCEPT { return m_is_const; } + bool is_reference() const CHAISCRIPT_NOEXCEPT { return m_is_reference; } + bool is_void() const CHAISCRIPT_NOEXCEPT { return m_is_void; } + bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return m_is_arithmetic; } + bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_is_undef || m_bare_type_info == nullptr; } + bool is_pointer() const CHAISCRIPT_NOEXCEPT { return m_is_pointer; } std::string name() const { @@ -110,7 +110,7 @@ namespace chaiscript } } - CHAISCRIPT_CONSTEXPR const std::type_info *bare_type_info() const + const std::type_info *bare_type_info() const { return m_bare_type_info; } @@ -134,7 +134,7 @@ namespace chaiscript { typedef T type; - CHAISCRIPT_CONSTEXPR static Type_Info get() + static Type_Info get() { return Type_Info(std::is_const::type>::type>::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, @@ -149,7 +149,7 @@ namespace chaiscript { typedef T type; - CHAISCRIPT_CONSTEXPR static Type_Info get() + static Type_Info get() { return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, @@ -164,7 +164,7 @@ namespace chaiscript { typedef T type; - CHAISCRIPT_CONSTEXPR static Type_Info get() + static Type_Info get() { return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, @@ -179,7 +179,7 @@ namespace chaiscript { typedef T type; - CHAISCRIPT_CONSTEXPR static Type_Info get() + static Type_Info get() { return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, @@ -194,7 +194,7 @@ namespace chaiscript { typedef T type; - CHAISCRIPT_CONSTEXPR static Type_Info get() + static Type_Info get() { return Type_Info(std::is_const::value, std::is_reference::value, std::is_pointer::value, std::is_void::value, @@ -216,7 +216,7 @@ namespace chaiscript /// chaiscript::Type_Info ti = chaiscript::user_type(i); /// \endcode template - CHAISCRIPT_CONSTEXPR Type_Info user_type(const T &/*t*/) + Type_Info user_type(const T &/*t*/) { return detail::Get_Type_Info::get(); } @@ -231,7 +231,7 @@ namespace chaiscript /// chaiscript::Type_Info ti = chaiscript::user_type(); /// \endcode template - CHAISCRIPT_CONSTEXPR Type_Info user_type() + Type_Info user_type() { return detail::Get_Type_Info::get(); } From 3701477f7f78ad77aa6d93fa358cf6df161bdc5b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 16:03:23 -0600 Subject: [PATCH 19/27] More cleanups to travis configuration --- .travis.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2f8a07d..e701d49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,23 +5,19 @@ env: matrix: - GCC_VER="4.6" - GCC_VER="4.8" - - GCC_VER="5" global: - secure: eiaR6pXiiEpyB8+LLQ1NvZdl0Yylru1BLy9lMoHl+IpUNGGQGywmW/2WAn77rFfmR1OPA2qWQLfgPwgK0HxUA9HHlot9tre5QhiN2Lw8NOT8tCZ6tTm2+QntDBjBGJyal/knRvQkn/6qs6GxlXRerz4ArnnuPL1vESt3zwB0YtU= # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created - # via the "travis encrypt" command using the project repo's public key - secure: "LfolGjP8tWm3yAwthfu3yp8Zn40aueFae580UUR34gusG87cyglq2tQDtxdy+63gWEeNfArbv9n5rZv+bDW3ggHyPjuCKKc1PlZAy07lfXUXf1uz+SFhNvNoYTn3mQG3VZ08o116p4Le2p8yqu4bylJ8wckEq7PrTwvSGVQWTWM=" before_install: - - if [ "$GCC_VER" = "4.6" ]; then export CXX="g++-4.6" CC="gcc-4.6" GCOV="gcov-4.6"; fi - - if [ "$GCC_VER" = "4.8" ]; then export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8" COVERALLS=1 CPPCHECK=1; fi - - if [ "$GCC_VER" = "5" ]; then export CXX="g++-5" CC="gcc-5" GCOV="gcov-5"; fi + - export CXX="g++-$GCC_VER" CC="gcc-$GCC_VER" GCOV="gcov-$GCC_VER" + - if [ "$GCC_VER" = "4.8" ]; then export COVERALLS=1 CPPCHECK=1; fi - sudo pip install cpp-coveralls - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - if [ "$GCC_VER" = "4.8" ]; then sudo apt-get install -qq g++-4.8; fi - - if [ "$GCC_VER" = "5" ]; then sudo apt-get install -qq g++-5; fi + - apt-get install -qq g++-$GCC_VER script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi From f6600c90e4cad2a62799a6780c902f908fc848f1 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 16:07:12 -0600 Subject: [PATCH 20/27] Correct missing 'sudo' for travis setup --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e701d49..ab4e905 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_install: - sudo pip install cpp-coveralls - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - apt-get install -qq g++-$GCC_VER + - sudo apt-get install -qq g++-$GCC_VER script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi From cff635fb6578a16a5e8e649d63dfd9936fb35d4a Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 17:02:06 -0600 Subject: [PATCH 21/27] Enable 'codecov' --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ab4e905..6b89a0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ env: before_install: - export CXX="g++-$GCC_VER" CC="gcc-$GCC_VER" GCOV="gcov-$GCC_VER" - - if [ "$GCC_VER" = "4.8" ]; then export COVERALLS=1 CPPCHECK=1; fi + - if [ "$GCC_VER" = "4.8" ]; then export COVERAGE=1 CPPCHECK=1; fi - sudo pip install cpp-coveralls - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update @@ -23,11 +23,14 @@ script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make -j2 ; fi - make test - - if [ ${COVERALLS} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi + - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi after_script: - if [ ${CPPCHECK} = 1 ]; then contrib/codeanalysis/runcppcheck.sh ; fi +after_success: + - if [ ${COVERAGE} = 1 ]; then bash <(curl -s https://codecov.io/bash); fi + notifications: email: recipients: From 916708ce295500da9abbee4b5faa0ac09683ba58 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 17:22:00 -0600 Subject: [PATCH 22/27] Disable coveralls, use codecov --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6b89a0f..db11991 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,13 +23,12 @@ script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make -j2 ; fi - make test - - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi + # - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi + - if [ ${COVERAGE} = 1 ]; then bash <(curl -s https://codecov.io/bash); fi after_script: - if [ ${CPPCHECK} = 1 ]; then contrib/codeanalysis/runcppcheck.sh ; fi -after_success: - - if [ ${COVERAGE} = 1 ]; then bash <(curl -s https://codecov.io/bash); fi notifications: email: From 2848e16ea150782757dd387a777c7645bbe192c7 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 17:59:36 -0600 Subject: [PATCH 23/27] Another attempt at getting codecov working --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index db11991..386d495 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make -j2 ; fi - make test # - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi + - if [ ${COVERAGE} = 1 ]; then find . -name "*.cpp" | xargs $GCOV; fi - if [ ${COVERAGE} = 1 ]; then bash <(curl -s https://codecov.io/bash); fi after_script: From 7f871374fa6d7246e9beb8a02a0c10c9237b1e6e Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 18:07:06 -0600 Subject: [PATCH 24/27] Codecov and coveralls enabled --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 386d495..cd5886f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,8 +23,8 @@ script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make -j2 ; fi - make test - # - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi - - if [ ${COVERAGE} = 1 ]; then find . -name "*.cpp" | xargs $GCOV; fi + - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi + # - if [ ${COVERAGE} = 1 ]; then find . -name "*.cpp" | xargs $GCOV; fi - if [ ${COVERAGE} = 1 ]; then bash <(curl -s https://codecov.io/bash); fi after_script: From d56e32e2c4122427d492f4ffd65bb30df62daf6b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 18:35:46 -0600 Subject: [PATCH 25/27] Tweak coveralls settings --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cd5886f..08ae996 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make -j2 ; fi - make test - - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV ; fi + - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" -i "include/chaiscript" --gcov $GCOV --gcov-options '\-lp' ; fi # - if [ ${COVERAGE} = 1 ]; then find . -name "*.cpp" | xargs $GCOV; fi - if [ ${COVERAGE} = 1 ]; then bash <(curl -s https://codecov.io/bash); fi From 9fe8150861a817c26d33588010de41a8237d0538 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 30 May 2015 18:48:27 -0600 Subject: [PATCH 26/27] Wrap up the coveralls / codecov choices --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08ae996..458ccd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,9 +23,7 @@ script: - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then cmake -D ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug . ; fi - if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make -j2 ; fi - make test - - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" -i "include/chaiscript" --gcov $GCOV --gcov-options '\-lp' ; fi - # - if [ ${COVERAGE} = 1 ]; then find . -name "*.cpp" | xargs $GCOV; fi - - if [ ${COVERAGE} = 1 ]; then bash <(curl -s https://codecov.io/bash); fi + - if [ ${COVERAGE} = 1 ]; then coveralls -e "unittests/catch.hpp" -E ".*\.cpp" --gcov $GCOV --gcov-options '\-lp' ; fi after_script: - if [ ${CPPCHECK} = 1 ]; then contrib/codeanalysis/runcppcheck.sh ; fi From 520f9bc0d2c69a8735297a64fe68ebf8f73e67ad Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 1 Jun 2015 15:49:50 -0600 Subject: [PATCH 27/27] Work around bug in g++4.6 I'm going to have to start dropping support for older compilers soon. The 4.6 line is 4 years old now, and 4.7 has these issues fixed --- include/chaiscript/chaiscript_defines.hpp | 4 + .../dispatchkit/proxy_functions_detail.hpp | 119 ++++++++++++++++-- 2 files changed, 113 insertions(+), 10 deletions(-) diff --git a/include/chaiscript/chaiscript_defines.hpp b/include/chaiscript/chaiscript_defines.hpp index 8e45977..6d0fd99 100644 --- a/include/chaiscript/chaiscript_defines.hpp +++ b/include/chaiscript/chaiscript_defines.hpp @@ -35,6 +35,10 @@ #define CHAISCRIPT_HAS_THREAD_LOCAL #endif +#if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#define CHAISCRIPT_GCC_4_6 +#endif + #if (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || defined(CHAISCRIPT_MSVC) || defined(__llvm__) #define CHAISCRIPT_OVERRIDE override #else diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index a77376f..a98124b 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -53,6 +53,113 @@ namespace chaiscript { namespace detail { + /** + * Used by Proxy_Function_Impl to return a list of all param types + * it contains. + */ + template + std::vector build_param_type_list(Ret (*)(Params...)) + { + /// \note somehow this is responsible for a large part of the code generation + return { user_type(), user_type()... }; + } + + +#ifdef CHAISCRIPT_GCC_4_6 + /// \todo REMOVE THIS WHEN WE DROP G++4.6 + + // Forward declaration + template + struct Try_Cast; + + template + struct Try_Cast + { + static void do_try(const std::vector ¶ms, size_t generation, const Type_Conversions &t_conversions) + { + boxed_cast(params[generation], &t_conversions); + Try_Cast::do_try(params, generation+1, t_conversions); + } + }; + + // 0th case + template<> + struct Try_Cast<> + { + static void do_try(const std::vector &, size_t, const Type_Conversions &) + { + } + }; + + + /** + * Used by Proxy_Function_Impl to determine if it is equivalent to another + * Proxy_Function_Impl object. This function is primarily used to prevent + * registration of two functions with the exact same signatures + */ + template + bool compare_types_cast(Ret (*)(Params...), + const std::vector ¶ms, const Type_Conversions &t_conversions) + { + try { + Try_Cast::do_try(params, 0, t_conversions); + } catch (const exception::bad_boxed_cast &) { + return false; + } + + return true; + } + + template + struct Call_Func + { + + template + static Ret do_call(const std::function &f, + const std::vector ¶ms, const Type_Conversions &t_conversions, InnerParams &&... innerparams) + { + return Call_Func::do_call(f, params, t_conversions, std::forward(innerparams)..., params[sizeof...(Params) - count]); + } + }; + + template + struct Call_Func + { +#ifdef CHAISCRIPT_MSVC +#pragma warning(push) +#pragma warning(disable : 4100) /// Disable unreferenced formal parameter warning, which only shows up in MSVC I don't think there's any way around it \todo evaluate this +#endif + template + static Ret do_call(const std::function &f, + const std::vector &, const Type_Conversions &t_conversions, InnerParams &&... innerparams) + { + return f(boxed_cast(std::forward(innerparams), &t_conversions)...); + } +#ifdef CHAISCRIPT_MSVC +#pragma warning(pop) +#endif + }; + + /** + * Used by Proxy_Function_Impl to perform typesafe execution of a function. + * The function attempts to unbox each parameter to the expected type. + * if any unboxing fails the execution of the function fails and + * the bad_boxed_cast is passed up to the caller. + */ + template + Ret call_func(const std::function &f, + const std::vector ¶ms, const Type_Conversions &t_conversions) + { + if (params.size() == sizeof...(Params)) + { + return Call_Func::do_call(f, params, t_conversions); + } + + throw exception::arity_error(static_cast(params.size()), sizeof...(Params)); + } + +#else + template struct Indexes { @@ -70,16 +177,6 @@ namespace chaiscript typedef Indexes indexes; }; - /** - * Used by Proxy_Function_Impl to return a list of all param types - * it contains. - */ - template - std::vector build_param_type_list(Ret (*)(Params...)) - { - /// \note somehow this is responsible for a large part of the code generation - return { user_type(), user_type()... }; - } /** @@ -135,6 +232,8 @@ namespace chaiscript throw exception::arity_error(static_cast(params.size()), sizeof...(Params)); } +#endif + } }