Merge branch 'develop' into add_performance_tests
This commit is contained in:
commit
c067575ac4
@ -30,4 +30,7 @@ compilers:
|
|||||||
collect_performance_results: true
|
collect_performance_results: true
|
||||||
- name: cppcheck
|
- name: cppcheck
|
||||||
compiler_extra_flags: --enable=all -I include --inline-suppr -Umax --suppress="*:cmake*" --suppress="*:unittests/catch.hpp" --force
|
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
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ chai.add(chaiscript::constructor<MyType (const MyType &)>(), "MyType");
|
|||||||
It's not strictly necessary to add types, but it helps with many things. Cloning, better errors, etc.
|
It's not strictly necessary to add types, but it helps with many things. Cloning, better errors, etc.
|
||||||
|
|
||||||
```
|
```
|
||||||
chai.add(chaiscript::user_type<MyClass>, "MyClass");
|
chai.add(chaiscript::user_type<MyClass>(), "MyClass");
|
||||||
```
|
```
|
||||||
|
|
||||||
## Adding Type Conversions
|
## Adding Type Conversions
|
||||||
|
11
contrib/check_for_tabs.rb
Executable file
11
contrib/check_for_tabs.rb
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
`grep -rPIHn '\t' src/* include/* samples/*`.lines { |line|
|
||||||
|
if /(?<filename>.+(hpp|cpp|chai)):(?<linenumber>[0-9]+):(?<restofline>.+)/ =~ line
|
||||||
|
puts(JSON.dump({:line => linenumber, :filename => filename, :tool => "tab_checker", :message => "Source Code Line Contains Tabs", :messagetype => "warning"}))
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -83,12 +83,12 @@ namespace chaiscript
|
|||||||
&& (*m_bare_type_info) == ti;
|
&& (*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_const() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_const_flag)) != 0; }
|
||||||
CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return bool(m_flags & (1 << is_reference_flag)); }
|
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 bool(m_flags & (1 << is_void_flag)); }
|
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 bool(m_flags & (1 << is_arithmetic_flag)); }
|
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 bool(m_flags & (1 << is_undef_flag)); }
|
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 bool(m_flags & (1 << is_pointer_flag)); }
|
CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_pointer_flag)) != 0; }
|
||||||
|
|
||||||
std::string name() const
|
std::string name() const
|
||||||
{
|
{
|
||||||
|
@ -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(1, m.count("a"))
|
||||||
assert_equal(0, m.count("c"))
|
assert_equal(0, m.count("c"))
|
||||||
assert_equal(1, m.erase("a"))
|
assert_equal(1, m.erase("a"))
|
||||||
assert_equal(1, m.size())
|
assert_equal(1, m.size())
|
||||||
assert_equal(0, m.erase("a"))
|
assert_equal(0, m.erase("a"))
|
||||||
|
|
||||||
assert_equal(1, m.size());
|
assert_equal(1, m.size());
|
||||||
|
|
||||||
var m2 = ["c":3, "b":4]
|
var m2 = ["c":3, "b":4]
|
||||||
m.insert(m2);
|
m.insert(m2);
|
||||||
|
|
||||||
assert_equal(3, m["c"])
|
assert_equal(3, m["c"])
|
||||||
// The inserted values do not overwrite the existing ones
|
// The inserted values do not overwrite the existing ones
|
||||||
assert_equal(2, m["b"])
|
assert_equal(2, m["b"])
|
||||||
assert_equal(2, m.size())
|
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"])
|
assert_equal("bob", m["d"])
|
||||||
v = "bob2"
|
v = "bob2"
|
||||||
assert_equal("bob2", m["d"])
|
assert_equal("bob2", m["d"])
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user