diff --git a/.clang-format b/.clang-format index 8c8b3b26..2822d19f 100644 --- a/.clang-format +++ b/.clang-format @@ -1,10 +1,14 @@ -# clang-format: 11 +# clang-format: 19 AccessModifierOffset: -2 AlignAfterOpenBracket: Align AlignConsecutiveBitFields: false -AllowShortBlocksOnASingleLine: false +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: AllIfsAndElse AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true AlwaysBreakTemplateDeclarations: true BasedOnStyle: WebKit BinPackArguments: true @@ -13,12 +17,14 @@ BreakBeforeBraces: Attach ColumnLimit: 0 Cpp11BracedListStyle: true FixNamespaceComments: true +IfMacros: ['SECTION'] IncludeBlocks: Preserve IndentCaseLabels: true IndentPPDirectives: None IndentWidth: 2 KeepEmptyLinesAtTheStartOfBlocks: false NamespaceIndentation: All +PackConstructorInitializers: CurrentLine PenaltyBreakBeforeFirstCallParameter: 200 PenaltyBreakComment: 5 PenaltyBreakFirstLessLess: 50 @@ -27,7 +33,11 @@ PointerAlignment: Right SortIncludes: true SpaceAfterTemplateKeyword: false SpaceBeforeCpp11BracedList: false +SpaceBeforeParens: Custom +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterIfMacros: false SpaceInEmptyBlock: false Standard: Latest TabWidth: 2 -UseTab: Never \ No newline at end of file +UseTab: Never diff --git a/.github/workflows/auto-clang-format.yml b/.github/workflows/auto-clang-format.yml new file mode 100644 index 00000000..1cb91357 --- /dev/null +++ b/.github/workflows/auto-clang-format.yml @@ -0,0 +1,27 @@ +name: auto-clang-format +on: + push: + branches: + - develop + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + - uses: DoozyX/clang-format-lint-action@v0.20 + with: + source: '.' + exclude: './third_party ./external ./unittests/catch.hpp' + extensions: 'h,cpp,hpp' + clangFormatVersion: 19 + inplace: True + - uses: EndBug/add-and-commit@v9 + with: + author_name: Clang Robot + author_email: robot@example.com + message: ':art: Committing clang-format changes' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/emscripten/chaiscript_eval.hpp b/emscripten/chaiscript_eval.hpp index 52791ab3..45cf2378 100644 --- a/emscripten/chaiscript_eval.hpp +++ b/emscripten/chaiscript_eval.hpp @@ -11,14 +11,14 @@ #ifndef CHAISCRIPT_EMSCRIPTEN_EVAL_HPP_ #define CHAISCRIPT_EMSCRIPTEN_EVAL_HPP_ -#include #include +#include namespace detail { -inline chaiscript::ChaiScript &get_chai_instance() { - static chaiscript::ChaiScript chai; - return chai; -} + inline chaiscript::ChaiScript &get_chai_instance() { + static chaiscript::ChaiScript chai; + return chai; + } } // namespace detail inline void chaiscript_eval(const std::string &input) { diff --git a/include/chaiscript/chaiscript_stdlib.hpp b/include/chaiscript/chaiscript_stdlib.hpp index 73b11542..15b3d442 100644 --- a/include/chaiscript/chaiscript_stdlib.hpp +++ b/include/chaiscript/chaiscript_stdlib.hpp @@ -18,11 +18,11 @@ #include "dispatchkit/function_call.hpp" -//#include "dispatchkit/dispatchkit.hpp" +// #include "dispatchkit/dispatchkit.hpp" #include "dispatchkit/bootstrap.hpp" #include "dispatchkit/bootstrap_stl.hpp" #include "dispatchkit/operators.hpp" -//#include "dispatchkit/boxed_value.hpp" +// #include "dispatchkit/boxed_value.hpp" #include "dispatchkit/register_function.hpp" #include "language/chaiscript_prelude.hpp" #include "utility/json_wrap.hpp" diff --git a/include/chaiscript/dispatchkit/dynamic_object.hpp b/include/chaiscript/dispatchkit/dynamic_object.hpp index 03ae5276..cfcc5f17 100644 --- a/include/chaiscript/dispatchkit/dynamic_object.hpp +++ b/include/chaiscript/dispatchkit/dynamic_object.hpp @@ -65,7 +65,6 @@ namespace chaiscript { return false; } - bool is_explicit() const noexcept { return m_option_explicit; } void set_explicit(const bool t_explicit) noexcept { m_option_explicit = t_explicit; } diff --git a/include/chaiscript/dispatchkit/dynamic_object_detail.hpp b/include/chaiscript/dispatchkit/dynamic_object_detail.hpp index e9c8012e..824c5355 100644 --- a/include/chaiscript/dispatchkit/dynamic_object_detail.hpp +++ b/include/chaiscript/dispatchkit/dynamic_object_detail.hpp @@ -148,11 +148,11 @@ namespace chaiscript { }; /** - * A Proxy_Function implementation designed for creating a new - * Dynamic_Object - * that is automatically guarded based on the first param based on the - * param's type name - */ + * A Proxy_Function implementation designed for creating a new + * Dynamic_Object + * that is automatically guarded based on the first param based on the + * param's type name + */ class Dynamic_Object_Constructor final : public Proxy_Function_Base { public: Dynamic_Object_Constructor(std::string t_type_name, const Proxy_Function &t_func) diff --git a/include/chaiscript/dispatchkit/function_signature.hpp b/include/chaiscript/dispatchkit/function_signature.hpp index 174f8576..a87e60d0 100644 --- a/include/chaiscript/dispatchkit/function_signature.hpp +++ b/include/chaiscript/dispatchkit/function_signature.hpp @@ -64,7 +64,7 @@ namespace chaiscript::dispatch::detail { Function_Signature(Ret (Class::*f)(Param...) volatile &) -> Function_Signature, false, true>; template - Function_Signature(Ret (Class::*f)(Param...) volatile &noexcept) + Function_Signature(Ret (Class::*f)(Param...) volatile & noexcept) -> Function_Signature, true, true>; template @@ -72,20 +72,20 @@ namespace chaiscript::dispatch::detail { -> Function_Signature, false, true>; template - Function_Signature(Ret (Class::*f)(Param...) volatile const &noexcept) + Function_Signature(Ret (Class::*f)(Param...) volatile const & noexcept) -> Function_Signature, true, true>; template Function_Signature(Ret (Class::*f)(Param...) &) -> Function_Signature, false, true>; template - Function_Signature(Ret (Class::*f)(Param...) &noexcept) -> Function_Signature, true, true>; + Function_Signature(Ret (Class::*f)(Param...) & noexcept) -> Function_Signature, true, true>; template Function_Signature(Ret (Class::*f)(Param...) const &) -> Function_Signature, false, true>; template - Function_Signature(Ret (Class::*f)(Param...) const &noexcept) -> Function_Signature, true, true>; + Function_Signature(Ret (Class::*f)(Param...) const & noexcept) -> Function_Signature, true, true>; // && reference specifier @@ -93,7 +93,7 @@ namespace chaiscript::dispatch::detail { Function_Signature(Ret (Class::*f)(Param...) volatile &&) -> Function_Signature, false, true>; template - Function_Signature(Ret (Class::*f)(Param...) volatile &&noexcept) + Function_Signature(Ret (Class::*f)(Param...) volatile && noexcept) -> Function_Signature, true, true>; template @@ -101,20 +101,20 @@ namespace chaiscript::dispatch::detail { -> Function_Signature, false, true>; template - Function_Signature(Ret (Class::*f)(Param...) volatile const &&noexcept) + Function_Signature(Ret (Class::*f)(Param...) volatile const && noexcept) -> Function_Signature, true, true>; template Function_Signature(Ret (Class::*f)(Param...) &&) -> Function_Signature, false, true>; template - Function_Signature(Ret (Class::*f)(Param...) &&noexcept) -> Function_Signature, true, true>; + Function_Signature(Ret (Class::*f)(Param...) && noexcept) -> Function_Signature, true, true>; template Function_Signature(Ret (Class::*f)(Param...) const &&) -> Function_Signature, false, true>; template - Function_Signature(Ret (Class::*f)(Param...) const &&noexcept) + Function_Signature(Ret (Class::*f)(Param...) const && noexcept) -> Function_Signature, true, true>; template diff --git a/include/chaiscript/dispatchkit/handle_return.hpp b/include/chaiscript/dispatchkit/handle_return.hpp index e0d4e3ae..2bc296d3 100644 --- a/include/chaiscript/dispatchkit/handle_return.hpp +++ b/include/chaiscript/dispatchkit/handle_return.hpp @@ -170,8 +170,8 @@ namespace chaiscript { }; /** - * Used internally for handling a return value from a Proxy_Function call - */ + * Used internally for handling a return value from a Proxy_Function call + */ template<> struct Handle_Return { static Boxed_Value handle(const Boxed_Number &r) noexcept { return r.bv; } @@ -182,8 +182,8 @@ namespace chaiscript { }; /** - * Used internally for handling a return value from a Proxy_Function call - */ + * Used internally for handling a return value from a Proxy_Function call + */ template<> struct Handle_Return { static Boxed_Value handle() { return void_var(); } diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index 326fa257..bd29294d 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -165,13 +165,13 @@ namespace chaiscript { }; /** - * Pure virtual base class for all Proxy_Function implementations - * Proxy_Functions are a type erasure of type safe C++ - * function calls. At runtime parameter types are expected to be - * tested against passed in types. - * Dispatch_Engine only knows how to work with Proxy_Function, no other - * function classes. - */ + * Pure virtual base class for all Proxy_Function implementations + * Proxy_Functions are a type erasure of type safe C++ + * function calls. At runtime parameter types are expected to be + * tested against passed in types. + * Dispatch_Engine only knows how to work with Proxy_Function, no other + * function classes. + */ class Proxy_Function_Base { public: virtual ~Proxy_Function_Base() = default; diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index d43d4a13..c1bcf7bd 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -32,9 +32,9 @@ namespace chaiscript { namespace chaiscript { namespace exception { /** - * Exception thrown when there is a mismatch in number of - * parameters during Proxy_Function execution - */ + * Exception thrown when there is a mismatch in number of + * parameters during Proxy_Function execution + */ struct arity_error : std::range_error { arity_error(int t_got, int t_expected) : std::range_error("Function dispatch arity mismatch") @@ -54,9 +54,9 @@ namespace chaiscript { namespace dispatch { namespace detail { /** - * Used by Proxy_Function_Impl to return a list of all param types - * it contains. - */ + * 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 @@ -64,10 +64,10 @@ namespace chaiscript { } /** - * 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 - */ + * 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 chaiscript::Function_Params ¶ms, const Type_Conversions_State &t_conversions) noexcept { try { diff --git a/include/chaiscript/dispatchkit/type_conversions.hpp b/include/chaiscript/dispatchkit/type_conversions.hpp index 3f89e66b..c509945d 100644 --- a/include/chaiscript/dispatchkit/type_conversions.hpp +++ b/include/chaiscript/dispatchkit/type_conversions.hpp @@ -542,9 +542,8 @@ namespace chaiscript { = detail::Cast_Helper &>::cast(t_bv, nullptr); auto pair = std::make_pair( - detail::Cast_Helper::cast(from_pair.first, nullptr), - detail::Cast_Helper::cast(from_pair.second, nullptr) - ); + detail::Cast_Helper::cast(from_pair.first, nullptr), + detail::Cast_Helper::cast(from_pair.second, nullptr)); return Boxed_Value(std::move(pair)); }; diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index 0e770e9e..0ddd6f15 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -593,13 +593,13 @@ namespace chaiscript { } // namespace exception - //static + // static bool AST_Node::get_bool_condition(const Boxed_Value &t_bv, const chaiscript::detail::Dispatch_State &t_ss) { - try { - return t_ss->boxed_cast(t_bv); - } catch (const exception::bad_boxed_cast &) { - throw exception::eval_error("Condition not boolean"); - } + try { + return t_ss->boxed_cast(t_bv); + } catch (const exception::bad_boxed_cast &) { + throw exception::eval_error("Condition not boolean"); + } } namespace parser { diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index a3c25639..39c46271 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -137,8 +137,9 @@ namespace chaiscript { m_engine.add(fun([this](const std::string &s) { m_print_handler(s + "\n"); }), "println_string"); m_engine.add(fun([this](const std::function &t_handler) { - m_print_handler = t_handler; - }), "set_print_handler"); + m_print_handler = t_handler; + }), + "set_print_handler"); m_engine.add(fun([this](const std::function &t_reader) { m_file_reader = t_reader; @@ -291,7 +292,6 @@ namespace chaiscript { } public: - /// \brief Set a custom handler for print output, used by both print_string and println_string /// \param[in] t_handler Function to call with the string to print void set_print_handler(std::function t_handler) { @@ -306,7 +306,7 @@ namespace chaiscript { /// \brief Virtual destructor for ChaiScript virtual ~ChaiScript_Basic() = default; - + /// \brief Constructor for ChaiScript /// \param[in] t_lib Standard library to apply to this ChaiScript instance /// \param[in] t_modulepaths Vector of paths to search when attempting to load a binary module diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 759accd9..2b7b8320 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -10,13 +10,13 @@ #ifndef CHAISCRIPT_EVAL_HPP_ #define CHAISCRIPT_EVAL_HPP_ +#include #include #include #include #include #include #include -#include #include #include #include @@ -389,11 +389,11 @@ namespace chaiscript { // static and public so we can use this to process Switch_AST_Node case equality static Boxed_Value do_oper(const chaiscript::detail::Dispatch_State &t_ss, - Operators::Opers t_oper, - const std::string &t_oper_string, - const Boxed_Value &t_lhs, - const Boxed_Value &t_rhs, - std::atomic_uint_fast32_t &t_loc) { + Operators::Opers t_oper, + const std::string &t_oper_string, + const Boxed_Value &t_lhs, + const Boxed_Value &t_rhs, + std::atomic_uint_fast32_t &t_loc) { try { if (t_oper != Operators::Opers::invalid && t_lhs.get_type_info().is_arithmetic() && t_rhs.get_type_info().is_arithmetic()) { // If it's an arithmetic operation we want to short circuit dispatch @@ -1271,8 +1271,7 @@ namespace chaiscript { const auto process_statement = [&](const AST_Node_Impl &stmt) { if (stmt.identifier == AST_Node_Type::Def) { const auto &def_node = static_cast &>(stmt); - target_ns[def_node.children[0]->text] = - Boxed_Value(Def_AST_Node::make_proxy_function(def_node, t_ss)); + target_ns[def_node.children[0]->text] = Boxed_Value(Def_AST_Node::make_proxy_function(def_node, t_ss)); } else if (stmt.identifier == AST_Node_Type::Assign_Decl || stmt.identifier == AST_Node_Type::Const_Assign_Decl) { const auto &var_name = stmt.children[0]->text; diff --git a/include/chaiscript/utility/json_wrap.hpp b/include/chaiscript/utility/json_wrap.hpp index 2bcff1ca..82658a6b 100644 --- a/include/chaiscript/utility/json_wrap.hpp +++ b/include/chaiscript/utility/json_wrap.hpp @@ -1,8 +1,8 @@ #ifndef CHAISCRIPT_SIMPLEJSON_WRAP_HPP #define CHAISCRIPT_SIMPLEJSON_WRAP_HPP -#include "json.hpp" #include "../dispatchkit/dynamic_object.hpp" +#include "json.hpp" namespace chaiscript { class json_wrap { diff --git a/unittests/compiled_tests.cpp b/unittests/compiled_tests.cpp index 4ac537ca..4e0080de 100644 --- a/unittests/compiled_tests.cpp +++ b/unittests/compiled_tests.cpp @@ -605,7 +605,9 @@ TEST_CASE("Utility_Test utility class wrapper for enum") { } // Issue #601: add_class for enums should work directly with ChaiScript reference -enum class Issue601_EnumClass { Apple, Banana, Pear }; +enum class Issue601_EnumClass { Apple, + Banana, + Pear }; TEST_CASE("Issue 601: add_class enum with ChaiScript reference directly") { chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(), create_chaiscript_parser()); @@ -626,7 +628,9 @@ TEST_CASE("Issue 601: add_class enum with ChaiScript reference directly") { } // Also test non-scoped enum directly with ChaiScript reference -enum Issue601_PlainEnum { Issue601_Red = 0, Issue601_Green = 1, Issue601_Blue = 2 }; +enum Issue601_PlainEnum { Issue601_Red = 0, + Issue601_Green = 1, + Issue601_Blue = 2 }; TEST_CASE("Issue 601: add_class plain enum with ChaiScript reference directly") { chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(), create_chaiscript_parser()); @@ -952,7 +956,7 @@ TEST_CASE("Pair conversions") { const auto p = chai.eval>(R"cs( Pair("chai", "script"); )cs"); - CHECK(p.first == std::string{ "chai" }); + CHECK(p.first == std::string{"chai"}); CHECK(p.second == "script"); } { @@ -1532,7 +1536,8 @@ TEST_CASE("ChaiScript default has all functions") { TEST_CASE("Issue #421 - Switch with type_conversion does not compare destroyed objects") { struct MyType { int value; - explicit MyType(int v) : value(v) {} + explicit MyType(int v) + : value(v) {} }; chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(), create_chaiscript_parser()); @@ -1755,51 +1760,50 @@ TEST_CASE("push_back on script vector with vector_conversion") { // Register a C++ function that accepts the converted type, so we can // verify that vector_conversion actually works for passing vectors chai.add(chaiscript::fun([](const std::vector &v) -> std::string { - std::string result; - for (const auto &s : v) { - if (!result.empty()) { result += ","; } - result += s; - } - return result; - }), "join_strings"); + std::string result; + for (const auto &s : v) { + if (!result.empty()) { result += ","; } + result += s; + } + return result; + }), + "join_strings"); // push_back on an empty script-created vector must be visible CHECK(chai.eval( - "auto x = [];" - "x.push_back(\"Hello\");" - "x.size() == 1" - )); + "auto x = [];" + "x.push_back(\"Hello\");" + "x.size() == 1")); // push_back on a vector with initial elements must grow correctly CHECK(chai.eval( - "auto y = [\"a\", \"b\"];" - "y.push_back(\"c\");" - "y.push_back(\"d\");" - "y.size() == 4" - )); + "auto y = [\"a\", \"b\"];" + "y.push_back(\"c\");" + "y.push_back(\"d\");" + "y.size() == 4")); // Verify the actual content is preserved after push_back CHECK(chai.eval( - "auto z = [];" - "z.push_back(\"World\");" - "z[0]" - ) == "World"); + "auto z = [];" + "z.push_back(\"World\");" + "z[0]") + == "World"); // Round-trip: build a vector in script, push_back elements, then pass it // to a C++ function via vector_conversion and verify the contents CHECK(chai.eval( - "auto v = [\"one\", \"two\"];" - "v.push_back(\"three\");" - "join_strings(v)" - ) == "one,two,three"); + "auto v = [\"one\", \"two\"];" + "v.push_back(\"three\");" + "join_strings(v)") + == "one,two,three"); // Verify conversion works on a freshly created vector too CHECK(chai.eval( - "auto w = [];" - "w.push_back(\"hello\");" - "w.push_back(\"world\");" - "join_strings(w)" - ) == "hello,world"); + "auto w = [];" + "w.push_back(\"hello\");" + "w.push_back(\"world\");" + "join_strings(w)") + == "hello,world"); } // Regression test for issue #607: AST_Node_Trace must be a complete type @@ -1962,20 +1966,23 @@ TEST_CASE("Namespace block rejects non-declaration statements") { namespace bad { 1 + 2 } - )"), chaiscript::exception::eval_error); + )"), + chaiscript::exception::eval_error); CHECK_THROWS_AS(chai.eval(R"( namespace bad { print("hello") } - )"), chaiscript::exception::eval_error); + )"), + chaiscript::exception::eval_error); CHECK_THROWS_AS(chai.eval(R"( var x = 5 namespace bad { x = 10 } - )"), chaiscript::exception::eval_error); + )"), + chaiscript::exception::eval_error); } TEST_CASE("C++ runtime_error thrown from registered function is catchable in ChaiScript") { @@ -2061,7 +2068,8 @@ TEST_CASE("Typed catch with no match propagates exception") { catch(string e) { // wrong type, should not match } - )"), chaiscript::Boxed_Value); + )"), + chaiscript::Boxed_Value); } TEST_CASE("Typed catch with no match still runs finally block") { @@ -2078,7 +2086,8 @@ TEST_CASE("Typed catch with no match still runs finally block") { finally { finally_ran = true } - )"), chaiscript::Boxed_Value); + )"), + chaiscript::Boxed_Value); CHECK(chai.eval("finally_ran") == true); } @@ -2087,13 +2096,14 @@ TEST_CASE("Multiple C++ exception types from registered functions") { chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(), create_chaiscript_parser()); chai.add(chaiscript::fun([](int which) -> int { - switch (which) { - case 0: throw std::runtime_error("runtime"); - case 1: throw std::out_of_range("range"); - case 2: throw std::logic_error("logic"); - default: return which; - } - }), "cpp_multi_throw"); + switch (which) { + case 0: throw std::runtime_error("runtime"); + case 1: throw std::out_of_range("range"); + case 2: throw std::logic_error("logic"); + default: return which; + } + }), + "cpp_multi_throw"); CHECK(chai.eval(R"( var catch_count = 0 @@ -2121,8 +2131,9 @@ TEST_CASE("Exception from C++ binary operator is catchable in ChaiScript") { chai.add(chaiscript::user_type(), "ThrowingType"); chai.add(chaiscript::constructor(), "ThrowingType"); chai.add(chaiscript::fun([](const ThrowingType &, const ThrowingType &) -> ThrowingType { - throw std::runtime_error("cpp operator+ threw"); - }), "+"); + throw std::runtime_error("cpp operator+ threw"); + }), + "+"); CHECK(chai.eval(R"( var caught = false @@ -2148,9 +2159,10 @@ TEST_CASE("Exception from C++ [] operator is catchable in ChaiScript") { chai.add(chaiscript::user_type(), "IndexableType"); chai.add(chaiscript::constructor(), "IndexableType"); chai.add(chaiscript::fun([](const IndexableType &, int idx) -> int { - if (idx < 0) { throw std::out_of_range("negative index"); } - return idx; - }), "[]"); + if (idx < 0) { throw std::out_of_range("negative index"); } + return idx; + }), + "[]"); CHECK(chai.eval("var obj = IndexableType(0); obj[5]") == 5); diff --git a/unittests/emscripten_eval_test.cpp b/unittests/emscripten_eval_test.cpp index 6084c9d3..a146fcb8 100644 --- a/unittests/emscripten_eval_test.cpp +++ b/unittests/emscripten_eval_test.cpp @@ -9,9 +9,9 @@ #define CHAISCRIPT_NO_DYNLOAD #endif -#include #include "../emscripten/chaiscript_eval.hpp" #include +#include #include #include diff --git a/unittests/emscripten_exception_test.cpp b/unittests/emscripten_exception_test.cpp index 1dfe26d1..432fd52b 100644 --- a/unittests/emscripten_exception_test.cpp +++ b/unittests/emscripten_exception_test.cpp @@ -10,9 +10,9 @@ #define CHAISCRIPT_NO_DYNLOAD #endif -#include #include "../emscripten/chaiscript_eval.hpp" #include +#include #include #include #include diff --git a/unittests/multifile_test_chai.cpp b/unittests/multifile_test_chai.cpp index f0a19fff..ea1379d8 100644 --- a/unittests/multifile_test_chai.cpp +++ b/unittests/multifile_test_chai.cpp @@ -5,8 +5,8 @@ Multi_Test_Chai::Multi_Test_Chai() : m_chai(new chaiscript::ChaiScript_Basic( - chaiscript::Std_Lib::library(), - std::make_unique>())) { + chaiscript::Std_Lib::library(), + std::make_unique>())) { } std::shared_ptr Multi_Test_Chai::get_chai() {