diff --git a/.decent_ci-Linux.yaml b/.decent_ci-Linux.yaml index 495b699..e8ecf73 100644 --- a/.decent_ci-Linux.yaml +++ b/.decent_ci-Linux.yaml @@ -30,4 +30,7 @@ compilers: collect_performance_results: true - name: cppcheck compiler_extra_flags: --enable=all -I include --inline-suppr -Umax --suppress="*:cmake*" --suppress="*:unittests/catch.hpp" --force + - name: custom_check + commands: + - ./contrib/check_for_tabs.rb diff --git a/cheatsheet.md b/cheatsheet.md index 5e78553..eca67f0 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -77,7 +77,7 @@ chai.add(chaiscript::constructor(), "MyType"); It's not strictly necessary to add types, but it helps with many things. Cloning, better errors, etc. ``` -chai.add(chaiscript::user_type, "MyClass"); +chai.add(chaiscript::user_type(), "MyClass"); ``` ## Adding Type Conversions diff --git a/contrib/check_for_tabs.rb b/contrib/check_for_tabs.rb new file mode 100755 index 0000000..bee7d0d --- /dev/null +++ b/contrib/check_for_tabs.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +require 'json' + +`grep -rPIHn '\t' src/* include/* samples/*`.lines { |line| + if /(?.+(hpp|cpp|chai)):(?[0-9]+):(?.+)/ =~ line + puts(JSON.dump({:line => linenumber, :filename => filename, :tool => "tab_checker", :message => "Source Code Line Contains Tabs", :messagetype => "warning"})) + end +} + + diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index 9cb338c..9614597 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -83,12 +83,12 @@ namespace chaiscript && (*m_bare_type_info) == ti; } - CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return bool(m_flags & (1 << is_const_flag)); } - CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return bool(m_flags & (1 << is_reference_flag)); } - CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return bool(m_flags & (1 << is_void_flag)); } - CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return bool(m_flags & (1 << is_arithmetic_flag)); } - CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return bool(m_flags & (1 << is_undef_flag)); } - CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return bool(m_flags & (1 << is_pointer_flag)); } + CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_const_flag)) != 0; } + CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_reference_flag)) != 0; } + CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_void_flag)) != 0; } + CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_arithmetic_flag)) != 0; } + CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_undef_flag)) != 0; } + CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_pointer_flag)) != 0; } std::string name() const { diff --git a/unittests/map.chai b/unittests/map.chai index b2901ce..eb7a133 100644 --- a/unittests/map.chai +++ b/unittests/map.chai @@ -1,29 +1,41 @@ -assert_equal([true, false, true], map([1,2,3], odd)) +// Map function + +{ + assert_equal([true, false, true], map([1,2,3], odd)) + + var v = [1, 2, 3]; + var y = map(v, fun(s) { s*2; }); + y[0] = 1; + assert_equal(1, y[0]); +} +// Map objects -var m = ["a":1, "b":2]; +{ + var m = ["a":1, "b":2]; -assert_equal(1, m.count("a")) -assert_equal(0, m.count("c")) -assert_equal(1, m.erase("a")) -assert_equal(1, m.size()) -assert_equal(0, m.erase("a")) + assert_equal(1, m.count("a")) + assert_equal(0, m.count("c")) + assert_equal(1, m.erase("a")) + assert_equal(1, m.size()) + assert_equal(0, m.erase("a")) -assert_equal(1, m.size()); + assert_equal(1, m.size()); -var m2 = ["c":3, "b":4] -m.insert(m2); + var m2 = ["c":3, "b":4] + m.insert(m2); -assert_equal(3, m["c"]) -// The inserted values do not overwrite the existing ones -assert_equal(2, m["b"]) -assert_equal(2, m.size()) + assert_equal(3, m["c"]) + // The inserted values do not overwrite the existing ones + assert_equal(2, m["b"]) + assert_equal(2, m.size()) -var v = "bob"; + var v = "bob"; -m.insert_ref(Map_Pair("d", v)) + m.insert_ref(Map_Pair("d", v)) -assert_equal("bob", m["d"]) -v = "bob2" -assert_equal("bob2", m["d"]) + assert_equal("bob", m["d"]) + v = "bob2" + assert_equal("bob2", m["d"]) +}