From 57d9a05f8847e73ca7876b2361769732276cb740 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sat, 6 Mar 2021 10:14:48 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Refactor=20tutorial=20examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 🛠 Make sure the tutorials compile across platforms! - ✍ Redo quite a bit of the documentation --- .clang-format | 2 +- .dockerignore | 2 +- .gitignore | 7 +- .travis.yml | 2 +- CMakeLists.txt | 11 +- CONTRIBUTORS.md | 6 +- Dockerfile | 2 +- README.md | 6 +- appveyor.yml | 2 +- cmake/Modules/Common/Core.cmake | 2 +- cmake/Modules/FindKaguyaBuild.cmake | 2 +- cmake/Modules/FindLua/set_version_vars.cmake | 2 +- cmake/Modules/FindLuaBridgeBuild.cmake | 2 +- cmake/Modules/FindLuaBuild.cmake | 2 +- cmake/Modules/FindLuaBuild/LuaJIT.cmake | 2 +- cmake/Modules/FindLuaBuild/LuaVanilla.cmake | 2 +- cmake/Modules/FindLuwraBuild.cmake | 2 +- cmake/Modules/FindSphinx.cmake | 2 +- cmake/Modules/FindToLuappBuild.cmake | 2 +- cmake/sol2-config.cmake.in | 2 +- documentation/.clang-format | 2 +- documentation/CMakeLists.txt | 4 +- documentation/Doxyfile.in | 2 +- documentation/source/api/c_call.rst | 2 +- documentation/source/api/policies.rst | 2 +- documentation/source/api/proxy.rst | 2 +- documentation/source/api/stack.rst | 16 +- documentation/source/api/this_environment.rst | 2 +- documentation/source/api/usertype.rst | 4 +- documentation/source/api/usertype_memory.rst | 4 +- documentation/source/benchmarks.rst | 2 +- documentation/source/build.rst | 6 +- documentation/source/codecvt.rst | 2 +- documentation/source/compilation.rst | 73 +++-- documentation/source/containers.rst | 8 +- documentation/source/errors.rst | 8 +- documentation/source/exceptions.rst | 2 +- documentation/source/features.rst | 2 +- documentation/source/functions.rst | 14 +- documentation/source/index.rst | 37 ++- documentation/source/mentions.rst | 20 +- documentation/source/origin.rst | 2 +- documentation/source/safety.rst | 6 +- documentation/source/traits.rst | 2 +- .../source/tutorial/all-the-things.rst | 41 ++- documentation/source/tutorial/functions.rst | 10 +- documentation/source/usertypes.rst | 8 +- examples/.clang-format | 110 +++++++ examples/CMakeLists.txt | 4 +- examples/customization/CMakeLists.txt | 4 +- .../customization/include/lua_zm_interop.hpp | 10 +- examples/customization/include/zm/vec3.hpp | 12 +- examples/customization/source/lua_interop.cpp | 5 +- .../customization/source/lua_zm_interop.cpp | 19 +- examples/customization/source/main.cpp | 9 +- examples/interop/LuaBridge/CMakeLists.txt | 4 +- .../interop/LuaBridge/source/LuaBridge.cpp | 40 ++- examples/interop/kaguya/CMakeLists.txt | 4 +- examples/interop/kaguya/source/kaguya.cpp | 67 +++-- examples/interop/luwra/CMakeLists.txt | 4 +- examples/interop/luwra/source/luwra.cpp | 47 ++- examples/interop/tolua/CMakeLists.txt | 4 +- examples/interop/tolua/source/Player.h | 3 +- examples/interop/tolua/source/tolua.cpp | 40 ++- examples/interop/tolua/source/tolua_Player.h | 273 +++++++++--------- examples/require_dll_example/CMakeLists.txt | 4 +- .../include/my_object/my_object_api.hpp | 3 +- .../require_dll_example/source/my_object.cpp | 13 +- .../source/require_from_dll.cpp | 9 +- examples/source/allocation_limit.cpp | 66 ++++- examples/source/any_return.cpp | 19 +- examples/source/as_returns.cpp | 4 +- examples/source/basic.cpp | 42 ++- examples/source/c_array.cpp | 8 +- examples/source/c_call.cpp | 5 +- examples/source/calling_lua_functions.cpp | 29 +- examples/source/config.cpp | 8 +- .../container_usertype_as_container.cpp | 12 +- examples/source/container_with_pairs.cpp | 22 +- examples/source/containers_as_table.cpp | 43 ++- examples/source/coroutine.cpp | 48 +-- examples/source/coroutine_multiple_stacks.cpp | 14 +- examples/source/coroutine_state.cpp | 18 +- examples/source/custom_reader.cpp | 22 +- .../customization_base_object_catch.cpp | 81 ++++-- .../source/customization_convert_on_get.cpp | 23 +- ...tomization_global_transparent_argument.cpp | 27 +- examples/source/customization_multiple.cpp | 26 +- examples/source/docs/as_table_ipairs.cpp | 7 +- examples/source/docs/coroutine_main.cpp | 13 +- examples/source/docs/coroutine_thread.cpp | 6 +- examples/source/docs/inheritance.cpp | 6 +- examples/source/docs/my_panic.cpp | 15 +- .../source/docs/preparing_environments.cpp | 3 +- examples/source/docs/runtime_extension.cpp | 3 +- examples/source/docs/simple_structs.cpp | 3 +- examples/source/docs/state_script_safe.cpp | 33 ++- examples/source/docs/state_transfer.cpp | 15 +- examples/source/docs/std_thread.cpp | 55 +++- examples/source/dump.cpp | 12 +- examples/source/dynamic_object.cpp | 12 +- examples/source/environment_snooping.cpp | 44 ++- examples/source/environment_state.cpp | 3 +- examples/source/environments.cpp | 27 +- examples/source/environments_on_functions.cpp | 34 ++- examples/source/error_handler.cpp | 9 +- examples/source/exception_handler.cpp | 26 +- examples/source/functions.cpp | 3 +- examples/source/functions_empty_arguments.cpp | 6 +- .../source/index_and_newindex_usertype.cpp | 8 +- examples/source/indirect_function_calls.cpp | 7 +- examples/source/lua_value.cpp | 22 +- examples/source/metatable_customization.cpp | 139 ++++++--- examples/source/metatable_key_low_level.cpp | 4 +- examples/source/multi_results.cpp | 20 +- examples/source/optional_with_iteration.cpp | 25 +- examples/source/overloading_with_fallback.cpp | 13 +- examples/source/overloading_with_members.cpp | 7 +- .../source/overridable_function_members.cpp | 12 +- examples/source/pairs.cpp | 28 +- examples/source/pairs_with_raw_functions.cpp | 16 +- examples/source/property.cpp | 11 +- examples/source/protect.cpp | 3 +- examples/source/protected_functions.cpp | 6 +- examples/source/read_only.cpp | 6 +- examples/source/require.cpp | 12 +- examples/source/require_override_behavior.cpp | 16 +- examples/source/script_error_handling.cpp | 62 ++-- examples/source/self_from_lua.cpp | 10 +- examples/source/shared_ptr.cpp | 66 +++-- examples/source/shared_ptr_inheritance.cpp | 40 ++- .../source/shared_ptr_modify_in_place.cpp | 30 +- examples/source/singleton.cpp | 8 +- examples/source/stack_aligned_function.cpp | 7 +- .../stack_aligned_stack_handler_function.cpp | 14 +- examples/source/static_variables.cpp | 8 +- examples/source/table_as_container.cpp | 11 +- examples/source/table_create_if_nil.cpp | 9 +- examples/source/table_proxy.cpp | 3 +- examples/source/tables.cpp | 24 +- examples/source/this_state.cpp | 21 +- examples/source/tutorials/erase_demo.cpp | 6 +- examples/source/tutorials/lazy_demo.cpp | 3 +- .../tutorials/open_multiple_libraries.cpp | 5 +- .../source/tutorials/pointer_lifetime.cpp | 17 +- .../quick_n_dirty/arguments_to_scripts.cpp | 7 +- .../tutorials/quick_n_dirty/functions_all.cpp | 6 +- .../quick_n_dirty/functions_easy.cpp | 3 +- .../quick_n_dirty/multiple_returns_to_lua.cpp | 6 +- .../tutorials/quick_n_dirty/namespacing.cpp | 20 +- .../opening_state_on_raw_lua.cpp | 3 +- .../quick_n_dirty/running_lua_code.cpp | 21 +- .../running_lua_code_low_level.cpp | 6 +- .../quick_n_dirty/running_lua_code_safely.cpp | 45 ++- .../tutorials/quick_n_dirty/self_call.cpp | 3 +- .../quick_n_dirty/set_and_get_variables.cpp | 3 +- .../quick_n_dirty/tables_and_nesting.cpp | 6 +- .../tutorials/quick_n_dirty/userdata.cpp | 29 +- .../userdata_memory_reference.cpp | 8 +- .../tutorials/quick_n_dirty/usertypes.cpp | 8 +- examples/source/tutorials/variables_demo.cpp | 25 +- .../source/tutorials/write_variables_demo.cpp | 12 +- .../source/tutorials/writing_functions.cpp | 4 +- .../tutorials/writing_member_functions.cpp | 12 +- .../writing_overloaded_template_functions.cpp | 11 +- .../tutorials/writing_template_functions.cpp | 11 +- examples/source/unique_ptr.cpp | 43 ++- examples/source/usertype.cpp | 24 +- examples/source/usertype_advanced.cpp | 23 +- .../source/usertype_automatic_operators.cpp | 9 +- examples/source/usertype_basics.cpp | 12 +- examples/source/usertype_bitfields.cpp | 106 +++++-- examples/source/usertype_call_from_c++.cpp | 7 +- examples/source/usertype_constructors.cpp | 27 +- examples/source/usertype_dynamic_get_set.cpp | 56 ++-- examples/source/usertype_initializers.cpp | 12 +- .../source/usertype_special_functions.cpp | 4 +- examples/source/usertype_var.cpp | 8 +- examples/source/variadic_args.cpp | 30 +- examples/source/variadic_args_into_lua.cpp | 31 +- examples/source/variadic_args_shifted.cpp | 3 +- examples/source/variadic_args_storage.cpp | 11 +- include/sol/as_args.hpp | 2 +- include/sol/as_returns.hpp | 2 +- include/sol/assert.hpp | 2 +- include/sol/base_traits.hpp | 2 +- include/sol/bind_traits.hpp | 2 +- include/sol/bytecode.hpp | 2 +- include/sol/call.hpp | 2 +- include/sol/compatibility.hpp | 2 +- include/sol/compatibility/lua_version.hpp | 2 +- include/sol/config.hpp | 2 +- include/sol/coroutine.hpp | 2 +- include/sol/debug.hpp | 2 +- include/sol/demangle.hpp | 2 +- include/sol/deprecate.hpp | 2 +- include/sol/dump_handler.hpp | 2 +- include/sol/ebco.hpp | 2 +- include/sol/environment.hpp | 2 +- include/sol/error.hpp | 2 +- include/sol/error_handler.hpp | 4 +- include/sol/forward.hpp | 2 +- include/sol/forward_detail.hpp | 2 +- include/sol/function.hpp | 2 +- include/sol/function_result.hpp | 2 +- include/sol/function_types.hpp | 2 +- include/sol/function_types_core.hpp | 2 +- include/sol/function_types_overloaded.hpp | 2 +- include/sol/function_types_stateful.hpp | 2 +- include/sol/function_types_stateless.hpp | 2 +- include/sol/function_types_templated.hpp | 2 +- include/sol/in_place.hpp | 2 +- include/sol/inheritance.hpp | 2 +- include/sol/load_result.hpp | 2 +- include/sol/lua_table.hpp | 2 +- include/sol/lua_value.hpp | 2 +- include/sol/make_reference.hpp | 2 +- include/sol/metatable.hpp | 2 +- include/sol/object.hpp | 2 +- include/sol/object_base.hpp | 2 +- include/sol/optional.hpp | 2 +- include/sol/optional_implementation.hpp | 56 ++-- include/sol/overload.hpp | 2 +- include/sol/packaged_coroutine.hpp | 2 +- include/sol/pairs_iterator.hpp | 2 +- include/sol/pointer_like.hpp | 2 +- include/sol/policies.hpp | 2 +- include/sol/property.hpp | 2 +- include/sol/protect.hpp | 2 +- include/sol/protected_function.hpp | 2 +- include/sol/protected_function_result.hpp | 2 +- include/sol/protected_handler.hpp | 2 +- include/sol/proxy_base.hpp | 2 +- include/sol/raii.hpp | 2 +- include/sol/reference.hpp | 2 +- include/sol/resolve.hpp | 2 +- include/sol/stack.hpp | 2 +- include/sol/stack_check.hpp | 2 +- include/sol/stack_check_get.hpp | 2 +- include/sol/stack_check_get_qualified.hpp | 2 +- include/sol/stack_check_get_unqualified.hpp | 2 +- include/sol/stack_check_qualified.hpp | 2 +- include/sol/stack_check_unqualified.hpp | 2 +- include/sol/stack_core.hpp | 4 +- include/sol/stack_field.hpp | 2 +- include/sol/stack_get.hpp | 2 +- include/sol/stack_get_qualified.hpp | 2 +- include/sol/stack_get_unqualified.hpp | 2 +- include/sol/stack_guard.hpp | 2 +- include/sol/stack_iterator.hpp | 2 +- include/sol/stack_pop.hpp | 2 +- include/sol/stack_probe.hpp | 2 +- include/sol/stack_proxy.hpp | 2 +- include/sol/stack_proxy_base.hpp | 2 +- include/sol/stack_push.hpp | 2 +- include/sol/stack_reference.hpp | 2 +- include/sol/state.hpp | 2 +- include/sol/state_handling.hpp | 8 +- include/sol/state_view.hpp | 2 +- include/sol/string_view.hpp | 2 +- include/sol/table.hpp | 2 +- include/sol/table_core.hpp | 2 +- include/sol/table_iterator.hpp | 2 +- include/sol/thread.hpp | 2 +- include/sol/tie.hpp | 2 +- include/sol/traits.hpp | 2 +- include/sol/trampoline.hpp | 4 +- include/sol/tuple.hpp | 2 +- include/sol/types.hpp | 2 +- include/sol/unique_usertype_traits.hpp | 2 +- include/sol/unsafe_function.hpp | 2 +- include/sol/unsafe_function_result.hpp | 2 +- include/sol/userdata.hpp | 2 +- include/sol/usertype.hpp | 2 +- include/sol/usertype_container.hpp | 2 +- include/sol/usertype_container_launch.hpp | 2 +- include/sol/usertype_core.hpp | 2 +- include/sol/usertype_proxy.hpp | 2 +- include/sol/usertype_storage.hpp | 4 +- include/sol/usertype_traits.hpp | 2 +- include/sol/variadic_args.hpp | 2 +- include/sol/variadic_results.hpp | 2 +- include/sol/version.hpp | 2 +- include/sol/wrapper.hpp | 2 +- list_headers.py | 2 +- meson.build | 4 +- meson_options.txt | 2 +- scripts/build.linux.sh | 2 +- scripts/preparation.linux.sh | 2 +- scripts/preparation.osx.sh | 2 +- scripts/push.linux.sh | 2 +- scripts/run.linux.sh | 2 +- scripts/run.osx.sh | 2 +- tests/CMakeLists.txt | 6 +- tests/config_tests/CMakeLists.txt | 4 +- .../function_pointers/CMakeLists.txt | 4 +- tests/header_tests/source/main.cpp | 30 -- .../CMakeLists.txt | 4 +- .../source/as_args.cpp | 2 +- .../source/as_returns.cpp | 2 +- .../source/base_traits.cpp | 2 +- .../source/bind_traits.cpp | 2 +- .../source/bytecode.cpp | 2 +- .../source/call.cpp | 2 +- .../source/compatibility.cpp | 2 +- .../source/compatibility/compat-5.3.cpp | 2 +- .../source/compatibility/lua_version.cpp | 2 +- .../source/config.cpp | 2 +- .../source/coroutine.cpp | 2 +- .../source/debug.cpp | 2 +- .../source/demangle.cpp | 2 +- .../source/deprecate.cpp | 2 +- .../source/ebco.cpp | 2 +- .../source/environment.cpp | 2 +- .../source/error.cpp | 0 .../source/error_handler.cpp | 2 +- .../source/forward.cpp | 2 +- .../source/forward_detail.cpp | 2 +- .../source/function.cpp | 2 +- .../source/function_result.cpp | 2 +- .../source/function_types.cpp | 2 +- .../source/function_types_core.cpp | 2 +- .../source/function_types_overloaded.cpp | 2 +- .../source/function_types_stateful.cpp | 2 +- .../source/function_types_stateless.cpp | 2 +- .../source/function_types_templated.cpp | 2 +- .../source/in_place.cpp | 2 +- .../source/inheritance.cpp | 2 +- .../source/load_result.cpp | 2 +- .../source/lua_table.cpp | 2 +- .../source/lua_value.cpp | 2 +- .../source/make_reference.cpp | 2 +- .../source/metatable.cpp | 2 +- .../source/object.cpp | 2 +- .../source/object_base.cpp | 2 +- .../source/optional.cpp | 2 +- .../source/optional_implementation.cpp | 2 +- .../source/overload.cpp | 2 +- .../source/packaged_coroutine.cpp | 2 +- .../source/pairs_iterator.cpp | 2 +- .../source/pointer_like.cpp | 2 +- .../source/policies.cpp | 2 +- .../source/property.cpp | 2 +- .../source/protect.cpp | 2 +- .../source/protected_function.cpp | 2 +- .../source/protected_function_result.cpp | 2 +- .../source/protected_handler.cpp | 2 +- .../source/proxy.cpp | 2 +- .../source/proxy_base.cpp | 2 +- .../source/raii.cpp | 2 +- .../source/reference.cpp | 2 +- .../source/resolve.cpp | 2 +- .../source/sol.cpp | 2 +- .../source/sol_defines.hpp | 2 +- .../source/stack.cpp | 2 +- .../source/stack_check.cpp | 2 +- .../source/stack_check_get.cpp | 2 +- .../source/stack_check_get_qualified.cpp | 2 +- .../source/stack_check_get_unqualified.cpp | 2 +- .../source/stack_check_qualified.cpp | 2 +- .../source/stack_check_unqualified.cpp | 2 +- .../source/stack_core.cpp | 2 +- .../source/stack_field.cpp | 2 +- .../source/stack_get.cpp | 2 +- .../source/stack_get_qualified.cpp | 2 +- .../source/stack_get_unqualified.cpp | 2 +- .../source/stack_guard.cpp | 2 +- .../source/stack_iterator.cpp | 2 +- .../source/stack_pop.cpp | 2 +- .../source/stack_probe.cpp | 2 +- .../source/stack_proxy.cpp | 2 +- .../source/stack_proxy_base.cpp | 2 +- .../source/stack_push.cpp | 2 +- .../source/stack_reference.cpp | 2 +- .../source/state.cpp | 0 .../source/state_handling.cpp | 2 +- .../source/state_view.cpp | 0 .../source/string_view.cpp | 2 +- .../source/table.cpp | 2 +- .../source/table_core.cpp | 2 +- .../source/table_iterator.cpp | 2 +- .../source/thread.cpp | 2 +- .../source/tie.cpp | 2 +- .../source/traits.cpp | 2 +- .../source/trampoline.cpp | 2 +- .../source/tuple.cpp | 2 +- .../source/types.cpp | 2 +- .../source/unicode.cpp | 2 +- .../source/unique_usertype_traits.cpp | 2 +- .../source/unsafe_function.cpp | 2 +- .../source/unsafe_function_result.cpp | 2 +- .../source/userdata.cpp | 2 +- .../source/usertype.cpp | 2 +- .../source/usertype_container.cpp | 2 +- .../source/usertype_container_launch.cpp | 2 +- .../source/usertype_core.cpp | 2 +- .../source/usertype_proxy.cpp | 2 +- .../source/usertype_storage.cpp | 2 +- .../source/usertype_traits.cpp | 2 +- .../source/variadic_args.cpp | 2 +- .../source/variadic_results.cpp | 2 +- .../source/version.cpp | 2 +- .../source/wrapper.cpp | 2 +- tests/regression_tests/1011/CMakeLists.txt | 17 +- tests/regression_tests/CMakeLists.txt | 4 +- tests/regression_tests/simple/CMakeLists.txt | 11 +- tests/runtime_tests/CMakeLists.txt | 4 +- tests/runtime_tests/source/abort_clean.cpp | 11 - tests/runtime_tests/source/basic.cpp | 2 +- tests/runtime_tests/source/common_classes.hpp | 2 +- .../source/container.usertype_check.cpp | 2 +- .../source/container_semantics.cpp | 2 +- .../source/container_semantics.custom.cpp | 2 +- .../source/container_semantics.ordered.cpp | 2 +- .../source/container_semantics.unordered.cpp | 2 +- .../runtime_tests/source/container_shims.cpp | 2 +- .../runtime_tests/source/container_table.cpp | 2 +- tests/runtime_tests/source/containers.cpp | 2 +- .../source/containers.roundtrip.cpp | 2 +- .../runtime_tests/source/containers.table.cpp | 2 +- tests/runtime_tests/source/coroutines.cpp | 6 +- tests/runtime_tests/source/customizations.cpp | 2 +- .../source/customizations_private.cpp | 4 +- tests/runtime_tests/source/dump.cpp | 2 +- tests/runtime_tests/source/environments.cpp | 2 +- tests/runtime_tests/source/functions.cpp | 4 +- tests/runtime_tests/source/functions.std.cpp | 2 +- tests/runtime_tests/source/gc.cpp | 2 +- tests/runtime_tests/source/large_integer.cpp | 2 +- tests/runtime_tests/source/lua_value.cpp | 2 +- tests/runtime_tests/source/operators.cpp | 2 +- tests/runtime_tests/source/overflow.cpp | 2 +- tests/runtime_tests/source/plain_types.cpp | 2 +- tests/runtime_tests/source/policies.cpp | 2 +- tests/runtime_tests/source/proxies.cpp | 2 +- tests/runtime_tests/source/sol_test.hpp | 2 +- tests/runtime_tests/source/state.cpp | 2 +- tests/runtime_tests/source/storage.cpp | 2 +- tests/runtime_tests/source/strings.cpp | 2 +- tests/runtime_tests/source/tables.checks.cpp | 2 +- tests/runtime_tests/source/tables.clear.cpp | 2 +- tests/runtime_tests/source/tables.cpp | 2 +- tests/runtime_tests/source/tables.enums.cpp | 2 +- .../runtime_tests/source/tables.indexing.cpp | 2 +- .../runtime_tests/source/tables.insertion.cpp | 2 +- .../runtime_tests/source/tables.traversal.cpp | 2 +- .../source/usertypes.auxiliary_keys.cpp | 2 +- .../runtime_tests/source/usertypes.basic.cpp | 2 +- .../source/usertypes.constructors.cpp | 2 +- tests/runtime_tests/source/usertypes.cpp | 2 +- .../source/usertypes.inheritance.cpp | 2 +- .../source/usertypes.inheritance.multi.cpp | 2 +- .../source/usertypes.member_variables.cpp | 2 +- .../source/usertypes.overload.cpp | 2 +- .../source/usertypes.properties.cpp | 2 +- .../source/usertypes.runtime.cpp | 2 +- .../runtime_tests/source/usertypes.unique.cpp | 4 +- .../source/usertypes.unregister.cpp | 2 +- tests/runtime_tests/source/utility.cpp | 2 +- tests/runtime_tests/source/variadics.cpp | 2 +- 460 files changed, 2468 insertions(+), 1476 deletions(-) create mode 100644 examples/.clang-format delete mode 100644 tests/header_tests/source/main.cpp rename tests/{header_tests => inclusion}/CMakeLists.txt (95%) rename tests/{header_tests => inclusion}/source/as_args.cpp (99%) rename tests/{header_tests => inclusion}/source/as_returns.cpp (99%) rename tests/{header_tests => inclusion}/source/base_traits.cpp (97%) rename tests/{header_tests => inclusion}/source/bind_traits.cpp (99%) rename tests/{header_tests => inclusion}/source/bytecode.cpp (97%) rename tests/{header_tests => inclusion}/source/call.cpp (99%) rename tests/{header_tests => inclusion}/source/compatibility.cpp (99%) rename tests/{header_tests => inclusion}/source/compatibility/compat-5.3.cpp (99%) rename tests/{header_tests => inclusion}/source/compatibility/lua_version.cpp (99%) rename tests/{header_tests => inclusion}/source/config.cpp (99%) rename tests/{header_tests => inclusion}/source/coroutine.cpp (99%) rename tests/{header_tests => inclusion}/source/debug.cpp (99%) rename tests/{header_tests => inclusion}/source/demangle.cpp (99%) rename tests/{header_tests => inclusion}/source/deprecate.cpp (99%) rename tests/{header_tests => inclusion}/source/ebco.cpp (97%) rename tests/{header_tests => inclusion}/source/environment.cpp (99%) rename tests/{header_tests => inclusion}/source/error.cpp (100%) rename tests/{header_tests => inclusion}/source/error_handler.cpp (99%) rename tests/{header_tests => inclusion}/source/forward.cpp (99%) rename tests/{header_tests => inclusion}/source/forward_detail.cpp (99%) rename tests/{header_tests => inclusion}/source/function.cpp (99%) rename tests/{header_tests => inclusion}/source/function_result.cpp (99%) rename tests/{header_tests => inclusion}/source/function_types.cpp (99%) rename tests/{header_tests => inclusion}/source/function_types_core.cpp (99%) rename tests/{header_tests => inclusion}/source/function_types_overloaded.cpp (99%) rename tests/{header_tests => inclusion}/source/function_types_stateful.cpp (99%) rename tests/{header_tests => inclusion}/source/function_types_stateless.cpp (99%) rename tests/{header_tests => inclusion}/source/function_types_templated.cpp (99%) rename tests/{header_tests => inclusion}/source/in_place.cpp (99%) rename tests/{header_tests => inclusion}/source/inheritance.cpp (99%) rename tests/{header_tests => inclusion}/source/load_result.cpp (99%) rename tests/{header_tests => inclusion}/source/lua_table.cpp (97%) rename tests/{header_tests => inclusion}/source/lua_value.cpp (97%) rename tests/{header_tests => inclusion}/source/make_reference.cpp (99%) rename tests/{header_tests => inclusion}/source/metatable.cpp (99%) rename tests/{header_tests => inclusion}/source/object.cpp (99%) rename tests/{header_tests => inclusion}/source/object_base.cpp (99%) rename tests/{header_tests => inclusion}/source/optional.cpp (99%) rename tests/{header_tests => inclusion}/source/optional_implementation.cpp (99%) rename tests/{header_tests => inclusion}/source/overload.cpp (99%) rename tests/{header_tests => inclusion}/source/packaged_coroutine.cpp (97%) rename tests/{header_tests => inclusion}/source/pairs_iterator.cpp (97%) rename tests/{header_tests => inclusion}/source/pointer_like.cpp (97%) rename tests/{header_tests => inclusion}/source/policies.cpp (99%) rename tests/{header_tests => inclusion}/source/property.cpp (99%) rename tests/{header_tests => inclusion}/source/protect.cpp (99%) rename tests/{header_tests => inclusion}/source/protected_function.cpp (99%) rename tests/{header_tests => inclusion}/source/protected_function_result.cpp (99%) rename tests/{header_tests => inclusion}/source/protected_handler.cpp (99%) rename tests/{header_tests => inclusion}/source/proxy.cpp (99%) rename tests/{header_tests => inclusion}/source/proxy_base.cpp (99%) rename tests/{header_tests => inclusion}/source/raii.cpp (99%) rename tests/{header_tests => inclusion}/source/reference.cpp (99%) rename tests/{header_tests => inclusion}/source/resolve.cpp (99%) rename tests/{header_tests => inclusion}/source/sol.cpp (99%) rename tests/{header_tests => inclusion}/source/sol_defines.hpp (97%) rename tests/{header_tests => inclusion}/source/stack.cpp (99%) rename tests/{header_tests => inclusion}/source/stack_check.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_check_get.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_check_get_qualified.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_check_get_unqualified.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_check_qualified.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_check_unqualified.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_core.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_field.cpp (99%) rename tests/{header_tests => inclusion}/source/stack_get.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_get_qualified.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_get_unqualified.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_guard.cpp (99%) rename tests/{header_tests => inclusion}/source/stack_iterator.cpp (99%) rename tests/{header_tests => inclusion}/source/stack_pop.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_probe.cpp (99%) rename tests/{header_tests => inclusion}/source/stack_proxy.cpp (99%) rename tests/{header_tests => inclusion}/source/stack_proxy_base.cpp (99%) rename tests/{header_tests => inclusion}/source/stack_push.cpp (97%) rename tests/{header_tests => inclusion}/source/stack_reference.cpp (99%) rename tests/{header_tests => inclusion}/source/state.cpp (100%) rename tests/{header_tests => inclusion}/source/state_handling.cpp (97%) rename tests/{header_tests => inclusion}/source/state_view.cpp (100%) rename tests/{header_tests => inclusion}/source/string_view.cpp (99%) rename tests/{header_tests => inclusion}/source/table.cpp (99%) rename tests/{header_tests => inclusion}/source/table_core.cpp (99%) rename tests/{header_tests => inclusion}/source/table_iterator.cpp (99%) rename tests/{header_tests => inclusion}/source/thread.cpp (97%) rename tests/{header_tests => inclusion}/source/tie.cpp (99%) rename tests/{header_tests => inclusion}/source/traits.cpp (99%) rename tests/{header_tests => inclusion}/source/trampoline.cpp (99%) rename tests/{header_tests => inclusion}/source/tuple.cpp (99%) rename tests/{header_tests => inclusion}/source/types.cpp (99%) rename tests/{header_tests => inclusion}/source/unicode.cpp (99%) rename tests/{header_tests => inclusion}/source/unique_usertype_traits.cpp (97%) rename tests/{header_tests => inclusion}/source/unsafe_function.cpp (99%) rename tests/{header_tests => inclusion}/source/unsafe_function_result.cpp (99%) rename tests/{header_tests => inclusion}/source/userdata.cpp (99%) rename tests/{header_tests => inclusion}/source/usertype.cpp (99%) rename tests/{header_tests => inclusion}/source/usertype_container.cpp (99%) rename tests/{header_tests => inclusion}/source/usertype_container_launch.cpp (99%) rename tests/{header_tests => inclusion}/source/usertype_core.cpp (99%) rename tests/{header_tests => inclusion}/source/usertype_proxy.cpp (99%) rename tests/{header_tests => inclusion}/source/usertype_storage.cpp (99%) rename tests/{header_tests => inclusion}/source/usertype_traits.cpp (99%) rename tests/{header_tests => inclusion}/source/variadic_args.cpp (99%) rename tests/{header_tests => inclusion}/source/variadic_results.cpp (99%) rename tests/{header_tests => inclusion}/source/version.cpp (97%) rename tests/{header_tests => inclusion}/source/wrapper.cpp (99%) delete mode 100644 tests/runtime_tests/source/abort_clean.cpp diff --git a/.clang-format b/.clang-format index 00287c34..cc98bcf3 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/.dockerignore b/.dockerignore index 66da40ea..c50cd66d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/.gitignore b/.gitignore index 62319697..5fb730e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -46,6 +46,10 @@ x86/ # VSCode .vscode/ +# scratch space +main.cpp +scratch/ + # CMake build/ build-sol2/ @@ -109,7 +113,6 @@ desktop.ini # Miscellaneous external/ -scratch/ vendor/ .idea/ cmake-build-debug/ diff --git a/.travis.yml b/.travis.yml index 0859e587..bc568d08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/CMakeLists.txt b/CMakeLists.txt index 07a5dc7b..30a3977b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3 +# # # # sol2 # # # Required minimum version statement cmake_minimum_required(VERSION 3.15.0) @@ -311,4 +311,11 @@ if (SOL2_IS_TOP_LEVEL AND (SOL2_DO_TESTS OR SOL2_DO_EXAMPLES)) message(STATUS "sol2 adding tests...") add_subdirectory(tests "${CMAKE_BINARY_DIR}/tests") endif() + + # # # Scratch Space + # # Scratch space for diagnosing bugs and other shenanigans + if (SOL2_SCRATCH) + message(STATUS "sol2 adding scratch space...") + add_subdirectory(scratch) + endif() endif() diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 54d776f2..9c219cea 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,6 +1,6 @@ # 🎉 Donators! ♥ 🎉 -Thank you to all patrons, donators and contributors who help keep sol3 amazing. +Thank you to all patrons, donators and contributors who help keep sol2 amazing. - Robert Salvet - Ορφέας Ζαφείρης - 2x Donations! @@ -12,7 +12,7 @@ Thank you to all patrons, donators and contributors who help keep sol3 amazing. # 🎉 Patrons! ♥ 🎉 -Beyond just a one-time donation, patrons make a continued commitment to help keep sol3 supported and bug-free. Thank you for your patronage! Here are the supporters that wanted to be featured as sol3 contributors. +Beyond just a one-time donation, patrons make a continued commitment to help keep sol2 supported and bug-free. Thank you for your patronage! Here are the supporters that wanted to be featured as sol2 contributors. - Joel Falcou - Michael Caisse @@ -22,6 +22,6 @@ Beyond just a one-time donation, patrons make a continued commitment to help kee # Company Patrons / Supporters # -Companies who sign up for a long-term support contract or patronage are listed here! They really push forward what's possible with sol3 (and the newer v3)! Please reach out to phdofthehouse@gmail.com if you are interested in a custom solution or a long-term support contract that goes beyond the current release's needs! +Companies who sign up for a long-term support contract or patronage are listed here! They really push forward what's possible with sol2 (and the newer v3)! Please reach out to phdofthehouse@gmail.com if you are interested in a custom solution or a long-term support contract that goes beyond the current release's needs! - Intrepid Control Systems [intrepidcs.com](https://www.intrepidcs.com/) diff --git a/Dockerfile b/Dockerfile index 34207a39..1d9925d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2017 Rapptz, ThePhD, and contributors diff --git a/README.md b/README.md index d0274c7c..05ca9e1d 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ You can find [donation and sponorship options here](https://github.com/ThePhD/.g # Features -- [Fastest in the land](http://sol2.readthedocs.io/en/latest/benchmarks.html) (see: sol3 bar in graph). +- [Fastest in the land](http://sol2.readthedocs.io/en/latest/benchmarks.html) (see: sol2 bar in graph). - Supports retrieval and setting of multiple types including: * `std::string`, `std::wstring`, `std::u16string` and `std::u32string` support (and for views). * understands and works with containers such as `std::map/unordered_map`, c-style arrays, vectors, non-standard custom containers and more. @@ -98,7 +98,7 @@ Please make sure you use the `-std=c++2a`, `-std=c++1z`, `-std=c++17` or better If you would like support for an older compiler (at the cost of some features), use the latest tagged sol2 branch. If you would like support for an even older compiler, feel free to contact me for a Custom Solution. -sol3 is checked by-hand for other platforms as well, including Android-based builds with GCC and iOS-based builds out of XCode with Apple-clang. It should work on both of these platforms, so long as you have the proper standards flags. If something doesn't work or you need special options, you may need to look into the different ways to support the project to have it done for you! +sol2 is checked by-hand for other platforms as well, including Android-based builds with GCC and iOS-based builds out of XCode with Apple-clang. It should work on both of these platforms, so long as you have the proper standards flags. If something doesn't work or you need special options, you may need to look into the different ways to support the project to have it done for you! @@ -141,7 +141,7 @@ ThePhD C++Now 2018 - Hudson Commons, Aspen Physics Center, Aspen, Colorado [Deck](https://github.com/ThePhD/sol2/blob/develop/docs/presentations/2018.05.10%20-%20ThePhD%20-%20Compile%20Fast%2C%20Run%20Faster%2C%20Scale%20Forever.pdf) -"Scripting at the Speed of Thought: Using Lua in C++ with sol3" +"Scripting at the Speed of Thought: Using Lua in C++ with sol2" ThePhD CppCon 2018 - 404 Keystone, Meydenbauer Center, Aspen, Colorado [Deck](https://github.com/ThePhD/sol2/blob/develop/docs/presentations/2018.09.28%20-%20ThePhD%20-%20Scripting%20at%20the%20Speed%20of%20Thought.pdf) diff --git a/appveyor.yml b/appveyor.yml index b852b6b0..8d027c5b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/Common/Core.cmake b/cmake/Modules/Common/Core.cmake index 7bead144..ed9d95ed 100644 --- a/cmake/Modules/Common/Core.cmake +++ b/cmake/Modules/Common/Core.cmake @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/FindKaguyaBuild.cmake b/cmake/Modules/FindKaguyaBuild.cmake index bcf10cae..0a6086a1 100644 --- a/cmake/Modules/FindKaguyaBuild.cmake +++ b/cmake/Modules/FindKaguyaBuild.cmake @@ -1,5 +1,5 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/FindLua/set_version_vars.cmake b/cmake/Modules/FindLua/set_version_vars.cmake index 0907212f..5df75acd 100644 --- a/cmake/Modules/FindLua/set_version_vars.cmake +++ b/cmake/Modules/FindLua/set_version_vars.cmake @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/FindLuaBridgeBuild.cmake b/cmake/Modules/FindLuaBridgeBuild.cmake index 10d155e5..7d3d92d0 100644 --- a/cmake/Modules/FindLuaBridgeBuild.cmake +++ b/cmake/Modules/FindLuaBridgeBuild.cmake @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/FindLuaBuild.cmake b/cmake/Modules/FindLuaBuild.cmake index 353a4c7b..42341271 100644 --- a/cmake/Modules/FindLuaBuild.cmake +++ b/cmake/Modules/FindLuaBuild.cmake @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/FindLuaBuild/LuaJIT.cmake b/cmake/Modules/FindLuaBuild/LuaJIT.cmake index 80598b80..557f29d6 100644 --- a/cmake/Modules/FindLuaBuild/LuaJIT.cmake +++ b/cmake/Modules/FindLuaBuild/LuaJIT.cmake @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/FindLuaBuild/LuaVanilla.cmake b/cmake/Modules/FindLuaBuild/LuaVanilla.cmake index 8ba8be52..a4186841 100644 --- a/cmake/Modules/FindLuaBuild/LuaVanilla.cmake +++ b/cmake/Modules/FindLuaBuild/LuaVanilla.cmake @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/FindLuwraBuild.cmake b/cmake/Modules/FindLuwraBuild.cmake index 6bb64149..d395f128 100644 --- a/cmake/Modules/FindLuwraBuild.cmake +++ b/cmake/Modules/FindLuwraBuild.cmake @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/FindSphinx.cmake b/cmake/Modules/FindSphinx.cmake index 6d3ae928..55d83c3b 100644 --- a/cmake/Modules/FindSphinx.cmake +++ b/cmake/Modules/FindSphinx.cmake @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/Modules/FindToLuappBuild.cmake b/cmake/Modules/FindToLuappBuild.cmake index fc6a8b7f..92247c3f 100644 --- a/cmake/Modules/FindToLuappBuild.cmake +++ b/cmake/Modules/FindToLuappBuild.cmake @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/cmake/sol2-config.cmake.in b/cmake/sol2-config.cmake.in index e36f3c5b..f9b6a110 100644 --- a/cmake/sol2-config.cmake.in +++ b/cmake/sol2-config.cmake.in @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/documentation/.clang-format b/documentation/.clang-format index 991a73da..a2c0dcaa 100644 --- a/documentation/.clang-format +++ b/documentation/.clang-format @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/documentation/CMakeLists.txt b/documentation/CMakeLists.txt index 91230e37..231b515a 100644 --- a/documentation/CMakeLists.txt +++ b/documentation/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3, documentation generation +# # # # sol2, documentation generation # # # Required minimum version statement cmake_minimum_required(VERSION 3.15.0) diff --git a/documentation/Doxyfile.in b/documentation/Doxyfile.in index 30a5d03f..1cfbc867 100644 --- a/documentation/Doxyfile.in +++ b/documentation/Doxyfile.in @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/documentation/source/api/c_call.rst b/documentation/source/api/c_call.rst index 505a8c32..95f7f608 100644 --- a/documentation/source/api/c_call.rst +++ b/documentation/source/api/c_call.rst @@ -17,7 +17,7 @@ The goal of ``sol::c_call<...>`` is to provide a way to wrap a function and tran This can also be placed into the argument list for a :doc:`usertype` as well. -This pushes a raw ``lua_CFunction`` into whatever you pass the resulting ``c_call`` function pointer into, whether it be a table or a userdata or whatever else using sol3's API. The resulting ``lua_CFunction`` can also be used directly with the lua API, just like many of sol3's types can be intermingled with Lua's API if you know what you're doing. +This pushes a raw ``lua_CFunction`` into whatever you pass the resulting ``c_call`` function pointer into, whether it be a table or a userdata or whatever else using sol2's API. The resulting ``lua_CFunction`` can also be used directly with the lua API, just like many of sol2's types can be intermingled with Lua's API if you know what you're doing. It is advisable for the user to consider making a macro to do the necessary ``decltype( &function_name, ), function_name``. sol does not provide one because many codebases already have `one similar to this`_. diff --git a/documentation/source/api/policies.rst b/documentation/source/api/policies.rst index c6d127d4..82ab1dc6 100644 --- a/documentation/source/api/policies.rst +++ b/documentation/source/api/policies.rst @@ -2,7 +2,7 @@ policies ======== *stack modification right before lua call returns* -``sol::policies`` is an advanced, low-level modification feature allowing you to take advantage of sol3's abstractions before applying your own stack-based modifications at the last moment. They cover the same functionality as `luabind's "return reference to" and "dependency"`_ types. A few pre-rolled policies are defined for your use: +``sol::policies`` is an advanced, low-level modification feature allowing you to take advantage of sol2's abstractions before applying your own stack-based modifications at the last moment. They cover the same functionality as `luabind's "return reference to" and "dependency"`_ types. A few pre-rolled policies are defined for your use: +------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | policy | usage | modification | diff --git a/documentation/source/api/proxy.rst b/documentation/source/api/proxy.rst index 2a520ee0..6112b0d0 100644 --- a/documentation/source/api/proxy.rst +++ b/documentation/source/api/proxy.rst @@ -171,5 +171,5 @@ on function objects and proxies .. note:: - As of recent versions of sol3 (2.18.2 and above), this is no longer an issue, as even bound classes will have any detectable function call operator automatically bound to the object, to allow this to work without having to use ``.set`` or ``.set_function``. The note here is kept for posterity and information for older versions. There are only some small caveats, see: :ref:`this note here`. + As of recent versions of sol2 (2.18.2 and above), this is no longer an issue, as even bound classes will have any detectable function call operator automatically bound to the object, to allow this to work without having to use ``.set`` or ``.set_function``. The note here is kept for posterity and information for older versions. There are only some small caveats, see: :ref:`this note here`. diff --git a/documentation/source/api/stack.rst b/documentation/source/api/stack.rst index 560bdf03..19e3a1a5 100644 --- a/documentation/source/api/stack.rst +++ b/documentation/source/api/stack.rst @@ -58,7 +58,7 @@ members template inline int call_lua(lua_State* L, int start, Fx&& fx, FxArgs&&... fxargs); -This function is helpful for when you bind to a raw C function but need sol's abstractions to save you the agony of setting up arguments and know how `calling C functions works`_. The ``start`` parameter tells the function where to start pulling arguments from. The parameter ``fx`` is what's supposed to be called. Extra arguments are passed to the function directly. There are intermediate versions of this (``sol::stack::call_into_lua`` and similar) for more advanced users, but they are not documented as they are subject to change to improve performance or adjust the API accordingly in later iterations of sol3. Use the more advanced versions at your own peril. +This function is helpful for when you bind to a raw C function but need sol's abstractions to save you the agony of setting up arguments and know how `calling C functions works`_. The ``start`` parameter tells the function where to start pulling arguments from. The parameter ``fx`` is what's supposed to be called. Extra arguments are passed to the function directly. There are intermediate versions of this (``sol::stack::call_into_lua`` and similar) for more advanced users, but they are not documented as they are subject to change to improve performance or adjust the API accordingly in later iterations of sol2. Use the more advanced versions at your own peril. .. code-block:: cpp :caption: function: get @@ -97,7 +97,7 @@ Checks if the object at ``index`` is of type ``T``. If it is not, it will call t template auto get_usertype( lua_State* L, int index, record& tracking ) -Directly attempts to rertieve the type ``T`` using sol3's usertype mechanisms. Similar to a regular ``get`` for a user-defined type. Useful when you need to access sol3's usertype getter mechanism while at the same time `providing your own customization`_. +Directly attempts to rertieve the type ``T`` using sol2's usertype mechanisms. Similar to a regular ``get`` for a user-defined type. Useful when you need to access sol2's usertype getter mechanism while at the same time `providing your own customization`_. .. code-block:: cpp :caption: function: check_usertype @@ -112,7 +112,7 @@ Directly attempts to rertieve the type ``T`` using sol3's usertype mechanisms. S template bool check_usertype( lua_State* L, int index, Handler&& handler, record& tracking ) -Checks if the object at ``index`` is of type ``T`` and stored as a sol3 usertype. Useful when you need to access sol3's usertype checker mechanism while at the same time `providing your own customization`_. +Checks if the object at ``index`` is of type ``T`` and stored as a sol2 usertype. Useful when you need to access sol2's usertype checker mechanism while at the same time `providing your own customization`_. .. code-block:: cpp :caption: function: check_get @@ -160,7 +160,7 @@ Based on how it is called, pushes a variable amount of objects onto the stack. i int multi_push_reference( lua_State* L, Args&&... args ) -These functinos behave similarly to the ones above, but they check for specific criteria and instead attempt to push a reference rather than forcing a copy if appropriate. Use cautiously as sol3 uses this mainly as a return from usertype functions and variables to preserve chaining/variable semantics from that a class object. Its internals are updated to fit the needs of sol3 and while it generally does the "right thing" and has not needed to be changed for a while, sol3 reserves the right to change its internal detection mechanisms to suit its users needs at any time, generally without breaking backwards compatibility and expectations but not exactly guaranteed. +These functinos behave similarly to the ones above, but they check for specific criteria and instead attempt to push a reference rather than forcing a copy if appropriate. Use cautiously as sol2 uses this mainly as a return from usertype functions and variables to preserve chaining/variable semantics from that a class object. Its internals are updated to fit the needs of sol2 and while it generally does the "right thing" and has not needed to be changed for a while, sol2 reserves the right to change its internal detection mechanisms to suit its users needs at any time, generally without breaking backwards compatibility and expectations but not exactly guaranteed. .. code-block:: cpp :caption: function: pop @@ -290,7 +290,7 @@ Note that you may } -This extension point is to ``check`` a foreign userdata. It should return ``true`` if a type meets some custom userdata specifiction (from, say, another library or an internal framework), and ``false`` if it does not. The default implementation just returns ``false`` to let the original sol3 handlers take care of everything. If you want to implement your own usertype checking; e.g., for messing with ``toLua`` or ``OOLua`` or ``kaguya`` or some other libraries. Note that the library must have a with a :doc:`memory compatible layout` if you **want to specialize this checker method but not the subsequent getter method**. You can specialize it as shown in the `interop examples`_. +This extension point is to ``check`` a foreign userdata. It should return ``true`` if a type meets some custom userdata specifiction (from, say, another library or an internal framework), and ``false`` if it does not. The default implementation just returns ``false`` to let the original sol2 handlers take care of everything. If you want to implement your own usertype checking; e.g., for messing with ``toLua`` or ``OOLua`` or ``kaguya`` or some other libraries. Note that the library must have a with a :doc:`memory compatible layout` if you **want to specialize this checker method but not the subsequent getter method**. You can specialize it as shown in the `interop examples`_. .. note:: @@ -303,14 +303,14 @@ This extension point is to ``check`` a foreign userdata. It should return ``true template std::pair sol_lua_interop_get(sol::types t, lua_State* L, int relindex, void* unadjusted_pointer, sol::stack::record& tracking) { - // implement custom getting here for non-sol3 userdatas: + // implement custom getting here for non-sol2 userdatas: // if it doesn't match, return "false" and regular // sol userdata getters will kick in return { false, nullptr }; } -This extension point is to ``get`` a foreign userdata. It should return both ``true`` and an adjusted pointer if a type meets some custom userdata specifiction (from, say, another library or an internal framework). The default implementation just returns ``{ false, nullptr }`` to let the default sol3 implementation take care of everything. You can use it to interop with other frameworks that are not sol3 but still include their power; e.g., for messing with ``kaguya`` or some other libraries. You can specialize it as shown in the `interop examples`_. +This extension point is to ``get`` a foreign userdata. It should return both ``true`` and an adjusted pointer if a type meets some custom userdata specifiction (from, say, another library or an internal framework). The default implementation just returns ``{ false, nullptr }`` to let the default sol2 implementation take care of everything. You can use it to interop with other frameworks that are not sol2 but still include their power; e.g., for messing with ``kaguya`` or some other libraries. You can specialize it as shown in the `interop examples`_. .. note:: @@ -319,7 +319,7 @@ This extension point is to ``get`` a foreign userdata. It should return both ``t .. note:: - You do NOT need to use this method in particular if the :doc:`memory layout` is compatible. (For example, ``toLua`` stores userdata in a sol3-compatible way.) + You do NOT need to use this method in particular if the :doc:`memory layout` is compatible. (For example, ``toLua`` stores userdata in a sol2-compatible way.) .. _lua_CFunction: http://www.Lua.org/manual/5.3/manual.html#lua_CFunction diff --git a/documentation/source/api/this_environment.rst b/documentation/source/api/this_environment.rst index de37a63d..9f0be657 100644 --- a/documentation/source/api/this_environment.rst +++ b/documentation/source/api/this_environment.rst @@ -3,7 +3,7 @@ this_environment *retrieving the environment of the calling function* -Sometimes in C++ it's useful to know where a Lua call is coming from and what :doc:`environment` it is from. The former is covered by Lua's Debug API, which is extensive and is not fully wrapped up by sol3. But, sol3 covers the latter in letting you get the environment of the calling script / function, if it has one. ``sol::this_environment`` is a *transparent argument* and does not need to be passed in Lua scripts or provided when using :doc:`sol::function`, similar to :doc:`sol::this_state`: +Sometimes in C++ it's useful to know where a Lua call is coming from and what :doc:`environment` it is from. The former is covered by Lua's Debug API, which is extensive and is not fully wrapped up by sol2. But, sol2 covers the latter in letting you get the environment of the calling script / function, if it has one. ``sol::this_environment`` is a *transparent argument* and does not need to be passed in Lua scripts or provided when using :doc:`sol::function`, similar to :doc:`sol::this_state`: .. code-block:: cpp :linenos: diff --git a/documentation/source/api/usertype.rst b/documentation/source/api/usertype.rst index 92d98dc7..01e60224 100644 --- a/documentation/source/api/usertype.rst +++ b/documentation/source/api/usertype.rst @@ -163,7 +163,7 @@ If you don't specify anything at all and the type is `destructible`_, then a des usertype automatic (automagic) meta functions +++++++++++++++++++++++++++++++++++++++++++++ -If you don't specify a ``sol::meta_function`` name (or equivalent string metamethod name) and the type ``T`` supports certain operations, sol3 will generate the following operations provided it can find a good default implementation: +If you don't specify a ``sol::meta_function`` name (or equivalent string metamethod name) and the type ``T`` supports certain operations, sol2 will generate the following operations provided it can find a good default implementation: * for ``to_string`` operations where ``std::ostream& operator<<( std::ostream&, const T& )``, ``obj.to_string()``, or ``to_string( const T& )`` (in the namespace) exists on the C++ type - a ``sol::meta_function::to_string`` operator will be generated @@ -229,7 +229,7 @@ Otherwise, the following is used to specify functions to bind on the specific us unregister ---------- -You can unlink and kill a usertype and its associated functionality by calling ``.unregister()`` on a ``sol::usertype`` or ``sol::metatable`` pointed at a proper sol3 metatable. This will entirely unlink and clean out sol3's internal lookup structures and key information. +You can unlink and kill a usertype and its associated functionality by calling ``.unregister()`` on a ``sol::usertype`` or ``sol::metatable`` pointed at a proper sol2 metatable. This will entirely unlink and clean out sol2's internal lookup structures and key information. runtime functions ----------------- diff --git a/documentation/source/api/usertype_memory.rst b/documentation/source/api/usertype_memory.rst index c6d21c47..532511e7 100644 --- a/documentation/source/api/usertype_memory.rst +++ b/documentation/source/api/usertype_memory.rst @@ -12,7 +12,7 @@ In general, we always insert a ``T*`` in the first ``sizeof(T*)`` bytes, so the .. warning:: - The layout of memory described below does **not** take into account alignment. sol3 now takes alignment into account and aligns memory, which is important for misbehaving allocators and types that do not align well to the size of a pointer on their system. If you need to obtain proper alignments for usertypes stored in userdata pointers, **please** use the detail functions named ``sol::detail::align_usertype_pointer``, ``sol::detail::align_usertype``, and ``sol::detail::align_usertype_unique``. This will shift a ``void*`` pointer by the appropriate amount to reach a certain section in memory. For almost all other use cases, please use ``void* memory = lua_touserdata(L, index);``, followed by ``memory = sol::detail::align_usertype_pointer( memory );`` to adjust the pointer to be at the right place. + The layout of memory described below does **not** take into account alignment. sol2 now takes alignment into account and aligns memory, which is important for misbehaving allocators and types that do not align well to the size of a pointer on their system. If you need to obtain proper alignments for usertypes stored in userdata pointers, **please** use the detail functions named ``sol::detail::align_usertype_pointer``, ``sol::detail::align_usertype``, and ``sol::detail::align_usertype_unique``. This will shift a ``void*`` pointer by the appropriate amount to reach a certain section in memory. For almost all other use cases, please use ``void* memory = lua_touserdata(L, index);``, followed by ``memory = sol::detail::align_usertype_pointer( memory );`` to adjust the pointer to be at the right place. .. warning:: @@ -23,7 +23,7 @@ In general, we always insert a ``T*`` in the first ``sizeof(T*)`` bytes, so the To retrieve a ``T`` ------------------- -If you want to retrieve a ``T*`` pointer to the data managed by a sol3 userdata and are not using sol3's abstractions to do it (e.g., messing with the plain Lua C API), simply use ``lua_touserdata`` to get the ``void*`` pointer. Then, execute a ``T* object_pointer = *static_cast(the_void_pointer);``. Every type pushed into C++ that is classified as a userdata (e.g., all user-defined objects that are not covered by the stack abstraction's basic types) can be retrieved in this format, whether they are values or pointers or ``unique_ptr``. The reasons for why this works is below. +If you want to retrieve a ``T*`` pointer to the data managed by a sol2 userdata and are not using sol2's abstractions to do it (e.g., messing with the plain Lua C API), simply use ``lua_touserdata`` to get the ``void*`` pointer. Then, execute a ``T* object_pointer = *static_cast(the_void_pointer);``. Every type pushed into C++ that is classified as a userdata (e.g., all user-defined objects that are not covered by the stack abstraction's basic types) can be retrieved in this format, whether they are values or pointers or ``unique_ptr``. The reasons for why this works is below. For ``T`` --------- diff --git a/documentation/source/benchmarks.rst b/documentation/source/benchmarks.rst index 7de43438..c4d24e85 100644 --- a/documentation/source/benchmarks.rst +++ b/documentation/source/benchmarks.rst @@ -8,7 +8,7 @@ Here are measurements of the *overhead that libraries impose around the Lua C AP These are some informal and formal benchmarks done by both the developers of sol and other library developers / users. We leave you to interpret the data as you see fit. -* `lua_binding_benchmarks`_ by satoren (developer of `kaguya`_) (`sol`_ is the "sol3" entry) +* `lua_binding_benchmarks`_ by satoren (developer of `kaguya`_) (`sol`_ is the "sol2" entry) * `lua-bindings-shootout`_ by ThePhD (developer of `sol`_) As of the writing of this documentation (May 17th, 2018), :doc:`sol` seems to take the cake in most categories for speed! Below are some graphs from `lua-bindings-shootout`_. You can read the benchmarking code there if you think something was done wrong, and submit a pull requests or comment on something to make sure that ThePhD is being honest about his work. All categories are the performance of things described at the top of the :doc:`feature table`. diff --git a/documentation/source/build.rst b/documentation/source/build.rst index b5be6077..712f1826 100644 --- a/documentation/source/build.rst +++ b/documentation/source/build.rst @@ -1,10 +1,10 @@ build ===== -sol3 is a header-only library. +sol2 is a header-only library. -sol3 comes with a CMake script in the top level. It is primarily made for building and running the examples and tests, but it includes exported and configured targets (``sol2``, ``sol2_single``) for your use. +sol2 comes with a CMake script in the top level. It is primarily made for building and running the examples and tests, but it includes exported and configured targets (``sol2``, ``sol2_single``) for your use. -sol3 also comes with a Meson Script. If things stop working, file a bug report. +sol2 also comes with a Meson Script. If things stop working, file a bug report. diff --git a/documentation/source/codecvt.rst b/documentation/source/codecvt.rst index 66f1966e..edd3d115 100644 --- a/documentation/source/codecvt.rst +++ b/documentation/source/codecvt.rst @@ -5,7 +5,7 @@ because this is surprisingly hard using standard C++ .. note:: - The ```` header is no longer used and sol3 now converts utf8, utf16, and utf32 with internal routines. If you have a problem with the transcoding, please `file an issue report`_. + The ```` header is no longer used and sol2 now converts utf8, utf16, and utf32 with internal routines. If you have a problem with the transcoding, please `file an issue report`_. ``std::(w)string(u16/u32)`` are assumed to be in the platform's native wide (for ``wstring``) or unicode format. Lua canonically stores its string literals as utf8 and embraces utf8, albeit its storage is simply a sequence of bytes that are also null-terminated (it is also counted and the size is kept around, so embedded nulls can be used in the string). Therefore, if you need to interact with the unicode or wide alternatives of strings, runtime conversions are performed from the (assumed) utf8 string data into other forms. These conversions check for well-formed UTF, and will replace ill-formed characters with the unicode replacement codepoint, 0xFFFD. diff --git a/documentation/source/compilation.rst b/documentation/source/compilation.rst index d7163e25..7b41db81 100644 --- a/documentation/source/compilation.rst +++ b/documentation/source/compilation.rst @@ -3,10 +3,46 @@ supported compilers, binary size, compile time getting good final product out of sol ------------------------------------- + + supported compilers ------------------- -GCC 7.x is now out alongside Visual Studio 2018. This means that `sol release v2.20.1`_ is the current version of the code targeted at the older compilers not listed below. Newer code will be targeted at working with the following compilers and leveraging their features, possibly taking advantage of whatever C++17 features are made available by the compilers and standard libraries bundled by-default with them. +Newer features will be targeted at the following compilers: + +* VC++ + - Visual Studio 2019, latest shipped compilers + - Visual Studio 2018, latest shipped compilers +* GCC (includes MinGW) + - v11.x + - v10.x + - v9.x + - v8.x + - v7.x +* Clang + - v11.x + - v10.x + - v9.x + - v8.x + - v7.x + - v6.x + - v5.x + - v4.x + - v3.9.x + +Note that Visual Studio's 2018 Community Edition is absolutely free now, and installs faster and easier than ever before. It also removes a lot of hacky work arounds and formally supports decltype SFINAE. + +MinGW's GCC version 7.x of the compiler fixes a long-standing derp in the ```` header that swapped the endianness of utf16 and utf32 strings. + +Clang 3.4, 3.5 and 3.6 have many bugs we have run into when developing sol3 and that have negatively impacted users for a long time now. + +We encourage all users to upgrade immediately. If you need old code for some reason, use `sol2 release v2.20.1`_: otherwise, always grab sol2's latest. + + +"I need older support" +++++++++++++++++++++++ + +GCC 7.x is now out alongside Visual Studio 2018. This means that `sol2 release v2.20.1`_ is the current version of the code targeted at the older compilers not listed above. Newer code will be targeted at C++17 and above. ``v2.20.1`` supports: @@ -26,36 +62,16 @@ GCC 7.x is now out alongside Visual Studio 2018. This means that `sol release v2 - v3.6.x - Note: this applies to XCode's Apple Clang as well, but that compiler packs its own deficiencies and problems as well -**This does not mean we are immediately abandoning older compilers.** We will update this page as relevant bugfixes are backported to the v2.x.x releases. Remember that sol3 is feature-complete: there is nothing more we can add to the library at this time with C++11/C++14 compiler support, so your code will be covered for a long time to come. +If you need someone to, explicitly, backport some functionality or feature from a newer version that you like, then you can reach out to `these folks here `_. -Newer features will be targeted at the following compilers: - -* VC++ - - Visual Studio vNext - - Visual Studio 2018 -* GCC (includes MinGW) - - v8.x - - v7.x -* Clang - - v7.x - - v6.x - - v5.x - - v4.x - - v3.9.x - -Note that Visual Studio's 2018 Community Edition is absolutely free now, and installs faster and easier than ever before. It also removes a lot of hacky work arounds and formally supports decltype SFINAE. - -MinGW's GCC version 7.x of the compiler fixes a long-standing derp in the header that swapped the endianness of utf16 and utf32 strings. - -Clang 3.4, 3.5 and 3.6 have many bugs we have run into when developing sol3 and that have negatively impacted users for a long time now. - -We encourage all users to upgrade immediately. If you need old code for some reason, use `sol release v2.20.1`_: otherwise, always grab sol3's latest. feature support --------------- -track future compiler and feature support in `this issue here`_. +We support C++17. We have optional support for ```` that is turned off by default for bad compilers like AppleClang with its missing implementation. + + supported Lua version --------------------- @@ -69,11 +85,14 @@ We support: * LuaJIT 2.1.x-beta3+ + binary sizes ------------ For individiauls who use :doc:`usertypes` a lot, they can find their compilation times increase. This is due to C++11 and C++14 not having very good facilities for handling template parameters and variadic template parameters. There are a few things in cutting-edge C++17 and C++Next that sol can use, but the problem is many people cannot work with the latest and greatest: therefore, we have to use older techniques that result in a fair amount of redundant function specializations that can be subject to the pickiness of the compiler's inlining and other such techniques. + + compile speed improvemements ---------------------------- @@ -87,6 +106,7 @@ Here are some notes on achieving better compile times without sacrificing too mu * For people who already have a tool that retrieves function signatures and arguments, it might be in your best interest to hook into that tool or generator and dump out the information once using sol3's lower-level abstractions. An `issue describing preliminary steps can be found here`_. + next steps ---------- @@ -95,6 +115,5 @@ The next step for sol from a developer standpoint is to formally make the librar Hopefully, as things progress, we move things forward. -.. _sol release v2.20.1: https://github.com/ThePhD/sol2/releases/tag/v2.20.1 +.. _sol2 release v2.20.1: https://github.com/ThePhD/sol2/releases/tag/v2.20.1 .. _issue describing preliminary steps can be found here: https://github.com/ThePhD/sol2/issues/436#issuecomment-312021508 -.. _this issue here: https://github.com/ThePhD/sol2/issues/426 diff --git a/documentation/source/containers.rst b/documentation/source/containers.rst index 3ecae579..f5d6d6fa 100644 --- a/documentation/source/containers.rst +++ b/documentation/source/containers.rst @@ -1,8 +1,8 @@ containers ========== -*working with containers in sol3* +*working with containers in sol2* -Containers are objects that are meant to be inspected and iterated and whose job is to typically provide storage to a collection of items. The standard library has several containers of varying types, and all of them have ``begin()`` and ``end()`` methods which return iterators. C-style arrays are also containers, and sol3 will detect all of them for use and bestow upon them special properties and functions. +Containers are objects that are meant to be inspected and iterated and whose job is to typically provide storage to a collection of items. The standard library has several containers of varying types, and all of them have ``begin()`` and ``end()`` methods which return iterators. C-style arrays are also containers, and sol2 will detect all of them for use and bestow upon them special properties and functions. * Containers from C++ are stored as ``userdata`` with special ``usertype`` metatables with :ref:`special operations` - In Lua 5.1, this means containers pushed without wrappers like :doc:`as_table` and :doc:`nested` will not work with ``pairs`` or other built-in iteration functions from Lua @@ -28,7 +28,7 @@ Containers are objects that are meant to be inspected and iterated and whose job container detection ------------------- -containers are detected by the type trait ``sol::is_container``. If that turns out to be true, sol3 will attempt to push a userdata into Lua for the specified type ``T``, and bestow it with some of the functions and properties listed below. These functions and properties are provided by a template struct ``sol::usertype_container``, which has a number of static Lua C functions bound to a safety metatable. If you want to override the behavior for a specific container, you must first specialize ``sol::is_container`` to drive from ``std::true_type``, then override the functions you want to change. Any function you do not override will call the default implementation or equivalent. The default implementation for unrecognized containers is simply errors. +containers are detected by the type trait ``sol::is_container``. If that turns out to be true, sol2 will attempt to push a userdata into Lua for the specified type ``T``, and bestow it with some of the functions and properties listed below. These functions and properties are provided by a template struct ``sol::usertype_container``, which has a number of static Lua C functions bound to a safety metatable. If you want to override the behavior for a specific container, you must first specialize ``sol::is_container`` to drive from ``std::true_type``, then override the functions you want to change. Any function you do not override will call the default implementation or equivalent. The default implementation for unrecognized containers is simply errors. You can also specialize ``sol::is_container`` to turn off container detection, if you find it too eager for a type that just happens to have ``begin`` and ``end`` functions, like so: @@ -95,7 +95,7 @@ The various operations provided by ``usertype_container`` are expected to be container classifications ------------------------- -When you push a container into sol3, the default container handler deals with the containers by inspecting various properties, functions, and type definitions on them. Here are the broad implications of containers sol3's defaults will recognize, and which already-known containers fall into their categories: +When you push a container into sol2, the default container handler deals with the containers by inspecting various properties, functions, and type definitions on them. Here are the broad implications of containers sol2's defaults will recognize, and which already-known containers fall into their categories: +------------------------+----------------------------------------+-------------------------+-----------------------------------------------------------------------------------------------+ | container type | requirements | known containers | notes/caveats | diff --git a/documentation/source/errors.rst b/documentation/source/errors.rst index e05f1736..93db5ca0 100644 --- a/documentation/source/errors.rst +++ b/documentation/source/errors.rst @@ -64,7 +64,7 @@ Linker Errors There are lots of reasons for compiler linker errors. A common one is not knowing that you've compiled the Lua library as C++: when building with C++, it is important to note that every typical (static or dynamic) library expects the C calling convention to be used and that sol includes the code using ``extern 'C'`` where applicable. -However, when the target Lua library is compiled with C++, one must change the calling convention and name mangling scheme by getting rid of the ``extern 'C'`` block. This can be achieved by adding ``#define SOL_USING_CXX_LUA`` before including sol3, or by adding it to your compilation's command line. If you build LuaJIT in C++ mode (how you would even, is beyond me), then you need to ``#define SOL_USING_CXX_LUAJIT`` as well. Typically, there is never a need to use this last one. +However, when the target Lua library is compiled with C++, one must change the calling convention and name mangling scheme by getting rid of the ``extern 'C'`` block. This can be achieved by adding ``#define SOL_USING_CXX_LUA`` before including sol2, or by adding it to your compilation's command line. If you build LuaJIT in C++ mode (how you would even, is beyond me), then you need to ``#define SOL_USING_CXX_LUAJIT`` as well. Typically, there is never a need to use this last one. Note that you should not be defining these with standard builds of either Lua or LuaJIT. See the :ref:`config page` for more details. @@ -73,7 +73,7 @@ Note that you should not be defining these with standard builds of either Lua or Sometimes, you expect properly written errors and instead receive an error about catching a ``...`` exception instead. This might mean that you either built Lua as C++ or are using a framework like LuaJIT that has full interopability support for exceptions on certain system types (x64 for LuaJIT 2.0.5, x86 and x64 on LuaJIT 2.1.x-beta and later). -Please make sure to use the ``SOL_EXCEPTIONS_SAFE_PROPAGATION`` define before including sol3 to make this work out. You can read more :ref:`at the exception page here`. +Please make sure to use the ``SOL_EXCEPTIONS_SAFE_PROPAGATION`` define before including sol2 to make this work out. You can read more :ref:`at the exception page here`. Catch and CRASH! ---------------- @@ -82,7 +82,7 @@ By default, sol will add a ``default_at_panic`` handler to states opened by sol It is preferred if you catch an error that you log what happened, terminate the Lua VM as soon as possible, and then crash if your application cannot handle spinning up a new Lua state. Catching can be done, but you should understand the risks of what you're doing when you do it. For more information about catching exceptions, the potentials, not turning off exceptions and other tricks and caveats, read about :doc:`exceptions in sol here`. -Lua is a C API first and foremost: exceptions bubbling out of it is essentially last-ditch, terminal behavior that the VM does not expect. You can see an example of handling a panic on the exceptions page :ref:`here`. This means that setting up a ``try { ... } catch (...) {}`` around an unprotected sol3 function or script call is **NOT** enough to keep the VM in a clean state. Lua does not understand exceptions and throwing them results in undefined behavior if they bubble through the C API once and then the state is used again. Please catch, and crash. +Lua is a C API first and foremost: exceptions bubbling out of it is essentially last-ditch, terminal behavior that the VM does not expect. You can see an example of handling a panic on the exceptions page :ref:`here`. This means that setting up a ``try { ... } catch (...) {}`` around an unprotected sol2 function or script call is **NOT** enough to keep the VM in a clean state. Lua does not understand exceptions and throwing them results in undefined behavior if they bubble through the C API once and then the state is used again. Please catch, and crash. Furthermore, it would be a great idea for you to use the safety features talked about :doc:`safety section`, especially for those related to functions. @@ -103,7 +103,7 @@ By default, :doc:`sol::function` assumes the code ran just fine an Protected Functions Are Not Catch All ------------------------------------- -Sometimes, some scripts load poorly. Even if you protect the function call, the actual file loading or file execution will be bad, in which case :doc:`sol::protected_function` will not save you. Make sure you register your own panic handler so you can catch errors, or follow the advice of the catch + crash behavior above. Remember that you can also bind your own functions and forego sol3's built-in protections for you own by binding a :ref:`raw lua_CFunction function` +Sometimes, some scripts load poorly. Even if you protect the function call, the actual file loading or file execution will be bad, in which case :doc:`sol::protected_function` will not save you. Make sure you register your own panic handler so you can catch errors, or follow the advice of the catch + crash behavior above. Remember that you can also bind your own functions and forego sol2's built-in protections for you own by binding a :ref:`raw lua_CFunction function` Iteration --------- diff --git a/documentation/source/exceptions.rst b/documentation/source/exceptions.rst index 35a018a3..143d1104 100644 --- a/documentation/source/exceptions.rst +++ b/documentation/source/exceptions.rst @@ -32,7 +32,7 @@ Lua comes with two kind of built-in handlers that sol provides easy opt-ins for. :linenos: -The other handler is specific to sol3. If you open a ``sol::state``, or open the default state handlers for your ``lua_State*`` (see :ref:`sol::state's automatic handlers` for more details), there is a ``sol::exception_handler_function`` type. It allows you to register a function in the event that an exception happens that bubbles out of your functions. The function requires that you push 1 item onto the stack that will be used with a call to `lua_error`_ +The other handler is specific to sol2. If you open a ``sol::state``, or open the default state handlers for your ``lua_State*`` (see :ref:`sol::state's automatic handlers` for more details), there is a ``sol::exception_handler_function`` type. It allows you to register a function in the event that an exception happens that bubbles out of your functions. The function requires that you push 1 item onto the stack that will be used with a call to `lua_error`_ .. literalinclude:: ../../examples/source/exception_handler.cpp :caption: exception handling diff --git a/documentation/source/features.rst b/documentation/source/features.rst index 88074e0f..c918cca2 100644 --- a/documentation/source/features.rst +++ b/documentation/source/features.rst @@ -92,7 +92,7 @@ Explanations for a few categories are below (rest are self-explanatory). * environments: an abstraction for getting, setting and manipulating an environment, using table techniques, functions or otherwise. Typically for the purposes of sandboxing +---------------------------+-------------+------------+----------+---------+----------+-----------+-----------+----------------+----------+----------+-----------+-----------------+--------+ -| | plain C | luawrapper | lua-intf | luabind | Selene | Sol3 | oolua | lua-api-pp | kaguya | SLB3 | SWIG | luacppinterface | luwra | +| | plain C | luawrapper | lua-intf | luabind | Selene | sol2 | oolua | lua-api-pp | kaguya | SLB3 | SWIG | luacppinterface | luwra | | | | | | | | | | | | | | | | +===========================+=============+============+==========+=========+==========+===========+===========+================+==========+==========+===========+=================+========+ | optional | ~ | ✗ | ✔ | ✗ | ✗ | ✔ | ✗ | ✗ | ✔ | ✗ | ✗ | ✗ | ✗ | diff --git a/documentation/source/functions.rst b/documentation/source/functions.rst index ea81fd27..762d4081 100644 --- a/documentation/source/functions.rst +++ b/documentation/source/functions.rst @@ -1,13 +1,13 @@ functions ========= -*working with functions in sol3* +*working with functions in sol2* -There are a number of examples dealing with functions and how they can be bound to sol3: +There are a number of examples dealing with functions and how they can be bound to sol2: * For a quicker walkthrough that demonstrates almost everything, see `the examples`_ and the :doc:`the quick and dirty tutorial` * For a full explanation, :doc:`read the tutorial` and consult the subjects below -* If you have bindings and set-ups that want to leverage the C API without sol3's interference, you can push a raw function, which has certain implications (noted :ref:`below`) +* If you have bindings and set-ups that want to leverage the C API without sol2's interference, you can push a raw function, which has certain implications (noted :ref:`below`) * Return multiple values into Lua by: - returning a ``std::tuple`` - using :doc:`sol::variadic_results` @@ -51,7 +51,7 @@ Furthermore, it is important to know that lambdas without a specified return typ exception safety/handling ------------------------- -All functions bound to sol3 set up an exception trampoline around the function (unless you are working with a :ref:`raw lua_CFunction you pushed yourself`). :doc:`protected_function` also has an error handler member and an exception trampoline around its internals, but it is not guaranteed safe if an exception bubbles outside of it. Catching that exception is not safe either: if an exception has exploded out from the sol3 API somehow, you must assume the VM is in some indeterminate and/or busted state. +All functions bound to sol2 set up an exception trampoline around the function (unless you are working with a :ref:`raw lua_CFunction you pushed yourself`). :doc:`protected_function` also has an error handler member and an exception trampoline around its internals, but it is not guaranteed safe if an exception bubbles outside of it. Catching that exception is not safe either: if an exception has exploded out from the sol2 API somehow, you must assume the VM is in some indeterminate and/or busted state. Please read the :doc:`error page` and :doc:`exception page` for more details about what to do with exceptions that explode out from the API. @@ -63,18 +63,18 @@ functions and argument passing All arguments are forwarded. Unlike :doc:`get/set/operator[] on sol::state` or :doc:`sol::table`, value semantics are not used here. It is forwarding reference semantics, which do not copy/move unless it is specifically done by the receiving functions / specifically done by the user. -You can change this behavior by defining ``SOL_FUNCTION_CALL_VALUE_SEMANTICS``, as defined in the :doc:`safety configuration page`. You can also change it for specific types using the ``sol::is_value_semantic_for_function`` template and _partially specializing_ it to make either ``std::true_type``, ``std::false_type``, or equivalent ``true``/``false`` functionality. +You can change this behavior by defining ``SOL_FUNCTION_CALL_VALUE_SEMANTICS``, as defined in the :doc:`safety configuration page`. You can also change it for specific types using the ``sol::is_value_semantic_for_function`` template and *partially specializing* it to make either ``std::true_type``, ``std::false_type``, or equivalent ``true``/``false`` functionality. .. note:: This also means that you should pass and receive arguments in certain ways to maximize efficiency. For example, ``sol::table``, ``sol::object``, ``sol::userdata`` and friends are cheap to copy, and should simply by taken as values. This includes primitive types like ``int`` and ``double``. However, C++ types -- if you do not want copies -- should be taken as ``const type&`` or ``type&``, to save on copies if it's important. Note that taking references from Lua also means you can modify the data inside of Lua directly, so be careful. Lua by default deals with things mostly by reference (save for primitive types). -When you bind a function to Lua, please take any pointer arguments as ``T*``, unless you specifically know you are going to match the exact type of the unique/shared pointer and the class it wraps. sol3 cannot support "implicit wrapped pointer casting", such as taking a ``std::shared_ptr`` when the function is passed a ``std::shared_ptr``. Sometimes it may work because the compiler might be able to line up your classes in such a way that raw casts work, but this is undefined behavior through and through and sol3 has no mechanisms by which it can make this safe and not blow up in the user's face. +When you bind a function to Lua, please take any pointer arguments as ``T*``, unless you specifically know you are going to match the exact type of the unique/shared pointer and the class it wraps. sol2 cannot support "implicit wrapped pointer casting", such as taking a ``std::shared_ptr`` when the function is passed a ``std::shared_ptr``. Sometimes it may work because the compiler might be able to line up your classes in such a way that raw casts work, but this is undefined behavior through and through and sol2 has no mechanisms by which it can make this safe and not blow up in the user's face. .. note:: - Please avoid taking special unique_usertype arguments, by either reference or value. In many cases, by-value does not work (e.g., with ``std::unique_ptr``) because many types are move-only and Lua has no concept of "move" semantics. By-reference is dangerous because sol3 will hand you a reference to the original data: but, any pointers stored in Lua can be invalidated if you call ``.reset()`` or similar on the core pointer. Please take a pointer (``T*``) if you anticipate ``nil``/``nullptr`` being passed to your function, or a reference (``const T&`` or ``T&``) if you do not. As a side note, if you write a small wrapping class that holds a base pointer type, and interact using the wrapper, then when you get the wrapper as an argument in a C++-function bound to Lua you can cast the internal object freely. It is simply a direct cast as an argument to a function that is the problem. + Please avoid taking special unique_usertype arguments, by either reference or value. In many cases, by-value does not work (e.g., with ``std::unique_ptr``) because many types are move-only and Lua has no concept of "move" semantics. By-reference is dangerous because sol2 will hand you a reference to the original data: but, any pointers stored in Lua can be invalidated if you call ``.reset()`` or similar on the core pointer. Please take a pointer (``T*``) if you anticipate ``nil``/``nullptr`` being passed to your function, or a reference (``const T&`` or ``T&``) if you do not. As a side note, if you write a small wrapping class that holds a base pointer type, and interact using the wrapper, then when you get the wrapper as an argument in a C++-function bound to Lua you can cast the internal object freely. It is simply a direct cast as an argument to a function that is the problem. .. note:: diff --git a/documentation/source/index.rst b/documentation/source/index.rst index 9da08081..0a241c6e 100644 --- a/documentation/source/index.rst +++ b/documentation/source/index.rst @@ -1,20 +1,16 @@ -.. sol documentation master file, created by - sphinx-quickstart on Mon Feb 29 21:49:51 2016. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - .. image:: media/sol.png :target: https://github.com/ThePhD/sol2 :alt: sol repository :align: center -sol |version| -============= +sol2 (sol2, version |version|) +============================== *a fast, simple C++ and Lua Binding* - When you need to hit the ground running with Lua and C++, `sol`_ is the go-to framework for high-performance binding with an easy to use API. + + get going: ---------- @@ -53,6 +49,8 @@ Come to the Github Issues! We've got a friendly community, and they can help you |gh| + + support ------- @@ -65,7 +63,8 @@ This is a time-consuming effort, so individuals who donate get to: - steer the direction and time spent on sol - get their name put up in the CONTRIBUTORS list -- put something of their choice on sol3's README or the documentation's front page +- put something of their choice on sol2's README or the documentation's front page + "I need feature X, maybe you have it?" @@ -73,6 +72,7 @@ This is a time-consuming effort, so individuals who donate get to: Take a look at the :doc:`Features` page: it links to much of the API. You can also just straight up browse the :doc:`api` or ease in with the :doc:`tutorials`. To know more about the implementation for usertypes, see :doc:`here` To know how function arguments are handled, see :ref:`this note`. Don't see a feature you want? Send inquiries for support for a particular abstraction to the `issues`_ tracker. + the basics: ----------- @@ -89,6 +89,8 @@ the basics: :linenos: + + Search ====== @@ -101,33 +103,38 @@ Search .. |pa| image:: media/become_a_patron_button.png :height: 50 :target: https://www.patreon.com/soasis - :alt: sol3 Patreon + :alt: sol2 Patreon :align: middle .. |kf| image:: media/Ko-fi_Blue.png :height: 50 :target: https://ko-fi.com/soasis - :alt: sol3 ko-fi + :alt: sol2 ko-fi :align: middle .. |lp| image:: media/liberapay_logo.png :height: 50 :target: https://liberapay.com/Soasis - :alt: sol3 ko-fi + :alt: sol2 ko-fi :align: middle .. |pp| image:: media/pp_cc_mark_111x69.jpg :height: 50 :target: https://www.paypal.me/Soasis - :alt: sol3 PayPal + :alt: sol2 PayPal :align: middle .. |gh| image:: media/github_logo.png :height: 75 :target: https://github.com/ThePhD/sol2/issues - :alt: sol3 Github Issues Page + :alt: sol2 Github Issues Page .. |gs| image:: media/github_sponsors_logo.png :height: 55 :target: https://github.com/users/ThePhD/sponsorship - :alt: sol3 Sponsors Page + :alt: sol2 Sponsors Page + +.. sol documentation master file, created by + sphinx-quickstart on Mon Feb 29 21:49:51 2016. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. diff --git a/documentation/source/mentions.rst b/documentation/source/mentions.rst index 03f1ba05..0cf3bcc1 100644 --- a/documentation/source/mentions.rst +++ b/documentation/source/mentions.rst @@ -4,9 +4,9 @@ mentions First off, feel free to `tell me about your uses!`_ -Okay, so the features don't convince you, the documentation doesn't convince you, you want to see what *other* people think about sol? Well, aside from the well-wishes that come through in the issue tracker, here's a few things floating around about sol3 that I occasionally get pinged about: +Okay, so the features don't convince you, the documentation doesn't convince you, you want to see what *other* people think about sol? Well, aside from the well-wishes that come through in the issue tracker, here's a few things floating around about sol2 that I occasionally get pinged about: -`eevee`_ demonstrating the sheer code reduction by using sol3: +`eevee`_ demonstrating the sheer code reduction by using sol2: .. |before| image:: media/eevee_code_before.jpg @@ -27,10 +27,10 @@ Okay, so the features don't convince you, the documentation doesn't convince you * For Sandboxing `Fun`_! * In `High Performance Computing research`_ - `Published research, too!`_ -* The `Multiple Arcade Machine Emulator (MAME)`_ project switched from using LuaBridge to sol3! +* The `Multiple Arcade Machine Emulator (MAME)`_ project switched from using LuaBridge to sol2! - `The pull request`_ in which it was introduced to the master branch. * For scripting, in `OpenMPT`_ -* (CppNow) sol3 was mentioned in a comparison to other scripting languages by ChaiScript developer, Jason Turner (@lefticus), at a conference! +* (CppNow) sol2 was mentioned in a comparison to other scripting languages by ChaiScript developer, Jason Turner (@lefticus), at a conference! - `Jason Turner's presentation`_ * (CppCast) Showed up in CppCast with Elias Daler! - `Elias Daler's blog`_ @@ -39,27 +39,27 @@ Okay, so the features don't convince you, the documentation doesn't convince you - `eevee's blog`_ * (Twitter) Twitter has some people that link it: - The image above, `tweeted out by eevee`_ - - Eevee: `"I heartily recommend sol3"`_ + - Eevee: `"I heartily recommend sol2"`_ - Elias Daler: `"sol2 is making usertypes in Lua so awesome <3"`_ - - Racod's Lair: `"from outdated LuaBridge to superior #sol3"`_ + - Racod's Lair: `"from outdated LuaBridge to superior #sol2"`_ * (Reddit) Posts on reddit about it! - `sol2's initial reddit release`_ - `Benchmarking Discussing`_ * Somehow landed on a Torque3D thread... - http://forums.torque3d.org/viewtopic.php?f=32&t=629&p=5246&sid=8e759990ab1ce38a48e896fc9fd62653#p5241 -Are you using sol3 for something neat? Want it to be featured here or think it's unfair that ThePhD hasn't found it yet? Well, drop an issue in the repo or send an e-mail! +Are you using sol2 for something neat? Want it to be featured here or think it's unfair that ThePhD hasn't found it yet? Well, drop an issue in the repo or send an e-mail! .. _tell me about your uses!: https://github.com/ThePhD/sol2/issues/189 .. _eevee: https://twitter.com/eevee .. _eevee's blog: https://eev.ee/dev/2016/08/07/weekly-roundup-three-big-things/ -.. _Fun: https://blog.rubenwardy.com/2020/07/26/sol3-script-sandbox/ +.. _Fun: https://blog.rubenwardy.com/2020/07/26/sol2-script-sandbox/ .. _Jason Turner's presentation: https://github.com/lefticus/presentations/blob/master/WhyAndHowToAddScripting.md .. _Elias Daler's blog: https://eliasdaler.github.io/cppcast#read-more .. _CppCast: http://cppcast.com/2016/07/elias-daler/ .. _tweeted out by eevee: https://twitter.com/eevee/status/762039984085798913 -.. _"I heartily recommend sol3": https://twitter.com/eevee/status/762040086540144644 -.. _"from outdated LuaBridge to superior #sol3": https://twitter.com/racodslair/status/754031870640267264 +.. _"I heartily recommend sol2": https://twitter.com/eevee/status/762040086540144644 +.. _"from outdated LuaBridge to superior #sol2": https://twitter.com/racodslair/status/754031870640267264 .. _"sol2 is making usertypes in Lua so awesome <3": https://twitter.com/EliasDaler/status/778708299029946368 .. _sol2's initial reddit release: https://www.reddit.com/r/cpp/comments/4a8gy7/sol2_lua_c_binding_framework/ .. _Benchmarking Discussing: https://www.reddit.com/r/cpp/comments/4x82hd/plain_c_versus_lua_libraries_benchmarking_speed/ diff --git a/documentation/source/origin.rst b/documentation/source/origin.rst index 34b8e674..6ccbf40f 100644 --- a/documentation/source/origin.rst +++ b/documentation/source/origin.rst @@ -13,7 +13,7 @@ And lo, `Danny Y., Rapptz`_ did stand firm in the sea and cast his hands to the seriously --------- -sol was originally started by many moon cycles ago to interop with Lua and C++, by `Rapptz`_. It was very successful and many rejoiced at having an easy to use abstraction on top of the Lua API. Rapptz continued to make a number of great projects and has been busy with other things, so upon seeing the repository grow stagnant and tired in the last very long while (over a year), `ThePhD`_ forked it into Sol3 and rebooted the code with the hopes of reaching the Milestone and the documentation you have today. +sol was originally started by many moon cycles ago to interop with Lua and C++, by `Rapptz`_. It was very successful and many rejoiced at having an easy to use abstraction on top of the Lua API. Rapptz continued to make a number of great projects and has been busy with other things, so upon seeing the repository grow stagnant and tired in the last very long while (over a year), `ThePhD`_ forked it into sol2 and rebooted the code with the hopes of reaching the Milestone and the documentation you have today. To get to the old repo, head over `here`_. diff --git a/documentation/source/safety.rst b/documentation/source/safety.rst index 82e30243..2f6f8b51 100644 --- a/documentation/source/safety.rst +++ b/documentation/source/safety.rst @@ -10,7 +10,7 @@ config Note that you can obtain safety with regards to functions you bind by using the :doc:`protect` wrapper around function/variable bindings you set into Lua. Additionally, you can have basic boolean checks when using the API by just converting to a :doc:`sol::optional\` when necessary for getting things out of Lua and for function arguments. -Also note that you can have your own states use sol3's safety panics and similar to protect your code from crashes. See :ref:`sol::state automatic handlers` for more details. +Also note that you can have your own states use sol2's safety panics and similar to protect your code from crashes. See :ref:`sol::state automatic handlers` for more details. .. _config-safety: @@ -69,7 +69,7 @@ Safety Config ``SOL_STRINGS_ARE_NUMBERS`` triggers the following changes: * Allows automatic to-string conversions for numbers - - ``lua_tolstring`` conversions are not permitted on numbers through sol3 by default: only actual strings are allowed + - ``lua_tolstring`` conversions are not permitted on numbers through sol2 by default: only actual strings are allowed - This is necessary to allow :doc:`sol::overload` to work properly * ``sol::stack::get`` and ``sol::stack::check_get`` will allow anything that Lua thinks is number-worthy to be number-worthy * This includes: integers, floating-point numbers, and strings @@ -179,7 +179,7 @@ Memory safety can be tricky. Lua is handled by a garbage-collected runtime, mean The usertype memory layout for all Lua-instantiated userdata and for all objects pushed/set into the Lua Runtime is also described :doc:`here`. Things before or after that specified memory slot is implementation-defined and no assumptions are to be made about it. -Please be wary of alignment issues. sol3 **aligns memory** by default. If you need to access underlying userdata memory from sol, please see the :doc:`usertype memory documentation` +Please be wary of alignment issues. sol2 **aligns memory** by default. If you need to access underlying userdata memory from sol, please see the :doc:`usertype memory documentation` functions --------- diff --git a/documentation/source/traits.rst b/documentation/source/traits.rst index ca1b5664..908df124 100644 --- a/documentation/source/traits.rst +++ b/documentation/source/traits.rst @@ -1,7 +1,7 @@ customization traits ==================== -These are customization points within the library to help you make sol3 work for the types in your framework and types. +These are customization points within the library to help you make sol2 work for the types in your framework and types. To learn more about various customizable traits, visit: diff --git a/documentation/source/tutorial/all-the-things.rst b/documentation/source/tutorial/all-the-things.rst index a22aae07..34a36190 100644 --- a/documentation/source/tutorial/all-the-things.rst +++ b/documentation/source/tutorial/all-the-things.rst @@ -9,24 +9,22 @@ These are all the things. Use your browser's search to find things you want. .. note:: - All of the code below is available at the `sol3 tutorial examples`_. + All of the code below is available at the `sol2 tutorial examples`_. .. note:: Make sure to add ``SOL_ALL_SAFETIES_ON`` preprocessor define to your build configuration to turn safety on. + + asserts / prerequisites ----------------------- You'll need to ``#include `` somewhere in your code. sol is header-only, so you don't need to compile anything. However, **Lua must be compiled and available**. See the :doc:`getting started tutorial` for more details. -The implementation for ``assert.hpp`` with ``c_assert`` looks like so: +Below, you will see use of a function called ``sol_c_assert``. This is an assert macro that comes with sol2 for the expression purpose of checking things; it's value is immaterial. -.. literalinclude:: ../../../include/sol/assert.hpp - :linenos: - :lines: 1-3, 19- -This is the assert used in the quick code below. opening a state --------------- @@ -35,17 +33,21 @@ opening a state :linenos: + + .. _sol-state-on-lua-state: -using sol3 on a lua_State\* +using sol2 on a lua_State\* --------------------------- -For your system/game that already has Lua or uses an in-house or pre-rolled Lua system (LuaBridge, kaguya, Luwra, etc.), but you'd still like sol3 and nice things: +For your system/game that already has Lua or uses an in-house or pre-rolled Lua system (LuaBridge, kaguya, Luwra, etc.), but you'd still like sol2 and nice things: .. literalinclude:: ../../../examples/source/tutorials/quick_n_dirty/opening_state_on_raw_lua.cpp :linenos: + + .. _running-lua-code: running lua code @@ -69,6 +71,7 @@ You can see more use of safety by employing the use of `.safe_script`_, which re If you have the safety definitions on, `.script` will call into the `.safe_script` versions automatically. Otherwise, it will call into the `.unsafe_script` versions. + running lua code (low-level) ---------------------------- @@ -81,11 +84,12 @@ You can use the individual load and function call operator to load, check, and t .. literalinclude:: ../../../examples/source/tutorials/quick_n_dirty/running_lua_code_low_level.cpp :linenos: - :lines: 1-10, 16-40, 47-49 + :lines: 1-10, 16-40, 46-48 You can also `develop custom loaders`_ that pull from things that are not strings or files. + passing arguments to scripts ---------------------------- @@ -95,6 +99,7 @@ Arguments to Lua scripts can be passed by first loading the file or script blob, :linenos: + transferring functions (dumping bytecode) ----------------------------------------- @@ -104,6 +109,7 @@ You can dump the bytecode of a function, which allows you to transfer it to anot :linenos: + set and get variables --------------------- @@ -144,6 +150,8 @@ You can erase things by setting it to ``nullptr`` or ``sol::lua_nil``. Note that if its a :doc:`userdata/usertype<../api/usertype>` for a C++ type, the destructor will run only when the garbage collector deems it appropriate to destroy the memory. If you are relying on the destructor being run when its set to ``sol::lua_nil``, you're probably committing a mistake. + + tables ------ @@ -159,6 +167,8 @@ If you're going deep, be safe: :linenos: :lines: 35- + + make tables ----------- @@ -179,6 +189,7 @@ You can put anything you want in tables as values or keys, including strings, nu Note that this idea that things can be nested is important and will help later when you get into :ref:`namespacing`. + functions --------- @@ -205,6 +216,7 @@ The lua code to call these things is: You can use ``sol::readonly( &some_class::variable )`` to make a variable readonly and error if someone tries to write to it. + self call --------- @@ -215,6 +227,7 @@ You can pass the ``self`` argument through C++ to emulate 'member function' call :lines: 1- + multiple returns from lua ------------------------- @@ -223,6 +236,7 @@ multiple returns from lua :lines: 1- + multiple returns to lua ----------------------- @@ -231,6 +245,7 @@ multiple returns to lua :lines: 1- + C++ classes from C++ -------------------- @@ -248,7 +263,7 @@ Is set as a :doc:`userdata + usertype<../api/usertype>`. .. literalinclude:: ../../../examples/source/tutorials/quick_n_dirty/userdata.cpp :linenos: - :lines: 1-57,97- + :lines: 1-60,101- ``std::unique_ptr``/``std::shared_ptr``'s reference counts / deleters will :doc:`be respected<../api/unique_usertype_traits>`. @@ -265,12 +280,14 @@ You can retrieve the userdata in the same way as everything else. Importantly, n :lines: 46- + C++ classes put into Lua ------------------------ See this :doc:`section here`. Also check out a `basic example`_, `special functions example`_ and `initializers example`_! There are many more examples that show off the usage of classes in C++, so please peruse them all carefully as it can be as simple or as complex as your needs are. + .. _namespacing: namespacing @@ -285,6 +302,8 @@ You can emulate namespacing by having a table and giving it the namespace names This technique can be used to register namespace-like functions and classes. It can be as deep as you want. Just make a table and name it appropriately, in either Lua script or using the equivalent sol code. As long as the table FIRST exists (e.g., make it using a script or with one of sol's methods or whatever you like), you can put anything you want specifically into that table using :doc:`sol::table's<../api/table>` abstractions. + + there is a LOT more ------------------- @@ -308,4 +327,4 @@ Some more things you can do/read about: .. _basic example: https://github.com/ThePhD/sol2/blob/develop/examples/source/usertype.cpp .. _special functions example: https://github.com/ThePhD/sol2/blob/develop/examples/source/usertype_special_functions.cpp .. _initializers example: https://github.com/ThePhD/sol2/blob/develop/examples/source/usertype_initializers.cpp -.. _sol3 tutorial examples: https://github.com/ThePhD/sol2/tree/develop/examples/source/tutorials/quick_n_dirty +.. _sol2 tutorial examples: https://github.com/ThePhD/sol2/tree/develop/examples/source/tutorials/quick_n_dirty diff --git a/documentation/source/tutorial/functions.rst b/documentation/source/tutorial/functions.rst index 6646bc1e..4abbbe28 100644 --- a/documentation/source/tutorial/functions.rst +++ b/documentation/source/tutorial/functions.rst @@ -55,13 +55,13 @@ Notice here that we bind two separate functions. What if we wanted to bind only This is useful for functions which can take multiple types and need to behave differently based on those types. You can set as many overloads as you want, and they can be of many different types. -..note:: +.. note:: - Binding functions with default parameters (``void func(int a = 1)``) does not magically bind multiple versions of the function to be called with the default parameters. You must instead use :doc:`sol::overload<../api/overload>` and bind the full version of the function, with lambdas or similar for the function calls one by one. + Binding functions with default parameters (``void func(int a = 1);``) does not magically bind multiple versions of the function to be called with the default parameters. You must instead use :doc:`sol::overload<../api/overload>` and bind the full version of the function, with lambdas or similar for the function calls one by one. -..note:: +.. note:: - please make sure to understand the :ref:`implications of binding a lambda/callable struct in the various ways` and what it means for your code! + please make sure to understand the :ref:`implications of binding a lambda/callable struct in the various ways ` and what it means for your code! Getting a function from Lua @@ -74,7 +74,7 @@ You can use them to retrieve callables from Lua and call the underlying function .. literalinclude:: ../../../examples/source/tutorials/reading_functions.cpp :language: cpp :linenos: - :caption: Retrieving a sol::(unsafe_/protected_)function + :caption: Retrieving a sol::(unsafe\ _/protected\ _)function :name: reading-functions .. note:: diff --git a/documentation/source/usertypes.rst b/documentation/source/usertypes.rst index 60336b50..12121fd1 100644 --- a/documentation/source/usertypes.rst +++ b/documentation/source/usertypes.rst @@ -1,7 +1,7 @@ usertypes ========= -Perhaps the most powerful feature of sol3, ``usertypes`` are the way sol3 and C++ communicate your classes to the Lua runtime and bind things between both tables and to specific blocks of C++ memory, allowing you to treat Lua userdata and other things like classes. +Perhaps the most powerful feature of sol2, ``usertypes`` are the way sol2 and C++ communicate your classes to the Lua runtime and bind things between both tables and to specific blocks of C++ memory, allowing you to treat Lua userdata and other things like classes. To learn more about usertypes, visit: @@ -45,14 +45,14 @@ Here are some other general advice and tips for understanding and dealing with u - Retrieve a plain ``T`` to get a copy - Return types and passing arguments to ``sol::function``-types use perfect forwarding and reference semantics, which means no copies happen unless you specify a value explicitly. See :ref:`this note for details` * You can set ``index`` and ``new_index`` freely on any usertype you like to override the default "if a key is missing, find it / set it here" functionality of a specific object of a usertype - - ``new_index`` and ``index`` will not be called if you try to manipulate the named usertype table directly. sol3's will be called to add that function to the usertype's function/variable lookup table + - ``new_index`` and ``index`` will not be called if you try to manipulate the named usertype table directly. sol2's will be called to add that function to the usertype's function/variable lookup table - ``new_index`` and ``index`` will be called if you attempt to call a key that does not exist on an actual userdata object (the C++ object) itself - If you made a usertype named ``test``, this means ``t = test()``, with ``t.hi = 54`` will call your function, but ``test.hi = function () print ("hi"); end`` will instead set the key ``hi`` to to lookup that function for all ``test`` types -* The first ``sizeof( void* )`` bytes is always a pointer to the typed C++ memory. What comes after is based on what you've pushed into the system according to :doc:`the memory specification for usertypes`. This is compatible with a number of systems other than just sol3, making it easy to interop with select other Lua systems. +* The first ``sizeof( void* )`` bytes is always a pointer to the typed C++ memory. What comes after is based on what you've pushed into the system according to :doc:`the memory specification for usertypes`. This is compatible with a number of systems other than just sol2, making it easy to interop with select other Lua systems. * Member methods, properties, variables and functions taking ``self&`` arguments modify data directly - Work on a copy by taking arguments or returning by value. - Do not use r-value references: they do not mean anything in Lua code. - - Move-only types can only be taken by reference: sol3 cannot know if/when to move a value (except when serializing with perfect forwarding *into* Lua, but not calling a C++ function from Lua) + - Move-only types can only be taken by reference: sol2 cannot know if/when to move a value (except when serializing with perfect forwarding *into* Lua, but not calling a C++ function from Lua) * The actual metatable associated with the usertype has a long name and is defined to be opaque by the sol implementation. * The actual metatable inner workings is opaque and defined by the sol implementation, and there are no internal docs because optimizations on the operations are applied based on heuristics we discover from performance testing the system. diff --git a/examples/.clang-format b/examples/.clang-format new file mode 100644 index 00000000..adf570ac --- /dev/null +++ b/examples/.clang-format @@ -0,0 +1,110 @@ +# # # # sol2 +# The MIT License (MIT) +# +# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- +BasedOnStyle: WebKit +IndentWidth: 5 +TabWidth: 5 +ContinuationIndentWidth: 5 +UseTab: ForIndentation + +# Namespaces +NamespaceIndentation: All +CompactNamespaces: true +FixNamespaceComments: true + +# Overall Alignment +ColumnLimit: 65 +AlignAfterOpenBracket: DontAlign # uses ContinuationIndentWidth for this instead +AccessModifierOffset: -5 # do not push public: or private: around +#AlignConsecutiveAssignments: true # affects more than what's expected: do not use +#AlignConsecutiveDeclarations: true # affects more than what's expected: do not use + +# Type Alignment +DerivePointerAlignment: false +PointerAlignment: Left +AlwaysBreakTemplateDeclarations: true +AlwaysBreakBeforeMultilineStrings: true + +# Comments +AlignTrailingComments: true +ReflowComments: true + +# Macros +AlignEscapedNewlines: Left +#IndentPPDirectives: None + +# Functions +AllowShortFunctionsOnASingleLine: None +AlwaysBreakAfterReturnType: None +BreakConstructorInitializers: BeforeComma +ConstructorInitializerIndentWidth: 0 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +BinPackArguments: false +BinPackParameters: true + +# Classes +BreakBeforeInheritanceComma: false + +# Braces +Cpp11BracedListStyle: false +BreakBeforeBraces: Custom +BraceWrapping: + AfterEnum: false + AfterStruct: false + AfterControlStatement: false + AfterClass: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + BeforeElse: true + BeforeCatch: true + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: true + +# Control Statements +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +IndentCaseLabels: false + +# Spaces +SpaceAfterCStyleCast: false +SpacesInCStyleCastParentheses: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +MaxEmptyLinesToKeep: 3 + +# OCD +SortUsingDeclarations: true +SortIncludes: false + +--- +Language: Cpp +Standard: Cpp11 diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b28d658c..72b02ebb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # sol3 Examples +# # # sol2 Examples if (SOL2_DYNAMIC_LOADING_EXAMPLES OR SOL2_DYNAMIC_LOADING_EXAMPLES_SINGLE OR SOL2_DYNAMIC_LOADING_EXAMPLES_SINGLE_GENERATED) # # require_from_dll example diff --git a/examples/customization/CMakeLists.txt b/examples/customization/CMakeLists.txt index 3b322d42..13cceb21 100644 --- a/examples/customization/CMakeLists.txt +++ b/examples/customization/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # sol3 Customization Examples +# # # sol2 Customization Examples function (MAKE_CUSTOMIZATION_EXAMPLE example_suffix target_sol) set(customization_example_name customization_to_table${example_suffix}) diff --git a/examples/customization/include/lua_zm_interop.hpp b/examples/customization/include/lua_zm_interop.hpp index 37384428..cec2c277 100644 --- a/examples/customization/include/lua_zm_interop.hpp +++ b/examples/customization/include/lua_zm_interop.hpp @@ -10,10 +10,14 @@ #include -bool sol_lua_check(sol::types, lua_State* L, int index, std::function handler, sol::stack::record& tracking); +bool sol_lua_check(sol::types, lua_State* L, int index, + std::function handler, + sol::stack::record& tracking); -zm::vec3 sol_lua_get(sol::types, lua_State* L, int index, sol::stack::record& tracking); +zm::vec3 sol_lua_get(sol::types, lua_State* L, + int index, sol::stack::record& tracking); -int sol_lua_push(sol::types, lua_State* L, const zm::vec3& v); +int sol_lua_push( + sol::types, lua_State* L, const zm::vec3& v); #endif // PROGRAM_LUA_ZM_INTEROP_HPP diff --git a/examples/customization/include/zm/vec3.hpp b/examples/customization/include/zm/vec3.hpp index ec253dfd..3cc7dd19 100644 --- a/examples/customization/include/zm/vec3.hpp +++ b/examples/customization/include/zm/vec3.hpp @@ -17,8 +17,10 @@ namespace zm { #pragma GCC diagnostic ignored "-Wpedantic" #elif defined(_MSC_VER) #pragma warning(push) -#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union -#pragma warning(disable : 4324) // structure was padded due to alignment specifier +#pragma warning(disable : 4201) // nonstandard extension used : + // nameless struct/union +#pragma warning(disable : 4324) // structure was padded due to + // alignment specifier #endif union { float elements[3]; @@ -46,7 +48,8 @@ namespace zm { vec3() : x(0), y(0), z(0) { } - vec3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { + vec3(float x_, float y_, float z_) + : x(x_), y(y_), z(z_) { } constexpr float* data() { @@ -61,7 +64,8 @@ namespace zm { return this->elements[i]; } - constexpr const float& operator[](std::size_t i) const { + constexpr const float& operator[]( + std::size_t i) const { return this->elements[i]; } }; diff --git a/examples/customization/source/lua_interop.cpp b/examples/customization/source/lua_interop.cpp index aa28ab06..75527183 100644 --- a/examples/customization/source/lua_interop.cpp +++ b/examples/customization/source/lua_interop.cpp @@ -6,5 +6,8 @@ #include void register_lua(sol::state& lua) { - lua.new_usertype("entity", "position", sol::property(&entity::get_position, &entity::set_position)); + lua.new_usertype("entity", + "position", + sol::property( + &entity::get_position, &entity::set_position)); } diff --git a/examples/customization/source/lua_zm_interop.cpp b/examples/customization/source/lua_zm_interop.cpp index 25a09fe0..02daf6bb 100644 --- a/examples/customization/source/lua_zm_interop.cpp +++ b/examples/customization/source/lua_zm_interop.cpp @@ -5,24 +5,31 @@ #define SOL_ALL_SAFETIES_ON 1 #include -bool sol_lua_check(sol::types, lua_State* L, int index, std::function handler, sol::stack::record& tracking) { +bool sol_lua_check(sol::types, lua_State* L, int index, + std::function handler, + sol::stack::record& tracking) { // use sol's method for checking // specifically for a table - return sol::stack::check(L, index, handler, tracking); + return sol::stack::check( + L, index, handler, tracking); } -zm::vec3 sol_lua_get(sol::types, lua_State* L, int index, sol::stack::record& tracking) { - sol::lua_table vec3table = sol::stack::get(L, index, tracking); +zm::vec3 sol_lua_get(sol::types, lua_State* L, + int index, sol::stack::record& tracking) { + sol::lua_table vec3table + = sol::stack::get(L, index, tracking); float x = vec3table["x"]; float y = vec3table["y"]; float z = vec3table["z"]; return zm::vec3 { x, y, z }; } -int sol_lua_push(sol::types, lua_State* L, const zm::vec3& v) { +int sol_lua_push( + sol::types, lua_State* L, const zm::vec3& v) { // create table sol::state_view lua(L); - sol::table vec3table = sol::table::create_with(L, "x", v.x, "y", v.y, "z", v.z); + sol::table vec3table = sol::table::create_with( + L, "x", v.x, "y", v.y, "z", v.z); // use base sol method to // push the table int amount = sol::stack::push(L, vec3table); diff --git a/examples/customization/source/main.cpp b/examples/customization/source/main.cpp index 6c6400c3..51ef2ee2 100644 --- a/examples/customization/source/main.cpp +++ b/examples/customization/source/main.cpp @@ -7,12 +7,14 @@ #include int main(int, char*[]) { - std::cout << "=== customization: vec3 as table ===" << std::endl; + std::cout << "=== customization: vec3 as table ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); - std::cout << "registering entities into Lua ..." << std::endl; + std::cout << "registering entities into Lua ..." + << std::endl; register_lua(lua); std::cout << "running script ..." << std::endl; @@ -29,7 +31,8 @@ print("new_pos", new_pos.x, new_pos.y, new_pos.z) sol::optional result = lua.safe_script(script); if (result.has_value()) { - std::cerr << "Something went horribly wrong: " << result.value().what() << std::endl; + std::cerr << "Something went horribly wrong: " + << result.value().what() << std::endl; } std::cout << "finishing ..." << std::endl; diff --git a/examples/interop/LuaBridge/CMakeLists.txt b/examples/interop/LuaBridge/CMakeLists.txt index e4117f18..54ad6bc6 100644 --- a/examples/interop/LuaBridge/CMakeLists.txt +++ b/examples/interop/LuaBridge/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # sol3 interop Examples - luabridge +# # # sol2 interop Examples - luabridge find_package(LuaBridgeBuild) diff --git a/examples/interop/LuaBridge/source/LuaBridge.cpp b/examples/interop/LuaBridge/source/LuaBridge.cpp index 5436f63b..f9092b3a 100644 --- a/examples/interop/LuaBridge/source/LuaBridge.cpp +++ b/examples/interop/LuaBridge/source/LuaBridge.cpp @@ -1,5 +1,6 @@ #define SOL_ALL_SAFETIES_ON 1 -#define SOL_ENABLE_INTEROP 1 // MUST be defined to use interop features +#define SOL_ENABLE_INTEROP \ + 1 // MUST be defined to use interop features #include #include @@ -28,7 +29,9 @@ private: }; template -inline bool sol_lua_interop_check(sol::types, lua_State* L, int relindex, sol::type index_type, Handler&& handler, sol::stack::record& tracking) { +inline bool sol_lua_interop_check(sol::types, lua_State* L, + int relindex, sol::type index_type, Handler&& handler, + sol::stack::record& tracking) { // just marking unused parameters for no compiler warnings (void)index_type; (void)handler; @@ -39,10 +42,17 @@ inline bool sol_lua_interop_check(sol::types, lua_State* L, int relindex, sol } template -inline std::pair sol_lua_interop_get(sol::types t, lua_State* L, int relindex, void* unadjusted_pointer, sol::stack::record& tracking) { +inline std::pair sol_lua_interop_get(sol::types t, + lua_State* L, int relindex, void* unadjusted_pointer, + sol::stack::record& tracking) { (void)unadjusted_pointer; int index = lua_absindex(L, relindex); - if (!sol_lua_interop_check(t, L, index, sol::type::userdata, sol::no_panic, tracking)) { + if (!sol_lua_interop_check(t, + L, + index, + sol::type::userdata, + sol::no_panic, + tracking)) { return { false, nullptr }; } T* corrected = luabridge::Userdata::get(L, index, true); @@ -53,15 +63,22 @@ void register_sol_stuff(lua_State* L) { // grab raw state and put into state_view // state_view is cheap to construct sol::state_view lua(L); - // bind and set up your things: everything is entirely self-contained + // bind and set up your things: everything is entirely + // self-contained lua["f"] = sol::overload( [](A& from_luabridge) { - std::cout << "calling 1-argument version with luabridge-created A { " << from_luabridge.value() << " }" << std::endl; + std::cout << "calling 1-argument version with " + "luabridge-created A { " + << from_luabridge.value() << " }" + << std::endl; sol_c_assert(from_luabridge.value() == 24); }, [](A& from_luabridge, int second_arg) { - std::cout << "calling 2-argument version with luabridge-created A { " << from_luabridge.value() << " } and integer argument of " << second_arg - << std::endl; + std::cout << "calling 2-argument version with " + "luabridge-created A { " + << from_luabridge.value() + << " } and integer argument of " + << second_arg << std::endl; sol_c_assert(from_luabridge.value() == 24); sol_c_assert(second_arg == 5); }); @@ -76,8 +93,11 @@ void check_with_sol(lua_State* L) { int main(int, char*[]) { - std::cout << "=== interop example (LuaBridge) ===" << std::endl; - std::cout << "code modified from LuaBridge's examples: https://github.com/vinniefalco/LuaBridge" << std::endl; + std::cout << "=== interop example (LuaBridge) ===" + << std::endl; + std::cout << "code modified from LuaBridge's examples: " + "https://github.com/vinniefalco/LuaBridge" + << std::endl; struct closer { void operator()(lua_State* L) { diff --git a/examples/interop/kaguya/CMakeLists.txt b/examples/interop/kaguya/CMakeLists.txt index 2f710701..ce4f2015 100644 --- a/examples/interop/kaguya/CMakeLists.txt +++ b/examples/interop/kaguya/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # sol3 interop Examples - kaguya +# # # sol2 interop Examples - kaguya find_package(KaguyaBuild) diff --git a/examples/interop/kaguya/source/kaguya.cpp b/examples/interop/kaguya/source/kaguya.cpp index a2c87475..ff3ffb27 100644 --- a/examples/interop/kaguya/source/kaguya.cpp +++ b/examples/interop/kaguya/source/kaguya.cpp @@ -1,5 +1,6 @@ #define SOL_ALL_SAFETIES_ON 1 -#define SOL_ENABLE_INTEROP 1 // MUST be defined to use interop features +#define SOL_ENABLE_INTEROP \ + 1 // MUST be defined to use interop features #include #include @@ -8,8 +9,8 @@ // written by satoren: // https://github.com/satoren/kaguya // Copyright satoren -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) struct ABC { @@ -35,34 +36,41 @@ private: }; template -inline bool sol_lua_interop_check(sol::types, lua_State* L, int relindex, sol::type index_type, Handler&& handler, sol::stack::record& tracking) { +inline bool sol_lua_interop_check(sol::types, lua_State* L, + int relindex, sol::type index_type, Handler&& handler, + sol::stack::record& tracking) { // just marking unused parameters for no compiler warnings (void)index_type; (void)handler; // using 1 element tracking.use(1); int index = lua_absindex(L, relindex); - // use kaguya's own detail wrapper check to see if it's correct - bool is_correct_type = kaguya::detail::object_wrapper_type_check(L, index); + // use kaguya's own detail wrapper check to see if it's + // correct + bool is_correct_type + = kaguya::detail::object_wrapper_type_check(L, index); return is_correct_type; } template -inline std::pair sol_lua_interop_get(sol::types, lua_State* L, int relindex, void* unadjusted_pointer, sol::stack::record& tracking) { +inline std::pair sol_lua_interop_get(sol::types, + lua_State* L, int relindex, void* unadjusted_pointer, + sol::stack::record& tracking) { // you may not need to specialize this method every time: // some libraries are compatible with sol2's layout // kaguya's storage of data is incompatible with sol's - // it stores the data directly in the pointer, not a pointer inside of the `void*` - // therefore, leave the raw userdata pointer as-is, - // if it's of the right type + // it stores the data directly in the pointer, not a pointer + // inside of the `void*` therefore, leave the raw userdata + // pointer as-is, if it's of the right type int index = lua_absindex(L, relindex); if (!kaguya::detail::object_wrapper_type_check(L, index)) { return { false, nullptr }; } // using 1 element tracking.use(1); - kaguya::ObjectWrapperBase* base = kaguya::object_wrapper(L, index); + kaguya::ObjectWrapperBase* base + = kaguya::object_wrapper(L, index); return { true, static_cast(base->get()) }; } @@ -70,15 +78,22 @@ void register_sol_stuff(lua_State* L) { // grab raw state and put into state_view // state_view is cheap to construct sol::state_view lua(L); - // bind and set up your things: everything is entirely self-contained + // bind and set up your things: everything is entirely + // self-contained lua["f"] = sol::overload( [](ABC& from_kaguya) { - std::cout << "calling 1-argument version with kaguya-created ABC { " << from_kaguya.value() << " }" << std::endl; + std::cout << "calling 1-argument version with " + "kaguya-created ABC { " + << from_kaguya.value() << " }" + << std::endl; sol_c_assert(from_kaguya.value() == 24); }, [](ABC& from_kaguya, int second_arg) { - std::cout << "calling 2-argument version with kaguya-created ABC { " << from_kaguya.value() << " } and integer argument of " << second_arg - << std::endl; + std::cout << "calling 2-argument version with " + "kaguya-created ABC { " + << from_kaguya.value() + << " } and integer argument of " + << second_arg << std::endl; sol_c_assert(from_kaguya.value() == 24); sol_c_assert(second_arg == 5); }); @@ -93,17 +108,23 @@ void check_with_sol(lua_State* L) { int main(int, char*[]) { - std::cout << "=== interop example (kaguya) ===" << std::endl; - std::cout << "(code lifted from kaguya's README examples: https://github.com/satoren/kaguya)" << std::endl; + std::cout << "=== interop example (kaguya) ===" + << std::endl; + std::cout << "(code lifted from kaguya's README examples: " + "https://github.com/satoren/kaguya)" + << std::endl; kaguya::State state; - state["ABC"].setClass(kaguya::UserdataMetatable() - .setConstructors() - .addFunction("get_value", &ABC::value) - .addFunction("set_value", &ABC::setValue) - .addOverloadedFunctions("overload", &ABC::overload1, &ABC::overload2) - .addStaticFunction("nonmemberfun", [](ABC* self, int) { return 1; })); + state["ABC"].setClass( + kaguya::UserdataMetatable() + .setConstructors() + .addFunction("get_value", &ABC::value) + .addFunction("set_value", &ABC::setValue) + .addOverloadedFunctions( + "overload", &ABC::overload1, &ABC::overload2) + .addStaticFunction("nonmemberfun", + [](ABC* self, int) { return 1; })); register_sol_stuff(state.state()); diff --git a/examples/interop/luwra/CMakeLists.txt b/examples/interop/luwra/CMakeLists.txt index 66a89262..4a61e0f4 100644 --- a/examples/interop/luwra/CMakeLists.txt +++ b/examples/interop/luwra/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # sol3 interop Examples - luwra +# # # sol2 interop Examples - luwra find_package(LuwraBuild) diff --git a/examples/interop/luwra/source/luwra.cpp b/examples/interop/luwra/source/luwra.cpp index fa9e1ab3..de6f6740 100644 --- a/examples/interop/luwra/source/luwra.cpp +++ b/examples/interop/luwra/source/luwra.cpp @@ -1,5 +1,6 @@ #define SOL_ALL_SAFETIES_ON 1 -#define SOL_ENABLE_INTEROP 1 // MUST be defined to use interop features +#define SOL_ENABLE_INTEROP \ + 1 // MUST be defined to use interop features #include #include @@ -33,7 +34,9 @@ private: }; template -inline bool sol_lua_interop_check(sol::types, lua_State* L, int relindex, sol::type index_type, Handler&& handler, sol::stack::record& tracking) { +inline bool sol_lua_interop_check(sol::types, lua_State* L, + int relindex, sol::type index_type, Handler&& handler, + sol::stack::record& tracking) { // just marking unused parameters for no compiler warnings (void)index_type; (void)handler; @@ -41,7 +44,8 @@ inline bool sol_lua_interop_check(sol::types, lua_State* L, int relindex, sol tracking.use(1); int index = lua_absindex(L, relindex); if (lua_getmetatable(L, index) == 1) { - luaL_getmetatable(L, luwra::internal::UserTypeReg::name.c_str()); + luaL_getmetatable( + L, luwra::internal::UserTypeReg::name.c_str()); bool is_correct_type = lua_rawequal(L, -2, -1) == 1; lua_pop(L, 2); return is_correct_type; @@ -50,11 +54,18 @@ inline bool sol_lua_interop_check(sol::types, lua_State* L, int relindex, sol } template -inline std::pair sol_lua_interop_get(sol::types t, lua_State* L, int relindex, void* unadjusted_pointer, sol::stack::record& tracking) { +inline std::pair sol_lua_interop_get(sol::types t, + lua_State* L, int relindex, void* unadjusted_pointer, + sol::stack::record& tracking) { // you may not need to specialize this method every time: - // some libraries are compatible with sol3's layout + // some libraries are compatible with sol2's layout int index = lua_absindex(L, relindex); - if (!sol_lua_interop_check(t, L, index, sol::type::userdata, sol::no_panic, tracking)) { + if (!sol_lua_interop_check(t, + L, + index, + sol::type::userdata, + sol::no_panic, + tracking)) { return { false, nullptr }; } return { true, static_cast(unadjusted_pointer) }; @@ -64,15 +75,22 @@ void register_sol_stuff(lua_State* L) { // grab raw state and put into state_view // state_view is cheap to construct sol::state_view lua(L); - // bind and set up your things: everything is entirely self-contained + // bind and set up your things: everything is entirely + // self-contained lua["f"] = sol::overload( [](ABC& from_luwra) { - std::cout << "calling 1-argument version with luwra-created ABC { " << from_luwra.value() << " }" << std::endl; + std::cout << "calling 1-argument version with " + "luwra-created ABC { " + << from_luwra.value() << " }" + << std::endl; sol_c_assert(from_luwra.value() == 24); }, [](ABC& from_luwra, int second_arg) { - std::cout << "calling 2-argument version with luwra-created ABC { " << from_luwra.value() << " } and integer argument of " << second_arg - << std::endl; + std::cout << "calling 2-argument version with " + "luwra-created ABC { " + << from_luwra.value() + << " } and integer argument of " + << second_arg << std::endl; sol_c_assert(from_luwra.value() == 24); sol_c_assert(second_arg == 5); }); @@ -88,11 +106,16 @@ void check_with_sol(lua_State* L) { int main(int, char*[]) { std::cout << "=== interop example (luwra) ===" << std::endl; - std::cout << "code modified from luwra's documentation examples: https://github.com/vapourismo/luwra" << std::endl; + std::cout << "code modified from luwra's documentation " + "examples: https://github.com/vapourismo/luwra" + << std::endl; luwra::StateWrapper state; - state.registerUserType("ABC", { LUWRA_MEMBER(ABC, value), LUWRA_MEMBER(ABC, setValue) }, {}); + state.registerUserType("ABC", + { LUWRA_MEMBER(ABC, value), + LUWRA_MEMBER(ABC, setValue) }, + {}); register_sol_stuff(state); diff --git a/examples/interop/tolua/CMakeLists.txt b/examples/interop/tolua/CMakeLists.txt index db72feb5..4132323e 100644 --- a/examples/interop/tolua/CMakeLists.txt +++ b/examples/interop/tolua/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # sol3 interop Examples - tolua +# # # sol2 interop Examples - tolua find_package(ToLuappBuild REQUIRED) diff --git a/examples/interop/tolua/source/Player.h b/examples/interop/tolua/source/Player.h index 7d8148c9..8d64abcc 100644 --- a/examples/interop/tolua/source/Player.h +++ b/examples/interop/tolua/source/Player.h @@ -6,8 +6,7 @@ private: int m_health; public: - Player() - : m_health(0) { + Player() : m_health(0) { } void setHealth(int health) { m_health = health; diff --git a/examples/interop/tolua/source/tolua.cpp b/examples/interop/tolua/source/tolua.cpp index 19ebfc8e..bf1d1d85 100644 --- a/examples/interop/tolua/source/tolua.cpp +++ b/examples/interop/tolua/source/tolua.cpp @@ -1,5 +1,6 @@ #define SOL_ALL_SAFETIES_ON 1 -#define SOL_ENABLE_INTEROP 1 // MUST be defined to use interop features +#define SOL_ENABLE_INTEROP \ + 1 // MUST be defined to use interop features #include #include "Player.h" @@ -18,10 +19,12 @@ /* NOTE: there is no sol_lua_interop_get here, because tolua types are -- thankfully -- memory-compatible in most cases with sol. - Please check other examples like kaguya or LuaBribe for an example - of how to also write the getter for your type*/ + Please check other examples like kaguya or LuaBribe for an + example of how to also write the getter for your type*/ template -inline bool sol_lua_interop_check(sol::types, lua_State* L, int relindex, sol::type index_type, Handler&& handler, sol::stack::record& tracking) { +inline bool sol_lua_interop_check(sol::types, lua_State* L, + int relindex, sol::type index_type, Handler&& handler, + sol::stack::record& tracking) { tracking.use(1); // just marking unused parameters for no compiler warnings (void)index_type; @@ -29,7 +32,8 @@ inline bool sol_lua_interop_check(sol::types, lua_State* L, int relindex, sol int index = lua_absindex(L, relindex); std::string name = sol::detail::short_demangle(); tolua_Error tolua_err {}; - int r = tolua_isusertype(L, index, name.c_str(), 0, &tolua_err); + int r = tolua_isusertype( + L, index, name.c_str(), 0, &tolua_err); if (r == 0) { // tolua seems to leave garbage on the stack // when the check fails @@ -44,14 +48,21 @@ void register_sol_stuff(lua_State* L) { // grab raw state and put into state_view // state_view is cheap to construct sol::state_view lua(L); - // bind and set up your things: everything is entirely self-contained + // bind and set up your things: everything is entirely + // self-contained lua["f"] = sol::overload( [](Player& from_tolua) { - std::cout << "calling 1-argument version with tolua-created Player { health:" << from_tolua.getHealth() << " }" << std::endl; + std::cout << "calling 1-argument version with " + "tolua-created Player { health:" + << from_tolua.getHealth() << " }" + << std::endl; sol_c_assert(from_tolua.getHealth() == 4); }, [](Player& from_tolua, int second_arg) { - std::cout << "calling 2-argument version with tolua-created Player { health: " << from_tolua.getHealth() << " } and integer argument of " + std::cout << "calling 2-argument version with " + "tolua-created Player { health: " + << from_tolua.getHealth() + << " } and integer argument of " << second_arg << std::endl; sol_c_assert(from_tolua.getHealth() == 4); sol_c_assert(second_arg == 5); @@ -68,13 +79,18 @@ void check_with_sol(lua_State* L) { int main(int, char*[]) { std::cout << "=== interop example (tolua) ===" << std::endl; - std::cout << "(code lifted from a sol2 user's use case: https://github.com/ThePhD/sol2/issues/511#issuecomment-331729884)" << std::endl; + std::cout << "(code lifted from a sol2 user's use case: " + "https://github.com/ThePhD/sol2/issues/" + "511#issuecomment-331729884)" + << std::endl; lua_State* L = luaL_newstate(); - luaL_openlibs(L); // initalize all lua standard library functions - tolua_open(L); // initalize tolua - tolua_Player_open(L); // make Player class accessible from LUA + luaL_openlibs( + L); // initalize all lua standard library functions + tolua_open(L); // initalize tolua + tolua_Player_open( + L); // make Player class accessible from LUA register_sol_stuff(L); diff --git a/examples/interop/tolua/source/tolua_Player.h b/examples/interop/tolua/source/tolua_Player.h index 8a4fa14f..fa1de997 100644 --- a/examples/interop/tolua/source/tolua_Player.h +++ b/examples/interop/tolua/source/tolua_Player.h @@ -1,6 +1,7 @@ /* ** Lua binding: Player -** Generated automatically by tolua++-1.0.93-lua53 on Sat Feb 10 08:48:53 2018. +** Generated automatically by tolua++-1.0.93-lua53 on Sat Feb 10 +*08:48:53 2018. */ #ifndef __cplusplus @@ -11,16 +12,15 @@ #include "tolua++.h" /* Exported function */ -TOLUA_API int tolua_Player_open (lua_State* tolua_S); +TOLUA_API int tolua_Player_open(lua_State* tolua_S); #include "Player.h" /* function to release collected object via destructor */ #ifdef __cplusplus -static int tolua_collect_Player (lua_State* tolua_S) -{ - Player* self = (Player*) tolua_tousertype(tolua_S,1,0); +static int tolua_collect_Player(lua_State* tolua_S) { + Player* self = (Player*)tolua_tousertype(tolua_S, 1, 0); Mtolua_delete(self); return 0; } @@ -28,190 +28,199 @@ static int tolua_collect_Player (lua_State* tolua_S) /* function to register type */ -static void tolua_reg_types (lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"Player"); +static void tolua_reg_types(lua_State* tolua_S) { + tolua_usertype(tolua_S, "Player"); } /* method: new of class Player */ #ifndef TOLUA_DISABLE_tolua_Player_Player_new00 -static int tolua_Player_Player_new00(lua_State* tolua_S) -{ +static int tolua_Player_Player_new00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"Player",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S, 1, "Player", 0, &tolua_err) + || !tolua_isnoobj(tolua_S, 2, &tolua_err)) + goto tolua_lerror; + else #endif - { - { - Player* tolua_ret = (Player*) Mtolua_new((Player)()); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"Player"); - } - } - return 1; + { + { + Player* tolua_ret + = (Player*)Mtolua_new((Player)()); + tolua_pushusertype( + tolua_S, (void*)tolua_ret, "Player"); + } + } + return 1; #ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; +tolua_lerror: + tolua_error( + tolua_S, "#ferror in function 'new'.", &tolua_err); + return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class Player */ #ifndef TOLUA_DISABLE_tolua_Player_Player_new00_local -static int tolua_Player_Player_new00_local(lua_State* tolua_S) -{ +static int tolua_Player_Player_new00_local(lua_State* tolua_S) { #ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"Player",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S, 1, "Player", 0, &tolua_err) + || !tolua_isnoobj(tolua_S, 2, &tolua_err)) + goto tolua_lerror; + else #endif - { - { - Player* tolua_ret = (Player*) Mtolua_new((Player)()); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"Player"); - tolua_register_gc(tolua_S,lua_gettop(tolua_S)); - } - } - return 1; + { + { + Player* tolua_ret + = (Player*)Mtolua_new((Player)()); + tolua_pushusertype( + tolua_S, (void*)tolua_ret, "Player"); + tolua_register_gc(tolua_S, lua_gettop(tolua_S)); + } + } + return 1; #ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; +tolua_lerror: + tolua_error( + tolua_S, "#ferror in function 'new'.", &tolua_err); + return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: delete of class Player */ #ifndef TOLUA_DISABLE_tolua_Player_Player_delete00 -static int tolua_Player_Player_delete00(lua_State* tolua_S) -{ +static int tolua_Player_Player_delete00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"Player",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S, 1, "Player", 0, &tolua_err) + || !tolua_isnoobj(tolua_S, 2, &tolua_err)) + goto tolua_lerror; + else #endif - { - Player* self = (Player*) tolua_tousertype(tolua_S,1,0); + { + Player* self + = (Player*)tolua_tousertype(tolua_S, 1, 0); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL); + if (!self) + tolua_error(tolua_S, + "invalid 'self' in function 'delete'", + NULL); #endif - Mtolua_delete(self); - } - return 0; + Mtolua_delete(self); + } + return 0; #ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); - return 0; +tolua_lerror: + tolua_error( + tolua_S, "#ferror in function 'delete'.", &tolua_err); + return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setHealth of class Player */ #ifndef TOLUA_DISABLE_tolua_Player_Player_setHealth00 -static int tolua_Player_Player_setHealth00(lua_State* tolua_S) -{ +static int tolua_Player_Player_setHealth00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"Player",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S, 1, "Player", 0, &tolua_err) + || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) + || !tolua_isnoobj(tolua_S, 3, &tolua_err)) + goto tolua_lerror; + else #endif - { - Player* self = (Player*) tolua_tousertype(tolua_S,1,0); - int _health = ((int) tolua_tonumber(tolua_S,2,0)); + { + Player* self + = (Player*)tolua_tousertype(tolua_S, 1, 0); + int _health = ((int)tolua_tonumber(tolua_S, 2, 0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setHealth'", NULL); + if (!self) + tolua_error(tolua_S, + "invalid 'self' in function 'setHealth'", + NULL); #endif - { - self->setHealth(_health); - } - } - return 0; + { self->setHealth(_health); } + } + return 0; #ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'setHealth'.",&tolua_err); - return 0; +tolua_lerror: + tolua_error(tolua_S, + "#ferror in function 'setHealth'.", + &tolua_err); + return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getHealth of class Player */ #ifndef TOLUA_DISABLE_tolua_Player_Player_getHealth00 -static int tolua_Player_Player_getHealth00(lua_State* tolua_S) -{ +static int tolua_Player_Player_getHealth00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"Player",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S, 1, "Player", 0, &tolua_err) + || !tolua_isnoobj(tolua_S, 2, &tolua_err)) + goto tolua_lerror; + else #endif - { - Player* self = (Player*) tolua_tousertype(tolua_S,1,0); + { + Player* self + = (Player*)tolua_tousertype(tolua_S, 1, 0); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHealth'", NULL); + if (!self) + tolua_error(tolua_S, + "invalid 'self' in function 'getHealth'", + NULL); #endif - { - int tolua_ret = (int) self->getHealth(); - tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); - } - } - return 1; + { + int tolua_ret = (int)self->getHealth(); + tolua_pushnumber(tolua_S, (lua_Number)tolua_ret); + } + } + return 1; #ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'getHealth'.",&tolua_err); - return 0; +tolua_lerror: + tolua_error(tolua_S, + "#ferror in function 'getHealth'.", + &tolua_err); + return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* Open function */ -TOLUA_API int tolua_Player_open (lua_State* tolua_S) -{ - tolua_open(tolua_S); - tolua_reg_types(tolua_S); - tolua_module(tolua_S,NULL,0); - tolua_beginmodule(tolua_S,NULL); - #ifdef __cplusplus - tolua_cclass(tolua_S,"Player","Player","",tolua_collect_Player); - #else - tolua_cclass(tolua_S,"Player","Player","",NULL); - #endif - tolua_beginmodule(tolua_S,"Player"); - tolua_function(tolua_S,"new",tolua_Player_Player_new00); - tolua_function(tolua_S,"new_local",tolua_Player_Player_new00_local); - tolua_function(tolua_S,".call",tolua_Player_Player_new00_local); - tolua_function(tolua_S,"delete",tolua_Player_Player_delete00); - tolua_function(tolua_S,"setHealth",tolua_Player_Player_setHealth00); - tolua_function(tolua_S,"getHealth",tolua_Player_Player_getHealth00); - tolua_endmodule(tolua_S); - tolua_endmodule(tolua_S); - return 1; +TOLUA_API int tolua_Player_open(lua_State* tolua_S) { + tolua_open(tolua_S); + tolua_reg_types(tolua_S); + tolua_module(tolua_S, NULL, 0); + tolua_beginmodule(tolua_S, NULL); +#ifdef __cplusplus + tolua_cclass( + tolua_S, "Player", "Player", "", tolua_collect_Player); +#else + tolua_cclass(tolua_S, "Player", "Player", "", NULL); +#endif + tolua_beginmodule(tolua_S, "Player"); + tolua_function(tolua_S, "new", tolua_Player_Player_new00); + tolua_function( + tolua_S, "new_local", tolua_Player_Player_new00_local); + tolua_function( + tolua_S, ".call", tolua_Player_Player_new00_local); + tolua_function( + tolua_S, "delete", tolua_Player_Player_delete00); + tolua_function( + tolua_S, "setHealth", tolua_Player_Player_setHealth00); + tolua_function( + tolua_S, "getHealth", tolua_Player_Player_getHealth00); + tolua_endmodule(tolua_S); + tolua_endmodule(tolua_S); + return 1; } #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 - TOLUA_API int luaopen_Player (lua_State* tolua_S) { - return tolua_Player_open(tolua_S); +TOLUA_API int luaopen_Player(lua_State* tolua_S) { + return tolua_Player_open(tolua_S); }; #endif - diff --git a/examples/require_dll_example/CMakeLists.txt b/examples/require_dll_example/CMakeLists.txt index 8ad817ac..b54da5b3 100644 --- a/examples/require_dll_example/CMakeLists.txt +++ b/examples/require_dll_example/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # sol3 Examples - require_from_dll +# # # sol2 Examples - require_from_dll # # Reusable function to call for single target # # Also hides variables from directory/global scope diff --git a/examples/require_dll_example/include/my_object/my_object_api.hpp b/examples/require_dll_example/include/my_object/my_object_api.hpp index 96cc71f2..a31532d9 100644 --- a/examples/require_dll_example/include/my_object/my_object_api.hpp +++ b/examples/require_dll_example/include/my_object/my_object_api.hpp @@ -16,7 +16,8 @@ namespace my_object { #define MY_OBJECT_API __declspec(dllexport) #else #define MY_OBJECT_API __declspec(dllexport) -#endif // MY_OBJECT_BUILD - Building the Library vs. Using the Library +#endif // MY_OBJECT_BUILD - Building the Library vs. Using the + // Library #else #define MY_OBJECT_API #endif // Building a DLL vs. Static Library diff --git a/examples/require_dll_example/source/my_object.cpp b/examples/require_dll_example/source/my_object.cpp index 96ec9f3e..2094c519 100644 --- a/examples/require_dll_example/source/my_object.cpp +++ b/examples/require_dll_example/source/my_object.cpp @@ -8,7 +8,10 @@ namespace my_object { sol::table open_my_object(sol::this_state L) { sol::state_view lua(L); sol::table module = lua.create_table(); - module.new_usertype("test", sol::constructors(), "value", &test::value); + module.new_usertype("test", + sol::constructors(), + "value", + &test::value); return module; } @@ -19,7 +22,9 @@ extern "C" int luaopen_my_object(lua_State* L) { // pass the lua_State, // the index to start grabbing arguments from, // and the function itself - // optionally, you can pass extra arguments to the function if that's necessary, - // but that's advanced usage and is generally reserved for internals only - return sol::stack::call_lua(L, 1, my_object::open_my_object); + // optionally, you can pass extra arguments to the function + // if that's necessary, but that's advanced usage and is + // generally reserved for internals only + return sol::stack::call_lua( + L, 1, my_object::open_my_object); } diff --git a/examples/require_dll_example/source/require_from_dll.cpp b/examples/require_dll_example/source/require_from_dll.cpp index d6d59127..1d8f96bb 100644 --- a/examples/require_dll_example/source/require_from_dll.cpp +++ b/examples/require_dll_example/source/require_from_dll.cpp @@ -16,13 +16,16 @@ mo = require("my_object") obj = mo.test.new(24) print(obj.value))"; - auto script_result = lua.safe_script(code, &sol::script_pass_on_error); + auto script_result + = lua.safe_script(code, &sol::script_pass_on_error); if (script_result.valid()) { - std::cout << "The DLL was require'd from successfully!" << std::endl; + std::cout << "The DLL was require'd from successfully!" + << std::endl; } else { sol::error err = script_result; - std::cout << "Something bad happened: " << err.what() << std::endl; + std::cout << "Something bad happened: " << err.what() + << std::endl; } sol_c_assert(script_result.valid()); my_object::test& obj = lua["obj"]; diff --git a/examples/source/allocation_limit.cpp b/examples/source/allocation_limit.cpp index 670bb0b5..44982874 100644 --- a/examples/source/allocation_limit.cpp +++ b/examples/source/allocation_limit.cpp @@ -8,12 +8,20 @@ class memory_tracker { public: // 10 MB or something? // idk whatever - inline static constexpr std::size_t arbitrary_default_limit = 1024 * 1024 * 10; + inline static constexpr std::size_t arbitrary_default_limit + = 1024 * 1024 * 10; memory_tracker() : memory_tracker(arbitrary_default_limit) { } - memory_tracker(std::size_t maximum_memory) : used(0), limit(maximum_memory), n_threads(0), n_tables(0), n_functions(0), n_userdata(0), n_strings(0) { + memory_tracker(std::size_t maximum_memory) + : used(0) + , limit(maximum_memory) + , n_threads(0) + , n_tables(0) + , n_functions(0) + , n_userdata(0) + , n_strings(0) { } std::size_t currently_used() const { @@ -24,17 +32,22 @@ public: return limit; } - static void* allocate(void* memory_tracker_ud, void* ptr, size_t object_code, size_t nsize) { - memory_tracker& self = (*static_cast(memory_tracker_ud)); + static void* allocate(void* memory_tracker_ud, void* ptr, + size_t object_code, size_t nsize) { + memory_tracker& self = (*static_cast( + memory_tracker_ud)); return self.alloc(ptr, object_code, nsize); } private: - void* alloc(void* ptr, size_t original_block_size_or_code, size_t new_block_size) { - std::size_t original_block_size = original_block_size_or_code; + void* alloc(void* ptr, size_t original_block_size_or_code, + size_t new_block_size) { + std::size_t original_block_size + = original_block_size_or_code; if (ptr == nullptr) { // object code! - sol::type object_type = static_cast(original_block_size_or_code); + sol::type object_type = static_cast( + original_block_size_or_code); switch (object_type) { case sol::type::function: ++n_functions; @@ -70,7 +83,8 @@ private: } // did we hit the limit? - std::size_t memory_differntial = new_block_size - original_block_size; + std::size_t memory_differntial + = new_block_size - original_block_size; std::size_t desired_use = used + memory_differntial; if (desired_use > limit) { // tell the Lua Virtual Machine @@ -111,25 +125,45 @@ int main() { std::cout << "=== memory tracker ===" << std::endl; #if SOL_LUAJIT_VERSION < 20100 && (UINTPTR_MAX > 0xFFFFFFFF) - std::cout << "LuaJIT in x64 mode on LuaJIT 2.0.X versions does not support using a custom allocator!" << std::endl; + std::cout << "LuaJIT in x64 mode on LuaJIT 2.0.X versions " + "does not support using a custom allocator!" + << std::endl; #else memory_tracker box; - std::cout << "memory at start: " << box.currently_used() << " bytes / " << box.memory_limit() << " bytes" << std::endl; - sol::state lua(&sol::default_at_panic, &memory_tracker::allocate, &box); + std::cout << "memory at start: " << box.currently_used() + << " bytes / " << box.memory_limit() << " bytes" + << std::endl; + sol::state lua(&sol::default_at_panic, + &memory_tracker::allocate, + &box); lua.open_libraries(sol::lib::base); - std::cout << "memory after state creation: " << box.currently_used() << " bytes / " << box.memory_limit() << " bytes" << std::endl; + std::cout << "memory after state creation: " + << box.currently_used() << " bytes / " + << box.memory_limit() << " bytes" << std::endl; // trigger some allocations - lua.new_usertype("my_type", "a", &my_type::a, "b", &my_type::b, "d", &my_type::d); + lua.new_usertype("my_type", + "a", + &my_type::a, + "b", + &my_type::b, + "d", + &my_type::d); lua["f"] = [](std::string s) { return s + " woof!"; }; - std::cout << "memory after function and usertype setup: " << box.currently_used() << " bytes / " << box.memory_limit() << " bytes" << std::endl; + std::cout << "memory after function and usertype setup: " + << box.currently_used() << " bytes / " + << box.memory_limit() << " bytes" << std::endl; lua.safe_script("print(f('bark'))"); - lua.safe_script("local obj = my_type.new() print(obj.a, obj.b, obj.c) obj.b = true print(obj.a, obj.b, obj.c)"); + lua.safe_script( + "local obj = my_type.new() print(obj.a, obj.b, obj.c) " + "obj.b = true print(obj.a, obj.b, obj.c)"); - std::cout << "memory at end: " << box.currently_used() << " bytes / " << box.memory_limit() << " bytes" << std::endl; + std::cout << "memory at end: " << box.currently_used() + << " bytes / " << box.memory_limit() << " bytes" + << std::endl; #endif return 0; } diff --git a/examples/source/any_return.cpp b/examples/source/any_return.cpp index 0c1384a0..7530effb 100644 --- a/examples/source/any_return.cpp +++ b/examples/source/any_return.cpp @@ -3,17 +3,21 @@ #include -// Uses some of the fancier bits of sol3, including the "transparent argument", -// sol::this_state, which gets the current state and does not increment -// function arguments -sol::object fancy_func(sol::object a, sol::object b, sol::this_state s) { +// Uses some of the fancier bits of sol2, including the +// "transparent argument", sol::this_state, which gets the +// current state and does not increment function arguments +sol::object fancy_func( + sol::object a, sol::object b, sol::this_state s) { sol::state_view lua(s); if (a.is() && b.is()) { - return sol::object(lua, sol::in_place, a.as() + b.as()); + return sol::object( + lua, sol::in_place, a.as() + b.as()); } else if (a.is()) { bool do_triple = a.as(); - return sol::object(lua, sol::in_place_type, b.as() * (do_triple ? 3 : 1)); + return sol::object(lua, + sol::in_place_type, + b.as() * (do_triple ? 3 : 1)); } // Can also use make_object return sol::make_object(lua, sol::lua_nil); @@ -32,7 +36,8 @@ int main() { sol_c_assert(result2 == 2.5); // call in Lua, get result - // notice we only need 2 arguments here, not 3 (sol::this_state is transparent) + // notice we only need 2 arguments here, not 3 + // (sol::this_state is transparent) lua.script("result3 = f(true, 5.5)"); double result3 = lua["result3"]; // result3 == 16.5 diff --git a/examples/source/as_returns.cpp b/examples/source/as_returns.cpp index 02a51939..421a0618 100644 --- a/examples/source/as_returns.cpp +++ b/examples/source/as_returns.cpp @@ -9,7 +9,9 @@ int main() { sol::state lua; lua.set_function("f", []() { - std::set results { "arf", "bark", "woof" }; + std::set results { + "arf", "bark", "woof" + }; return sol::as_returns(std::move(results)); }); diff --git a/examples/source/basic.cpp b/examples/source/basic.cpp index 2314083c..9b45dc78 100644 --- a/examples/source/basic.cpp +++ b/examples/source/basic.cpp @@ -18,42 +18,58 @@ int main() { // call lua code directly lua.script("print('hello world')"); - // call lua code, and check to make sure it has loaded and run properly: + // call lua code, and check to make sure it has loaded and + // run properly: auto handler = &sol::script_default_on_error; lua.script("print('hello again, world')", handler); // Use a custom error handler if you need it // This gets called when the result is bad - auto simple_handler = [](lua_State*, sol::protected_function_result result) { - // You can just pass it through to let the call-site handle it - return result; - }; - // the above lambda is identical to sol::simple_on_error, but it's - // shown here to show you can write whatever you like + auto simple_handler = + [](lua_State*, sol::protected_function_result result) { + // You can just pass it through to let the + // call-site handle it + return result; + }; + // the above lambda is identical to sol::simple_on_error, + // but it's shown here to show you can write whatever you + // like // { - auto result = lua.script("print('hello hello again, world') \n return 24", simple_handler); + auto result = lua.script( + "print('hello hello again, world') \n return 24", + simple_handler); if (result.valid()) { - std::cout << "the third script worked, and a double-hello statement should appear above this one!" << std::endl; + std::cout << "the third script worked, and a " + "double-hello statement should " + "appear above this one!" + << std::endl; int value = result; sol_c_assert(value == 24); } else { - std::cout << "the third script failed, check the result type for more information!" << std::endl; + std::cout << "the third script failed, check the " + "result type for more information!" + << std::endl; } } { - auto result = lua.script("does.not.exist", simple_handler); + auto result + = lua.script("does.not.exist", simple_handler); if (result.valid()) { - std::cout << "the fourth script worked, which it wasn't supposed to! Panic!" << std::endl; + std::cout << "the fourth script worked, which it " + "wasn't supposed to! Panic!" + << std::endl; int value = result; sol_c_assert(value == 24); } else { sol::error err = result; - std::cout << "the fourth script failed, which was intentional!\t\nError: " << err.what() << std::endl; + std::cout << "the fourth script failed, which " + "was intentional!\t\nError: " + << err.what() << std::endl; } } diff --git a/examples/source/c_array.cpp b/examples/source/c_array.cpp index 79d72f52..68d1f021 100644 --- a/examples/source/c_array.cpp +++ b/examples/source/c_array.cpp @@ -13,12 +13,16 @@ struct something { int main() { - std::cout << "=== c arrays (works with Visual C++ too) ===" << std::endl; + std::cout << "=== c arrays (works with Visual C++ too) ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype("something", "arr", sol::property([](something& s) { return std::ref(s.arr); })); + lua.new_usertype( + "something", "arr", sol::property([](something& s) { + return std::ref(s.arr); + })); lua.script(R"(s = something.new() print(s.arr[3]) s.arr[3] = 40 diff --git a/examples/source/c_call.cpp b/examples/source/c_call.cpp index b7e7a97a..1e422657 100644 --- a/examples/source/c_call.cpp +++ b/examples/source/c_call.cpp @@ -19,7 +19,10 @@ int main() { sol::state lua; // overloaded function f - lua.set("f", sol::c_call, sol::wrap, sol::wrap>); + lua.set("f", + sol::c_call, + sol::wrap, + sol::wrap>); // singly-wrapped function lua.set("g", sol::c_call>); // without the 'sol::wrap' boilerplate diff --git a/examples/source/calling_lua_functions.cpp b/examples/source/calling_lua_functions.cpp index 66680384..21a6b4da 100644 --- a/examples/source/calling_lua_functions.cpp +++ b/examples/source/calling_lua_functions.cpp @@ -11,10 +11,13 @@ std::string func_2(std::string text) { return "received: " + text; } -sol::variadic_results fallback(sol::this_state ts, sol::variadic_args args) { +sol::variadic_results fallback( + sol::this_state ts, sol::variadic_args args) { sol::variadic_results r; if (args.size() == 2) { - r.push_back({ ts, sol::in_place, args.get(0) + args.get(1) }); + r.push_back({ ts, + sol::in_place, + args.get(0) + args.get(1) }); } else { r.push_back({ ts, sol::in_place, 52 }); @@ -28,22 +31,28 @@ int main(int, char*[]) { sol::state lua; lua.open_libraries(); - sol::table mLuaPackets = lua.create_named_table("mLuaPackets"); + sol::table mLuaPackets + = lua.create_named_table("mLuaPackets"); mLuaPackets[1] = lua.create_table_with("timestamp", 0LL); mLuaPackets[2] = lua.create_table_with("timestamp", 3LL); mLuaPackets[3] = lua.create_table_with("timestamp", 1LL); lua.script("print('--- pre sort ---')"); - lua.script("for i=1,#mLuaPackets do print(i, mLuaPackets[i].timestamp) end"); + lua.script( + "for i=1,#mLuaPackets do print(i, " + "mLuaPackets[i].timestamp) end"); - lua["table"]["sort"](mLuaPackets, sol::as_function([](sol::table l, sol::table r) { - std::uint64_t tl = l["timestamp"]; - std::uint64_t tr = r["timestamp"]; - return tl < tr; - })); + lua["table"]["sort"](mLuaPackets, + sol::as_function([](sol::table l, sol::table r) { + std::uint64_t tl = l["timestamp"]; + std::uint64_t tr = r["timestamp"]; + return tl < tr; + })); lua.script("print('--- post sort ---')"); - lua.script("for i=1,#mLuaPackets do print(i, mLuaPackets[i].timestamp) end"); + lua.script( + "for i=1,#mLuaPackets do print(i, " + "mLuaPackets[i].timestamp) end"); return 0; } \ No newline at end of file diff --git a/examples/source/config.cpp b/examples/source/config.cpp index bc245436..1dcc8d51 100644 --- a/examples/source/config.cpp +++ b/examples/source/config.cpp @@ -12,15 +12,17 @@ struct config { int height; void print() { - std::cout << "Name: " << name << '\n' << "Width: " << width << '\n' << "Height: " << height << '\n'; + std::cout << "Name: " << name << '\n' + << "Width: " << width << '\n' + << "Height: " << height << '\n'; } }; int main() { sol::state lua; config screen; - // To use the file, uncomment here and make sure it is in local dir - // lua.script_file("config.lua"); + // To use the file, uncomment here and make sure it is in + // local dir lua.script_file("config.lua"); lua.script(R"( name = "Asus" width = 1920 diff --git a/examples/source/container_usertype_as_container.cpp b/examples/source/container_usertype_as_container.cpp index 2d3f3179..6f55b40e 100644 --- a/examples/source/container_usertype_as_container.cpp +++ b/examples/source/container_usertype_as_container.cpp @@ -54,9 +54,15 @@ int main(int, char*[]) { sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype( - "number_storage", sol::constructors(), "accumulate", &number_storage::accumulate, "iterable", [](number_storage& ns) { - return sol::as_container(ns); // treat like a container, despite is_container specialization + lua.new_usertype("number_storage", + sol::constructors(), + "accumulate", + &number_storage::accumulate, + "iterable", + [](number_storage& ns) { + return sol::as_container( + ns); // treat like a container, despite + // is_container specialization }); lua.script(R"( diff --git a/examples/source/container_with_pairs.cpp b/examples/source/container_with_pairs.cpp index 2fba8d67..69171d4d 100644 --- a/examples/source/container_with_pairs.cpp +++ b/examples/source/container_with_pairs.cpp @@ -7,7 +7,8 @@ int main() { struct hasher { - typedef std::pair argument_type; + typedef std::pair + argument_type; typedef std::size_t result_type; result_type operator()(const argument_type& p) const { @@ -15,21 +16,30 @@ int main() { } }; - using my_set = std::unordered_set, hasher>; + using my_set = std::unordered_set< + std::pair, + hasher>; - std::cout << "=== containers with std::pair<> ===" << std::endl; + std::cout << "=== containers with std::pair<> ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); - lua.set_function("f", []() { return my_set { { "key1", "value1" }, { "key2", "value2" }, { "key3", "value3" } }; }); + lua.set_function("f", []() { + return my_set { { "key1", "value1" }, + { "key2", "value2" }, + { "key3", "value3" } }; + }); lua.safe_script("v = f()"); lua.safe_script("print('v:', v)"); lua.safe_script("print('#v:', #v)"); // note that using my_obj:pairs() is a - // way around pairs(my_obj) not working in Lua 5.1/LuaJIT: try it! - lua.safe_script("for k,v1,v2 in v:pairs() do print(k, v1, v2) end"); + // way around pairs(my_obj) not working in Lua 5.1/LuaJIT: + // try it! + lua.safe_script( + "for k,v1,v2 in v:pairs() do print(k, v1, v2) end"); std::cout << std::endl; diff --git a/examples/source/containers_as_table.cpp b/examples/source/containers_as_table.cpp index b60ba07a..1a8c9063 100644 --- a/examples/source/containers_as_table.cpp +++ b/examples/source/containers_as_table.cpp @@ -6,12 +6,14 @@ #include -// nested allows serialization of maps with vectors inside, and vice-versa -// all from a nested structure of Lua tables -// it has less control over which pieces are considered tables in Lua, -// and which ones are considered userdata, but it covers a good 90% of cases -// where someone wants to handle a nested table -void demo(sol::nested>> src) { +// nested allows serialization of maps with vectors inside, and +// vice-versa all from a nested structure of Lua tables it has +// less control over which pieces are considered tables in Lua, +// and which ones are considered userdata, but it covers a good +// 90% of cases where someone wants to handle a nested table +void demo( + sol::nested>> + src) { std::cout << "demo, sol::nested<...>" << std::endl; const auto& listmap = src.value(); sol_c_assert(listmap.size() == 2); @@ -32,17 +34,24 @@ void demo(sol::nested>> src) { // Nota bene the signature here // Every container-type that's meant to be // a table must be wrapped in `sol::as_table_t` -// it's verbose, so feel free to use typedefs to make it easy on you -// you can mix which parts are considered tables from Lua, and which parts -// are considered other kinds of types, such as userdata and the like -void demo_explicit(sol::as_table_t>>> src) { - std::cout << "demo, explicit sol::as_table_t<...>" << std::endl; - // Have to access the "source" member variable for as_table_t +// it's verbose, so feel free to use typedefs to make it easy on +// you you can mix which parts are considered tables from Lua, +// and which parts are considered other kinds of types, such as +// userdata and the like +void demo_explicit(sol::as_table_t>>> + src) { + std::cout << "demo, explicit sol::as_table_t<...>" + << std::endl; + // Have to access the "source" member variable for + // as_table_t const auto& listmap = src.value(); sol_c_assert(listmap.size() == 2); for (const auto& kvp : listmap) { - // Have to access the internal "source" for the inner as_table_t, as well - const std::vector& strings = kvp.second.value(); + // Have to access the internal "source" for the inner + // as_table_t, as well + const std::vector& strings + = kvp.second.value(); sol_c_assert(strings.size() == 3); std::cout << "\t" << kvp.first << " = "; for (const auto& s : strings) { @@ -55,13 +64,15 @@ void demo_explicit(sol::as_table_t int main() { - std::cout << "=== coroutine - multple threads ===" << std::endl; + std::cout << "=== coroutine - multple threads ===" + << std::endl; sol::state lua; - lua.open_libraries(sol::lib::base, sol::lib::package, sol::lib::coroutine); + lua.open_libraries(sol::lib::base, + sol::lib::package, + sol::lib::coroutine); - lua["print"] = [](sol::object v) { std::cout << v.as() << std::endl; }; - lua["cyield"] = sol::yielding([]() { std::cout << "YIELDING" << std::endl; }); + lua["print"] = [](sol::object v) { + std::cout << v.as() << std::endl; + }; + lua["cyield"] = sol::yielding( + []() { std::cout << "YIELDING" << std::endl; }); // notice the new threads! sol::thread thread1 = sol::thread::create(lua); diff --git a/examples/source/coroutine_state.cpp b/examples/source/coroutine_state.cpp index bda47e52..0845470e 100644 --- a/examples/source/coroutine_state.cpp +++ b/examples/source/coroutine_state.cpp @@ -4,17 +4,21 @@ #include int main(int, char*[]) { - std::cout << "=== coroutine state transfer ===" << std::endl; + std::cout << "=== coroutine state transfer ===" + << std::endl; sol::state lua; lua.open_libraries(); sol::function transferred_into; - lua["f"] = [&lua, &transferred_into](sol::object t, sol::this_state this_L) { - std::cout << "state of main : " << (void*)lua.lua_state() << std::endl; - std::cout << "state of function : " << (void*)this_L.lua_state() << std::endl; - // pass original lua_State* (or sol::state/sol::state_view) - // transfers ownership from the state of "t", - // to the "lua" sol::state + lua["f"] = [&lua, &transferred_into]( + sol::object t, sol::this_state this_L) { + std::cout << "state of main : " + << (void*)lua.lua_state() << std::endl; + std::cout << "state of function : " + << (void*)this_L.lua_state() << std::endl; + // pass original lua_State* (or + // sol::state/sol::state_view) transfers ownership from + // the state of "t", to the "lua" sol::state transferred_into = sol::function(lua, t); }; diff --git a/examples/source/custom_reader.cpp b/examples/source/custom_reader.cpp index 9aaf8edf..d2d88344 100644 --- a/examples/source/custom_reader.cpp +++ b/examples/source/custom_reader.cpp @@ -18,11 +18,13 @@ struct custom_reader { std::size_t current_size; std::size_t read_count; - custom_reader(FILE* f_) : f(f_), buffer(), current_size(0), read_count(0) { + custom_reader(FILE* f_) + : f(f_), buffer(), current_size(0), read_count(0) { } bool read() { - std::cout << "custom read: read #" << ++read_count << std::endl; + std::cout << "custom read: read #" << ++read_count + << std::endl; current_size = fread(buffer, 1, 2, f); return current_size > 0 && ferror(f) == 0; } @@ -34,8 +36,10 @@ struct custom_reader { // function must match signature found in type lua_Reader: // const char* ( lua_State*, void*, size_t* ) -const char* custom_reader_function(lua_State*, void* pointer_to_my_object, size_t* data_size) { - custom_reader& cr = *(static_cast(pointer_to_my_object)); +const char* custom_reader_function( + lua_State*, void* pointer_to_my_object, size_t* data_size) { + custom_reader& cr + = *(static_cast(pointer_to_my_object)); if (cr.read()) { *data_size = cr.current_size; return cr.buffer; @@ -68,20 +72,24 @@ int main() { FILE* bjork_fp; #ifdef _MSC_VER if (fopen_s(&bjork_fp, "bjork.lua", "r") != 0) { - std::cerr << "failed to open bjork.lua -- exiting" << std::endl; + std::cerr << "failed to open bjork.lua -- exiting" + << std::endl; return -1; } #else bjork_fp = fopen("bjork.lua", "r"); #endif if (bjork_fp == nullptr) { - std::cerr << "failed to open bjork.lua -- exiting" << std::endl; + std::cerr << "failed to open bjork.lua -- exiting" + << std::endl; return -1; } custom_reader reader(bjork_fp); // load the code using our custom reader, then run it - auto result = lua.safe_script(custom_reader_function, &reader, sol::script_pass_on_error); + auto result = lua.safe_script(custom_reader_function, + &reader, + sol::script_pass_on_error); // make sure we ran loaded and ran the code successfully sol_c_assert(result.valid()); diff --git a/examples/source/customization_base_object_catch.cpp b/examples/source/customization_base_object_catch.cpp index 8659ee99..68e54cc2 100644 --- a/examples/source/customization_base_object_catch.cpp +++ b/examples/source/customization_base_object_catch.cpp @@ -31,10 +31,12 @@ public: // helper function defined later after we define all the // base classes we care about - sol::object getAsRetyped(lua_State* L, BaseObjectLifetime Lifetime) const; + sol::object getAsRetyped( + lua_State* L, BaseObjectLifetime Lifetime) const; // For convenience with the customization points below - int pushAsRetyped(lua_State* L, BaseObjectLifetime Lifetime) const { + int pushAsRetyped( + lua_State* L, BaseObjectLifetime Lifetime) const { return getAsRetyped(L, Lifetime).push(L); } @@ -67,30 +69,41 @@ public: // Get the most-derived type // that we care about from the base object, // obeying the lifetime type -sol::object BaseObject::getAsRetyped(lua_State* L, BaseObjectLifetime Lifetime) const { +sol::object BaseObject::getAsRetyped( + lua_State* L, BaseObjectLifetime Lifetime) const { switch (objectType) { case 1: std::cout << "Retyping as armor." << std::endl; switch (Lifetime) { case BaseObjectLifetime::Value: - return sol::make_object(L, *static_cast(this)); + return sol::make_object( + L, *static_cast(this)); case BaseObjectLifetime::Pointer: - return sol::make_object(L, static_cast(this)); + return sol::make_object( + L, static_cast(this)); case BaseObjectLifetime::Shared: - return sol::make_object(L, std::make_shared(*static_cast(this))); + return sol::make_object(L, + std::make_shared( + *static_cast(this))); } case 2: std::cout << "Retyping as weapon." << std::endl; switch (Lifetime) { case BaseObjectLifetime::Value: - return sol::make_object(L, *static_cast(this)); + return sol::make_object( + L, *static_cast(this)); case BaseObjectLifetime::Pointer: - return sol::make_object(L, static_cast(this)); + return sol::make_object( + L, static_cast(this)); case BaseObjectLifetime::Shared: - return sol::make_object(L, std::make_shared(*static_cast(this))); + return sol::make_object(L, + std::make_shared( + *static_cast(this))); } default: - std::cout << "Unknown type: falling back to base object." << std::endl; + std::cout + << "Unknown type: falling back to base object." + << std::endl; // we have a normal type here, so that means we // must bypass typical customization points by using // sol::make_object_userdata/sol::make_reference_userdata @@ -104,7 +117,8 @@ sol::object BaseObject::getAsRetyped(lua_State* L, BaseObjectLifetime Lifetime) case BaseObjectLifetime::Value: return sol::make_object_userdata(L, *this); case BaseObjectLifetime::Shared: - return sol::make_object_userdata(L, std::make_shared(*this)); + return sol::make_object_userdata( + L, std::make_shared(*this)); case BaseObjectLifetime::Pointer: default: return sol::make_object_userdata(L, this); @@ -116,36 +130,47 @@ sol::object BaseObject::getAsRetyped(lua_State* L, BaseObjectLifetime Lifetime) // sol customization points // -// Defining a customization point that lets us put the correct object type on the stack. -int sol_lua_push(sol::types, lua_State* L, const BaseObject& obj) { +// Defining a customization point that lets us put the correct +// object type on the stack. +int sol_lua_push(sol::types, lua_State* L, + const BaseObject& obj) { return obj.pushAsRetyped(L, BaseObjectLifetime::Value); } -int sol_lua_push(sol::types, lua_State* L, const BaseObject* obj) { +int sol_lua_push(sol::types, lua_State* L, + const BaseObject* obj) { return obj->pushAsRetyped(L, BaseObjectLifetime::Pointer); } -int sol_lua_push(sol::types>, lua_State* L, const std::shared_ptr& obj) { +int sol_lua_push(sol::types>, + lua_State* L, const std::shared_ptr& obj) { return obj->pushAsRetyped(L, BaseObjectLifetime::Shared); } int main() { // test our customization points out - std::cout << "=== Base object customization points ===" << std::endl; + std::cout << "=== Base object customization points ===" + << std::endl; sol::state lua; - lua.open_libraries(sol::lib::base, sol::lib::string, sol::lib::table); + lua.open_libraries( + sol::lib::base, sol::lib::string, sol::lib::table); lua["objectCache"] = lua.create_table(); // Do basic type binding. - auto luaBaseObject = lua.new_usertype("tes3baseObject"); - luaBaseObject["objectType"] = sol::readonly_property(&BaseObject::getObjectType); + auto luaBaseObject + = lua.new_usertype("tes3baseObject"); + luaBaseObject["objectType"] + = sol::readonly_property(&BaseObject::getObjectType); luaBaseObject["doArmorThing"] = &BaseObject::doArmorThing; luaBaseObject["doWeaponThing"] = &BaseObject::doWeaponThing; auto luaArmorObject = lua.new_usertype("tes3armor"); - luaArmorObject[sol::base_classes] = sol::bases(); + luaArmorObject[sol::base_classes] + = sol::bases(); luaArmorObject["doArmorThing"] = &Armor::doArmorThing; - auto luaWeaponObject = lua.new_usertype("tes3weapon"); - luaWeaponObject[sol::base_classes] = sol::bases(); + auto luaWeaponObject + = lua.new_usertype("tes3weapon"); + luaWeaponObject[sol::base_classes] + = sol::bases(); luaWeaponObject["doWeaponThing"] = &Weapon::doWeaponThing; // Objects we'll play with. @@ -173,10 +198,14 @@ int main() { lua["sharedArmor"] = std::make_shared(); std::cout << std::endl; - std::cout << "Smart pointers put as the base class..." << std::endl; - lua["sharedBaseAsBase"] = (std::shared_ptr)std::make_shared(); - lua["sharedArmorAsBase"] = (std::shared_ptr)std::make_shared(); - lua["sharedArmorAsBase"] = (std::shared_ptr)std::make_shared(); + std::cout << "Smart pointers put as the base class..." + << std::endl; + lua["sharedBaseAsBase"] = (std::shared_ptr) + std::make_shared(); + lua["sharedArmorAsBase"] = (std::shared_ptr) + std::make_shared(); + lua["sharedArmorAsBase"] = (std::shared_ptr) + std::make_shared(); std::cout << std::endl; return 0; diff --git a/examples/source/customization_convert_on_get.cpp b/examples/source/customization_convert_on_get.cpp index 29b9eb17..d7b0ed96 100644 --- a/examples/source/customization_convert_on_get.cpp +++ b/examples/source/customization_convert_on_get.cpp @@ -9,19 +9,30 @@ struct number_shim { }; template -bool sol_lua_check(sol::types, lua_State* L, int index, Handler&& handler, sol::stack::record& tracking) { - // check_usertype is a backdoor for directly checking sol3 usertypes - if (!sol::stack::check_usertype(L, index) && !sol::stack::check(L, index)) { - handler(L, index, sol::type_of(L, index), sol::type::userdata, "expected a number_shim or a number"); +bool sol_lua_check(sol::types, lua_State* L, + int index, Handler&& handler, + sol::stack::record& tracking) { + // check_usertype is a backdoor for directly checking sol2 + // usertypes + if (!sol::stack::check_usertype(L, index) + && !sol::stack::check(L, index)) { + handler(L, + index, + sol::type_of(L, index), + sol::type::userdata, + "expected a number_shim or a number"); return false; } tracking.use(1); return true; } -number_shim sol_lua_get(sol::types, lua_State* L, int index, sol::stack::record& tracking) { +number_shim sol_lua_get(sol::types, lua_State* L, + int index, sol::stack::record& tracking) { if (sol::stack::check_usertype(L, index)) { - number_shim& ns = sol::stack::get_usertype(L, index, tracking); + number_shim& ns + = sol::stack::get_usertype( + L, index, tracking); return ns; } number_shim ns {}; diff --git a/examples/source/customization_global_transparent_argument.cpp b/examples/source/customization_global_transparent_argument.cpp index 11ac6484..98821a42 100644 --- a/examples/source/customization_global_transparent_argument.cpp +++ b/examples/source/customization_global_transparent_argument.cpp @@ -2,14 +2,17 @@ #include // Something that can't be collided with -static const auto& script_key = "GlobalResource.MySpecialIdentifier123"; +static const auto& script_key + = "GlobalResource.MySpecialIdentifier123"; struct GlobalResource { int value = 2; }; template -bool sol_lua_check(sol::types, lua_State* L, int /*index*/, Handler&& handler, sol::stack::record& tracking) { +bool sol_lua_check(sol::types, lua_State* L, + int /*index*/, Handler&& handler, + sol::stack::record& tracking) { // not actually taking anything off the stack tracking.use(0); // get the field from global storage @@ -18,26 +21,34 @@ bool sol_lua_check(sol::types, lua_State* L, int /*index*/, Han sol::type t = static_cast(lua_type(L, -1)); lua_pop(L, 1); if (t != sol::type::lightuserdata) { - handler(L, 0, sol::type::lightuserdata, t, "global resource is not present as a light userdata"); + handler(L, + 0, + sol::type::lightuserdata, + t, + "global resource is not present as a light " + "userdata"); return false; } return true; } -GlobalResource* sol_lua_get(sol::types, lua_State* L, int /*index*/, sol::stack::record& tracking) { +GlobalResource* sol_lua_get(sol::types, + lua_State* L, int /*index*/, sol::stack::record& tracking) { // retrieve the (light) userdata for this type // not actually pulling anything off the stack tracking.use(0); sol::stack::get_field(L, script_key); - GlobalResource* ls = static_cast(lua_touserdata(L, -1)); + GlobalResource* ls + = static_cast(lua_touserdata(L, -1)); // clean up stack value returned by `get_field` lua_pop(L, 1); return ls; } -int sol_lua_push(sol::types, lua_State* L, GlobalResource* ls) { +int sol_lua_push(sol::types, lua_State* L, + GlobalResource* ls) { // push light userdata return sol::stack::push(L, static_cast(ls)); } @@ -50,7 +61,9 @@ int main() { GlobalResource instance; // get GlobalResource - lua.set_function("f", [](GlobalResource* l, int value) { return l->value + value; }); + lua.set_function("f", [](GlobalResource* l, int value) { + return l->value + value; + }); lua.set(script_key, &instance); // note only 1 argument, diff --git a/examples/source/customization_multiple.cpp b/examples/source/customization_multiple.cpp index d36587d5..193ea8c4 100644 --- a/examples/source/customization_multiple.cpp +++ b/examples/source/customization_multiple.cpp @@ -9,19 +9,26 @@ struct two_things { }; template -bool sol_lua_check(sol::types, lua_State* L, int index, Handler&& handler, sol::stack::record& tracking) { - // indices can be negative to count backwards from the top of the stack, - // rather than the bottom up - // to deal with this, we adjust the index to - // its absolute position using the lua_absindex function +bool sol_lua_check(sol::types, lua_State* L, + int index, Handler&& handler, + sol::stack::record& tracking) { + // indices can be negative to count backwards from the top + // of the stack, rather than the bottom up to deal with + // this, we adjust the index to its absolute position using + // the lua_absindex function int absolute_index = lua_absindex(L, index); - // Check first and second second index for being the proper types - bool success = sol::stack::check(L, absolute_index, handler) && sol::stack::check(L, absolute_index + 1, handler); + // Check first and second second index for being the proper + // types + bool success + = sol::stack::check(L, absolute_index, handler) + && sol::stack::check( + L, absolute_index + 1, handler); tracking.use(2); return success; } -two_things sol_lua_get(sol::types, lua_State* L, int index, sol::stack::record& tracking) { +two_things sol_lua_get(sol::types, lua_State* L, + int index, sol::stack::record& tracking) { int absolute_index = lua_absindex(L, index); // Get the first element int a = sol::stack::get(L, absolute_index); @@ -50,7 +57,8 @@ int main() { lua.open_libraries(sol::lib::base); // Create a pass-through style of function - lua.script("function f ( a, b ) print(a, b) return a, b end"); + lua.script( + "function f ( a, b ) print(a, b) return a, b end"); // get the function out of Lua sol::function f = lua["f"]; diff --git a/examples/source/docs/as_table_ipairs.cpp b/examples/source/docs/as_table_ipairs.cpp index b16c15fc..50604407 100644 --- a/examples/source/docs/as_table_ipairs.cpp +++ b/examples/source/docs/as_table_ipairs.cpp @@ -7,8 +7,11 @@ int main(int, char*[]) { sol::state lua; lua.open_libraries(); - lua.set("my_table", sol::as_table(std::vector { 1, 2, 3, 4, 5 })); - lua.script("for k, v in ipairs(my_table) do print(k, v) assert(k == v) end"); + lua.set("my_table", + sol::as_table(std::vector { 1, 2, 3, 4, 5 })); + lua.script( + "for k, v in ipairs(my_table) do print(k, v) assert(k " + "== v) end"); return 0; } diff --git a/examples/source/docs/coroutine_main.cpp b/examples/source/docs/coroutine_main.cpp index 8913887e..45509b64 100644 --- a/examples/source/docs/coroutine_main.cpp +++ b/examples/source/docs/coroutine_main.cpp @@ -35,14 +35,15 @@ end // we start from 0; // we want 10 values, and we only want to // run if the coroutine "loop_coroutine" is valid - for (int counter = 0; counter < 10 && loop_coroutine; ++counter) { + for (int counter = 0; counter < 10 && loop_coroutine; + ++counter) { // Alternative: counter < 10 && cr.valid() - // Call the coroutine, does the computation and then suspends - // once it returns, we get the value back from the return - // and then can use it - // we can either leave the coroutine like that can come to it later, - // or loop back around + // Call the coroutine, does the computation and then + // suspends once it returns, we get the value back from + // the return and then can use it we can either leave + // the coroutine like that can come to it later, or + // loop back around int value = loop_coroutine(); std::cout << "In C++: " << value << std::endl; } diff --git a/examples/source/docs/coroutine_thread.cpp b/examples/source/docs/coroutine_thread.cpp index 6cfb500b..d8b74c7b 100644 --- a/examples/source/docs/coroutine_thread.cpp +++ b/examples/source/docs/coroutine_thread.cpp @@ -27,8 +27,10 @@ end sol::coroutine loop_coroutine = runnerstate["loop"]; lua["counter"] = 20; - for (int counter = 0; counter < 10 && loop_coroutine; ++counter) { - // Call the coroutine, does the computation and then suspends + for (int counter = 0; counter < 10 && loop_coroutine; + ++counter) { + // Call the coroutine, does the computation and then + // suspends int value = loop_coroutine(); std::cout << "value is " << value << std::endl; } diff --git a/examples/source/docs/inheritance.cpp b/examples/source/docs/inheritance.cpp index c7b13af1..c011db46 100644 --- a/examples/source/docs/inheritance.cpp +++ b/examples/source/docs/inheritance.cpp @@ -22,7 +22,11 @@ int main(int, char*[]) { lua.new_usertype("A", "call", &A::call); - lua.new_usertype("B", "call", &B::call, sol::base_classes, sol::bases()); + lua.new_usertype("B", + "call", + &B::call, + sol::base_classes, + sol::bases()); return 0; } diff --git a/examples/source/docs/my_panic.cpp b/examples/source/docs/my_panic.cpp index 97d3f4c9..443a7b77 100644 --- a/examples/source/docs/my_panic.cpp +++ b/examples/source/docs/my_panic.cpp @@ -3,21 +3,24 @@ #include inline void my_panic(sol::optional maybe_msg) { - std::cerr << "Lua is in a panic state and will now abort() the application" << std::endl; + std::cerr << "Lua is in a panic state and will now abort() " + "the application" + << std::endl; if (maybe_msg) { const std::string& msg = maybe_msg.value(); std::cerr << "\terror message: " << msg << std::endl; } - // When this function exits, Lua will exhibit default behavior and abort() + // When this function exits, Lua will exhibit default + // behavior and abort() } int main(int, char*[]) { sol::state lua(sol::c_call); // or, if you already have a lua_State* L - // lua_atpanic( L, sol::c_call ); - // or, with state/state_view: - // sol::state_view lua(L); - // lua.set_panic( sol::c_call ); + // lua_atpanic( L, sol::c_call ); or, with state/state_view: sol::state_view + // lua(L); lua.set_panic( sol::c_call ); // uncomment the below to see // lua.script("boom_goes.the_dynamite"); diff --git a/examples/source/docs/preparing_environments.cpp b/examples/source/docs/preparing_environments.cpp index be498df5..bdd8871d 100644 --- a/examples/source/docs/preparing_environments.cpp +++ b/examples/source/docs/preparing_environments.cpp @@ -13,7 +13,8 @@ int main(int, char*[]) { my_env["var"] = 50; my_env["print"] = lua["print"]; - sol::environment my_other_env(lua, sol::create, lua.globals()); + sol::environment my_other_env( + lua, sol::create, lua.globals()); // do not need to explicitly allow access to "print", // since we used the "Set a fallback" version // of the sol::environment constructor diff --git a/examples/source/docs/runtime_extension.cpp b/examples/source/docs/runtime_extension.cpp index b1fa4738..3088b34e 100644 --- a/examples/source/docs/runtime_extension.cpp +++ b/examples/source/docs/runtime_extension.cpp @@ -19,7 +19,8 @@ int main(int, char*[]) { // runtime additions: through the sol API lua["object"]["func"] = [](object& o) { return o.value; }; // runtime additions: through a lua script - lua.script("function object:print () print(self:func()) end"); + lua.script( + "function object:print () print(self:func()) end"); // see it work lua.script("local obj = object.new() \n obj:print()"); diff --git a/examples/source/docs/simple_structs.cpp b/examples/source/docs/simple_structs.cpp index ce8d529a..8ba4adb5 100644 --- a/examples/source/docs/simple_structs.cpp +++ b/examples/source/docs/simple_structs.cpp @@ -12,7 +12,8 @@ struct vars { int main() { sol::state lua; - lua.new_usertype("vars", "boop", &vars::boop, "bop", &vars::bop); + lua.new_usertype( + "vars", "boop", &vars::boop, "bop", &vars::bop); lua.script( "beep = vars.new()\n" "beep.boop = 1\n" diff --git a/examples/source/docs/state_script_safe.cpp b/examples/source/docs/state_script_safe.cpp index 633f71e1..467a24ba 100644 --- a/examples/source/docs/state_script_safe.cpp +++ b/examples/source/docs/state_script_safe.cpp @@ -8,26 +8,35 @@ int main() { std::cout << "=== safe_script usage ===" << std::endl; sol::state lua; - // uses sol::script_default_on_error, which either panics or throws, - // depending on your configuration and compiler settings + // uses sol::script_default_on_error, which either panics or + // throws, depending on your configuration and compiler + // settings try { auto result1 = lua.safe_script("bad.code"); } catch (const sol::error& e) { - std::cout << "an expected error has occurred: " << e.what() << std::endl; + std::cout << "an expected error has occurred: " + << e.what() << std::endl; } // a custom handler that you write yourself - // is only called when an error happens with loading or running the script - auto result2 = lua.safe_script("123 bad.code", [](lua_State*, sol::protected_function_result pfr) { - // pfr will contain things that went wrong, for either loading or executing the script - // the user can do whatever they like here, including throw. Otherwise... - sol::error err = pfr; - std::cout << "An error (an expected one) occurred: " << err.what() << std::endl; + // is only called when an error happens with loading or + // running the script + auto result2 = lua.safe_script("123 bad.code", + [](lua_State*, sol::protected_function_result pfr) { + // pfr will contain things that went wrong, for + // either loading or executing the script the user + // can do whatever they like here, including + // throw. Otherwise... + sol::error err = pfr; + std::cout + << "An error (an expected one) occurred: " + << err.what() << std::endl; - // ... they need to return the protected_function_result - return pfr; - }); + // ... they need to return the + // protected_function_result + return pfr; + }); std::cout << std::endl; diff --git a/examples/source/docs/state_transfer.cpp b/examples/source/docs/state_transfer.cpp index 8e77db2f..af114daa 100644 --- a/examples/source/docs/state_transfer.cpp +++ b/examples/source/docs/state_transfer.cpp @@ -9,12 +9,15 @@ int main(int, char*[]) { sol::state lua; lua.open_libraries(); sol::function transferred_into; - lua["f"] = [&lua, &transferred_into](sol::object t, sol::this_state this_L) { - std::cout << "state of main : " << (void*)lua.lua_state() << std::endl; - std::cout << "state of function : " << (void*)this_L.lua_state() << std::endl; - // pass original lua_State* (or sol::state/sol::state_view) - // transfers ownership from the state of "t", - // to the "lua" sol::state + lua["f"] = [&lua, &transferred_into]( + sol::object t, sol::this_state this_L) { + std::cout << "state of main : " + << (void*)lua.lua_state() << std::endl; + std::cout << "state of function : " + << (void*)this_L.lua_state() << std::endl; + // pass original lua_State* (or + // sol::state/sol::state_view) transfers ownership from + // the state of "t", to the "lua" sol::state transferred_into = sol::function(lua, t); }; diff --git a/examples/source/docs/std_thread.cpp b/examples/source/docs/std_thread.cpp index c6101692..3c15f80b 100644 --- a/examples/source/docs/std_thread.cpp +++ b/examples/source/docs/std_thread.cpp @@ -25,8 +25,10 @@ struct worker_data { void worker_thread(worker_data& data) { for (std::uint64_t loops = 0; true; ++loops) { // Wait until main() sends data - std::unique_lock data_lock(data.until_ready_mutex); - data.until_ready_condition.wait(data_lock, [&data] { return data.is_ready; }); + std::unique_lock data_lock( + data.until_ready_mutex); + data.until_ready_condition.wait( + data_lock, [&data] { return data.is_ready; }); if (data.payload.size() == 0) { // signaling we are done @@ -37,7 +39,8 @@ void worker_thread(worker_data& data) { sol::state& lua = data.worker_lua; // we own the lock now, do the work - std::variant> result = lua.safe_script(data.payload.as_string_view()); + std::variant> result + = lua.safe_script(data.payload.as_string_view()); // store returning payload, // clear current payload @@ -45,7 +48,8 @@ void worker_thread(worker_data& data) { data.payload.clear(); // Send result back to main - std::cout << "worker_thread data processing is completed: signaling & unlocking\n"; + std::cout << "worker_thread data processing is " + "completed: signaling & unlocking\n"; data.is_processed = true; data.is_ready = false; data_lock.unlock(); @@ -88,9 +92,12 @@ int main() { // send data to the worker thread { - std::lock_guard lk(data.until_ready_mutex); + std::lock_guard lk( + data.until_ready_mutex); data.is_ready = true; - std::cout << "function serialized: sending to worker thread to execute on Lua state...\n"; + std::cout + << "function serialized: sending to worker " + "thread to execute on Lua state...\n"; } data.until_ready_condition.notify_one(); @@ -99,27 +106,43 @@ int main() { } // wait for the worker { - std::unique_lock lock_waiting_for_worker(data.until_ready_mutex); - data.until_ready_condition.wait(lock_waiting_for_worker, [&data] { return data.is_processed; }); + std::unique_lock + lock_waiting_for_worker( + data.until_ready_mutex); + data.until_ready_condition.wait( + lock_waiting_for_worker, + [&data] { return data.is_processed; }); data.is_processed = false; } auto data_processor = [](auto& returned_data) { - using option_type = std::remove_cv_t>; - if constexpr (std::is_same_v) { - std::cout << "received a double: " << returned_data << "\n"; + using option_type + = std::remove_cv_t>; + if constexpr (std::is_same_v) { + std::cout << "received a double: " + << returned_data << "\n"; } - else if constexpr (std::is_same_v>) { - std::cout << "received a std::vector: { "; - for (std::size_t i = 0; i < returned_data.size(); ++i) { + else if constexpr (std::is_same_v>) { + std::cout + << "received a std::vector: { "; + for (std::size_t i = 0; + i < returned_data.size(); + ++i) { std::cout << returned_data[i]; - if (i != static_cast(returned_data.size() - 1)) { + if (i + != static_cast( + returned_data.size() - 1)) { std::cout << ", "; } } std::cout << " }\n"; } else { - std::cerr << "OH MY GOD YOU FORGOT TO HANDLE A TYPE OF DATA FROM A WORKER ABORT ABORT ABORT\n"; + std::cerr << "OH MY GOD YOU FORGOT TO " + "HANDLE A TYPE OF DATA FROM A " + "WORKER ABORT ABORT ABORT\n"; std::abort(); } }; diff --git a/examples/source/dump.cpp b/examples/source/dump.cpp index aaf39342..decb448f 100644 --- a/examples/source/dump.cpp +++ b/examples/source/dump.cpp @@ -5,7 +5,8 @@ int main() { - std::cout << "=== dump (serialize between states) ===" << std::endl; + std::cout << "=== dump (serialize between states) ===" + << std::endl; // 2 states, transferring function from 1 to another sol::state lua; @@ -18,17 +19,20 @@ int main() { lua2.open_libraries(sol::lib::base); // load this code (but do not run) - sol::load_result lr = lua.load("a = function (v) print(v) return v end"); + sol::load_result lr + = lua.load("a = function (v) print(v) return v end"); // check if it's sucessfully loaded sol_c_assert(lr.valid()); // turn it into a function, then dump the bytecode - sol::protected_function target = lr.get(); + sol::protected_function target + = lr.get(); sol::bytecode target_bc = target.dump(); // reload the byte code // in the SECOND state - auto result2 = lua2.safe_script(target_bc.as_string_view(), sol::script_pass_on_error); + auto result2 = lua2.safe_script( + target_bc.as_string_view(), sol::script_pass_on_error); // check if it was done properly sol_c_assert(result2.valid()); diff --git a/examples/source/dynamic_object.cpp b/examples/source/dynamic_object.cpp index d656fb87..a2a60ae6 100644 --- a/examples/source/dynamic_object.cpp +++ b/examples/source/dynamic_object.cpp @@ -13,10 +13,12 @@ struct dynamic_object { void dynamic_set(std::string key, sol::stack_object value) { auto it = entries.find(key); if (it == entries.cend()) { - entries.insert(it, { std::move(key), std::move(value) }); + entries.insert( + it, { std::move(key), std::move(value) }); } else { - std::pair& kvp = *it; + std::pair& kvp + = *it; sol::object& entry = kvp.second; entry = sol::object(std::move(value)); } @@ -74,10 +76,12 @@ assert(value == 15) )"); // does not work on d1: 'run' wasn't added to d1, only d2 - auto script_result = lua.safe_script("local value = d1:run(5)", sol::script_pass_on_error); + auto script_result = lua.safe_script( + "local value = d1:run(5)", sol::script_pass_on_error); sol_c_assert(!script_result.valid()); sol::error err = script_result; - std::cout << "received expected error: " << err.what() << std::endl; + std::cout << "received expected error: " << err.what() + << std::endl; std::cout << std::endl; return 0; diff --git a/examples/source/environment_snooping.cpp b/examples/source/environment_snooping.cpp index d5a86268..b5591025 100644 --- a/examples/source/environment_snooping.cpp +++ b/examples/source/environment_snooping.cpp @@ -3,34 +3,40 @@ #include -// Simple sol3 version of the below +// Simple sol2 version of the below void simple(sol::this_state ts, sol::this_environment te) { sol::state_view lua = ts; if (te) { sol::environment& env = te; sol::environment freshenv = lua["freshenv"]; bool is_same_env = freshenv == env; - std::cout << "this_environment -- env == freshenv : " << is_same_env << std::endl; + std::cout << "this_environment -- env == freshenv : " + << is_same_env << std::endl; } - std::cout << "this_environment -- no environment present" << std::endl; + std::cout << "this_environment -- no environment present" + << std::endl; } // NOTE: // THIS IS A LOW-LEVEL EXAMPLE, using pieces of sol2 // to facilitate better usage -// It is recommended you just do the simple version, as it is basically this code -// but it is sometimes useful to show the hoops you need to jump through to use the Lua C API +// It is recommended you just do the simple version, as it is +// basically this code but it is sometimes useful to show the +// hoops you need to jump through to use the Lua C API void complicated(sol::this_state ts) { lua_State* L = ts; lua_Debug info; - // Level 0 means current function (this C function, which is useless for our purposes) - // Level 1 means next call frame up the stack. This is probably the environment we're looking for? + // Level 0 means current function (this C function, which is + // useless for our purposes) Level 1 means next call frame + // up the stack. This is probably the environment we're + // looking for? int level = 1; int pre_stack_size = lua_gettop(L); if (lua_getstack(L, level, &info) != 1) { // failure: call it quits - std::cout << "error: unable to traverse the stack" << std::endl; + std::cout << "error: unable to traverse the stack" + << std::endl; lua_settop(L, pre_stack_size); return; } @@ -40,32 +46,38 @@ void complicated(sol::this_state ts) { // the rest is for printing / debugging purposes if (lua_getinfo(L, "fnluS", &info) == 0) { // failure? - std::cout << "manually -- error: unable to get stack information" << std::endl; + std::cout << "manually -- error: unable to get stack " + "information" + << std::endl; lua_settop(L, pre_stack_size); return; } // Okay, so all the calls worked. // Print out some information about this "level" - std::cout << "manually -- [" << level << "] " << info.short_src << ":" << info.currentline << " -- " << (info.name ? info.name : "") << "[" - << info.what << "]" << std::endl; + std::cout << "manually -- [" << level << "] " + << info.short_src << ":" << info.currentline + << " -- " << (info.name ? info.name : "") + << "[" << info.what << "]" << std::endl; // Grab the function off the top of the stack - // remember: -1 means top, -2 means 1 below the top, and so on... - // 1 means the very bottom of the stack, - // 2 means 1 more up, and so on to the top value... + // remember: -1 means top, -2 means 1 below the top, and so + // on... 1 means the very bottom of the stack, 2 means 1 + // more up, and so on to the top value... sol::function f(L, -1); // The environment can now be ripped out of the function sol::environment env(sol::env_key, f); if (!env.valid()) { - std::cout << "manually -- error: no environment to get" << std::endl; + std::cout << "manually -- error: no environment to get" + << std::endl; lua_settop(L, pre_stack_size); return; } sol::state_view lua(L); sol::environment freshenv = lua["freshenv"]; bool is_same_env = freshenv == env; - std::cout << "manually -- env == freshenv : " << is_same_env << std::endl; + std::cout << "manually -- env == freshenv : " << is_same_env + << std::endl; } int main() { diff --git a/examples/source/environment_state.cpp b/examples/source/environment_state.cpp index 2c2e5d45..c5554fe6 100644 --- a/examples/source/environment_state.cpp +++ b/examples/source/environment_state.cpp @@ -17,7 +17,8 @@ int main(int, char*[]) { my_env["var"] = 50; my_env["print"] = lua["print"]; - sol::environment my_other_env(lua, sol::create, lua.globals()); + sol::environment my_other_env( + lua, sol::create, lua.globals()); // do not need to explicitly allow access to "print", // since we used the "Set a fallback" version // of the sol::environment constructor diff --git a/examples/source/environments.cpp b/examples/source/environments.cpp index 0087dea3..2afa28ea 100644 --- a/examples/source/environments.cpp +++ b/examples/source/environments.cpp @@ -3,20 +3,30 @@ #include -void test_environment(std::string key, const sol::environment& env, const sol::state_view& lua) { +void test_environment(std::string key, + const sol::environment& env, const sol::state_view& lua) { sol::optional maybe_env_a = env[key]; sol::optional maybe_global_a = lua[key]; if (maybe_global_a) { - std::cout << "\t'" << key << "' is " << maybe_global_a.value() << " in the global environment" << std::endl; + std::cout << "\t'" << key << "' is " + << maybe_global_a.value() + << " in the global environment" << std::endl; } else { - std::cout << "\t'" << key << "' does not exist in the global environment" << std::endl; + std::cout + << "\t'" << key + << "' does not exist in the global environment" + << std::endl; } if (maybe_env_a) { - std::cout << "\t'" << key << "' is " << maybe_env_a.value() << " in target environment" << std::endl; + std::cout << "\t'" << key << "' is " + << maybe_env_a.value() + << " in target environment" << std::endl; } else { - std::cout << "\t'" << key << "' does not exist in target environment" << std::endl; + std::cout << "\t'" << key + << "' does not exist in target environment" + << std::endl; } } @@ -37,10 +47,13 @@ int main(int, char**) { std::cout << std::endl; // Create an environment with a fallback - sol::environment env_with_fallback(lua, sol::create, lua.globals()); + sol::environment env_with_fallback( + lua, sol::create, lua.globals()); // Use it lua.script("a = 56", env_with_fallback); - std::cout << "-- target: env_with_fallback (fallback is global table)" << std::endl; + std::cout << "-- target: env_with_fallback (fallback is " + "global table)" + << std::endl; test_environment("a", env_with_fallback, lua); test_environment("b", env_with_fallback, lua); std::cout << std::endl; diff --git a/examples/source/environments_on_functions.cpp b/examples/source/environments_on_functions.cpp index 80891202..8c541ebc 100644 --- a/examples/source/environments_on_functions.cpp +++ b/examples/source/environments_on_functions.cpp @@ -7,8 +7,8 @@ int main(int, char**) { sol::state lua; lua.open_libraries(sol::lib::base); - // Environments can set on functions (scripts), userdata and threads - // let's look at functions + // Environments can set on functions (scripts), userdata and + // threads let's look at functions lua.script("f = function() return test end"); sol::function f = lua["f"]; @@ -36,7 +36,8 @@ int main(int, char**) { // the global environment - // is not polluted at all, despite both functions being used and set + // is not polluted at all, despite both functions being used + // and set sol::object global_test = lua["test"]; sol_c_assert(!global_test.valid()); @@ -46,7 +47,8 @@ int main(int, char**) { // gotten from Lua // get the environment from any sol::reference-styled type, - // including sol::object, sol::function, sol::table, sol::userdata ... + // including sol::object, sol::function, sol::table, + // sol::userdata ... lua.set_function("check_f_env", // capture necessary variable in C++ lambda [&env_f](sol::object target) { @@ -55,21 +57,23 @@ int main(int, char**) { sol::environment target_env(sol::env_key, target); int test_env_f = env_f["test"]; int test_target_env = target_env["test"]; - // the environment for f the one gotten from `target` - // are the same + // the environment for f the one gotten from + // `target` are the same sol_c_assert(test_env_f == test_target_env); sol_c_assert(test_env_f == 31); sol_c_assert(env_f == target_env); }); - lua.set_function("check_g_env", [&env_g](sol::function target) { - // equivalent: - sol::environment target_env = sol::get_environment(target); - int test_env_g = env_g["test"]; - int test_target_env = target_env["test"]; - sol_c_assert(test_env_g == test_target_env); - sol_c_assert(test_env_g == 5); - sol_c_assert(env_g == target_env); - }); + lua.set_function( + "check_g_env", [&env_g](sol::function target) { + // equivalent: + sol::environment target_env + = sol::get_environment(target); + int test_env_g = env_g["test"]; + int test_target_env = target_env["test"]; + sol_c_assert(test_env_g == test_target_env); + sol_c_assert(test_env_g == 5); + sol_c_assert(env_g == target_env); + }); lua.script("check_f_env(f)"); lua.script("check_g_env(g)"); diff --git a/examples/source/error_handler.cpp b/examples/source/error_handler.cpp index 5faedc64..d8479aa0 100644 --- a/examples/source/error_handler.cpp +++ b/examples/source/error_handler.cpp @@ -48,7 +48,8 @@ int main() { std::cout << what << std::endl; } - // errors, calls handler and then returns a string error from Lua at the top of the stack + // errors, calls handler and then returns a string error + // from Lua at the top of the stack auto secondwoof = problematic_woof(19); if (secondwoof.valid()) { // Call succeeded @@ -57,9 +58,9 @@ int main() { } else { // Call failed - // Note that if the handler was successfully called, this will include - // the additional appended error message information of - // "got_problems handler: " ... + // Note that if the handler was successfully called, + // this will include the additional appended error + // message information of "got_problems handler: " ... sol::error err = secondwoof; std::string what = err.what(); std::cout << what << std::endl; diff --git a/examples/source/exception_handler.cpp b/examples/source/exception_handler.cpp index 1f12ee23..78c3f67f 100644 --- a/examples/source/exception_handler.cpp +++ b/examples/source/exception_handler.cpp @@ -4,11 +4,16 @@ #include -int my_exception_handler(lua_State* L, sol::optional maybe_exception, sol::string_view description) { - // L is the lua state, which you can wrap in a state_view if necessary - // maybe_exception will contain exception, if it exists - // description will either be the what() of the exception or a description saying that we hit the general-case catch(...) - std::cout << "An exception occurred in a function, here's what it says "; +int my_exception_handler(lua_State* L, + sol::optional maybe_exception, + sol::string_view description) { + // L is the lua state, which you can wrap in a state_view if + // necessary maybe_exception will contain exception, if it + // exists description will either be the what() of the + // exception or a description saying that we hit the + // general-case catch(...) + std::cout << "An exception occurred in a function, here's " + "what it says "; if (maybe_exception) { std::cout << "(straight from the exception): "; const std::exception& ex = *maybe_exception; @@ -16,14 +21,16 @@ int my_exception_handler(lua_State* L, sol::optional mayb } else { std::cout << "(from the description parameter): "; - std::cout.write(description.data(), static_cast(description.size())); + std::cout.write(description.data(), + static_cast(description.size())); std::cout << std::endl; } // you must push 1 element onto the stack to be // transported through as the error object in Lua - // note that Lua -- and 99.5% of all Lua users and libraries -- expects a string - // so we push a single string (in our case, the description of the error) + // note that Lua -- and 99.5% of all Lua users and libraries + // -- expects a string so we push a single string (in our + // case, the description of the error) return sol::stack::push(L, description); } @@ -40,7 +47,8 @@ int main() { lua.set_function("will_throw", &will_throw); - sol::protected_function_result pfr = lua.safe_script("will_throw()", &sol::script_pass_on_error); + sol::protected_function_result pfr = lua.safe_script( + "will_throw()", &sol::script_pass_on_error); sol_c_assert(!pfr.valid()); diff --git a/examples/source/functions.cpp b/examples/source/functions.cpp index 134b3885..05070f2b 100644 --- a/examples/source/functions.cpp +++ b/examples/source/functions.cpp @@ -27,7 +27,8 @@ int main() { lua.set_function("my_add", my_add); // you could even use a lambda - lua.set_function("my_mul", [](double x, double y) { return x * y; }); + lua.set_function( + "my_mul", [](double x, double y) { return x * y; }); // member function pointers and functors as well lua.set_function("mult_by_ten", multiplier {}); diff --git a/examples/source/functions_empty_arguments.cpp b/examples/source/functions_empty_arguments.cpp index 2150d2ce..e5900289 100644 --- a/examples/source/functions_empty_arguments.cpp +++ b/examples/source/functions_empty_arguments.cpp @@ -10,7 +10,8 @@ int main(int, char*[]) { // sol::object (and main_* types) can all be // used to capture "nil", or "none" when a function // leaves it off - auto my_defaulting_function = [](sol::object maybe_defaulted) -> int { + auto my_defaulting_function + = [](sol::object maybe_defaulted) -> int { // if it's nil, it's "unused" or "inactive" bool inactive = maybe_defaulted == sol::lua_nil; if (inactive) { @@ -27,7 +28,8 @@ int main(int, char*[]) { lua.open_libraries(sol::lib::base); // copy function in (use std::ref to change this behavior) - lua.set_function("defaulting_function", my_defaulting_function); + lua.set_function( + "defaulting_function", my_defaulting_function); sol::string_view code = R"( result = defaulting_function(24) diff --git a/examples/source/index_and_newindex_usertype.cpp b/examples/source/index_and_newindex_usertype.cpp index c8772cf8..bd830c24 100644 --- a/examples/source/index_and_newindex_usertype.cpp +++ b/examples/source/index_and_newindex_usertype.cpp @@ -26,8 +26,12 @@ public: int main() { sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype( - "vector", sol::constructors>(), sol::meta_function::index, &vector::my_index, sol::meta_function::new_index, &vector::my_new_index); + lua.new_usertype("vector", + sol::constructors>(), + sol::meta_function::index, + &vector::my_index, + sol::meta_function::new_index, + &vector::my_new_index); lua.script( "v = vector.new()\n" "print(v[1])\n" diff --git a/examples/source/indirect_function_calls.cpp b/examples/source/indirect_function_calls.cpp index 735e3bde..3e25baa9 100644 --- a/examples/source/indirect_function_calls.cpp +++ b/examples/source/indirect_function_calls.cpp @@ -3,7 +3,9 @@ #include -sol::variadic_results call_it(sol::object function_name, sol::variadic_args args, sol::this_environment env, sol::this_state L) { +sol::variadic_results call_it(sol::object function_name, + sol::variadic_args args, sol::this_environment env, + sol::this_state L) { sol::state_view lua = L; // default to global table as environment sol::environment function_environment = lua.globals(); @@ -13,7 +15,8 @@ sol::variadic_results call_it(sol::object function_name, sol::variadic_args args } // get and call the function - sol::protected_function pf = function_environment[function_name]; + sol::protected_function pf + = function_environment[function_name]; sol::protected_function_result res = pf(args); // diff --git a/examples/source/lua_value.cpp b/examples/source/lua_value.cpp index 07577d42..a15178bc 100644 --- a/examples/source/lua_value.cpp +++ b/examples/source/lua_value.cpp @@ -24,16 +24,27 @@ struct int_entry { int main(int, char*[]) { - std::cout << "=== sol::lua_value/sol::array_value ===" << std::endl; + std::cout << "=== sol::lua_value/sol::array_value ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base, sol::lib::io); sol::lua_value lv_int(lua, 56); sol::lua_value lv_int_table(lua, { 1, 2, 3, 4, 5 }); - sol::lua_value lv_map(lua, { { "bark bark", "meow hiss!" }, { 3, 4 }, { ":D", 6 } }); - sol::lua_value lv_mixed_table(lua, sol::array_value { 1, int_entry(2), 3, int_entry(4), 5 }); - sol::lua_value lv_mixed_nested_table(lua, sol::array_value { 1, int_entry(2), 3, int_entry(4), sol::array_value { 5, 6, int_entry(7), "8" } }); + sol::lua_value lv_map(lua, + { { "bark bark", "meow hiss!" }, + { 3, 4 }, + { ":D", 6 } }); + sol::lua_value lv_mixed_table(lua, + sol::array_value { + 1, int_entry(2), 3, int_entry(4), 5 }); + sol::lua_value lv_mixed_nested_table(lua, + sol::array_value { 1, + int_entry(2), + 3, + int_entry(4), + sol::array_value { 5, 6, int_entry(7), "8" } }); const auto& code = R"( function real_print_recursive (e, level) @@ -68,7 +79,8 @@ int main(int, char*[]) { end )"; - sol::optional maybe_error = lua.safe_script(code, sol::script_pass_on_error); + sol::optional maybe_error + = lua.safe_script(code, sol::script_pass_on_error); if (maybe_error) { std::cerr << maybe_error->what() << std::endl; return 1; diff --git a/examples/source/metatable_customization.cpp b/examples/source/metatable_customization.cpp index b5faee25..d2cf210d 100644 --- a/examples/source/metatable_customization.cpp +++ b/examples/source/metatable_customization.cpp @@ -17,52 +17,79 @@ struct thing { // cheap storage: in reality, you'd need to find a // better way of handling this. // or not! It's up to you. -static std::unordered_map thing_function_associations; -static std::unordered_map thing_variable_associations; +static std::unordered_map + thing_function_associations; +static std::unordered_map + thing_variable_associations; void register_thing_type(sol::state& lua) { - thing_variable_associations.emplace_hint(thing_variable_associations.cend(), + thing_variable_associations.emplace_hint( + thing_variable_associations.cend(), "member_variable", - sol::object(lua.lua_state(), sol::in_place, &sol::c_call)); - thing_function_associations.emplace_hint(thing_function_associations.cend(), + sol::object(lua.lua_state(), + sol::in_place, + &sol::c_call)); + thing_function_associations.emplace_hint( + thing_function_associations.cend(), "member_function", - sol::object(lua.lua_state(), sol::in_place, &sol::c_call)); + sol::object(lua.lua_state(), + sol::in_place, + &sol::c_call)); struct call_handler { static int lookup_function(lua_State* L) { sol::stack_object source(L, 1); sol::stack_object key(L, 2); if (!source.is()) { - return luaL_error(L, "given an incorrect object for this call"); + return luaL_error(L, + "given an incorrect object for this " + "call"); } - sol::optional maybe_svkey = key.as>(); + sol::optional maybe_svkey + = key.as>(); if (maybe_svkey) { { - // functions are different from variables - // functions, when obtain with the syntax - // obj.f, obj.f(), and obj:f() - // must return the function itself - // so we just push it realy into our target - auto it = thing_function_associations.find(*maybe_svkey); - if (it != thing_function_associations.cend()) { + // functions are different from + // variables functions, when obtain with + // the syntax obj.f, obj.f(), and + // obj:f() must return the function + // itself so we just push it realy into + // our target + auto it + = thing_function_associations.find( + *maybe_svkey); + if (it + != thing_function_associations + .cend()) { return it->second.push(L); } } { // variables are different than funtions - // when someone does `obj.a`, they expect - // this __index call (this lookup function) to - // return to them the value itself they're seeing - // so we call out lua_CFunction that we serialized earlier - auto it = thing_variable_associations.find(*maybe_svkey); - if (it != thing_variable_associations.cend()) { - // note that calls generated by sol3 - // for member variables expect the stack ordering to be - // 2(, 3, ..., n) -- value(s) - // 1 -- source - // so we destroy the key on the stack + // when someone does `obj.a`, they + // expect this __index call (this lookup + // function) to return to them the value + // itself they're seeing so we call out + // lua_CFunction that we serialized + // earlier + auto it + = thing_variable_associations.find( + *maybe_svkey); + if (it + != thing_variable_associations + .cend()) { + // note that calls generated by + // sol2 for member variables expect + // the stack ordering to be 2(, 3, + // ..., n) -- value(s) 1 -- source + // so we destroy the key on the + // stack sol::stack::remove(L, 2, 1); - lua_CFunction cf = it->second.as(); + lua_CFunction cf + = it->second + .as(); return cf(L); } } @@ -75,38 +102,50 @@ void register_thing_type(sol::state& lua) { sol::stack_object key(L, 2); sol::stack_object value(L, 3); if (!source.is()) { - return luaL_error(L, "given an incorrect object for this call"); + return luaL_error(L, + "given an incorrect object for this " + "call"); } // write to member variables, etc. etc... - sol::optional maybe_svkey = key.as>(); + sol::optional maybe_svkey + = key.as>(); if (maybe_svkey) { { // variables are different than funtions - // when someone does `obj.a`, they expect - // this __index call (this lookup function) to - // return to them the value itself they're seeing - // so we call out lua_CFunction that we serialized earlier - auto it = thing_variable_associations.find(*maybe_svkey); - if (it != thing_variable_associations.cend()) { - // note that calls generated by sol3 - // for member variables expect the stack ordering to be - // 2(, 3, ..., n) -- value(s) - // 1 -- source + // when someone does `obj.a`, they + // expect this __index call (this lookup + // function) to return to them the value + // itself they're seeing so we call out + // lua_CFunction that we serialized + // earlier + auto it + = thing_variable_associations.find( + *maybe_svkey); + if (it + != thing_variable_associations + .cend()) { + // note that calls generated by + // sol2 for member variables expect + // the stack ordering to be 2(, 3, + // ..., n) -- value(s) 1 -- source // so we remove the key value sol::stack::remove(L, 2, 1); - lua_CFunction cf = it->second.as(); + lua_CFunction cf + = it->second + .as(); return cf(L); } else { - // write to member variable, maybe override function - // if your class allows for it? + // write to member variable, maybe + // override function if your class + // allows for it? (void)value; } } // exercise for reader: - // how do you override functions on the metatable with - // proper syntax, but error when the type is - // an "instance" object? + // how do you override functions on the + // metatable with proper syntax, but error + // when the type is an "instance" object? } return 0; } @@ -115,8 +154,10 @@ void register_thing_type(sol::state& lua) { lua.new_usertype("thing"); sol::table metatable = lua["thing"]; - metatable[sol::meta_method::index] = &call_handler::lookup_function; - metatable[sol::meta_method::new_index] = &call_handler::insertion_function; + metatable[sol::meta_method::index] + = &call_handler::lookup_function; + metatable[sol::meta_method::new_index] + = &call_handler::insertion_function; } void unregister_thing_type(sol::state&) { @@ -126,7 +167,9 @@ void unregister_thing_type(sol::state&) { int main() { - std::cout << "=== metatable with custom-built (static) handling ===" << std::endl; + std::cout << "=== metatable with custom-built (static) " + "handling ===" + << std::endl; sol::state lua; diff --git a/examples/source/metatable_key_low_level.cpp b/examples/source/metatable_key_low_level.cpp index 62b1694e..37620d4a 100644 --- a/examples/source/metatable_key_low_level.cpp +++ b/examples/source/metatable_key_low_level.cpp @@ -13,7 +13,9 @@ int main(int, char*[]) { sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype("bark", sol::meta_function::call_function, &bark::operator()); + lua.new_usertype("bark", + sol::meta_function::call_function, + &bark::operator()); bark b; lua.set("b", &b); diff --git a/examples/source/multi_results.cpp b/examples/source/multi_results.cpp index 4c76426b..12241bee 100644 --- a/examples/source/multi_results.cpp +++ b/examples/source/multi_results.cpp @@ -14,7 +14,8 @@ int main() { // std::tuple as the transfer type, // sol::as_returns for containers, // and sol::variadic_results for more special things - lua.set_function("multi_tuple", [] { return std::make_tuple(10, "goodbye"); }); + lua.set_function("multi_tuple", + [] { return std::make_tuple(10, "goodbye"); }); lua.script("print('calling multi_tuple')"); lua.script("print(multi_tuple())"); lua.script("x, y = multi_tuple()"); @@ -56,13 +57,16 @@ int main() { // note that sol::this_state is a transparent // argument: you don't need to pass // that state through Lua - lua.set_function("multi_vars", [](int a, bool b, sol::this_state L) { - sol::variadic_results values; - values.push_back({ L, sol::in_place_type, a }); - values.push_back({ L, sol::in_place_type, b }); - values.push_back({ L, sol::in_place, "awoo" }); - return values; - }); + lua.set_function( + "multi_vars", [](int a, bool b, sol::this_state L) { + sol::variadic_results values; + values.push_back( + { L, sol::in_place_type, a }); + values.push_back( + { L, sol::in_place_type, b }); + values.push_back({ L, sol::in_place, "awoo" }); + return values; + }); lua.script("print('calling multi_vars')"); lua.script("print(multi_vars(2, false))"); lua.script("t, u, v = multi_vars(42, true)"); diff --git a/examples/source/optional_with_iteration.cpp b/examples/source/optional_with_iteration.cpp index b93473d6..aa11af90 100644 --- a/examples/source/optional_with_iteration.cpp +++ b/examples/source/optional_with_iteration.cpp @@ -28,20 +28,23 @@ int main(int, char*[]) { // to prevent derived class "super_thing" // from being picked up and cast to its base // class - lua.new_usertype("super_thing", sol::base_classes, sol::bases()); + lua.new_usertype( + "super_thing", sol::base_classes, sol::bases()); // Make a few things lua["t1"] = thing {}; lua["t2"] = super_thing {}; lua["t3"] = unrelated {}; // And a table - lua["container"] = lua.create_table_with(0, thing { 50 }, 1, unrelated {}, 4, super_thing {}); + lua["container"] = lua.create_table_with( + 0, thing { 50 }, 1, unrelated {}, 4, super_thing {}); std::vector> things; // Our recursive function - // We use some lambda techniques and pass the function itself itself so we can recurse, - // but a regular function would work too! + // We use some lambda techniques and pass the function + // itself itself so we can recurse, but a regular function + // would work too! auto fx = [&things](auto& f, auto& tbl) -> void { // You can iterate through a table: it has // begin() and end() @@ -63,16 +66,22 @@ int main(int, char*[]) { case sol::type::userdata: { // This allows us to check if a userdata is // a specific class type - sol::optional maybe_thing = value.as>(); + sol::optional maybe_thing + = value.as>(); if (maybe_thing) { thing& the_thing = maybe_thing.value(); if (key.is()) { - std::cout << "key " << key.as() << " is a thing -- "; + std::cout << "key " + << key.as() + << " is a thing -- "; } else if (key.is()) { - std::cout << "key " << key.as() << " is a thing -- "; + std::cout << "key " + << key.as() + << " is a thing -- "; } - std::cout << "thing.a ==" << the_thing.a << std::endl; + std::cout << "thing.a ==" << the_thing.a + << std::endl; things.push_back(the_thing); } } break; diff --git a/examples/source/overloading_with_fallback.cpp b/examples/source/overloading_with_fallback.cpp index 60d94042..7ea1487d 100644 --- a/examples/source/overloading_with_fallback.cpp +++ b/examples/source/overloading_with_fallback.cpp @@ -11,10 +11,13 @@ std::string func_2(std::string text) { return "received: " + text; } -sol::variadic_results fallback(sol::this_state ts, sol::variadic_args args) { +sol::variadic_results fallback( + sol::this_state ts, sol::variadic_args args) { sol::variadic_results r; if (args.size() == 2) { - r.push_back({ ts, sol::in_place, args.get(0) + args.get(1) }); + r.push_back({ ts, + sol::in_place, + args.get(0) + args.get(1) }); } else { r.push_back({ ts, sol::in_place, 52 }); @@ -23,12 +26,14 @@ sol::variadic_results fallback(sol::this_state ts, sol::variadic_args args) { } int main(int, char*[]) { - std::cout << "=== overloading with fallback ===" << std::endl; + std::cout << "=== overloading with fallback ===" + << std::endl; sol::state lua; lua.open_libraries(); - lua.set_function("f", sol::overload(func_1, func_2, fallback)); + lua.set_function( + "f", sol::overload(func_1, func_2, fallback)); lua.script("print(f(1))"); // func_1 lua.script("print(f('hi'))"); // func_2 diff --git a/examples/source/overloading_with_members.cpp b/examples/source/overloading_with_members.cpp index 8b02ef1e..48dee3d7 100644 --- a/examples/source/overloading_with_members.cpp +++ b/examples/source/overloading_with_members.cpp @@ -27,12 +27,15 @@ void picky_bark(pup& p, std::string s) { } int main() { - std::cout << "=== overloading with members ===" << std::endl; + std::cout << "=== overloading with members ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); - lua.set_function("bark", sol::overload(ultra_bark, []() { return "the bark from nowhere"; })); + lua.set_function("bark", sol::overload(ultra_bark, []() { + return "the bark from nowhere"; + })); lua.new_usertype("pup", // regular function diff --git a/examples/source/overridable_function_members.cpp b/examples/source/overridable_function_members.cpp index 25ed081f..a516348d 100644 --- a/examples/source/overridable_function_members.cpp +++ b/examples/source/overridable_function_members.cpp @@ -4,12 +4,15 @@ #include int main() { - std::cout << "=== override-able member functions ===" << std::endl; + std::cout << "=== override-able member functions ===" + << std::endl; struct thingy { sol::function paint; - thingy(sol::this_state L) : paint(sol::make_reference(L.lua_state(), &thingy::default_paint)) { + thingy(sol::this_state L) + : paint(sol::make_reference( + L.lua_state(), &thingy::default_paint)) { } void default_paint() { @@ -20,7 +23,10 @@ int main() { sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype("thingy", sol::constructors(), "paint", &thingy::paint); + lua.new_usertype("thingy", + sol::constructors(), + "paint", + &thingy::paint); sol::string_view code = R"( obj = thingy.new() diff --git a/examples/source/pairs.cpp b/examples/source/pairs.cpp index d056e539..563b087b 100644 --- a/examples/source/pairs.cpp +++ b/examples/source/pairs.cpp @@ -21,11 +21,14 @@ struct lua_iterator_state { it_t it; it_t last; - lua_iterator_state(my_thing& mt) : it(mt.m.begin()), last(mt.m.end()) { + lua_iterator_state(my_thing& mt) + : it(mt.m.begin()), last(mt.m.end()) { } }; -std::tuple my_next(sol::user user_it_state, sol::this_state l) { +std::tuple my_next( + sol::user user_it_state, + sol::this_state l) { // this gets called // to start the first iteration, and every // iteration there after @@ -38,13 +41,16 @@ std::tuple my_next(sol::user user if (it == it_state.last) { // return nil to signify that // there's nothing more to work with. - return std::make_tuple(sol::object(sol::lua_nil), sol::object(sol::lua_nil)); + return std::make_tuple(sol::object(sol::lua_nil), + sol::object(sol::lua_nil)); } auto itderef = *it; // 2 values are returned (pushed onto the stack): // the key and the value // the state is left alone - auto r = std::make_tuple(sol::object(l, sol::in_place, it->first), sol::object(l, sol::in_place, it->second)); + auto r = std::make_tuple( + sol::object(l, sol::in_place, it->first), + sol::object(l, sol::in_place, it->second)); // the iterator must be moved forward one before we return std::advance(it, 1); return r; @@ -58,10 +64,13 @@ auto my_pairs(my_thing& mt) { // prepare our state lua_iterator_state it_state(mt); - // sol::user is a space/time optimization over regular usertypes, - // it's incompatible with regular usertypes and stores the type T directly in lua without any pretty setup - // saves space allocation and a single dereference - return std::make_tuple(&my_next, sol::user(std::move(it_state)), sol::lua_nil); + // sol::user is a space/time optimization over regular + // usertypes, it's incompatible with regular usertypes and + // stores the type T directly in lua without any pretty + // setup saves space allocation and a single dereference + return std::make_tuple(&my_next, + sol::user(std::move(it_state)), + sol::lua_nil); } int main(int, char*[]) { @@ -70,7 +79,8 @@ int main(int, char*[]) { sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype("my_thing", sol::meta_function::pairs, my_pairs); + lua.new_usertype( + "my_thing", sol::meta_function::pairs, my_pairs); #if SOL_LUA_VERSION > 501 lua.safe_script(R"( diff --git a/examples/source/pairs_with_raw_functions.cpp b/examples/source/pairs_with_raw_functions.cpp index 96392a88..c90daa7b 100644 --- a/examples/source/pairs_with_raw_functions.cpp +++ b/examples/source/pairs_with_raw_functions.cpp @@ -21,7 +21,8 @@ struct lua_iterator_state { it_t it; it_t last; - lua_iterator_state(my_thing& mt) : it(mt.m.begin()), last(mt.m.end()) { + lua_iterator_state(my_thing& mt) + : it(mt.m.begin()), last(mt.m.end()) { } }; @@ -32,7 +33,8 @@ int my_next(lua_State* L) { // the state you passed in pairs is argument 1 // the key value is argument 2 // we do not care about the key value here - lua_iterator_state& it_state = sol::stack::get>(L, 1); + lua_iterator_state& it_state + = sol::stack::get>(L, 1); auto& it = it_state.it; if (it == it_state.last) { return sol::stack::push(L, sol::lua_nil); @@ -57,18 +59,22 @@ int my_pairs(lua_State* L) { // next function controls iteration int pushed = sol::stack::push(L, my_next); - pushed += sol::stack::push>(L, std::move(it_state)); + pushed += sol::stack::push>( + L, std::move(it_state)); pushed += sol::stack::push(L, sol::lua_nil); return pushed; } int main(int, char*[]) { - std::cout << "===== pairs (using raw Lua C functions) (advanced) =====" << std::endl; + std::cout << "===== pairs (using raw Lua C functions) " + "(advanced) =====" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype("my_thing", sol::meta_function::pairs, &my_pairs); + lua.new_usertype( + "my_thing", sol::meta_function::pairs, &my_pairs); #if SOL_LUA_VERSION > 501 lua.safe_script(R"( diff --git a/examples/source/property.cpp b/examples/source/property.cpp index b49b9670..2f173734 100644 --- a/examples/source/property.cpp +++ b/examples/source/property.cpp @@ -29,7 +29,8 @@ private: int main(int, char*[]) { - std::cout << "=== properties from C++ functions ===" << std::endl; + std::cout << "=== properties from C++ functions ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); @@ -38,8 +39,12 @@ int main(int, char*[]) { // Yes, you can register after you set a value and it will // connect up the usertype automatically - lua.new_usertype( - "Player", "hp", sol::property(&Player::get_hp, &Player::set_hp), "maxHp", sol::property(&Player::get_max_hp, &Player::set_max_hp)); + lua.new_usertype("Player", + "hp", + sol::property(&Player::get_hp, &Player::set_hp), + "maxHp", + sol::property( + &Player::get_max_hp, &Player::set_max_hp)); const auto& code = R"( -- variable syntax, calls functions diff --git a/examples/source/protect.cpp b/examples/source/protect.cpp index 7ed6675d..18c6e79c 100644 --- a/examples/source/protect.cpp +++ b/examples/source/protect.cpp @@ -12,7 +12,8 @@ int main(int, char*[]) { sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype("protect_me", "gen", sol::protect(&protect_me::gen)); + lua.new_usertype( + "protect_me", "gen", sol::protect(&protect_me::gen)); lua.script(R"__( pm = protect_me.new() diff --git a/examples/source/protected_functions.cpp b/examples/source/protected_functions.cpp index a73b05d6..ae85bd6a 100644 --- a/examples/source/protected_functions.cpp +++ b/examples/source/protected_functions.cpp @@ -32,13 +32,15 @@ int main() { if (result.valid()) { // Call succeeded int x = result; - std::cout << "call succeeded, result is " << x << std::endl; + std::cout << "call succeeded, result is " << x + << std::endl; } else { // Call failed sol::error err = result; std::string what = err.what(); - std::cout << "call failed, sol::error::what() is " << what << std::endl; + std::cout << "call failed, sol::error::what() is " + << what << std::endl; // 'what' Should read // "Handled this message: negative number detected" } diff --git a/examples/source/read_only.cpp b/examples/source/read_only.cpp index 78dd0981..47e845d5 100644 --- a/examples/source/read_only.cpp +++ b/examples/source/read_only.cpp @@ -23,7 +23,8 @@ int main(int, char*[]) { sol::table obj_table = lua.create_named_table("object"); sol::table obj_metatable = lua.create_table_with(); - obj_metatable.set_function("my_func", &object::my_func, &my_obj); + obj_metatable.set_function( + "my_func", &object::my_func, &my_obj); // Set whatever else you need to // on the obj_metatable, // not on the obj_table itself! @@ -43,7 +44,8 @@ print(object.my_func) )"); } catch (const std::exception& e) { - std::cout << "an expected error occurred: " << e.what() << std::endl; + std::cout << "an expected error occurred: " << e.what() + << std::endl; } return 0; } \ No newline at end of file diff --git a/examples/source/require.cpp b/examples/source/require.cpp index 41615f29..a661ae3a 100644 --- a/examples/source/require.cpp +++ b/examples/source/require.cpp @@ -16,7 +16,8 @@ sol::table open_mylib(sol::this_state s) { return 2; }; // register a class too - module.new_usertype("some_class", "bark", &some_class::bark); + module.new_usertype( + "some_class", "bark", &some_class::bark); return module; } @@ -28,9 +29,12 @@ int main() { lua.open_libraries(sol::lib::package, sol::lib::base); // sol::c_call takes functions at the template level // and turns it into a lua_CFunction - // alternatively, one can use sol::c_call> to make the call - // if it's a constexpr struct - lua.require("my_lib", sol::c_call); + // alternatively, one can use + // sol::c_call> to make the call if it's a constexpr + // struct + lua.require("my_lib", + sol::c_call); // run some code against your require'd library lua.safe_script(R"( diff --git a/examples/source/require_override_behavior.cpp b/examples/source/require_override_behavior.cpp index 7689fff2..e6e44bfa 100644 --- a/examples/source/require_override_behavior.cpp +++ b/examples/source/require_override_behavior.cpp @@ -11,7 +11,7 @@ // -- this is called a "raw C function", // and matches the type for lua_CFunction int LoadFileRequire(lua_State* L) { - // use sol3 stack API to pull + // use sol2 stack API to pull // "first argument" std::string path = sol::stack::get(L, 1); @@ -22,19 +22,22 @@ int LoadFileRequire(lua_State* L) { return "bananas" )"; // load "module", but don't run it - luaL_loadbuffer(L, script.data(), script.size(), path.c_str()); + luaL_loadbuffer( + L, script.data(), script.size(), path.c_str()); // returning 1 object left on Lua stack: // a function that, when called, executes the script // (this is what lua_loadX/luaL_loadX functions return return 1; } - sol::stack::push(L, "This is not the module you're looking for!"); + sol::stack::push( + L, "This is not the module you're looking for!"); return 1; } int main() { - std::cout << "=== require override behavior ===" << std::endl; + std::cout << "=== require override behavior ===" + << std::endl; sol::state lua; // need base for print, @@ -65,9 +68,10 @@ int main() { sol_c_assert(!b_result.valid()); } catch (const std::exception& ex) { - // Whenever sol3 throws an exception from panic, + // Whenever sol2 throws an exception from panic, // catch - std::cout << "Something went wrong, as expected:\n" << ex.what() << std::endl; + std::cout << "Something went wrong, as expected:\n" + << ex.what() << std::endl; // and CRASH / exit the application return 0; } diff --git a/examples/source/script_error_handling.cpp b/examples/source/script_error_handling.cpp index 6b28ef52..a06c64c9 100644 --- a/examples/source/script_error_handling.cpp +++ b/examples/source/script_error_handling.cpp @@ -16,20 +16,23 @@ return 24 /* OPTION 1 */ // Handling code like this can be robust - // If you disable exceptions, then obviously you would remove - // the try-catch branches, - // and then rely on the `lua_atpanic` function being called - // and trapping errors there before exiting the application + // If you disable exceptions, then obviously you would + // remove the try-catch branches, and then rely on the + // `lua_atpanic` function being called and trapping errors + // there before exiting the application { - // script_default_on_error throws / panics when the code is bad: trap the error + // script_default_on_error throws / panics when the + // code is bad: trap the error try { - int value = lua.script(code, sol::script_default_on_error); + int value = lua.script( + code, sol::script_default_on_error); // This will never be reached std::cout << value << std::endl; sol_c_assert(value == 24); } catch (const sol::error& err) { - std::cout << "Something went horribly wrong: thrown error" + std::cout << "Something went horribly wrong: " + "thrown error" << "\n\t" << err.what() << std::endl; } } @@ -38,47 +41,58 @@ return 24 // Use the script_pass_on_error handler // this simply passes through the protected_function_result, // rather than throwing it or calling panic - // This will check code validity and also whether or not it runs well + // This will check code validity and also whether or not it + // runs well { - sol::protected_function_result result = lua.script(code, sol::script_pass_on_error); + sol::protected_function_result result + = lua.script(code, sol::script_pass_on_error); sol_c_assert(!result.valid()); if (!result.valid()) { sol::error err = result; sol::call_status status = result.status(); - std::cout << "Something went horribly wrong: " << sol::to_string(status) << " error" + std::cout << "Something went horribly wrong: " + << sol::to_string(status) << " error" << "\n\t" << err.what() << std::endl; } } /* OPTION 3 */ // This is a lower-level, more explicit way to load code - // This explicitly loads the code, giving you access to any errors - // plus the load status - // then, it turns the loaded code into a sol::protected_function - // which is then called so that the code can run - // you can then check that too, for any errors - // The two previous approaches are recommended + // This explicitly loads the code, giving you access to any + // errors plus the load status then, it turns the loaded + // code into a sol::protected_function which is then called + // so that the code can run you can then check that too, for + // any errors The two previous approaches are recommended { sol::load_result loaded_chunk = lua.load(code); sol_c_assert(!loaded_chunk.valid()); if (!loaded_chunk.valid()) { sol::error err = loaded_chunk; sol::load_status status = loaded_chunk.status(); - std::cout << "Something went horribly wrong loading the code: " << sol::to_string(status) << " error" + std::cout << "Something went horribly wrong " + "loading the code: " + << sol::to_string(status) << " error" << "\n\t" << err.what() << std::endl; } else { - // Because the syntax is bad, this will never be reached + // Because the syntax is bad, this will never be + // reached sol_c_assert(false); - // If there is a runtime error (lua GC memory error, nil access, etc.) - // it will be caught here - sol::protected_function script_func = loaded_chunk.get(); - sol::protected_function_result result = script_func(); + // If there is a runtime error (lua GC memory + // error, nil access, etc.) it will be caught here + sol::protected_function script_func + = loaded_chunk + .get(); + sol::protected_function_result result + = script_func(); if (!result.valid()) { sol::error err = result; sol::call_status status = result.status(); - std::cout << "Something went horribly wrong running the code: " << sol::to_string(status) << " error" - << "\n\t" << err.what() << std::endl; + std::cout + << "Something went horribly wrong " + "running the code: " + << sol::to_string(status) << " error" + << "\n\t" << err.what() << std::endl; } } } diff --git a/examples/source/self_from_lua.cpp b/examples/source/self_from_lua.cpp index d2b7c483..ff95d831 100644 --- a/examples/source/self_from_lua.cpp +++ b/examples/source/self_from_lua.cpp @@ -4,8 +4,9 @@ // NOTE: // There are TWO ways to retrieve the "this" -// object from calls, when it comes to constructors and regular member functions -// please pay attention to both: this is a low-level operation! +// object from calls, when it comes to constructors and regular +// member functions please pay attention to both: this is a +// low-level operation! int main() { struct thing { @@ -38,7 +39,10 @@ int main() { sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype("thing", sol::constructors(), "func", &thing::func); + lua.new_usertype("thing", + sol::constructors(), + "func", + &thing::func); lua.script(R"( obj = thing.new() diff --git a/examples/source/shared_ptr.cpp b/examples/source/shared_ptr.cpp index b0e754cd..4d992d52 100644 --- a/examples/source/shared_ptr.cpp +++ b/examples/source/shared_ptr.cpp @@ -8,31 +8,38 @@ struct my_type { int value = 10; my_type() { - std::cout << "my_type at " << static_cast(this) << " being default constructed!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being default constructed!" + << std::endl; } my_type(const my_type& other) : value(other.value) { - std::cout << "my_type at " << static_cast(this) << " being copy constructed!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being copy constructed!" << std::endl; } my_type(my_type&& other) : value(other.value) { - std::cout << "my_type at " << static_cast(this) << " being move-constructed!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being move-constructed!" << std::endl; } my_type& operator=(const my_type& other) { value = other.value; - std::cout << "my_type at " << static_cast(this) << " being copy-assigned to!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being copy-assigned to!" << std::endl; return *this; } my_type& operator=(my_type&& other) { value = other.value; - std::cout << "my_type at " << static_cast(this) << " being move-assigned to!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being move-assigned to!" << std::endl; return *this; } ~my_type() { - std::cout << "my_type at " << static_cast(this) << " being destructed!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being destructed!" << std::endl; } }; @@ -41,22 +48,34 @@ int main() { std::cout << "=== shared_ptr support ===" << std::endl; sol::state lua; - lua.new_usertype("my_type", "value", &my_type::value); + lua.new_usertype( + "my_type", "value", &my_type::value); { - std::shared_ptr shared = std::make_shared(); + std::shared_ptr shared + = std::make_shared(); lua["shared"] = std::move(shared); } { - std::cout << "getting reference to shared_ptr..." << std::endl; - std::shared_ptr& ref_to_shared_ptr = lua["shared"]; - std::cout << "\tshared.use_count(): " << ref_to_shared_ptr.use_count() << std::endl; + std::cout << "getting reference to shared_ptr..." + << std::endl; + std::shared_ptr& ref_to_shared_ptr + = lua["shared"]; + std::cout << "\tshared.use_count(): " + << ref_to_shared_ptr.use_count() + << std::endl; my_type& ref_to_my_type = lua["shared"]; - std::cout << "\tafter getting reference to my_type: " << ref_to_shared_ptr.use_count() << std::endl; + std::cout << "\tafter getting reference to my_type: " + << ref_to_shared_ptr.use_count() + << std::endl; my_type* ptr_to_my_type = lua["shared"]; - std::cout << "\tafter getting pointer to my_type: " << ref_to_shared_ptr.use_count() << std::endl; + std::cout << "\tafter getting pointer to my_type: " + << ref_to_shared_ptr.use_count() + << std::endl; - sol_c_assert(ptr_to_my_type == ref_to_shared_ptr.get()); - sol_c_assert(&ref_to_my_type == ref_to_shared_ptr.get()); + sol_c_assert( + ptr_to_my_type == ref_to_shared_ptr.get()); + sol_c_assert( + &ref_to_my_type == ref_to_shared_ptr.get()); sol_c_assert(ref_to_shared_ptr->value == 10); // script affects all of them equally @@ -67,16 +86,23 @@ int main() { sol_c_assert(ref_to_shared_ptr->value == 20); } { - std::cout << "getting copy of shared_ptr..." << std::endl; - std::shared_ptr copy_of_shared_ptr = lua["shared"]; - std::cout << "\tshared.use_count(): " << copy_of_shared_ptr.use_count() << std::endl; + std::cout << "getting copy of shared_ptr..." + << std::endl; + std::shared_ptr copy_of_shared_ptr + = lua["shared"]; + std::cout << "\tshared.use_count(): " + << copy_of_shared_ptr.use_count() + << std::endl; my_type copy_of_value = lua["shared"]; - std::cout << "\tafter getting value copy of my_type: " << copy_of_shared_ptr.use_count() << std::endl; + std::cout << "\tafter getting value copy of my_type: " + << copy_of_shared_ptr.use_count() + << std::endl; sol_c_assert(copy_of_shared_ptr->value == 20); sol_c_assert(copy_of_value.value == 20); - // script still affects pointer, but does not affect copy of `my_type` + // script still affects pointer, but does not affect + // copy of `my_type` lua.script("shared.value = 30"); sol_c_assert(copy_of_shared_ptr->value == 30); diff --git a/examples/source/shared_ptr_inheritance.cpp b/examples/source/shared_ptr_inheritance.cpp index 97cc852e..a4cc22fe 100644 --- a/examples/source/shared_ptr_inheritance.cpp +++ b/examples/source/shared_ptr_inheritance.cpp @@ -21,24 +21,40 @@ int main() { lua.new_usertype("Box", sol::factories([&]() { auto b = std::make_shared(); - std::cout << "create Box@" << std::hex << b.get() << '\n'; + std::cout << "create Box@" << std::hex << b.get() + << '\n'; return b; })); - lua.set_function("inspect_shape_table", [](const sol::table& args) { - std::shared_ptr defbox = nullptr; - // check if there's a field with the name "shape" - auto s = args.get>>("shape"); - std::cout << "has : " << std::boolalpha << s.has_value() << '\n'; + lua.set_function( + "inspect_shape_table", [](const sol::table& args) { + std::shared_ptr defbox = nullptr; + // check if there's a field with the name "shape" + auto s = args.get< + sol::optional>>( + "shape"); + std::cout << "has : " << std::boolalpha + << s.has_value() << '\n'; - // get the field named "shape" or use the default value - std::cout << "get_or: " << std::hex << args.get_or>("shape", defbox).get() << '\n'; + // get the field named "shape" or use the default + // value + std::cout << "get_or: " << std::hex + << args.get_or>( + "shape", defbox) + .get() + << '\n'; - // this works but I can't test for existence beforehand... - std::cout << "get : " << std::hex << args.get>("shape").get() << '\n'; - }); + // this works but I can't test for existence + // beforehand... + std::cout + << "get : " << std::hex + << args.get>("shape") + .get() + << '\n'; + }); - sol::protected_function_result result = lua.safe_script("inspect_shape_table({shape=Box.new()})"); + sol::protected_function_result result = lua.safe_script( + "inspect_shape_table({shape=Box.new()})"); sol_c_assert(result.valid()); return 0; diff --git a/examples/source/shared_ptr_modify_in_place.cpp b/examples/source/shared_ptr_modify_in_place.cpp index 3ca1e1d5..adaef2f6 100644 --- a/examples/source/shared_ptr_modify_in_place.cpp +++ b/examples/source/shared_ptr_modify_in_place.cpp @@ -13,29 +13,37 @@ struct ree { int main() { - std::cout << "=== special pointers -- modify in place ===" << std::endl; + std::cout << "=== special pointers -- modify in place ===" + << std::endl; sol::state lua; auto new_shared_ptr = [](sol::stack_reference obj) { // works just fine - sol::stack::modify_unique_usertype(obj, [](std::shared_ptr& sptr) { sptr = std::make_shared(sptr->value + 1); }); + sol::stack::modify_unique_usertype( + obj, [](std::shared_ptr& sptr) { + sptr = std::make_shared( + sptr->value + 1); + }); }; auto reset_shared_ptr = [](sol::stack_reference obj) { - sol::stack::modify_unique_usertype(obj, [](std::shared_ptr& sptr) { - // THIS IS SUCH A BAD IDEA AAAGH - sptr.reset(); - // DO NOT reset to nullptr: - // change it to an actual NEW value... - // otherwise you will inject a nullptr into the userdata representation... - // which will NOT compare == to Lua's nil - }); + sol::stack::modify_unique_usertype( + obj, [](std::shared_ptr& sptr) { + // THIS IS SUCH A BAD IDEA AAAGH + sptr.reset(); + // DO NOT reset to nullptr: + // change it to an actual NEW value... + // otherwise you will inject a nullptr into + // the userdata representation... which will + // NOT compare == to Lua's nil + }); }; lua.set_function("f", new_shared_ptr); lua.set_function("f2", reset_shared_ptr); - lua.set_function("g", [](ree* r) { std::cout << r->value << std::endl; }); + lua.set_function("g", + [](ree* r) { std::cout << r->value << std::endl; }); lua["p"] = std::make_shared(); lua.script("g(p) -- okay"); diff --git a/examples/source/singleton.cpp b/examples/source/singleton.cpp index b2c7d49f..edc2acfd 100644 --- a/examples/source/singleton.cpp +++ b/examples/source/singleton.cpp @@ -48,7 +48,13 @@ int main(int, char*[]) { sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype("SomeLib", "new", sol::no_constructor, "getInstance", &SomeLib::getInstance, "doSomething", &SomeLib::doSomething); + lua.new_usertype("SomeLib", + "new", + sol::no_constructor, + "getInstance", + &SomeLib::getInstance, + "doSomething", + &SomeLib::doSomething); lua.script(R"( diff --git a/examples/source/stack_aligned_function.cpp b/examples/source/stack_aligned_function.cpp index d37bf0b0..423a77ff 100644 --- a/examples/source/stack_aligned_function.cpp +++ b/examples/source/stack_aligned_function.cpp @@ -13,8 +13,8 @@ int main(int, char*[]) { // maybe this is in a lua_CFunction you bind, // or maybe you're trying to work with a pre-existing system - // maybe you've used a custom lua_load call, or you're working - // with state_view's load(lua_Reader, ...) call... + // maybe you've used a custom lua_load call, or you're + // working with state_view's load(lua_Reader, ...) call... // here's a little bit of how you can work with the stack lua_State* L = lua.lua_state(); sol::stack_aligned_unsafe_function func(L, -1); @@ -27,7 +27,8 @@ int main(int, char*[]) { // make sure everything is clean sol_c_assert(result == 22); - sol_c_assert(lua.stack_top() == 0); // stack is empty/balanced + sol_c_assert( + lua.stack_top() == 0); // stack is empty/balanced return 0; } diff --git a/examples/source/stack_aligned_stack_handler_function.cpp b/examples/source/stack_aligned_stack_handler_function.cpp index bd788da0..5ea58ed0 100644 --- a/examples/source/stack_aligned_stack_handler_function.cpp +++ b/examples/source/stack_aligned_stack_handler_function.cpp @@ -10,8 +10,8 @@ int main(int, char*[]) { // maybe this is in a lua_CFunction you bind, // or maybe you're trying to work with a pre-existing system - // maybe you've used a custom lua_load call, or you're working - // with state_view's load(lua_Reader, ...) call... + // maybe you've used a custom lua_load call, or you're + // working with state_view's load(lua_Reader, ...) call... // here's a little bit of how you can work with the stack lua_State* L = lua.lua_state(); @@ -19,11 +19,14 @@ int main(int, char*[]) { // stack_aligned_stack_handler, // as its type name explains so verbosely, // expects the handler on the stack - sol::stack_reference traceback_handler(L, -sol::stack::push(L, sol::default_traceback_error_handler)); + sol::stack_reference traceback_handler(L, + -sol::stack::push( + L, sol::default_traceback_error_handler)); // then, you need the function // to be on the stack func_ref.push(); - sol::stack_aligned_stack_handler_function func(L, -1, traceback_handler); + sol::stack_aligned_stack_handler_function func( + L, -1, traceback_handler); lua_pushinteger(L, 5); // argument 1, using plain API lua_pushinteger(L, 6); // argument 2 @@ -38,7 +41,8 @@ int main(int, char*[]) { // make sure everything is clean sol_c_assert(result == 22); - sol_c_assert(lua.stack_top() == 0); // stack is empty/balanced + sol_c_assert( + lua.stack_top() == 0); // stack is empty/balanced return 0; } diff --git a/examples/source/static_variables.cpp b/examples/source/static_variables.cpp index fa200e29..3cfcfef4 100644 --- a/examples/source/static_variables.cpp +++ b/examples/source/static_variables.cpp @@ -14,7 +14,13 @@ int main() { sol::state lua; lua.open_libraries(); - lua.new_usertype("test", "direct", sol::var(2), "global", sol::var(test::muh_variable), "ref_global", sol::var(std::ref(test::muh_variable))); + lua.new_usertype("test", + "direct", + sol::var(2), + "global", + sol::var(test::muh_variable), + "ref_global", + sol::var(std::ref(test::muh_variable))); int direct_value = lua["test"]["direct"]; // direct_value == 2 diff --git a/examples/source/table_as_container.cpp b/examples/source/table_as_container.cpp index 6b1f3742..efb37896 100644 --- a/examples/source/table_as_container.cpp +++ b/examples/source/table_as_container.cpp @@ -16,10 +16,15 @@ int main() { sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype( - "Vector", sol::constructors(), "x", sol::property(&Vector::x, &Vector::x), "y", sol::property(&Vector::y, &Vector::y)); + lua.new_usertype("Vector", + sol::constructors(), + "x", + sol::property(&Vector::x, &Vector::x), + "y", + sol::property(&Vector::y, &Vector::y)); - lua.script("vectors = { Vector.new(3, 6), Vector.new(6, 3) }"); + lua.script( + "vectors = { Vector.new(3, 6), Vector.new(6, 3) }"); auto vectors = lua["vectors"].get>(); sol_c_assert(vectors[0].x == 3); diff --git a/examples/source/table_create_if_nil.cpp b/examples/source/table_create_if_nil.cpp index b1664647..4e7c3e98 100644 --- a/examples/source/table_create_if_nil.cpp +++ b/examples/source/table_create_if_nil.cpp @@ -11,7 +11,8 @@ void create_namespace_sf(sol::state& lua) { int main(int, char*[]) { - std::cout << "=== sol::lua_value/sol::array_value ===" << std::endl; + std::cout << "=== sol::lua_value/sol::array_value ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); @@ -22,14 +23,16 @@ int main(int, char*[]) { assert(sf.value == 256) )"; - auto result = lua.safe_script(code, sol::script_pass_on_error); + auto result + = lua.safe_script(code, sol::script_pass_on_error); // did not work sol_c_assert(!result.valid()); // create values create_namespace_sf(lua); - auto result2 = lua.safe_script(code, sol::script_pass_on_error); + auto result2 + = lua.safe_script(code, sol::script_pass_on_error); // it worked properly sol_c_assert(result2.valid()); diff --git a/examples/source/table_proxy.cpp b/examples/source/table_proxy.cpp index a333ba4f..a2f5d747 100644 --- a/examples/source/table_proxy.cpp +++ b/examples/source/table_proxy.cpp @@ -16,7 +16,8 @@ int main() { lua.open_libraries(sol::lib::base); lua.script(code); - // produces table_proxy, implicitly converts to std::string, quietly destroys table_proxy + // produces table_proxy, implicitly converts to std::string, + // quietly destroys table_proxy std::string arf_string = lua["bark"]["woof"][2]; // lazy-evaluation of tables diff --git a/examples/source/tables.cpp b/examples/source/tables.cpp index 7b7cbaed..4eb8713b 100644 --- a/examples/source/tables.cpp +++ b/examples/source/tables.cpp @@ -39,22 +39,34 @@ int main() { // sol::table nestedTable = t2["nestedTable"]; std::string x = lua["table2"]["nestedTable"]["key2"]; - std::cout << "nested table: key1 : " << nestedTable.get("key1") << ", key2: " << x << '\n'; - std::cout << "name of t2: " << t2.get("name") << '\n'; + std::cout << "nested table: key1 : " + << nestedTable.get("key1") + << ", key2: " << x << '\n'; + std::cout << "name of t2: " << t2.get("name") + << '\n'; std::string t2name = t2["name"]; std::cout << "name of t2: " << t2name << '\n'; /* Longer Syntax: */ // using the values stored in table1 - std::cout << lua.get("table1").get(1) << " " << lua.get("table1").get(2) << '\n'; + std::cout << lua.get("table1").get( + 1) << " " + << lua.get("table1").get( + 2) + << '\n'; // some retrieval of values from the nested table // the cleaner way of doing things - std::cout << "nested table: key1 : " << nestedTable.get("key1") + std::cout << "nested table: key1 : " + << nestedTable.get("key1") << ", key2: " // yes you can chain the get<>() results - << lua.get("table2").get("nestedTable").get("key2") << '\n'; - std::cout << "name of t2: " << t2.get("name") << '\n'; + << lua.get("table2") + .get("nestedTable") + .get("key2") + << '\n'; + std::cout << "name of t2: " << t2.get("name") + << '\n'; std::cout << std::endl; diff --git a/examples/source/this_state.cpp b/examples/source/this_state.cpp index 4ef69412..b7f79b9b 100644 --- a/examples/source/this_state.cpp +++ b/examples/source/this_state.cpp @@ -5,18 +5,21 @@ int main() { sol::state lua; - lua.set_function("bark", [](sol::this_state s, int a, int b) { - lua_State* L = s; // current state - return a + b + lua_gettop(L); - }); + lua.set_function( + "bark", [](sol::this_state s, int a, int b) { + lua_State* L = s; // current state + return a + b + lua_gettop(L); + }); - lua.script("first = bark(2, 2)"); // only takes 2 arguments, NOT 3 + lua.script( + "first = bark(2, 2)"); // only takes 2 arguments, NOT 3 // Can be at the end, too, or in the middle: doesn't matter - lua.set_function("bark", [](int a, int b, sol::this_state s) { - lua_State* L = s; // current state - return a + b + lua_gettop(L); - }); + lua.set_function( + "bark", [](int a, int b, sol::this_state s) { + lua_State* L = s; // current state + return a + b + lua_gettop(L); + }); lua.script("second = bark(2, 2)"); // only takes 2 arguments int first = lua["first"]; diff --git a/examples/source/tutorials/erase_demo.cpp b/examples/source/tutorials/erase_demo.cpp index 3621a72b..ab4f4a37 100644 --- a/examples/source/tutorials/erase_demo.cpp +++ b/examples/source/tutorials/erase_demo.cpp @@ -10,7 +10,8 @@ int main() { sol::optional x = lua["bark"]; // x will have a value if (x) { - std::cout << "x has no value, as expected" << std::endl; + std::cout << "x has no value, as expected" + << std::endl; } else { return -1; @@ -23,7 +24,8 @@ int main() { return -1; } else { - std::cout << "y has no value, as expected" << std::endl; + std::cout << "y has no value, as expected" + << std::endl; } return 0; diff --git a/examples/source/tutorials/lazy_demo.cpp b/examples/source/tutorials/lazy_demo.cpp index b54b705b..6bad5eb0 100644 --- a/examples/source/tutorials/lazy_demo.cpp +++ b/examples/source/tutorials/lazy_demo.cpp @@ -10,7 +10,8 @@ int main() { auto barkkey = lua["bark"]; if (barkkey.valid()) { // Branch not taken: doesn't exist yet - std::cout << "How did you get in here, arf?!" << std::endl; + std::cout << "How did you get in here, arf?!" + << std::endl; } barkkey = 50; diff --git a/examples/source/tutorials/open_multiple_libraries.cpp b/examples/source/tutorials/open_multiple_libraries.cpp index dbca56d6..1ee49c50 100644 --- a/examples/source/tutorials/open_multiple_libraries.cpp +++ b/examples/source/tutorials/open_multiple_libraries.cpp @@ -6,7 +6,10 @@ int main(int argc, char* argv[]) { (void)argc; (void)argv; sol::state lua; - lua.open_libraries(sol::lib::base, sol::lib::coroutine, sol::lib::string, sol::lib::io); + lua.open_libraries(sol::lib::base, + sol::lib::coroutine, + sol::lib::string, + sol::lib::io); lua.script("print('bark bark bark!')"); diff --git a/examples/source/tutorials/pointer_lifetime.cpp b/examples/source/tutorials/pointer_lifetime.cpp index 31fafa75..d3131df5 100644 --- a/examples/source/tutorials/pointer_lifetime.cpp +++ b/examples/source/tutorials/pointer_lifetime.cpp @@ -23,18 +23,24 @@ int main() { */ // :ok: - lua["my_func0"] = []() -> std::unique_ptr { return std::make_unique(); }; + lua["my_func0"] = []() -> std::unique_ptr { + return std::make_unique(); + }; // :ok: - lua["my_func1"] = []() -> std::shared_ptr { return std::make_shared(); }; + lua["my_func1"] = []() -> std::shared_ptr { + return std::make_shared(); + }; // :ok: lua["my_func2"] = []() -> my_type { return my_type(); }; // :ok: - lua.set("something", std::unique_ptr(new my_type())); + lua.set( + "something", std::unique_ptr(new my_type())); - std::shared_ptr my_shared = std::make_shared(); + std::shared_ptr my_shared + = std::make_shared(); // :ok: lua.set("something_else", my_shared); @@ -54,7 +60,8 @@ int main() { lua["my_func6"] = []() -> my_type* { return nullptr; }; // :ok: - lua["my_func7"] = []() -> std::nullptr_t { return nullptr; }; + lua["my_func7"] + = []() -> std::nullptr_t { return nullptr; }; // :ok: lua["my_func8"] = []() -> std::unique_ptr { diff --git a/examples/source/tutorials/quick_n_dirty/arguments_to_scripts.cpp b/examples/source/tutorials/quick_n_dirty/arguments_to_scripts.cpp index 0a6dd519..ab633b40 100644 --- a/examples/source/tutorials/quick_n_dirty/arguments_to_scripts.cpp +++ b/examples/source/tutorials/quick_n_dirty/arguments_to_scripts.cpp @@ -4,7 +4,8 @@ #include int main(int, char*[]) { - std::cout << "=== passing arguments to scripts ===" << std::endl; + std::cout << "=== passing arguments to scripts ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); @@ -17,7 +18,9 @@ print(a,b,c) sol::load_result fx = lua.load(my_script); if (!fx.valid()) { sol::error err = fx; - std::cerr << "failed to load string-based script into the program" << err.what() << std::endl; + std::cerr << "failed to load string-based script into " + "the program" + << err.what() << std::endl; } // prints "your arguments here" diff --git a/examples/source/tutorials/quick_n_dirty/functions_all.cpp b/examples/source/tutorials/quick_n_dirty/functions_all.cpp index 1b5b4d35..514ba6e9 100644 --- a/examples/source/tutorials/quick_n_dirty/functions_all.cpp +++ b/examples/source/tutorials/quick_n_dirty/functions_all.cpp @@ -39,13 +39,15 @@ int main(int, char*[]) { lua["m1"] = &some_class::member_function; // binds the class to the type - lua.set_function("m2", &some_class::member_function, some_class {}); + lua.set_function( + "m2", &some_class::member_function, some_class {}); // binds just the member variable as a function lua["v1"] = &some_class::variable; // binds class with member variable as function - lua.set_function("v2", &some_class::variable, some_class {}); + lua.set_function( + "v2", &some_class::variable, some_class {}); lua.script(R"( f1() -- some function! diff --git a/examples/source/tutorials/quick_n_dirty/functions_easy.cpp b/examples/source/tutorials/quick_n_dirty/functions_easy.cpp index c7c50bd3..5f0a8b5b 100644 --- a/examples/source/tutorials/quick_n_dirty/functions_easy.cpp +++ b/examples/source/tutorials/quick_n_dirty/functions_easy.cpp @@ -14,7 +14,8 @@ int main(int, char*[]) { sol::function fx = lua["f"]; // fixed signature std::function<...> // can be used to tie a sol::function down - std::function stdfx = fx; + std::function stdfx + = fx; int is_one = stdfx(1, 34.5, 3, "bark"); sol_c_assert(is_one == 1); diff --git a/examples/source/tutorials/quick_n_dirty/multiple_returns_to_lua.cpp b/examples/source/tutorials/quick_n_dirty/multiple_returns_to_lua.cpp index b67f2901..98719851 100644 --- a/examples/source/tutorials/quick_n_dirty/multiple_returns_to_lua.cpp +++ b/examples/source/tutorials/quick_n_dirty/multiple_returns_to_lua.cpp @@ -7,7 +7,8 @@ int main(int, char*[]) { lua.open_libraries(sol::lib::base); lua["f"] = [](int a, int b, sol::object c) { - // sol::object can be anything here: just pass it through + // sol::object can be anything here: just pass it + // through return std::make_tuple(a, b, c); }; @@ -17,7 +18,8 @@ int main(int, char*[]) { std::tuple result2; result2 = lua["f"](100, 200, "BARK BARK BARK!"); - const std::tuple expected2(100, 200, "BARK BARK BARK!"); + const std::tuple expected2( + 100, 200, "BARK BARK BARK!"); sol_c_assert(result2 == expected2); int a, b; diff --git a/examples/source/tutorials/quick_n_dirty/namespacing.cpp b/examples/source/tutorials/quick_n_dirty/namespacing.cpp index 494b0ecb..86b44001 100644 --- a/examples/source/tutorials/quick_n_dirty/namespacing.cpp +++ b/examples/source/tutorials/quick_n_dirty/namespacing.cpp @@ -26,15 +26,23 @@ int main() { // forces creation if it does not exist auto bark = lua["bark"].get_or_create(); // equivalent-ish: - // sol::table bark = lua["bark"].force(); // forces table creation - // equivalent, and more flexible: - // sol::table bark = lua["bark"].get_or_create(sol::new_table()); + // sol::table bark = lua["bark"].force(); // forces table + // creation equivalent, and more flexible: sol::table bark = + // lua["bark"].get_or_create(sol::new_table()); // equivalent, but less efficient/ugly: - // sol::table bark = lua["bark"] = lua.get_or("bark", lua.create_table()); - bark.new_usertype("my_class", "f", &my_class::f, "g", &my_class::g); // the usual + // sol::table bark = lua["bark"] = lua.get_or("bark", + // lua.create_table()); + bark.new_usertype("my_class", + "f", + &my_class::f, + "g", + &my_class::g); // the usual // can add functions, as well (just like the global table) - bark.set_function("print_my_class", [](my_class& self) { std::cout << "my_class { b: " << self.b << " }" << std::endl; }); + bark.set_function("print_my_class", [](my_class& self) { + std::cout << "my_class { b: " << self.b << " }" + << std::endl; + }); // this works lua.script("obj = bark.my_class.new()"); diff --git a/examples/source/tutorials/quick_n_dirty/opening_state_on_raw_lua.cpp b/examples/source/tutorials/quick_n_dirty/opening_state_on_raw_lua.cpp index 42d74daf..0f5c7e5b 100644 --- a/examples/source/tutorials/quick_n_dirty/opening_state_on_raw_lua.cpp +++ b/examples/source/tutorials/quick_n_dirty/opening_state_on_raw_lua.cpp @@ -10,7 +10,8 @@ int use_sol2(lua_State* L) { } int main(int, char*[]) { - std::cout << "=== opening sol::state_view on raw Lua ===" << std::endl; + std::cout << "=== opening sol::state_view on raw Lua ===" + << std::endl; lua_State* L = luaL_newstate(); luaL_openlibs(L); diff --git a/examples/source/tutorials/quick_n_dirty/running_lua_code.cpp b/examples/source/tutorials/quick_n_dirty/running_lua_code.cpp index bc3d4142..6ea0aba8 100644 --- a/examples/source/tutorials/quick_n_dirty/running_lua_code.cpp +++ b/examples/source/tutorials/quick_n_dirty/running_lua_code.cpp @@ -24,18 +24,21 @@ int main(int, char*[]) { int value = lua.script("return 54"); sol_c_assert(value == 54); - auto bad_code_result = lua.script("123 herp.derp", [](lua_State*, sol::protected_function_result pfr) { - // pfr will contain things that went wrong, for either loading or executing the script - // Can throw your own custom error - // You can also just return it, and let the call-site handle the error if necessary. - return pfr; - }); + auto bad_code_result = lua.script("123 herp.derp", + [](lua_State*, sol::protected_function_result pfr) { + // pfr will contain things that went wrong, for + // either loading or executing the script Can + // throw your own custom error You can also just + // return it, and let the call-site handle the + // error if necessary. + return pfr; + }); // it did not work sol_c_assert(!bad_code_result.valid()); - // the default handler panics or throws, depending on your settings - // uncomment for explosions: - // auto bad_code_result_2 = lua.script("bad.code", &sol::script_default_on_error); + // the default handler panics or throws, depending on your + // settings uncomment for explosions: auto bad_code_result_2 + // = lua.script("bad.code", &sol::script_default_on_error); std::cout << std::endl; diff --git a/examples/source/tutorials/quick_n_dirty/running_lua_code_low_level.cpp b/examples/source/tutorials/quick_n_dirty/running_lua_code_low_level.cpp index aba67f49..dcf56536 100644 --- a/examples/source/tutorials/quick_n_dirty/running_lua_code_low_level.cpp +++ b/examples/source/tutorials/quick_n_dirty/running_lua_code_low_level.cpp @@ -6,7 +6,8 @@ #include int main(int, char*[]) { - std::cout << "=== running lua code (low level) ===" << std::endl; + std::cout << "=== running lua code (low level) ===" + << std::endl; { std::ofstream out("a_lua_script.lua"); @@ -17,7 +18,8 @@ int main(int, char*[]) { lua.open_libraries(sol::lib::base); // load file without execute - sol::load_result script1 = lua.load_file("a_lua_script.lua"); + sol::load_result script1 + = lua.load_file("a_lua_script.lua"); // execute script1(); diff --git a/examples/source/tutorials/quick_n_dirty/running_lua_code_safely.cpp b/examples/source/tutorials/quick_n_dirty/running_lua_code_safely.cpp index 7a3b20ad..7e639cad 100644 --- a/examples/source/tutorials/quick_n_dirty/running_lua_code_safely.cpp +++ b/examples/source/tutorials/quick_n_dirty/running_lua_code_safely.cpp @@ -5,7 +5,8 @@ #include int main(int, char*[]) { - std::cout << "=== running lua code (safely) ===" << std::endl; + std::cout << "=== running lua code (safely) ===" + << std::endl; { std::ofstream out("a_lua_script.lua"); @@ -16,43 +17,55 @@ int main(int, char*[]) { lua.open_libraries(sol::lib::base); // load and execute from string - auto result = lua.safe_script("a = 'test'", sol::script_pass_on_error); + auto result = lua.safe_script( + "a = 'test'", sol::script_pass_on_error); if (!result.valid()) { sol::error err = result; - std::cerr << "The code has failed to run!\n" << err.what() << "\nPanicking and exiting..." << std::endl; + std::cerr << "The code has failed to run!\n" + << err.what() << "\nPanicking and exiting..." + << std::endl; return 1; } // load and execute from file - auto script_from_file_result = lua.safe_script_file("a_lua_script.lua", sol::script_pass_on_error); + auto script_from_file_result = lua.safe_script_file( + "a_lua_script.lua", sol::script_pass_on_error); if (!script_from_file_result.valid()) { sol::error err = script_from_file_result; - std::cerr << "The code from the file has failed to run!\n" << err.what() << "\nPanicking and exiting..." << std::endl; + std::cerr + << "The code from the file has failed to run!\n" + << err.what() << "\nPanicking and exiting..." + << std::endl; return 1; } // run a script, get the result - sol::optional maybe_value = lua.safe_script("return 54", sol::script_pass_on_error); + sol::optional maybe_value = lua.safe_script( + "return 54", sol::script_pass_on_error); sol_c_assert(maybe_value.has_value()); sol_c_assert(*maybe_value == 54); - auto bad_code_result = lua.safe_script("123 herp.derp", sol::script_pass_on_error); + auto bad_code_result = lua.safe_script( + "123 herp.derp", sol::script_pass_on_error); sol_c_assert(!bad_code_result.valid()); // you can also specify a handler function, and it'll // properly work here - auto bad_code_result2 = lua.script("123 herp.derp", [](lua_State*, sol::protected_function_result pfr) { - // pfr will contain things that went wrong, for either loading or executing the script - // Can throw your own custom error - // You can also just return it, and let the call-site handle the error if necessary. - return pfr; - }); + auto bad_code_result2 = lua.script("123 herp.derp", + [](lua_State*, sol::protected_function_result pfr) { + // pfr will contain things that went wrong, for + // either loading or executing the script Can + // throw your own custom error You can also just + // return it, and let the call-site handle the + // error if necessary. + return pfr; + }); // it did not work sol_c_assert(!bad_code_result2.valid()); - // the default handler panics or throws, depending on your settings - // uncomment for explosions: - // auto bad_code_result_2 = lua.script("bad.code", &sol::script_default_on_error); + // the default handler panics or throws, depending on your + // settings uncomment for explosions: auto bad_code_result_2 + // = lua.script("bad.code", &sol::script_default_on_error); std::cout << std::endl; diff --git a/examples/source/tutorials/quick_n_dirty/self_call.cpp b/examples/source/tutorials/quick_n_dirty/self_call.cpp index b839e0ba..d29e0ebb 100644 --- a/examples/source/tutorials/quick_n_dirty/self_call.cpp +++ b/examples/source/tutorials/quick_n_dirty/self_call.cpp @@ -7,7 +7,8 @@ int main() { std::cout << "=== self_call ===" << std::endl; sol::state lua; - lua.open_libraries(sol::lib::base, sol::lib::package, sol::lib::table); + lua.open_libraries( + sol::lib::base, sol::lib::package, sol::lib::table); // a small script using 'self' syntax lua.script(R"( diff --git a/examples/source/tutorials/quick_n_dirty/set_and_get_variables.cpp b/examples/source/tutorials/quick_n_dirty/set_and_get_variables.cpp index 5c127ec9..e9bb561f 100644 --- a/examples/source/tutorials/quick_n_dirty/set_and_get_variables.cpp +++ b/examples/source/tutorials/quick_n_dirty/set_and_get_variables.cpp @@ -12,7 +12,8 @@ int main(int, char*[]) { lua["number2"] = 24.5; // string types lua["important_string"] = "woof woof"; - // is callable, therefore gets stored as a function that can be called + // is callable, therefore gets stored as a function that can + // be called lua["a_function"] = []() { return 100; }; // make a table lua["some_table"] = lua.create_table_with("value", 24); diff --git a/examples/source/tutorials/quick_n_dirty/tables_and_nesting.cpp b/examples/source/tutorials/quick_n_dirty/tables_and_nesting.cpp index 95a3256e..20dbab04 100644 --- a/examples/source/tutorials/quick_n_dirty/tables_and_nesting.cpp +++ b/examples/source/tutorials/quick_n_dirty/tables_and_nesting.cpp @@ -31,10 +31,12 @@ int main(int, char*[]) { sol_c_assert(abcval1 == 24); sol_c_assert(abcval2 == 24); - sol::optional will_not_error = lua["abc"]["DOESNOTEXIST"]["ghi"]; + sol::optional will_not_error + = lua["abc"]["DOESNOTEXIST"]["ghi"]; sol_c_assert(will_not_error == sol::nullopt); - int also_will_not_error = lua["abc"]["def"]["ghi"]["jklm"].get_or(25); + int also_will_not_error + = lua["abc"]["def"]["ghi"]["jklm"].get_or(25); sol_c_assert(also_will_not_error == 25); // if you don't go safe, diff --git a/examples/source/tutorials/quick_n_dirty/userdata.cpp b/examples/source/tutorials/quick_n_dirty/userdata.cpp index 34331262..6520d8c9 100644 --- a/examples/source/tutorials/quick_n_dirty/userdata.cpp +++ b/examples/source/tutorials/quick_n_dirty/userdata.cpp @@ -13,7 +13,8 @@ struct Doge { } ~Doge() { - std::cout << "Dog at " << this << " is being destroyed..." << std::endl; + std::cout << "Dog at " << this + << " is being destroyed..." << std::endl; } }; @@ -26,10 +27,11 @@ int main(int, char*[]) { // fresh one put into Lua lua["dog"] = Doge {}; - // Copy into lua: destroyed by Lua VM during garbage collection + // Copy into lua: destroyed by Lua VM during garbage + // collection lua["dog_copy"] = dog; - // OR: move semantics - will call move constructor if present instead - // Again, owned by Lua + // OR: move semantics - will call move constructor if + // present instead Again, owned by Lua lua["dog_move"] = std::move(dog); lua["dog_unique_ptr"] = std::make_unique(25); lua["dog_shared_ptr"] = std::make_shared(31); @@ -39,8 +41,10 @@ int main(int, char*[]) { lua.set("dog2", Doge {}); lua.set("dog2_copy", dog2); lua.set("dog2_move", std::move(dog2)); - lua.set("dog2_unique_ptr", std::unique_ptr(new Doge(25))); - lua.set("dog2_shared_ptr", std::shared_ptr(new Doge(31))); + lua.set("dog2_unique_ptr", + std::unique_ptr(new Doge(25))); + lua.set("dog2_shared_ptr", + std::shared_ptr(new Doge(31))); // Note all of them can be retrieved the same way: Doge& lua_dog = lua["dog"]; @@ -54,12 +58,16 @@ int main(int, char*[]) { sol_c_assert(lua_dog_unique_ptr.tailwag == 25); sol_c_assert(lua_dog_shared_ptr.tailwag == 31); - // lua will treat these types as opaque, and you will be able to pass them around - // to C++ functions and Lua functions alike + // lua will treat these types as opaque, and you will be + // able to pass them around to C++ functions and Lua + // functions alike // Use a C++ reference to handle memory directly // otherwise take by value, without '&' - lua["f"] = [](Doge& dog) { std::cout << "dog wags its tail " << dog.tailwag << " times!" << std::endl; }; + lua["f"] = [](Doge& dog) { + std::cout << "dog wags its tail " << dog.tailwag + << " times!" << std::endl; + }; // if you bind a function using a pointer, // you can handle when `nil` is passed @@ -68,7 +76,8 @@ int main(int, char*[]) { std::cout << "dog was nil!" << std::endl; return; } - std::cout << "dog wags its tail " << dog->tailwag << " times!" << std::endl; + std::cout << "dog wags its tail " << dog->tailwag + << " times!" << std::endl; }; lua.script(R"( diff --git a/examples/source/tutorials/quick_n_dirty/userdata_memory_reference.cpp b/examples/source/tutorials/quick_n_dirty/userdata_memory_reference.cpp index 300c19d4..8b7750ed 100644 --- a/examples/source/tutorials/quick_n_dirty/userdata_memory_reference.cpp +++ b/examples/source/tutorials/quick_n_dirty/userdata_memory_reference.cpp @@ -13,12 +13,14 @@ struct Doge { } ~Doge() { - std::cout << "Dog at " << this << " is being destroyed..." << std::endl; + std::cout << "Dog at " << this + << " is being destroyed..." << std::endl; } }; int main(int, char*[]) { - std::cout << "=== userdata memory reference ===" << std::endl; + std::cout << "=== userdata memory reference ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); @@ -39,7 +41,7 @@ int main(int, char*[]) { Doge& dog_ref = lua["dog"]; // References Lua memory Doge* dog_pointer = lua["dog"]; // References Lua memory - Doge dog_copy = lua["dog"]; // Copies, will not affect lua + Doge dog_copy = lua["dog"]; // Copies, will not affect lua lua.new_usertype("Doge", "tailwag", &Doge::tailwag); diff --git a/examples/source/tutorials/quick_n_dirty/usertypes.cpp b/examples/source/tutorials/quick_n_dirty/usertypes.cpp index 27778e17..3070af50 100644 --- a/examples/source/tutorials/quick_n_dirty/usertypes.cpp +++ b/examples/source/tutorials/quick_n_dirty/usertypes.cpp @@ -13,7 +13,8 @@ struct Doge { } ~Doge() { - std::cout << "Dog at " << this << " is being destroyed..." << std::endl; + std::cout << "Dog at " << this + << " is being destroyed..." << std::endl; } }; @@ -32,7 +33,10 @@ int main(int, char*[]) { lua["dog_shared_ptr"] = std::make_shared(51); // now we can access these types in Lua - lua.new_usertype("Doge", sol::constructors(), "tailwag", &Doge::tailwag); + lua.new_usertype("Doge", + sol::constructors(), + "tailwag", + &Doge::tailwag); lua.script(R"( function f (dog) if dog == nil then diff --git a/examples/source/tutorials/variables_demo.cpp b/examples/source/tutorials/variables_demo.cpp index e8804037..4e1e0b3c 100644 --- a/examples/source/tutorials/variables_demo.cpp +++ b/examples/source/tutorials/variables_demo.cpp @@ -18,7 +18,9 @@ config = { )"); // the type "sol::state" behaves // exactly like a table! - bool isfullscreen = lua["config"]["fullscreen"]; // can get nested variables + bool isfullscreen + = lua["config"] + ["fullscreen"]; // can get nested variables sol::table config = lua["config"]; sol_c_assert(!isfullscreen); @@ -26,32 +28,38 @@ config = { // auto replaces the unqualified type name auto resolution = config.get("resolution"); - // table and state can have multiple things pulled out of it too - std::tuple xyresolutiontuple = resolution.get("x", "y"); + // table and state can have multiple things pulled out of it + // too + std::tuple xyresolutiontuple + = resolution.get("x", "y"); sol_c_assert(std::get<0>(xyresolutiontuple) == 1024); sol_c_assert(std::get<1>(xyresolutiontuple) == 768); // test variable auto bark = lua["config"]["bark"]; if (bark.valid()) { - // branch not taken: config and/or bark are not variables + // branch not taken: config and/or bark are not + // variables } else { // Branch taken: config and bark are existing variables } // can also use optional - sol::optional not_an_integer = lua["config"]["fullscreen"]; + sol::optional not_an_integer + = lua["config"]["fullscreen"]; if (not_an_integer) { // Branch not taken: value is not an integer } - sol::optional is_a_boolean = lua["config"]["fullscreen"]; + sol::optional is_a_boolean + = lua["config"]["fullscreen"]; if (is_a_boolean) { // Branch taken: the value is a boolean } - sol::optional does_not_exist = lua["not_a_variable"]; + sol::optional does_not_exist + = lua["not_a_variable"]; if (does_not_exist) { // Branch not taken: that variable is not present } @@ -62,7 +70,8 @@ config = { int is_defaulted = lua["config"]["fullscreen"].get_or(24); sol_c_assert(is_defaulted == 24); - // This will result in the value of the config, which is 'false' + // This will result in the value of the config, which is + // 'false' bool is_not_defaulted = lua["config"]["fullscreen"]; sol_c_assert(!is_not_defaulted); diff --git a/examples/source/tutorials/write_variables_demo.cpp b/examples/source/tutorials/write_variables_demo.cpp index 512cfc2c..1b74e47f 100644 --- a/examples/source/tutorials/write_variables_demo.cpp +++ b/examples/source/tutorials/write_variables_demo.cpp @@ -15,11 +15,17 @@ int main() { lua["bark"] = 50; // a table being created in the global table - lua["some_table"] = lua.create_table_with("key0", 24, "key1", 25, lua["bark"], "the key is 50 and this string is its value!"); + lua["some_table"] = lua.create_table_with("key0", + 24, + "key1", + 25, + lua["bark"], + "the key is 50 and this string is its value!"); // Run a plain ol' string of lua code - // Note you can interact with things set through sol in C++ with lua! - // Using a "Raw String Literal" to have multi-line goodness: + // Note you can interact with things set through sol in C++ + // with lua! Using a "Raw String Literal" to have multi-line + // goodness: // http://en.cppreference.com/w/cpp/language/string_literal lua.script(R"( diff --git a/examples/source/tutorials/writing_functions.cpp b/examples/source/tutorials/writing_functions.cpp index 843eba9e..78a70cdb 100644 --- a/examples/source/tutorials/writing_functions.cpp +++ b/examples/source/tutorials/writing_functions.cpp @@ -19,8 +19,8 @@ int main() { // lua scripts / code run on this state: lua.script("some_str = my_func(1, 'Da')"); - // Read out the global variable we stored in 'some_str' in the - // quick lua code we just executed + // Read out the global variable we stored in 'some_str' in + // the quick lua code we just executed std::string some_str = lua["some_str"]; sol_c_assert(some_str == "DaD"); diff --git a/examples/source/tutorials/writing_member_functions.cpp b/examples/source/tutorials/writing_member_functions.cpp index c84473e9..1f7dda1e 100644 --- a/examples/source/tutorials/writing_member_functions.cpp +++ b/examples/source/tutorials/writing_member_functions.cpp @@ -18,13 +18,15 @@ int main() { sol::state lua; lua.open_libraries(sol::lib::base); - // Here, we are binding the member function and a class instance: it will call the function on - // the given class instance - lua.set_function("my_class_func", &my_class::func, my_class(0)); + // Here, we are binding the member function and a class + // instance: it will call the function on the given class + // instance + lua.set_function( + "my_class_func", &my_class::func, my_class(0)); // We do not pass a class instance here: - // the function will need you to pass an instance of "my_class" to it - // in lua to work, as shown below + // the function will need you to pass an instance of + // "my_class" to it in lua to work, as shown below lua.set_function("my_class_func_2", &my_class::func); // With a pre-bound instance: diff --git a/examples/source/tutorials/writing_overloaded_template_functions.cpp b/examples/source/tutorials/writing_overloaded_template_functions.cpp index acd5d784..ba85ffca 100644 --- a/examples/source/tutorials/writing_overloaded_template_functions.cpp +++ b/examples/source/tutorials/writing_overloaded_template_functions.cpp @@ -10,11 +10,16 @@ int main() { sol::state lua; - // adds 2 integers - lua["my_combine"] = sol::overload(&my_add, &my_add); + auto int_function_pointer = &my_add; + auto string_function_pointer + = &my_add; + // adds 2 integers, or "adds" (concatenates) two strings + lua["my_combine"] = sol::overload( + int_function_pointer, string_function_pointer); lua.script("my_num = my_combine(1, 2)"); - lua.script("my_str = my_combine('bark bark', ' woof woof')"); + lua.script( + "my_str = my_combine('bark bark', ' woof woof')"); int my_num = lua["my_num"]; std::string my_str = lua["my_str"]; sol_c_assert(my_num == 3); diff --git a/examples/source/tutorials/writing_template_functions.cpp b/examples/source/tutorials/writing_template_functions.cpp index 8b8d2528..00d7bc2b 100644 --- a/examples/source/tutorials/writing_template_functions.cpp +++ b/examples/source/tutorials/writing_template_functions.cpp @@ -11,16 +11,21 @@ int main() { sol::state lua; // adds 2 integers - lua["my_int_add"] = &my_add; + auto int_function_pointer = &my_add; + lua["my_int_add"] = int_function_pointer; // concatenates 2 strings - lua["my_string_combine"] = &my_add; + auto string_function_pointer + = &my_add; + lua["my_string_combine"] = string_function_pointer; lua.script("my_num = my_int_add(1, 2)"); int my_num = lua["my_num"]; sol_c_assert(my_num == 3); - lua.script("my_str = my_string_combine('bark bark', ' woof woof')"); + lua.script( + "my_str = my_string_combine('bark bark', ' woof " + "woof')"); std::string my_str = lua["my_str"]; sol_c_assert(my_str == "bark bark woof woof"); diff --git a/examples/source/unique_ptr.cpp b/examples/source/unique_ptr.cpp index aad53be8..f9be1f2d 100644 --- a/examples/source/unique_ptr.cpp +++ b/examples/source/unique_ptr.cpp @@ -8,31 +8,38 @@ struct my_type { int value = 10; my_type() { - std::cout << "my_type at " << static_cast(this) << " being default constructed!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being default constructed!" + << std::endl; } my_type(const my_type& other) : value(other.value) { - std::cout << "my_type at " << static_cast(this) << " being copy constructed!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being copy constructed!" << std::endl; } my_type(my_type&& other) : value(other.value) { - std::cout << "my_type at " << static_cast(this) << " being move-constructed!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being move-constructed!" << std::endl; } my_type& operator=(const my_type& other) { value = other.value; - std::cout << "my_type at " << static_cast(this) << " being copy-assigned to!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being copy-assigned to!" << std::endl; return *this; } my_type& operator=(my_type&& other) { value = other.value; - std::cout << "my_type at " << static_cast(this) << " being move-assigned to!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being move-assigned to!" << std::endl; return *this; } ~my_type() { - std::cout << "my_type at " << static_cast(this) << " being destructed!" << std::endl; + std::cout << "my_type at " << static_cast(this) + << " being destructed!" << std::endl; } }; @@ -41,19 +48,25 @@ int main() { std::cout << "=== unique_ptr support ===" << std::endl; sol::state lua; - lua.new_usertype("my_type", "value", &my_type::value); + lua.new_usertype( + "my_type", "value", &my_type::value); { - std::unique_ptr unique = std::make_unique(); + std::unique_ptr unique + = std::make_unique(); lua["unique"] = std::move(unique); } { - std::cout << "getting reference to unique_ptr..." << std::endl; - std::unique_ptr& ref_to_unique_ptr = lua["unique"]; + std::cout << "getting reference to unique_ptr..." + << std::endl; + std::unique_ptr& ref_to_unique_ptr + = lua["unique"]; my_type& ref_to_my_type = lua["unique"]; my_type* ptr_to_my_type = lua["unique"]; - sol_c_assert(ptr_to_my_type == ref_to_unique_ptr.get()); - sol_c_assert(&ref_to_my_type == ref_to_unique_ptr.get()); + sol_c_assert( + ptr_to_my_type == ref_to_unique_ptr.get()); + sol_c_assert( + &ref_to_my_type == ref_to_unique_ptr.get()); sol_c_assert(ref_to_unique_ptr->value == 10); // script affects all of them equally @@ -64,12 +77,14 @@ int main() { sol_c_assert(ref_to_unique_ptr->value == 20); } { - std::cout << "getting copy of unique_ptr..." << std::endl; + std::cout << "getting copy of unique_ptr..." + << std::endl; my_type copy_of_value = lua["unique"]; sol_c_assert(copy_of_value.value == 20); - // script still affects pointer, but does not affect copy of `my_type` + // script still affects pointer, but does not affect + // copy of `my_type` lua.script("unique.value = 30"); sol_c_assert(copy_of_value.value == 20); diff --git a/examples/source/usertype.cpp b/examples/source/usertype.cpp index 4cc8cd6b..24e263f8 100644 --- a/examples/source/usertype.cpp +++ b/examples/source/usertype.cpp @@ -58,7 +58,12 @@ int main() { // you must make sure that the name of the function // goes before the member function pointer - lua.new_usertype("foo", sol::constructors(), "print", &foo::print, "test", &foo::test); + lua.new_usertype("foo", + sol::constructors(), + "print", + &foo::print, + "test", + &foo::test); // making the class from lua is simple // same with calling member functions @@ -82,9 +87,13 @@ int main() { // on the function-type doesn't exactly matter, // which allows you to use a shorter class name/void // if necessary - sol::constructors ctor; + sol::constructors + ctor; // then you must register it - sol::usertype utype = lua.new_usertype("vector", ctor); + sol::usertype utype + = lua.new_usertype("vector", ctor); // add to it as much as you like utype["is_unit"] = &vector::is_unit; @@ -103,8 +112,13 @@ int main() { "assert(not v:is_unit())\n"); // You can even have C++-like member-variable-access - // just pass is public member variables in the same style as functions - lua.new_usertype("variables", "low_gravity", &variables::low_gravity, "boost_level", &variables::boost_level); + // just pass is public member variables in the same style as + // functions + lua.new_usertype("variables", + "low_gravity", + &variables::low_gravity, + "boost_level", + &variables::boost_level); // making the class from lua is simple // same with calling member functions/variables diff --git a/examples/source/usertype_advanced.cpp b/examples/source/usertype_advanced.cpp index de63a1b0..19abf395 100644 --- a/examples/source/usertype_advanced.cpp +++ b/examples/source/usertype_advanced.cpp @@ -18,7 +18,8 @@ public: player(int ammo) : player(ammo, 100) { } - player(int ammo, int hitpoints) : bullets(ammo), hp(hitpoints) { + player(int ammo, int hitpoints) + : bullets(ammo), hp(hitpoints) { } void boost() { @@ -59,9 +60,12 @@ int main() { lua["p2"] = player(0); // make usertype metatable - sol::usertype player_type = lua.new_usertype("player", - // 3 constructors - sol::constructors()); + sol::usertype player_type + = lua.new_usertype("player", + // 3 constructors + sol::constructors()); // typical member function that returns a variable player_type["shoot"] = &player::shoot; @@ -69,7 +73,8 @@ int main() { player_type["boost"] = &player::boost; // gets or set the value using member variable syntax - player_type["hp"] = sol::property(&player::get_hp, &player::set_hp); + player_type["hp"] + = sol::property(&player::get_hp, &player::set_hp); // read and write variable player_type["speed"] = &player::speed; @@ -78,7 +83,8 @@ int main() { player_type.set("bullets", sol::readonly(&player::bullets)); // You can also add members to the code, defined in Lua! - // This lets you have a high degree of flexibility in the code + // This lets you have a high degree of flexibility in the + // code std::string prelude_script = R"( function player:brake () self.speed = 0 @@ -122,8 +128,9 @@ p1:brake() )"; // Uncomment and use the file to try that out, too! - // Make sure it's in the local directory of the executable after you build, or adjust the filename path - // Or whatever else you like! + // Make sure it's in the local directory of the executable + // after you build, or adjust the filename path Or whatever + // else you like! // /* lua.script_file("prelude_script.lua"); diff --git a/examples/source/usertype_automatic_operators.cpp b/examples/source/usertype_automatic_operators.cpp index f7cfa13a..181eb36f 100644 --- a/examples/source/usertype_automatic_operators.cpp +++ b/examples/source/usertype_automatic_operators.cpp @@ -17,7 +17,8 @@ public: // automatically bound to obj( args... ) [ __call ] void operator()() { - data.push_back(static_cast(data.size() + 1) / 3.0); + data.push_back( + static_cast(data.size() + 1) / 3.0); } // automatically used for pairs(obj) [ __pairs ], 5.2+ @@ -50,7 +51,8 @@ public: }; // automatically bound to tostring(obj) [ __tostring ] -std::ostream& operator<<(std::ostream& os, const automatic& right) { +std::ostream& operator<<( + std::ostream& os, const automatic& right) { if (right.size() == 0) { os << "{ empty }"; return os; @@ -69,7 +71,8 @@ std::ostream& operator<<(std::ostream& os, const automatic& right) { } int main(int, char*[]) { - std::cout << "=== usertype automatic operators ===" << std::endl; + std::cout << "=== usertype automatic operators ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); diff --git a/examples/source/usertype_basics.cpp b/examples/source/usertype_basics.cpp index 319d31b7..7a1cbb24 100644 --- a/examples/source/usertype_basics.cpp +++ b/examples/source/usertype_basics.cpp @@ -35,9 +35,12 @@ int main() { lua.open_libraries(sol::lib::base); if (way_1) { - lua.new_usertype("ship", // the name of the class, as you want it to be used in lua - // List the member functions you wish to bind: - // "name_of_item", &class_name::function_or_variable + lua.new_usertype( + "ship", // the name of the class, as you want it + // to be used in lua List the member + // functions you wish to bind: + // "name_of_item", + // &class_name::function_or_variable "shoot", &ship::shoot, "hurt", @@ -53,7 +56,8 @@ int main() { } else { // set usertype explicitly, with the given name - sol::usertype usertype_table = lua.new_usertype("ship"); + sol::usertype usertype_table + = lua.new_usertype("ship"); usertype_table["shoot"] = &ship::shoot; usertype_table["hurt"] = &ship::hurt; usertype_table["life"] = &ship::life; diff --git a/examples/source/usertype_bitfields.cpp b/examples/source/usertype_bitfields.cpp index 73e5fb31..33efee27 100644 --- a/examples/source/usertype_bitfields.cpp +++ b/examples/source/usertype_bitfields.cpp @@ -19,17 +19,20 @@ namespace itsy_bitsy { }; template - struct bit_type 2 && sz <= 16)>> { + struct bit_type 2 && sz <= 16)>> { typedef uint16_t type; }; template - struct bit_type 16 && sz <= 32)>> { + struct bit_type 16 && sz <= 32)>> { typedef uint32_t type; }; template - struct bit_type 32 && sz <= 64)>> { + struct bit_type 32 && sz <= 64)>> { typedef uint64_t type; }; @@ -48,49 +51,82 @@ namespace itsy_bitsy { template auto vcxx_warning_crap(V val) { - return vcxx_warning_crap(std::is_same(), val); + return vcxx_warning_crap( + std::is_same(), val); } - template + template void write(Base& b, bit_type_t bits) { - typedef bit_type_t aligned_type; - static const std::size_t aligned_type_bit_size = sizeof(aligned_type) * CHAR_BIT; - static_assert(sizeof(Base) * CHAR_BIT >= (bit_target + size), "bit offset and size are too large for the desired structure."); - static_assert((bit_target % aligned_type_bit_size) <= ((bit_target + size) % aligned_type_bit_size), - "bit offset and size cross beyond largest integral constant boundary."); + typedef bit_type_t + aligned_type; + static const std::size_t aligned_type_bit_size + = sizeof(aligned_type) * CHAR_BIT; + static_assert( + sizeof(Base) * CHAR_BIT >= (bit_target + size), + "bit offset and size are too large for the " + "desired structure."); + static_assert((bit_target % aligned_type_bit_size) + <= ((bit_target + size) + % aligned_type_bit_size), + "bit offset and size cross beyond largest " + "integral constant boundary."); - const std::size_t aligned_target = (bit_target + size) / aligned_type_bit_size; - const aligned_type bits_left = static_cast(bit_target - aligned_target); - const aligned_type shifted_mask = ((static_cast(1) << size) - 1) << bits_left; + const std::size_t aligned_target + = (bit_target + size) / aligned_type_bit_size; + const aligned_type bits_left + = static_cast( + bit_target - aligned_target); + const aligned_type shifted_mask + = ((static_cast(1) << size) - 1) + << bits_left; const aligned_type compl_shifted_mask = ~shifted_mask; // Jump by native size of a pointer to target // then OR the bits - aligned_type* jumper = static_cast(static_cast(&b)); + aligned_type* jumper = static_cast( + static_cast(&b)); jumper += aligned_target; aligned_type& aligned = *jumper; aligned &= compl_shifted_mask; - aligned |= (static_cast(bits) << bits_left); + aligned + |= (static_cast(bits) << bits_left); } - template + template bit_type_t read(Base& b) { - typedef bit_type_t aligned_type; + typedef bit_type_t + aligned_type; typedef bit_type_t field_type; - static const std::size_t aligned_type_bit_size = sizeof(aligned_type) * CHAR_BIT; - static_assert(sizeof(Base) * CHAR_BIT >= (bit_target + size), "bit offset and size are too large for the desired structure."); - static_assert((bit_target % aligned_type_bit_size) <= ((bit_target + size) % aligned_type_bit_size), - "bit offset and size cross beyond largest integral constant boundary."); + static const std::size_t aligned_type_bit_size + = sizeof(aligned_type) * CHAR_BIT; + static_assert( + sizeof(Base) * CHAR_BIT >= (bit_target + size), + "bit offset and size are too large for the " + "desired structure."); + static_assert((bit_target % aligned_type_bit_size) + <= ((bit_target + size) + % aligned_type_bit_size), + "bit offset and size cross beyond largest " + "integral constant boundary."); - const std::size_t aligned_target = (bit_target + size) / aligned_type_bit_size; - const aligned_type bits_left = static_cast(bit_target - aligned_target); - const aligned_type mask = (static_cast(1) << size) - 1; + const std::size_t aligned_target + = (bit_target + size) / aligned_type_bit_size; + const aligned_type bits_left + = static_cast( + bit_target - aligned_target); + const aligned_type mask + = (static_cast(1) << size) - 1; // Jump by native size of a pointer to target // then OR the bits - aligned_type* jumper = static_cast(static_cast(&b)); + aligned_type* jumper = static_cast( + static_cast(&b)); jumper += aligned_target; const aligned_type& aligned = *jumper; - aligned_type field_bits = (aligned >> bits_left) & mask; - field_type bits = vcxx_warning_crap(field_bits); + aligned_type field_bits + = (aligned >> bits_left) & mask; + field_type bits + = vcxx_warning_crap(field_bits); return bits; } @@ -118,18 +154,23 @@ struct __attribute__((packed, aligned(1))) flags_t { int main() { std::cout << "=== usertype_bitfields ===" << std::endl; #ifdef __MINGW32__ - std::cout << "MinGW Detected, packing structs is broken in MinGW and this test may fail" << std::endl; + std::cout << "MinGW Detected, packing structs is broken in " + "MinGW and this test may fail" + << std::endl; #endif sol::state lua; lua.open_libraries(); lua.new_usertype("flags_t", "C", - sol::property(itsy_bitsy::read, itsy_bitsy::write), + sol::property(itsy_bitsy::read, + itsy_bitsy::write), "N", - sol::property(itsy_bitsy::read, itsy_bitsy::write), + sol::property(itsy_bitsy::read, + itsy_bitsy::write), "D", - sol::property(itsy_bitsy::read, itsy_bitsy::write)); + sol::property(itsy_bitsy::read, + itsy_bitsy::write)); lua["f"] = std::ref(flags); @@ -152,7 +193,8 @@ int main() { uint16_t D = flags.D; std::cout << std::hex; - std::cout << "sizeof(flags): " << sizeof(flags) << std::endl; + std::cout << "sizeof(flags): " << sizeof(flags) + << std::endl; std::cout << "C: " << C << std::endl; std::cout << "N: " << N << std::endl; std::cout << "D: " << D << std::endl; diff --git a/examples/source/usertype_call_from_c++.cpp b/examples/source/usertype_call_from_c++.cpp index 6701b2fb..55d790c0 100644 --- a/examples/source/usertype_call_from_c++.cpp +++ b/examples/source/usertype_call_from_c++.cpp @@ -23,9 +23,12 @@ int main(int, char*[]) { } }; - lua.new_usertype("test", "value", &cpp_object::value); + lua.new_usertype( + "test", "value", &cpp_object::value); lua.new_usertype("test", "func", &test::func); - lua.script("function test:lua_func(obj) print('lua_func', obj.value) end"); + lua.script( + "function test:lua_func(obj) print('lua_func', " + "obj.value) end"); lua["obj"] = test {}; cpp_object cppobj; diff --git a/examples/source/usertype_constructors.cpp b/examples/source/usertype_constructors.cpp index 80ebda03..dcdbd9d7 100644 --- a/examples/source/usertype_constructors.cpp +++ b/examples/source/usertype_constructors.cpp @@ -21,14 +21,21 @@ int main() { lua.new_usertype("MyClass", sol::meta_function::construct, sol::factories( - // MyClass.new(...) -- dot syntax, no "self" value passed in - [](const double& d) { return std::make_shared(d); }, - // MyClass:new(...) -- colon syntax, passes in the "self" value - // as first argument implicitly - [](sol::object, const double& d) { return std::make_shared(d); }), + // MyClass.new(...) -- dot syntax, no "self" value + // passed in + [](const double& d) { + return std::make_shared(d); + }, + // MyClass:new(...) -- colon syntax, passes in the + // "self" value as first argument implicitly + [](sol::object, const double& d) { + return std::make_shared(d); + }), // MyClass(...) syntax, only sol::call_constructor, - sol::factories([](const double& d) { return std::make_shared(d); }), + sol::factories([](const double& d) { + return std::make_shared(d); + }), "data", &MyClass::data); @@ -44,12 +51,16 @@ int main() { if (maybe_error) { // something went wrong! - std::cerr << "Something has gone horribly unexpected and wrong:\n" << maybe_error->what() << std::endl; + std::cerr << "Something has gone horribly unexpected " + "and wrong:\n" + << maybe_error->what() << std::endl; return 1; } // everything is okay! - std::cout << "Everything went okay and all the asserts passed!" << std::endl; + std::cout + << "Everything went okay and all the asserts passed!" + << std::endl; return 0; } diff --git a/examples/source/usertype_dynamic_get_set.cpp b/examples/source/usertype_dynamic_get_set.cpp index e2f82fe8..dc73e29f 100644 --- a/examples/source/usertype_dynamic_get_set.cpp +++ b/examples/source/usertype_dynamic_get_set.cpp @@ -6,11 +6,10 @@ // Note that this is a bunch of if/switch statements // for the sake of brevity and clarity -// A much more robust implementation could use a std::unordered_map -// to link between keys and desired actions for those keys on -// setting/getting -// The sky becomes the limit when you have this much control, -// so apply it wisely! +// A much more robust implementation could use a +// std::unordered_map to link between keys and desired actions +// for those keys on setting/getting The sky becomes the limit +// when you have this much control, so apply it wisely! struct vec { double x; @@ -24,19 +23,22 @@ struct vec { } sol::object get(sol::stack_object key, sol::this_state L) { - // we use stack_object for the arguments because we know - // the values from Lua will remain on Lua's stack, + // we use stack_object for the arguments because we + // know the values from Lua will remain on Lua's stack, // so long we we don't mess with it - auto maybe_string_key = key.as>(); + auto maybe_string_key + = key.as>(); if (maybe_string_key) { const std::string& k = *maybe_string_key; if (k == "x") { // Return x - return sol::object(L, sol::in_place, this->x); + return sol::object( + L, sol::in_place, this->x); } else if (k == "y") { // Return y - return sol::object(L, sol::in_place, this->y); + return sol::object( + L, sol::in_place, this->y); } } @@ -46,9 +48,11 @@ struct vec { int n = *maybe_numeric_key; switch (n) { case 0: - return sol::object(L, sol::in_place, this->x); + return sol::object( + L, sol::in_place, this->x); case 1: - return sol::object(L, sol::in_place, this->y); + return sol::object( + L, sol::in_place, this->y); default: break; } @@ -63,11 +67,13 @@ struct vec { return sol::object(L, sol::in_place, sol::lua_nil); } - void set(sol::stack_object key, sol::stack_object value, sol::this_state) { - // we use stack_object for the arguments because we know - // the values from Lua will remain on Lua's stack, + void set(sol::stack_object key, sol::stack_object value, + sol::this_state) { + // we use stack_object for the arguments because we + // know the values from Lua will remain on Lua's stack, // so long we we don't mess with it - auto maybe_string_key = key.as>(); + auto maybe_string_key + = key.as>(); if (maybe_string_key) { const std::string& k = *maybe_string_key; if (k == "x") { @@ -99,20 +105,24 @@ struct vec { }; int main() { - std::cout << "=== usertype dynamic get/set ===" << std::endl; + std::cout << "=== usertype dynamic get/set ===" + << std::endl; sol::state lua; lua.open_libraries(); lua.new_usertype("vec", - sol::constructors(), + sol::constructors(), // index and newindex control what happens when a "key" // is looked up that is not baked into the class itself - // it is called with the object and the key for index (get)s - // or it is called with the object, the key, and the index (set) - // we can use a member function to assume the "object" is of the `vec` - // type, and then just have a function that takes - // the key (get) or the key + the value (set) + // it is called with the object and the key for index + // (get)s or it is called with the object, the key, and + // the index (set) we can use a member function to + // assume the "object" is of the `vec` type, and then + // just have a function that takes the key (get) or the + // key + the value (set) sol::meta_function::index, &vec::get, sol::meta_function::new_index, diff --git a/examples/source/usertype_initializers.cpp b/examples/source/usertype_initializers.cpp index f14428f0..f8c4375a 100644 --- a/examples/source/usertype_initializers.cpp +++ b/examples/source/usertype_initializers.cpp @@ -23,12 +23,16 @@ public: const int data; static std::unique_ptr create() { - std::cout << "creating 'holy' unique_ptr directly and letting sol/Lua handle it" << std::endl; + std::cout << "creating 'holy' unique_ptr directly and " + "letting sol/Lua handle it" + << std::endl; return std::unique_ptr(new holy(50)); } static void initialize(holy& uninitialized_memory) { - std::cout << "initializing 'holy' userdata at " << static_cast(&uninitialized_memory) << std::endl; + std::cout << "initializing 'holy' userdata at " + << static_cast(&uninitialized_memory) + << std::endl; // receive uninitialized memory from Lua: // properly set it by calling a constructor // on it @@ -37,7 +41,9 @@ public: } static void destroy(holy& memory_from_lua) { - std::cout << "destroying 'holy' userdata at " << static_cast(&memory_from_lua) << std::endl; + std::cout << "destroying 'holy' userdata at " + << static_cast(&memory_from_lua) + << std::endl; memory_from_lua.~holy(); } }; diff --git a/examples/source/usertype_special_functions.cpp b/examples/source/usertype_special_functions.cpp index 2ccd767e..faa01260 100644 --- a/examples/source/usertype_special_functions.cpp +++ b/examples/source/usertype_special_functions.cpp @@ -39,8 +39,8 @@ int main() { double len = std::sqrt(dot(self, self)); return vec(self.x / len, self.y / len); }, - // we use `sol::resolve` because other operator+ can exist - // in the (global) namespace + // we use `sol::resolve` because other operator+ can + // exist in the (global) namespace sol::meta_function::addition, sol::resolve(::operator+), sol::meta_function::subtraction, diff --git a/examples/source/usertype_var.cpp b/examples/source/usertype_var.cpp index 8c62882a..22ed7522 100644 --- a/examples/source/usertype_var.cpp +++ b/examples/source/usertype_var.cpp @@ -12,7 +12,13 @@ int test::number = 25; int main() { sol::state lua; lua.open_libraries(); - lua.new_usertype("test", "direct", sol::var(2), "number", sol::var(test::number), "ref_number", sol::var(std::ref(test::number))); + lua.new_usertype("test", + "direct", + sol::var(2), + "number", + sol::var(test::number), + "ref_number", + sol::var(std::ref(test::number))); int direct_value = lua["test"]["direct"]; sol_c_assert(direct_value == 2); diff --git a/examples/source/variadic_args.cpp b/examples/source/variadic_args.cpp index f768726c..3e72dc33 100644 --- a/examples/source/variadic_args.cpp +++ b/examples/source/variadic_args.cpp @@ -12,19 +12,23 @@ int main() { // Function requires 2 arguments // rest can be variadic, but: // va will include everything after "a" argument, - // which means "b" will be part of the varaidic_args list too - // at position 0 - lua.set_function("v", [](int a, sol::variadic_args va, int /*b*/) { - int r = 0; - for (auto v : va) { - int value = v; // get argument out (implicit conversion) - // can also do int v = v.as(); - // can also do int v = va.get(i); with index i - r += value; - } - // Only have to add a, b was included from variadic_args and beyond - return r + a; - }); + // which means "b" will be part of the varaidic_args list + // too at position 0 + lua.set_function( + "v", [](int a, sol::variadic_args va, int /*b*/) { + int r = 0; + for (auto v : va) { + int value + = v; // get argument out (implicit + // conversion) can also do int v = + // v.as(); can also do int v = + // va.get(i); with index i + r += value; + } + // Only have to add a, b was included from + // variadic_args and beyond + return r + a; + }); lua.script("x = v(25, 25)"); lua.script("x2 = v(25, 25, 100, 50, 250, 150)"); diff --git a/examples/source/variadic_args_into_lua.cpp b/examples/source/variadic_args_into_lua.cpp index 268488c1..27b4d5e6 100644 --- a/examples/source/variadic_args_into_lua.cpp +++ b/examples/source/variadic_args_into_lua.cpp @@ -16,20 +16,23 @@ int main() { // Function requires 2 arguments // rest can be variadic, but: // va will include everything after "a" argument, - // which means "b" will be part of the varaidic_args list too - // at position 0 - lua.set_function("v", [doubler](int a, sol::variadic_args va, int /*b*/) { - int r = 0; - for (auto v : va) { - int value = doubler(v); // pass directly to Lua as well! - r += value; - } - // Only have to add a, b was included from variadic_args and beyond - // use explicit "call" syntax to return exactly an integer! - // this is useful for ambiguous operator overloads in C++ - // and other shenanigans - return r + a; - }); + // which means "b" will be part of the varaidic_args list + // too at position 0 + lua.set_function("v", + [doubler](int a, sol::variadic_args va, int /*b*/) { + int r = 0; + for (auto v : va) { + int value = doubler( + v); // pass directly to Lua as well! + r += value; + } + // Only have to add a, b was included from + // variadic_args and beyond use explicit "call" + // syntax to return exactly an integer! this is + // useful for ambiguous operator overloads in C++ + // and other shenanigans + return r + a; + }); lua.script("x = v(25, 25)"); lua.script("x2 = v(25, 25, 100, 50, 250, 150)"); diff --git a/examples/source/variadic_args_shifted.cpp b/examples/source/variadic_args_shifted.cpp index 33f53c83..a7d28a97 100644 --- a/examples/source/variadic_args_shifted.cpp +++ b/examples/source/variadic_args_shifted.cpp @@ -5,7 +5,8 @@ int main() { - std::cout << "=== variadic_args shifting constructor ===" << std::endl; + std::cout << "=== variadic_args shifting constructor ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); diff --git a/examples/source/variadic_args_storage.cpp b/examples/source/variadic_args_storage.cpp index 876c0e6b..2ed66639 100644 --- a/examples/source/variadic_args_storage.cpp +++ b/examples/source/variadic_args_storage.cpp @@ -6,15 +6,20 @@ int main() { - std::cout << "=== variadic_args serialization/storage ===" << std::endl; + std::cout << "=== variadic_args serialization/storage ===" + << std::endl; sol::state lua; lua.open_libraries(sol::lib::base); std::function function_storage; - auto store_routine = [&function_storage](sol::function f, sol::variadic_args va) { - function_storage = [f, args = std::vector(va.begin(), va.end())]() { f(sol::as_args(args)); }; + auto store_routine = [&function_storage](sol::function f, + sol::variadic_args va) { + function_storage = + [f, + args = std::vector(va.begin(), + va.end())]() { f(sol::as_args(args)); }; }; lua.set_function("store_routine", store_routine); diff --git a/include/sol/as_args.hpp b/include/sol/as_args.hpp index 2307d629..5afe78b0 100644 --- a/include/sol/as_args.hpp +++ b/include/sol/as_args.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/as_returns.hpp b/include/sol/as_returns.hpp index 2a2ae089..0ac499e6 100644 --- a/include/sol/as_returns.hpp +++ b/include/sol/as_returns.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/assert.hpp b/include/sol/assert.hpp index dc464389..ab896038 100644 --- a/include/sol/assert.hpp +++ b/include/sol/assert.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/base_traits.hpp b/include/sol/base_traits.hpp index 7e1ceef9..9fae18e2 100644 --- a/include/sol/base_traits.hpp +++ b/include/sol/base_traits.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/bind_traits.hpp b/include/sol/bind_traits.hpp index dc0e4ca2..e11d753d 100644 --- a/include/sol/bind_traits.hpp +++ b/include/sol/bind_traits.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/bytecode.hpp b/include/sol/bytecode.hpp index 22d9c1fe..a930d9a3 100644 --- a/include/sol/bytecode.hpp +++ b/include/sol/bytecode.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/call.hpp b/include/sol/call.hpp index 6ed45221..67131fd1 100644 --- a/include/sol/call.hpp +++ b/include/sol/call.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/compatibility.hpp b/include/sol/compatibility.hpp index bd827b14..d2d01bd7 100644 --- a/include/sol/compatibility.hpp +++ b/include/sol/compatibility.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/compatibility/lua_version.hpp b/include/sol/compatibility/lua_version.hpp index b7d233f7..d243054a 100644 --- a/include/sol/compatibility/lua_version.hpp +++ b/include/sol/compatibility/lua_version.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/config.hpp b/include/sol/config.hpp index 164644d9..fd2a228d 100644 --- a/include/sol/config.hpp +++ b/include/sol/config.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/coroutine.hpp b/include/sol/coroutine.hpp index 823808a5..9904c788 100644 --- a/include/sol/coroutine.hpp +++ b/include/sol/coroutine.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/debug.hpp b/include/sol/debug.hpp index 58b5c6f3..477b00ff 100644 --- a/include/sol/debug.hpp +++ b/include/sol/debug.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/demangle.hpp b/include/sol/demangle.hpp index 9aa0ac5c..f1743ae8 100644 --- a/include/sol/demangle.hpp +++ b/include/sol/demangle.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/deprecate.hpp b/include/sol/deprecate.hpp index 28779cb0..7fbb0308 100644 --- a/include/sol/deprecate.hpp +++ b/include/sol/deprecate.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/dump_handler.hpp b/include/sol/dump_handler.hpp index 9a209579..02613653 100644 --- a/include/sol/dump_handler.hpp +++ b/include/sol/dump_handler.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/ebco.hpp b/include/sol/ebco.hpp index 59b21fa9..af54024b 100644 --- a/include/sol/ebco.hpp +++ b/include/sol/ebco.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/environment.hpp b/include/sol/environment.hpp index ff1f5850..f1fd8b49 100644 --- a/include/sol/environment.hpp +++ b/include/sol/environment.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/error.hpp b/include/sol/error.hpp index 3888bc64..99d2a425 100644 --- a/include/sol/error.hpp +++ b/include/sol/error.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/error_handler.hpp b/include/sol/error_handler.hpp index bd56a18e..cfda69bd 100644 --- a/include/sol/error_handler.hpp +++ b/include/sol/error_handler.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) @@ -43,7 +43,7 @@ namespace sol { constexpr const char* not_enough_stack_space_integral = "not enough space left on Lua stack for an integral number"; constexpr const char* not_enough_stack_space_string = "not enough space left on Lua stack for a string"; constexpr const char* not_enough_stack_space_meta_function_name = "not enough space left on Lua stack for the name of a meta_function"; - constexpr const char* not_enough_stack_space_userdata = "not enough space left on Lua stack to create a sol3 userdata"; + constexpr const char* not_enough_stack_space_userdata = "not enough space left on Lua stack to create a sol2 userdata"; constexpr const char* not_enough_stack_space_generic = "not enough space left on Lua stack to push valuees"; constexpr const char* not_enough_stack_space_environment = "not enough space left on Lua stack to retrieve environment"; constexpr const char* protected_function_error = "caught (...) unknown error during protected_function call"; diff --git a/include/sol/forward.hpp b/include/sol/forward.hpp index 6421cd9a..708e711e 100644 --- a/include/sol/forward.hpp +++ b/include/sol/forward.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/forward_detail.hpp b/include/sol/forward_detail.hpp index c6849e0a..5815f485 100644 --- a/include/sol/forward_detail.hpp +++ b/include/sol/forward_detail.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/function.hpp b/include/sol/function.hpp index d4c0aa9d..7afeb6c1 100644 --- a/include/sol/function.hpp +++ b/include/sol/function.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/function_result.hpp b/include/sol/function_result.hpp index 2d1e455e..1f998d7f 100644 --- a/include/sol/function_result.hpp +++ b/include/sol/function_result.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/function_types.hpp b/include/sol/function_types.hpp index 0ce19302..1ae29f5e 100644 --- a/include/sol/function_types.hpp +++ b/include/sol/function_types.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/function_types_core.hpp b/include/sol/function_types_core.hpp index a04fc866..138b2b51 100644 --- a/include/sol/function_types_core.hpp +++ b/include/sol/function_types_core.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/function_types_overloaded.hpp b/include/sol/function_types_overloaded.hpp index 0d2d0fb4..8c8e5c1a 100644 --- a/include/sol/function_types_overloaded.hpp +++ b/include/sol/function_types_overloaded.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/function_types_stateful.hpp b/include/sol/function_types_stateful.hpp index f15040cd..45c97b1b 100644 --- a/include/sol/function_types_stateful.hpp +++ b/include/sol/function_types_stateful.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/function_types_stateless.hpp b/include/sol/function_types_stateless.hpp index ab70a602..672732fa 100644 --- a/include/sol/function_types_stateless.hpp +++ b/include/sol/function_types_stateless.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/function_types_templated.hpp b/include/sol/function_types_templated.hpp index fed6c88c..2cc892a9 100644 --- a/include/sol/function_types_templated.hpp +++ b/include/sol/function_types_templated.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/in_place.hpp b/include/sol/in_place.hpp index d98bc9aa..69716296 100644 --- a/include/sol/in_place.hpp +++ b/include/sol/in_place.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/inheritance.hpp b/include/sol/inheritance.hpp index 6683046d..88ba6fa8 100644 --- a/include/sol/inheritance.hpp +++ b/include/sol/inheritance.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/load_result.hpp b/include/sol/load_result.hpp index aef0dcae..4bafd3ee 100644 --- a/include/sol/load_result.hpp +++ b/include/sol/load_result.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/lua_table.hpp b/include/sol/lua_table.hpp index 58f02e54..05c5eb85 100644 --- a/include/sol/lua_table.hpp +++ b/include/sol/lua_table.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/lua_value.hpp b/include/sol/lua_value.hpp index a505a1a1..b2b8b6b1 100644 --- a/include/sol/lua_value.hpp +++ b/include/sol/lua_value.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/make_reference.hpp b/include/sol/make_reference.hpp index e403881d..6b13b1ea 100644 --- a/include/sol/make_reference.hpp +++ b/include/sol/make_reference.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/metatable.hpp b/include/sol/metatable.hpp index a1539ca9..78121293 100644 --- a/include/sol/metatable.hpp +++ b/include/sol/metatable.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/object.hpp b/include/sol/object.hpp index 92325451..da39b9f0 100644 --- a/include/sol/object.hpp +++ b/include/sol/object.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/object_base.hpp b/include/sol/object_base.hpp index d6698080..ea9b9be1 100644 --- a/include/sol/object_base.hpp +++ b/include/sol/object_base.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/optional.hpp b/include/sol/optional.hpp index b9312954..e7edc33d 100644 --- a/include/sol/optional.hpp +++ b/include/sol/optional.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/optional_implementation.hpp b/include/sol/optional_implementation.hpp index baafea48..b7673b17 100644 --- a/include/sol/optional_implementation.hpp +++ b/include/sol/optional_implementation.hpp @@ -695,7 +695,7 @@ namespace sol { /// otherwise the return value of `std::invoke(std::forward(f), value())` /// is returned. /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) &; + /// \synopsis template \n constexpr auto and_then(F &&f) &; template SOL_TL_OPTIONAL_11_CONSTEXPR auto and_then(F&& f) & { using result = detail::invoke_result_t; @@ -705,7 +705,7 @@ namespace sol { } /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) &&; + /// \synopsis template \n constexpr auto and_then(F &&f) &&; template SOL_TL_OPTIONAL_11_CONSTEXPR auto and_then(F&& f) && { using result = detail::invoke_result_t; @@ -715,7 +715,7 @@ namespace sol { } /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) const &; + /// \synopsis template \n constexpr auto and_then(F &&f) const &; template constexpr auto and_then(F&& f) const& { using result = detail::invoke_result_t; @@ -726,7 +726,7 @@ namespace sol { #ifndef SOL_TL_OPTIONAL_NO_CONSTRR /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) const &&; + /// \synopsis template \n constexpr auto and_then(F &&f) const &&; template constexpr auto and_then(F&& f) const&& { using result = detail::invoke_result_t; @@ -745,7 +745,7 @@ namespace sol { /// `*this` is empty, otherwise the return value of /// `std::invoke(std::forward(f), value())` is returned. /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) &; + /// \synopsis template \n constexpr auto and_then(F &&f) &; template SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t and_then(F&& f) & { using result = detail::invoke_result_t; @@ -755,7 +755,7 @@ namespace sol { } /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) &&; + /// \synopsis template \n constexpr auto and_then(F &&f) &&; template SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t and_then(F&& f) && { using result = detail::invoke_result_t; @@ -765,7 +765,7 @@ namespace sol { } /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) const &; + /// \synopsis template \n constexpr auto and_then(F &&f) const &; template constexpr detail::invoke_result_t and_then(F&& f) const& { using result = detail::invoke_result_t; @@ -776,7 +776,7 @@ namespace sol { #ifndef SOL_TL_OPTIONAL_NO_CONSTRR /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) const &&; + /// \synopsis template \n constexpr auto and_then(F &&f) const &&; template constexpr detail::invoke_result_t and_then(F&& f) const&& { using result = detail::invoke_result_t; @@ -977,14 +977,14 @@ namespace sol { /// `std::forward(u)()` is returned. /// /// \group map_or_else - /// \synopsis template \nauto map_or_else(F &&f, U &&u) &; + /// \synopsis template \n auto map_or_else(F &&f, U &&u) &; template detail::invoke_result_t map_or_else(F&& f, U&& u) & { return has_value() ? detail::invoke(std::forward(f), **this) : std::forward(u)(); } /// \group map_or_else - /// \synopsis template \nauto map_or_else(F &&f, U &&u) + /// \synopsis template \n auto map_or_else(F &&f, U &&u) /// &&; template detail::invoke_result_t map_or_else(F&& f, U&& u) && { @@ -992,7 +992,7 @@ namespace sol { } /// \group map_or_else - /// \synopsis template \nauto map_or_else(F &&f, U &&u) + /// \synopsis template \n auto map_or_else(F &&f, U &&u) /// const &; template detail::invoke_result_t map_or_else(F&& f, U&& u) const& { @@ -1001,7 +1001,7 @@ namespace sol { #ifndef SOL_TL_OPTIONAL_NO_CONSTRR /// \group map_or_else - /// \synopsis template \nauto map_or_else(F &&f, U &&u) + /// \synopsis template \n auto map_or_else(F &&f, U &&u) /// const &&; template detail::invoke_result_t map_or_else(F&& f, U&& u) const&& { @@ -1123,7 +1123,7 @@ namespace sol { } /// \group in_place - /// \synopsis template \nconstexpr explicit optional(in_place_t, std::initializer_list&, Args&&... args); + /// \synopsis template \n constexpr explicit optional(in_place_t, std::initializer_list&, Args&&... args); template SOL_TL_OPTIONAL_11_CONSTEXPR explicit optional(detail::enable_if_t&, Args&&...>::value, in_place_t>, std::initializer_list il, Args&&... args) { @@ -1150,7 +1150,7 @@ namespace sol { /// \exclude constexpr optional(const T& u) : base(in_place, u) { } -#endif // sol3 modification +#endif // sol2 modification /// Converting copy constructor. /// \synopsis template optional(const optional &rhs); @@ -1286,7 +1286,7 @@ namespace sol { } /// \group emplace - /// \synopsis template \nT& emplace(std::initializer_list il, Args &&... args); + /// \synopsis template \n T& emplace(std::initializer_list il, Args &&... args); template detail::enable_if_t&, Args&&...>::value, T&> emplace(std::initializer_list il, Args&&... args) { *this = nullopt; @@ -1604,7 +1604,7 @@ namespace sol { return rhs.has_value() ? lhs >= *rhs : true; } - /// \synopsis template \nvoid swap(optional &lhs, optional &rhs); + /// \synopsis template \n void swap(optional &lhs, optional &rhs); template ::value>* = nullptr, detail::enable_if_t::value>* = nullptr> void swap(optional& lhs, optional& rhs) noexcept(noexcept(lhs.swap(rhs))) { return lhs.swap(rhs); @@ -1713,7 +1713,7 @@ namespace sol { /// otherwise the return value of `std::invoke(std::forward(f), value())` /// is returned. /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) &; + /// \synopsis template \n constexpr auto and_then(F &&f) &; template SOL_TL_OPTIONAL_11_CONSTEXPR auto and_then(F&& f) & { using result = detail::invoke_result_t; @@ -1723,7 +1723,7 @@ namespace sol { } /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) &&; + /// \synopsis template \n constexpr auto and_then(F &&f) &&; template SOL_TL_OPTIONAL_11_CONSTEXPR auto and_then(F&& f) && { using result = detail::invoke_result_t; @@ -1733,7 +1733,7 @@ namespace sol { } /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) const &; + /// \synopsis template \n constexpr auto and_then(F &&f) const &; template constexpr auto and_then(F&& f) const& { using result = detail::invoke_result_t; @@ -1744,7 +1744,7 @@ namespace sol { #ifndef SOL_TL_OPTIONAL_NO_CONSTRR /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) const &&; + /// \synopsis template \n constexpr auto and_then(F &&f) const &&; template constexpr auto and_then(F&& f) const&& { using result = detail::invoke_result_t; @@ -1763,7 +1763,7 @@ namespace sol { /// otherwise the return value of `std::invoke(std::forward(f), value())` /// is returned. /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) &; + /// \synopsis template \n constexpr auto and_then(F &&f) &; template SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t and_then(F&& f) & { using result = detail::invoke_result_t; @@ -1773,7 +1773,7 @@ namespace sol { } /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) &&; + /// \synopsis template \n constexpr auto and_then(F &&f) &&; template SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t and_then(F&& f) && { using result = detail::invoke_result_t; @@ -1783,7 +1783,7 @@ namespace sol { } /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) const &; + /// \synopsis template \n constexpr auto and_then(F &&f) const &; template constexpr detail::invoke_result_t and_then(F&& f) const& { using result = detail::invoke_result_t; @@ -1794,7 +1794,7 @@ namespace sol { #ifndef SOL_TL_OPTIONAL_NO_CONSTRR /// \group and_then - /// \synopsis template \nconstexpr auto and_then(F &&f) const &&; + /// \synopsis template \n constexpr auto and_then(F &&f) const &&; template constexpr detail::invoke_result_t and_then(F&& f) const&& { using result = detail::invoke_result_t; @@ -1994,14 +1994,14 @@ namespace sol { /// `std::forward(u)()` is returned. /// /// \group map_or_else - /// \synopsis template \nauto map_or_else(F &&f, U &&u) &; + /// \synopsis template \n auto map_or_else(F &&f, U &&u) &; template detail::invoke_result_t map_or_else(F&& f, U&& u) & { return has_value() ? detail::invoke(std::forward(f), **this) : std::forward(u)(); } /// \group map_or_else - /// \synopsis template \nauto map_or_else(F &&f, U &&u) + /// \synopsis template \n auto map_or_else(F &&f, U &&u) /// &&; template detail::invoke_result_t map_or_else(F&& f, U&& u) && { @@ -2009,7 +2009,7 @@ namespace sol { } /// \group map_or_else - /// \synopsis template \nauto map_or_else(F &&f, U &&u) + /// \synopsis template \n auto map_or_else(F &&f, U &&u) /// const &; template detail::invoke_result_t map_or_else(F&& f, U&& u) const& { @@ -2018,7 +2018,7 @@ namespace sol { #ifndef SOL_TL_OPTIONAL_NO_CONSTRR /// \group map_or_else - /// \synopsis template \nauto map_or_else(F &&f, U &&u) + /// \synopsis template \n auto map_or_else(F &&f, U &&u) /// const &&; template detail::invoke_result_t map_or_else(F&& f, U&& u) const&& { diff --git a/include/sol/overload.hpp b/include/sol/overload.hpp index be5ffa80..74b7bcf6 100644 --- a/include/sol/overload.hpp +++ b/include/sol/overload.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/packaged_coroutine.hpp b/include/sol/packaged_coroutine.hpp index 00f11126..b5ffcb51 100644 --- a/include/sol/packaged_coroutine.hpp +++ b/include/sol/packaged_coroutine.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/pairs_iterator.hpp b/include/sol/pairs_iterator.hpp index 7a20f33d..cd1543eb 100644 --- a/include/sol/pairs_iterator.hpp +++ b/include/sol/pairs_iterator.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/pointer_like.hpp b/include/sol/pointer_like.hpp index 6ae3f78a..80bf58cb 100644 --- a/include/sol/pointer_like.hpp +++ b/include/sol/pointer_like.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/policies.hpp b/include/sol/policies.hpp index ad26c576..90789b78 100644 --- a/include/sol/policies.hpp +++ b/include/sol/policies.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/property.hpp b/include/sol/property.hpp index a0ddf088..8b818daf 100644 --- a/include/sol/property.hpp +++ b/include/sol/property.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/protect.hpp b/include/sol/protect.hpp index b4bb1207..8b1221df 100644 --- a/include/sol/protect.hpp +++ b/include/sol/protect.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/protected_function.hpp b/include/sol/protected_function.hpp index 38375beb..b690d46c 100644 --- a/include/sol/protected_function.hpp +++ b/include/sol/protected_function.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/protected_function_result.hpp b/include/sol/protected_function_result.hpp index 66b09fdb..bb25146e 100644 --- a/include/sol/protected_function_result.hpp +++ b/include/sol/protected_function_result.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/protected_handler.hpp b/include/sol/protected_handler.hpp index 900490ae..6d40640f 100644 --- a/include/sol/protected_handler.hpp +++ b/include/sol/protected_handler.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/proxy_base.hpp b/include/sol/proxy_base.hpp index d271f493..13a6c77d 100644 --- a/include/sol/proxy_base.hpp +++ b/include/sol/proxy_base.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/raii.hpp b/include/sol/raii.hpp index 32444304..10cbb28c 100644 --- a/include/sol/raii.hpp +++ b/include/sol/raii.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/reference.hpp b/include/sol/reference.hpp index c3ee45f4..a3e78fde 100644 --- a/include/sol/reference.hpp +++ b/include/sol/reference.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/resolve.hpp b/include/sol/resolve.hpp index 76dcc49d..2cbc8d2f 100644 --- a/include/sol/resolve.hpp +++ b/include/sol/resolve.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack.hpp b/include/sol/stack.hpp index 04d4d3b2..faf468d8 100644 --- a/include/sol/stack.hpp +++ b/include/sol/stack.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_check.hpp b/include/sol/stack_check.hpp index 6a02925b..b90d70e7 100644 --- a/include/sol/stack_check.hpp +++ b/include/sol/stack_check.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_check_get.hpp b/include/sol/stack_check_get.hpp index fda27ee3..9353c3c7 100644 --- a/include/sol/stack_check_get.hpp +++ b/include/sol/stack_check_get.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_check_get_qualified.hpp b/include/sol/stack_check_get_qualified.hpp index 25018112..b5dfc387 100644 --- a/include/sol/stack_check_get_qualified.hpp +++ b/include/sol/stack_check_get_qualified.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_check_get_unqualified.hpp b/include/sol/stack_check_get_unqualified.hpp index 6763ce5f..acdb5541 100644 --- a/include/sol/stack_check_get_unqualified.hpp +++ b/include/sol/stack_check_get_unqualified.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_check_qualified.hpp b/include/sol/stack_check_qualified.hpp index 536cf424..5712a168 100644 --- a/include/sol/stack_check_qualified.hpp +++ b/include/sol/stack_check_qualified.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_check_unqualified.hpp b/include/sol/stack_check_unqualified.hpp index b69cf000..4ecd9f6c 100644 --- a/include/sol/stack_check_unqualified.hpp +++ b/include/sol/stack_check_unqualified.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_core.hpp b/include/sol/stack_core.hpp index 2b7341b7..460a9e9a 100644 --- a/include/sol/stack_core.hpp +++ b/include/sol/stack_core.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) @@ -719,7 +719,7 @@ namespace sol { constexpr const char* not_enough_stack_space_integral = "not enough space left on Lua stack for an integral number"; constexpr const char* not_enough_stack_space_string = "not enough space left on Lua stack for a string"; constexpr const char* not_enough_stack_space_meta_function_name = "not enough space left on Lua stack for the name of a meta_function"; - constexpr const char* not_enough_stack_space_userdata = "not enough space left on Lua stack to create a sol3 userdata"; + constexpr const char* not_enough_stack_space_userdata = "not enough space left on Lua stack to create a sol2 userdata"; constexpr const char* not_enough_stack_space_generic = "not enough space left on Lua stack to push valuees"; constexpr const char* not_enough_stack_space_environment = "not enough space left on Lua stack to retrieve environment"; diff --git a/include/sol/stack_field.hpp b/include/sol/stack_field.hpp index d2d1d077..a9f688dd 100644 --- a/include/sol/stack_field.hpp +++ b/include/sol/stack_field.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_get.hpp b/include/sol/stack_get.hpp index 76774d45..70e8c699 100644 --- a/include/sol/stack_get.hpp +++ b/include/sol/stack_get.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_get_qualified.hpp b/include/sol/stack_get_qualified.hpp index ff12b6d5..a71c2959 100644 --- a/include/sol/stack_get_qualified.hpp +++ b/include/sol/stack_get_qualified.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_get_unqualified.hpp b/include/sol/stack_get_unqualified.hpp index 323e688f..b2c75e6b 100644 --- a/include/sol/stack_get_unqualified.hpp +++ b/include/sol/stack_get_unqualified.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_guard.hpp b/include/sol/stack_guard.hpp index 6ffc4d6e..9ae9a073 100644 --- a/include/sol/stack_guard.hpp +++ b/include/sol/stack_guard.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_iterator.hpp b/include/sol/stack_iterator.hpp index f1bcd5c0..e73a4df2 100644 --- a/include/sol/stack_iterator.hpp +++ b/include/sol/stack_iterator.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_pop.hpp b/include/sol/stack_pop.hpp index 5df00b85..065908fc 100644 --- a/include/sol/stack_pop.hpp +++ b/include/sol/stack_pop.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_probe.hpp b/include/sol/stack_probe.hpp index 7a1fb759..3b971621 100644 --- a/include/sol/stack_probe.hpp +++ b/include/sol/stack_probe.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_proxy.hpp b/include/sol/stack_proxy.hpp index e0173530..169efd00 100644 --- a/include/sol/stack_proxy.hpp +++ b/include/sol/stack_proxy.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_proxy_base.hpp b/include/sol/stack_proxy_base.hpp index 2cc5a752..75c6e781 100644 --- a/include/sol/stack_proxy_base.hpp +++ b/include/sol/stack_proxy_base.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_push.hpp b/include/sol/stack_push.hpp index b050c1c8..f02d3071 100644 --- a/include/sol/stack_push.hpp +++ b/include/sol/stack_push.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/stack_reference.hpp b/include/sol/stack_reference.hpp index aa3d50f7..18b987d6 100644 --- a/include/sol/stack_reference.hpp +++ b/include/sol/stack_reference.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/state.hpp b/include/sol/state.hpp index 4e22c4fd..1f0f0bc4 100644 --- a/include/sol/state.hpp +++ b/include/sol/state.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/state_handling.hpp b/include/sol/state_handling.hpp index c40c2897..5e7ceb1b 100644 --- a/include/sol/state_handling.hpp +++ b/include/sol/state_handling.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) @@ -61,7 +61,7 @@ namespace sol { std::string err(message, messagesize); lua_settop(L, 0); #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) - std::cerr << "[sol3] An error occurred and panic has been invoked: "; + std::cerr << "[sol2] An error occurred and panic has been invoked: "; std::cerr << err; std::cerr << std::endl; #endif @@ -86,7 +86,7 @@ namespace sol { msg.assign(traceback.data(), traceback.size()); } #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) - // std::cerr << "[sol3] An error occurred and was caught in traceback: "; + // std::cerr << "[sol2] An error occurred and was caught in traceback: "; // std::cerr << msg; // std::cerr << std::endl; #endif // Printing @@ -150,7 +150,7 @@ namespace sol { err.append(serr.data(), serr.size()); } #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) - std::cerr << "[sol3] An error occurred and has been passed to an error handler: "; + std::cerr << "[sol2] An error occurred and has been passed to an error handler: "; std::cerr << err; std::cerr << std::endl; #endif diff --git a/include/sol/state_view.hpp b/include/sol/state_view.hpp index 8f48e36e..0e3cf820 100644 --- a/include/sol/state_view.hpp +++ b/include/sol/state_view.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/string_view.hpp b/include/sol/string_view.hpp index 87ae03f1..19f89f53 100644 --- a/include/sol/string_view.hpp +++ b/include/sol/string_view.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/table.hpp b/include/sol/table.hpp index 3cb69338..fd0b0ea0 100644 --- a/include/sol/table.hpp +++ b/include/sol/table.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/table_core.hpp b/include/sol/table_core.hpp index ba64a3be..7862f9ce 100644 --- a/include/sol/table_core.hpp +++ b/include/sol/table_core.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/table_iterator.hpp b/include/sol/table_iterator.hpp index 613d2535..6f42df88 100644 --- a/include/sol/table_iterator.hpp +++ b/include/sol/table_iterator.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/thread.hpp b/include/sol/thread.hpp index dd57d268..fc933d0e 100644 --- a/include/sol/thread.hpp +++ b/include/sol/thread.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/tie.hpp b/include/sol/tie.hpp index ffc3d2b6..6f6b7dc4 100644 --- a/include/sol/tie.hpp +++ b/include/sol/tie.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/traits.hpp b/include/sol/traits.hpp index 6c78fb67..107e5947 100644 --- a/include/sol/traits.hpp +++ b/include/sol/traits.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/trampoline.hpp b/include/sol/trampoline.hpp index 29480b0a..d4e5bfc5 100644 --- a/include/sol/trampoline.hpp +++ b/include/sol/trampoline.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) @@ -48,7 +48,7 @@ namespace sol { // must push at least 1 object on the stack inline int default_exception_handler(lua_State* L, optional, string_view what) { #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) - std::cerr << "[sol3] An exception occurred: "; + std::cerr << "[sol2] An exception occurred: "; std::cerr.write(what.data(), static_cast(what.size())); std::cerr << std::endl; #endif diff --git a/include/sol/tuple.hpp b/include/sol/tuple.hpp index ae1b42be..3ec1e16f 100644 --- a/include/sol/tuple.hpp +++ b/include/sol/tuple.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/types.hpp b/include/sol/types.hpp index 345316ad..706f982f 100644 --- a/include/sol/types.hpp +++ b/include/sol/types.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/unique_usertype_traits.hpp b/include/sol/unique_usertype_traits.hpp index 9dd22723..d383dc96 100644 --- a/include/sol/unique_usertype_traits.hpp +++ b/include/sol/unique_usertype_traits.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/unsafe_function.hpp b/include/sol/unsafe_function.hpp index 3b364ed2..28110321 100644 --- a/include/sol/unsafe_function.hpp +++ b/include/sol/unsafe_function.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/unsafe_function_result.hpp b/include/sol/unsafe_function_result.hpp index 671dbe51..d340f0de 100644 --- a/include/sol/unsafe_function_result.hpp +++ b/include/sol/unsafe_function_result.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/userdata.hpp b/include/sol/userdata.hpp index 36fc90b9..e878d01b 100644 --- a/include/sol/userdata.hpp +++ b/include/sol/userdata.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/usertype.hpp b/include/sol/usertype.hpp index 1eadef33..b37436ad 100644 --- a/include/sol/usertype.hpp +++ b/include/sol/usertype.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/usertype_container.hpp b/include/sol/usertype_container.hpp index 9c2f3e91..9f5ec09c 100644 --- a/include/sol/usertype_container.hpp +++ b/include/sol/usertype_container.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/usertype_container_launch.hpp b/include/sol/usertype_container_launch.hpp index dbf5a8cd..e25f4a7e 100644 --- a/include/sol/usertype_container_launch.hpp +++ b/include/sol/usertype_container_launch.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/usertype_core.hpp b/include/sol/usertype_core.hpp index a761c354..4db8cefe 100644 --- a/include/sol/usertype_core.hpp +++ b/include/sol/usertype_core.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/usertype_proxy.hpp b/include/sol/usertype_proxy.hpp index 766c988f..2d36ef44 100644 --- a/include/sol/usertype_proxy.hpp +++ b/include/sol/usertype_proxy.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/usertype_storage.hpp b/include/sol/usertype_storage.hpp index 1891d1dd..1cc1fcc4 100644 --- a/include/sol/usertype_storage.hpp +++ b/include/sol/usertype_storage.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) @@ -980,7 +980,7 @@ namespace sol { namespace u_detail { // we then let typical definitions potentially override these intrinsics // it's the user's fault if they override things or screw them up: - // these names have been reserved and documented since sol3 + // these names have been reserved and documented since sol2 // STEP 0: tell the old usertype (if it exists) // to fuck off diff --git a/include/sol/usertype_traits.hpp b/include/sol/usertype_traits.hpp index c3fa33f4..cf60b274 100644 --- a/include/sol/usertype_traits.hpp +++ b/include/sol/usertype_traits.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/variadic_args.hpp b/include/sol/variadic_args.hpp index f01c2ed5..efaad38d 100644 --- a/include/sol/variadic_args.hpp +++ b/include/sol/variadic_args.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/variadic_results.hpp b/include/sol/variadic_results.hpp index 5d278fc4..6b8e981c 100644 --- a/include/sol/variadic_results.hpp +++ b/include/sol/variadic_results.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/version.hpp b/include/sol/version.hpp index 92ffbbc4..1cd8db4c 100644 --- a/include/sol/version.hpp +++ b/include/sol/version.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/include/sol/wrapper.hpp b/include/sol/wrapper.hpp index 1735fe93..608ed589 100644 --- a/include/sol/wrapper.hpp +++ b/include/sol/wrapper.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/list_headers.py b/list_headers.py index 7faf73fc..9e6c3c6f 100644 --- a/list_headers.py +++ b/list_headers.py @@ -3,7 +3,7 @@ import os import re -description = "Lists all primary sol3 header files" +description = "Lists all primary sol2 header files" script_path = os.path.normpath(os.path.dirname(os.path.realpath(__file__))) working_dir = os.getcwd() diff --git a/meson.build b/meson.build index dbd53a1a..bbda2bee 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('sol3', 'cpp') +project('sol2', 'cpp') # Find lua dependency if get_option('lua_cpp') @@ -41,7 +41,7 @@ if get_option('single') cmd = run_command(python, 'list_headers.py') if cmd.returncode() != 0 - error('Could not list sol3 header files.') + error('Could not list sol2 header files.') endif # Create our custom target to generate the single header file. diff --git a/meson_options.txt b/meson_options.txt index 2f157f69..dc6ddd9c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,2 @@ -option('single', type: 'boolean', value: false, description: 'Generate the sol3 single header and expose the corresponding build targets') +option('single', type: 'boolean', value: false, description: 'Generate the sol2 single header and expose the corresponding build targets') option('lua_cpp', type: 'boolean', value: false, description: 'Compile lua as C++ code') \ No newline at end of file diff --git a/scripts/build.linux.sh b/scripts/build.linux.sh index ddbd9b8f..6f7c879c 100644 --- a/scripts/build.linux.sh +++ b/scripts/build.linux.sh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/scripts/preparation.linux.sh b/scripts/preparation.linux.sh index c3530287..d009160e 100644 --- a/scripts/preparation.linux.sh +++ b/scripts/preparation.linux.sh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/scripts/preparation.osx.sh b/scripts/preparation.osx.sh index 2473e039..d2dc2656 100644 --- a/scripts/preparation.osx.sh +++ b/scripts/preparation.osx.sh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/scripts/push.linux.sh b/scripts/push.linux.sh index 7ff07ebc..0743fc76 100644 --- a/scripts/push.linux.sh +++ b/scripts/push.linux.sh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/scripts/run.linux.sh b/scripts/run.linux.sh index a268491d..5cb7b3e3 100644 --- a/scripts/run.linux.sh +++ b/scripts/run.linux.sh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/scripts/run.osx.sh b/scripts/run.osx.sh index 28e8ed6b..93166603 100644 --- a/scripts/run.osx.sh +++ b/scripts/run.osx.sh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 096bd9a1..8ab39765 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3 tests +# # # # sol2 tests # # Dependencies FetchContent_Declare( @@ -30,7 +30,7 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(Catch2) -add_subdirectory(header_tests) +add_subdirectory(inclusion) add_subdirectory(runtime_tests) add_subdirectory(config_tests) add_subdirectory(regression_tests) diff --git a/tests/config_tests/CMakeLists.txt b/tests/config_tests/CMakeLists.txt index 281213a5..080f17df 100644 --- a/tests/config_tests/CMakeLists.txt +++ b/tests/config_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,6 +20,6 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3 tests +# # # # sol2 tests add_subdirectory(function_pointers) diff --git a/tests/config_tests/function_pointers/CMakeLists.txt b/tests/config_tests/function_pointers/CMakeLists.txt index d3f1ca9e..1d906a2b 100644 --- a/tests/config_tests/function_pointers/CMakeLists.txt +++ b/tests/config_tests/function_pointers/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3 tests - simple regression tests +# # # # sol2 tests - simple regression tests file(GLOB test_sources source/*.cpp) source_group(sources FILES ${test_sources}) diff --git a/tests/header_tests/source/main.cpp b/tests/header_tests/source/main.cpp deleted file mode 100644 index c472b345..00000000 --- a/tests/header_tests/source/main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// sol3 - -// The MIT License (MIT) - -// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#include "sol_defines.hpp" - -#include - -int main() { - return 0; -} \ No newline at end of file diff --git a/tests/header_tests/CMakeLists.txt b/tests/inclusion/CMakeLists.txt similarity index 95% rename from tests/header_tests/CMakeLists.txt rename to tests/inclusion/CMakeLists.txt index bc30a7c8..a9330af7 100644 --- a/tests/header_tests/CMakeLists.txt +++ b/tests/inclusion/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3 tests - header compilation tests +# # # # sol2 tests - header compilation tests file(GLOB_RECURSE SOL2_COMPILE_TEST_SOURCES source/*.cpp) source_group(compile_test_sources FILES "${SOL2_COMPILE_TEST_SOURCES}") diff --git a/tests/header_tests/source/as_args.cpp b/tests/inclusion/source/as_args.cpp similarity index 99% rename from tests/header_tests/source/as_args.cpp rename to tests/inclusion/source/as_args.cpp index 2c6af751..44785aca 100644 --- a/tests/header_tests/source/as_args.cpp +++ b/tests/inclusion/source/as_args.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/as_returns.cpp b/tests/inclusion/source/as_returns.cpp similarity index 99% rename from tests/header_tests/source/as_returns.cpp rename to tests/inclusion/source/as_returns.cpp index 70ceda47..42d9b19d 100644 --- a/tests/header_tests/source/as_returns.cpp +++ b/tests/inclusion/source/as_returns.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/base_traits.cpp b/tests/inclusion/source/base_traits.cpp similarity index 97% rename from tests/header_tests/source/base_traits.cpp rename to tests/inclusion/source/base_traits.cpp index 90010f71..a0615ae4 100644 --- a/tests/header_tests/source/base_traits.cpp +++ b/tests/inclusion/source/base_traits.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/bind_traits.cpp b/tests/inclusion/source/bind_traits.cpp similarity index 99% rename from tests/header_tests/source/bind_traits.cpp rename to tests/inclusion/source/bind_traits.cpp index cf65d1de..8547787d 100644 --- a/tests/header_tests/source/bind_traits.cpp +++ b/tests/inclusion/source/bind_traits.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/bytecode.cpp b/tests/inclusion/source/bytecode.cpp similarity index 97% rename from tests/header_tests/source/bytecode.cpp rename to tests/inclusion/source/bytecode.cpp index e06c0d92..dee4c382 100644 --- a/tests/header_tests/source/bytecode.cpp +++ b/tests/inclusion/source/bytecode.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/call.cpp b/tests/inclusion/source/call.cpp similarity index 99% rename from tests/header_tests/source/call.cpp rename to tests/inclusion/source/call.cpp index c1cbe298..03348532 100644 --- a/tests/header_tests/source/call.cpp +++ b/tests/inclusion/source/call.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/compatibility.cpp b/tests/inclusion/source/compatibility.cpp similarity index 99% rename from tests/header_tests/source/compatibility.cpp rename to tests/inclusion/source/compatibility.cpp index f0d0fd87..23a1335f 100644 --- a/tests/header_tests/source/compatibility.cpp +++ b/tests/inclusion/source/compatibility.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/compatibility/compat-5.3.cpp b/tests/inclusion/source/compatibility/compat-5.3.cpp similarity index 99% rename from tests/header_tests/source/compatibility/compat-5.3.cpp rename to tests/inclusion/source/compatibility/compat-5.3.cpp index d6d51ea1..116ec195 100644 --- a/tests/header_tests/source/compatibility/compat-5.3.cpp +++ b/tests/inclusion/source/compatibility/compat-5.3.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/compatibility/lua_version.cpp b/tests/inclusion/source/compatibility/lua_version.cpp similarity index 99% rename from tests/header_tests/source/compatibility/lua_version.cpp rename to tests/inclusion/source/compatibility/lua_version.cpp index a9c912b6..0950c164 100644 --- a/tests/header_tests/source/compatibility/lua_version.cpp +++ b/tests/inclusion/source/compatibility/lua_version.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/config.cpp b/tests/inclusion/source/config.cpp similarity index 99% rename from tests/header_tests/source/config.cpp rename to tests/inclusion/source/config.cpp index c013eb4a..354a813e 100644 --- a/tests/header_tests/source/config.cpp +++ b/tests/inclusion/source/config.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/coroutine.cpp b/tests/inclusion/source/coroutine.cpp similarity index 99% rename from tests/header_tests/source/coroutine.cpp rename to tests/inclusion/source/coroutine.cpp index da70335d..cf88c06a 100644 --- a/tests/header_tests/source/coroutine.cpp +++ b/tests/inclusion/source/coroutine.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/debug.cpp b/tests/inclusion/source/debug.cpp similarity index 99% rename from tests/header_tests/source/debug.cpp rename to tests/inclusion/source/debug.cpp index 917f29b3..42dc365f 100644 --- a/tests/header_tests/source/debug.cpp +++ b/tests/inclusion/source/debug.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/demangle.cpp b/tests/inclusion/source/demangle.cpp similarity index 99% rename from tests/header_tests/source/demangle.cpp rename to tests/inclusion/source/demangle.cpp index aa9f74a1..29fcda6d 100644 --- a/tests/header_tests/source/demangle.cpp +++ b/tests/inclusion/source/demangle.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/deprecate.cpp b/tests/inclusion/source/deprecate.cpp similarity index 99% rename from tests/header_tests/source/deprecate.cpp rename to tests/inclusion/source/deprecate.cpp index 0bc43e82..b1c10927 100644 --- a/tests/header_tests/source/deprecate.cpp +++ b/tests/inclusion/source/deprecate.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/ebco.cpp b/tests/inclusion/source/ebco.cpp similarity index 97% rename from tests/header_tests/source/ebco.cpp rename to tests/inclusion/source/ebco.cpp index 099448e8..b7b246ea 100644 --- a/tests/header_tests/source/ebco.cpp +++ b/tests/inclusion/source/ebco.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/environment.cpp b/tests/inclusion/source/environment.cpp similarity index 99% rename from tests/header_tests/source/environment.cpp rename to tests/inclusion/source/environment.cpp index 33a1176d..99b93509 100644 --- a/tests/header_tests/source/environment.cpp +++ b/tests/inclusion/source/environment.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/error.cpp b/tests/inclusion/source/error.cpp similarity index 100% rename from tests/header_tests/source/error.cpp rename to tests/inclusion/source/error.cpp diff --git a/tests/header_tests/source/error_handler.cpp b/tests/inclusion/source/error_handler.cpp similarity index 99% rename from tests/header_tests/source/error_handler.cpp rename to tests/inclusion/source/error_handler.cpp index 192e5b8f..32e56f20 100644 --- a/tests/header_tests/source/error_handler.cpp +++ b/tests/inclusion/source/error_handler.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/forward.cpp b/tests/inclusion/source/forward.cpp similarity index 99% rename from tests/header_tests/source/forward.cpp rename to tests/inclusion/source/forward.cpp index 9a5a0705..d0ba841e 100644 --- a/tests/header_tests/source/forward.cpp +++ b/tests/inclusion/source/forward.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/forward_detail.cpp b/tests/inclusion/source/forward_detail.cpp similarity index 99% rename from tests/header_tests/source/forward_detail.cpp rename to tests/inclusion/source/forward_detail.cpp index d20ed791..6063e263 100644 --- a/tests/header_tests/source/forward_detail.cpp +++ b/tests/inclusion/source/forward_detail.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/function.cpp b/tests/inclusion/source/function.cpp similarity index 99% rename from tests/header_tests/source/function.cpp rename to tests/inclusion/source/function.cpp index 856542bc..3f612635 100644 --- a/tests/header_tests/source/function.cpp +++ b/tests/inclusion/source/function.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/function_result.cpp b/tests/inclusion/source/function_result.cpp similarity index 99% rename from tests/header_tests/source/function_result.cpp rename to tests/inclusion/source/function_result.cpp index 7b7d9780..d9b13df5 100644 --- a/tests/header_tests/source/function_result.cpp +++ b/tests/inclusion/source/function_result.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/function_types.cpp b/tests/inclusion/source/function_types.cpp similarity index 99% rename from tests/header_tests/source/function_types.cpp rename to tests/inclusion/source/function_types.cpp index 8d673a89..c314b564 100644 --- a/tests/header_tests/source/function_types.cpp +++ b/tests/inclusion/source/function_types.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/function_types_core.cpp b/tests/inclusion/source/function_types_core.cpp similarity index 99% rename from tests/header_tests/source/function_types_core.cpp rename to tests/inclusion/source/function_types_core.cpp index ee3c0fc7..629569c5 100644 --- a/tests/header_tests/source/function_types_core.cpp +++ b/tests/inclusion/source/function_types_core.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/function_types_overloaded.cpp b/tests/inclusion/source/function_types_overloaded.cpp similarity index 99% rename from tests/header_tests/source/function_types_overloaded.cpp rename to tests/inclusion/source/function_types_overloaded.cpp index 88561714..40bec012 100644 --- a/tests/header_tests/source/function_types_overloaded.cpp +++ b/tests/inclusion/source/function_types_overloaded.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/function_types_stateful.cpp b/tests/inclusion/source/function_types_stateful.cpp similarity index 99% rename from tests/header_tests/source/function_types_stateful.cpp rename to tests/inclusion/source/function_types_stateful.cpp index 23d01eb7..c2ae930a 100644 --- a/tests/header_tests/source/function_types_stateful.cpp +++ b/tests/inclusion/source/function_types_stateful.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/function_types_stateless.cpp b/tests/inclusion/source/function_types_stateless.cpp similarity index 99% rename from tests/header_tests/source/function_types_stateless.cpp rename to tests/inclusion/source/function_types_stateless.cpp index 31172f24..26b393f2 100644 --- a/tests/header_tests/source/function_types_stateless.cpp +++ b/tests/inclusion/source/function_types_stateless.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/function_types_templated.cpp b/tests/inclusion/source/function_types_templated.cpp similarity index 99% rename from tests/header_tests/source/function_types_templated.cpp rename to tests/inclusion/source/function_types_templated.cpp index b939dcab..921d2e82 100644 --- a/tests/header_tests/source/function_types_templated.cpp +++ b/tests/inclusion/source/function_types_templated.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/in_place.cpp b/tests/inclusion/source/in_place.cpp similarity index 99% rename from tests/header_tests/source/in_place.cpp rename to tests/inclusion/source/in_place.cpp index 2b38c6ec..7deae440 100644 --- a/tests/header_tests/source/in_place.cpp +++ b/tests/inclusion/source/in_place.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/inheritance.cpp b/tests/inclusion/source/inheritance.cpp similarity index 99% rename from tests/header_tests/source/inheritance.cpp rename to tests/inclusion/source/inheritance.cpp index 999563b5..2ac13945 100644 --- a/tests/header_tests/source/inheritance.cpp +++ b/tests/inclusion/source/inheritance.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/load_result.cpp b/tests/inclusion/source/load_result.cpp similarity index 99% rename from tests/header_tests/source/load_result.cpp rename to tests/inclusion/source/load_result.cpp index 82dce26f..a6992702 100644 --- a/tests/header_tests/source/load_result.cpp +++ b/tests/inclusion/source/load_result.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/lua_table.cpp b/tests/inclusion/source/lua_table.cpp similarity index 97% rename from tests/header_tests/source/lua_table.cpp rename to tests/inclusion/source/lua_table.cpp index 254edf66..5033a903 100644 --- a/tests/header_tests/source/lua_table.cpp +++ b/tests/inclusion/source/lua_table.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/lua_value.cpp b/tests/inclusion/source/lua_value.cpp similarity index 97% rename from tests/header_tests/source/lua_value.cpp rename to tests/inclusion/source/lua_value.cpp index f599be4e..0b4b0c6f 100644 --- a/tests/header_tests/source/lua_value.cpp +++ b/tests/inclusion/source/lua_value.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/make_reference.cpp b/tests/inclusion/source/make_reference.cpp similarity index 99% rename from tests/header_tests/source/make_reference.cpp rename to tests/inclusion/source/make_reference.cpp index c95ba293..53fc0f99 100644 --- a/tests/header_tests/source/make_reference.cpp +++ b/tests/inclusion/source/make_reference.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/metatable.cpp b/tests/inclusion/source/metatable.cpp similarity index 99% rename from tests/header_tests/source/metatable.cpp rename to tests/inclusion/source/metatable.cpp index ed5fd7a5..ea392c10 100644 --- a/tests/header_tests/source/metatable.cpp +++ b/tests/inclusion/source/metatable.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/object.cpp b/tests/inclusion/source/object.cpp similarity index 99% rename from tests/header_tests/source/object.cpp rename to tests/inclusion/source/object.cpp index 6ad10610..d73459ca 100644 --- a/tests/header_tests/source/object.cpp +++ b/tests/inclusion/source/object.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/object_base.cpp b/tests/inclusion/source/object_base.cpp similarity index 99% rename from tests/header_tests/source/object_base.cpp rename to tests/inclusion/source/object_base.cpp index be2bf4e1..860e1750 100644 --- a/tests/header_tests/source/object_base.cpp +++ b/tests/inclusion/source/object_base.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/optional.cpp b/tests/inclusion/source/optional.cpp similarity index 99% rename from tests/header_tests/source/optional.cpp rename to tests/inclusion/source/optional.cpp index 3c942b76..377d6cf2 100644 --- a/tests/header_tests/source/optional.cpp +++ b/tests/inclusion/source/optional.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/optional_implementation.cpp b/tests/inclusion/source/optional_implementation.cpp similarity index 99% rename from tests/header_tests/source/optional_implementation.cpp rename to tests/inclusion/source/optional_implementation.cpp index 6e7399fb..36d8fd06 100644 --- a/tests/header_tests/source/optional_implementation.cpp +++ b/tests/inclusion/source/optional_implementation.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/overload.cpp b/tests/inclusion/source/overload.cpp similarity index 99% rename from tests/header_tests/source/overload.cpp rename to tests/inclusion/source/overload.cpp index 22370153..a3950afb 100644 --- a/tests/header_tests/source/overload.cpp +++ b/tests/inclusion/source/overload.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/packaged_coroutine.cpp b/tests/inclusion/source/packaged_coroutine.cpp similarity index 97% rename from tests/header_tests/source/packaged_coroutine.cpp rename to tests/inclusion/source/packaged_coroutine.cpp index 04aac938..f33cfad5 100644 --- a/tests/header_tests/source/packaged_coroutine.cpp +++ b/tests/inclusion/source/packaged_coroutine.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/pairs_iterator.cpp b/tests/inclusion/source/pairs_iterator.cpp similarity index 97% rename from tests/header_tests/source/pairs_iterator.cpp rename to tests/inclusion/source/pairs_iterator.cpp index be3a3104..afcc9dcd 100644 --- a/tests/header_tests/source/pairs_iterator.cpp +++ b/tests/inclusion/source/pairs_iterator.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/pointer_like.cpp b/tests/inclusion/source/pointer_like.cpp similarity index 97% rename from tests/header_tests/source/pointer_like.cpp rename to tests/inclusion/source/pointer_like.cpp index 002d3c29..d6584694 100644 --- a/tests/header_tests/source/pointer_like.cpp +++ b/tests/inclusion/source/pointer_like.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/policies.cpp b/tests/inclusion/source/policies.cpp similarity index 99% rename from tests/header_tests/source/policies.cpp rename to tests/inclusion/source/policies.cpp index 999fdf05..6c38f312 100644 --- a/tests/header_tests/source/policies.cpp +++ b/tests/inclusion/source/policies.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/property.cpp b/tests/inclusion/source/property.cpp similarity index 99% rename from tests/header_tests/source/property.cpp rename to tests/inclusion/source/property.cpp index 7adc9e20..65f4d618 100644 --- a/tests/header_tests/source/property.cpp +++ b/tests/inclusion/source/property.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/protect.cpp b/tests/inclusion/source/protect.cpp similarity index 99% rename from tests/header_tests/source/protect.cpp rename to tests/inclusion/source/protect.cpp index 7808a888..9b39f276 100644 --- a/tests/header_tests/source/protect.cpp +++ b/tests/inclusion/source/protect.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/protected_function.cpp b/tests/inclusion/source/protected_function.cpp similarity index 99% rename from tests/header_tests/source/protected_function.cpp rename to tests/inclusion/source/protected_function.cpp index b5b6b922..7f42cc39 100644 --- a/tests/header_tests/source/protected_function.cpp +++ b/tests/inclusion/source/protected_function.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/protected_function_result.cpp b/tests/inclusion/source/protected_function_result.cpp similarity index 99% rename from tests/header_tests/source/protected_function_result.cpp rename to tests/inclusion/source/protected_function_result.cpp index b94d55ae..39c0febb 100644 --- a/tests/header_tests/source/protected_function_result.cpp +++ b/tests/inclusion/source/protected_function_result.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/protected_handler.cpp b/tests/inclusion/source/protected_handler.cpp similarity index 99% rename from tests/header_tests/source/protected_handler.cpp rename to tests/inclusion/source/protected_handler.cpp index c4ec567d..d1f55408 100644 --- a/tests/header_tests/source/protected_handler.cpp +++ b/tests/inclusion/source/protected_handler.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/proxy.cpp b/tests/inclusion/source/proxy.cpp similarity index 99% rename from tests/header_tests/source/proxy.cpp rename to tests/inclusion/source/proxy.cpp index 17a7b0f0..e69b9fdf 100644 --- a/tests/header_tests/source/proxy.cpp +++ b/tests/inclusion/source/proxy.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/proxy_base.cpp b/tests/inclusion/source/proxy_base.cpp similarity index 99% rename from tests/header_tests/source/proxy_base.cpp rename to tests/inclusion/source/proxy_base.cpp index 9208e6f7..05f753d8 100644 --- a/tests/header_tests/source/proxy_base.cpp +++ b/tests/inclusion/source/proxy_base.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/raii.cpp b/tests/inclusion/source/raii.cpp similarity index 99% rename from tests/header_tests/source/raii.cpp rename to tests/inclusion/source/raii.cpp index 4b95cbea..e4962ae5 100644 --- a/tests/header_tests/source/raii.cpp +++ b/tests/inclusion/source/raii.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/reference.cpp b/tests/inclusion/source/reference.cpp similarity index 99% rename from tests/header_tests/source/reference.cpp rename to tests/inclusion/source/reference.cpp index 93b43d8b..b68a3d3d 100644 --- a/tests/header_tests/source/reference.cpp +++ b/tests/inclusion/source/reference.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/resolve.cpp b/tests/inclusion/source/resolve.cpp similarity index 99% rename from tests/header_tests/source/resolve.cpp rename to tests/inclusion/source/resolve.cpp index 744035d2..135f75c3 100644 --- a/tests/header_tests/source/resolve.cpp +++ b/tests/inclusion/source/resolve.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/sol.cpp b/tests/inclusion/source/sol.cpp similarity index 99% rename from tests/header_tests/source/sol.cpp rename to tests/inclusion/source/sol.cpp index 7f8e4e38..0a0451d4 100644 --- a/tests/header_tests/source/sol.cpp +++ b/tests/inclusion/source/sol.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/sol_defines.hpp b/tests/inclusion/source/sol_defines.hpp similarity index 97% rename from tests/header_tests/source/sol_defines.hpp rename to tests/inclusion/source/sol_defines.hpp index aed5758e..7488ef30 100644 --- a/tests/header_tests/source/sol_defines.hpp +++ b/tests/inclusion/source/sol_defines.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack.cpp b/tests/inclusion/source/stack.cpp similarity index 99% rename from tests/header_tests/source/stack.cpp rename to tests/inclusion/source/stack.cpp index 1a4660b9..a16379e1 100644 --- a/tests/header_tests/source/stack.cpp +++ b/tests/inclusion/source/stack.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_check.cpp b/tests/inclusion/source/stack_check.cpp similarity index 97% rename from tests/header_tests/source/stack_check.cpp rename to tests/inclusion/source/stack_check.cpp index 799d1897..a3dbcd5e 100644 --- a/tests/header_tests/source/stack_check.cpp +++ b/tests/inclusion/source/stack_check.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_check_get.cpp b/tests/inclusion/source/stack_check_get.cpp similarity index 97% rename from tests/header_tests/source/stack_check_get.cpp rename to tests/inclusion/source/stack_check_get.cpp index a5925ab5..b984a54b 100644 --- a/tests/header_tests/source/stack_check_get.cpp +++ b/tests/inclusion/source/stack_check_get.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_check_get_qualified.cpp b/tests/inclusion/source/stack_check_get_qualified.cpp similarity index 97% rename from tests/header_tests/source/stack_check_get_qualified.cpp rename to tests/inclusion/source/stack_check_get_qualified.cpp index cfd5d1bb..302a4ac6 100644 --- a/tests/header_tests/source/stack_check_get_qualified.cpp +++ b/tests/inclusion/source/stack_check_get_qualified.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_check_get_unqualified.cpp b/tests/inclusion/source/stack_check_get_unqualified.cpp similarity index 97% rename from tests/header_tests/source/stack_check_get_unqualified.cpp rename to tests/inclusion/source/stack_check_get_unqualified.cpp index 8b7f8d91..a39e49cc 100644 --- a/tests/header_tests/source/stack_check_get_unqualified.cpp +++ b/tests/inclusion/source/stack_check_get_unqualified.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_check_qualified.cpp b/tests/inclusion/source/stack_check_qualified.cpp similarity index 97% rename from tests/header_tests/source/stack_check_qualified.cpp rename to tests/inclusion/source/stack_check_qualified.cpp index 279ee580..71a54cc4 100644 --- a/tests/header_tests/source/stack_check_qualified.cpp +++ b/tests/inclusion/source/stack_check_qualified.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_check_unqualified.cpp b/tests/inclusion/source/stack_check_unqualified.cpp similarity index 97% rename from tests/header_tests/source/stack_check_unqualified.cpp rename to tests/inclusion/source/stack_check_unqualified.cpp index 61a2c842..b117090f 100644 --- a/tests/header_tests/source/stack_check_unqualified.cpp +++ b/tests/inclusion/source/stack_check_unqualified.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_core.cpp b/tests/inclusion/source/stack_core.cpp similarity index 97% rename from tests/header_tests/source/stack_core.cpp rename to tests/inclusion/source/stack_core.cpp index 4521abb5..4f974ed8 100644 --- a/tests/header_tests/source/stack_core.cpp +++ b/tests/inclusion/source/stack_core.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_field.cpp b/tests/inclusion/source/stack_field.cpp similarity index 99% rename from tests/header_tests/source/stack_field.cpp rename to tests/inclusion/source/stack_field.cpp index 723faf62..21f43fef 100644 --- a/tests/header_tests/source/stack_field.cpp +++ b/tests/inclusion/source/stack_field.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_get.cpp b/tests/inclusion/source/stack_get.cpp similarity index 97% rename from tests/header_tests/source/stack_get.cpp rename to tests/inclusion/source/stack_get.cpp index 17702847..7076361a 100644 --- a/tests/header_tests/source/stack_get.cpp +++ b/tests/inclusion/source/stack_get.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_get_qualified.cpp b/tests/inclusion/source/stack_get_qualified.cpp similarity index 97% rename from tests/header_tests/source/stack_get_qualified.cpp rename to tests/inclusion/source/stack_get_qualified.cpp index 4b2425fc..385a0bd5 100644 --- a/tests/header_tests/source/stack_get_qualified.cpp +++ b/tests/inclusion/source/stack_get_qualified.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_get_unqualified.cpp b/tests/inclusion/source/stack_get_unqualified.cpp similarity index 97% rename from tests/header_tests/source/stack_get_unqualified.cpp rename to tests/inclusion/source/stack_get_unqualified.cpp index fbccba7e..7011c53c 100644 --- a/tests/header_tests/source/stack_get_unqualified.cpp +++ b/tests/inclusion/source/stack_get_unqualified.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_guard.cpp b/tests/inclusion/source/stack_guard.cpp similarity index 99% rename from tests/header_tests/source/stack_guard.cpp rename to tests/inclusion/source/stack_guard.cpp index 211606fb..974b94e6 100644 --- a/tests/header_tests/source/stack_guard.cpp +++ b/tests/inclusion/source/stack_guard.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_iterator.cpp b/tests/inclusion/source/stack_iterator.cpp similarity index 99% rename from tests/header_tests/source/stack_iterator.cpp rename to tests/inclusion/source/stack_iterator.cpp index 48427c50..9b53b8d3 100644 --- a/tests/header_tests/source/stack_iterator.cpp +++ b/tests/inclusion/source/stack_iterator.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_pop.cpp b/tests/inclusion/source/stack_pop.cpp similarity index 97% rename from tests/header_tests/source/stack_pop.cpp rename to tests/inclusion/source/stack_pop.cpp index 64ada86e..b0b5e19c 100644 --- a/tests/header_tests/source/stack_pop.cpp +++ b/tests/inclusion/source/stack_pop.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_probe.cpp b/tests/inclusion/source/stack_probe.cpp similarity index 99% rename from tests/header_tests/source/stack_probe.cpp rename to tests/inclusion/source/stack_probe.cpp index 207f71ab..89ceae48 100644 --- a/tests/header_tests/source/stack_probe.cpp +++ b/tests/inclusion/source/stack_probe.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_proxy.cpp b/tests/inclusion/source/stack_proxy.cpp similarity index 99% rename from tests/header_tests/source/stack_proxy.cpp rename to tests/inclusion/source/stack_proxy.cpp index b9796c4c..80bcbf6e 100644 --- a/tests/header_tests/source/stack_proxy.cpp +++ b/tests/inclusion/source/stack_proxy.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_proxy_base.cpp b/tests/inclusion/source/stack_proxy_base.cpp similarity index 99% rename from tests/header_tests/source/stack_proxy_base.cpp rename to tests/inclusion/source/stack_proxy_base.cpp index d5a7de81..4de7fef7 100644 --- a/tests/header_tests/source/stack_proxy_base.cpp +++ b/tests/inclusion/source/stack_proxy_base.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_push.cpp b/tests/inclusion/source/stack_push.cpp similarity index 97% rename from tests/header_tests/source/stack_push.cpp rename to tests/inclusion/source/stack_push.cpp index 133d4d7f..1fc513a8 100644 --- a/tests/header_tests/source/stack_push.cpp +++ b/tests/inclusion/source/stack_push.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/stack_reference.cpp b/tests/inclusion/source/stack_reference.cpp similarity index 99% rename from tests/header_tests/source/stack_reference.cpp rename to tests/inclusion/source/stack_reference.cpp index 55370695..4065b7bf 100644 --- a/tests/header_tests/source/stack_reference.cpp +++ b/tests/inclusion/source/stack_reference.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/state.cpp b/tests/inclusion/source/state.cpp similarity index 100% rename from tests/header_tests/source/state.cpp rename to tests/inclusion/source/state.cpp diff --git a/tests/header_tests/source/state_handling.cpp b/tests/inclusion/source/state_handling.cpp similarity index 97% rename from tests/header_tests/source/state_handling.cpp rename to tests/inclusion/source/state_handling.cpp index 8f2b0451..f5cafae8 100644 --- a/tests/header_tests/source/state_handling.cpp +++ b/tests/inclusion/source/state_handling.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/state_view.cpp b/tests/inclusion/source/state_view.cpp similarity index 100% rename from tests/header_tests/source/state_view.cpp rename to tests/inclusion/source/state_view.cpp diff --git a/tests/header_tests/source/string_view.cpp b/tests/inclusion/source/string_view.cpp similarity index 99% rename from tests/header_tests/source/string_view.cpp rename to tests/inclusion/source/string_view.cpp index be10bd9c..ac0ab532 100644 --- a/tests/header_tests/source/string_view.cpp +++ b/tests/inclusion/source/string_view.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/table.cpp b/tests/inclusion/source/table.cpp similarity index 99% rename from tests/header_tests/source/table.cpp rename to tests/inclusion/source/table.cpp index 290acb5a..1a741141 100644 --- a/tests/header_tests/source/table.cpp +++ b/tests/inclusion/source/table.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/table_core.cpp b/tests/inclusion/source/table_core.cpp similarity index 99% rename from tests/header_tests/source/table_core.cpp rename to tests/inclusion/source/table_core.cpp index 0fb93927..599cfcd0 100644 --- a/tests/header_tests/source/table_core.cpp +++ b/tests/inclusion/source/table_core.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/table_iterator.cpp b/tests/inclusion/source/table_iterator.cpp similarity index 99% rename from tests/header_tests/source/table_iterator.cpp rename to tests/inclusion/source/table_iterator.cpp index 65f5b4b4..2dc991c1 100644 --- a/tests/header_tests/source/table_iterator.cpp +++ b/tests/inclusion/source/table_iterator.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/thread.cpp b/tests/inclusion/source/thread.cpp similarity index 97% rename from tests/header_tests/source/thread.cpp rename to tests/inclusion/source/thread.cpp index 562b3218..98a58d41 100644 --- a/tests/header_tests/source/thread.cpp +++ b/tests/inclusion/source/thread.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/tie.cpp b/tests/inclusion/source/tie.cpp similarity index 99% rename from tests/header_tests/source/tie.cpp rename to tests/inclusion/source/tie.cpp index 34c9f239..ee873f0b 100644 --- a/tests/header_tests/source/tie.cpp +++ b/tests/inclusion/source/tie.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/traits.cpp b/tests/inclusion/source/traits.cpp similarity index 99% rename from tests/header_tests/source/traits.cpp rename to tests/inclusion/source/traits.cpp index 2f3afa7a..57802bd6 100644 --- a/tests/header_tests/source/traits.cpp +++ b/tests/inclusion/source/traits.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/trampoline.cpp b/tests/inclusion/source/trampoline.cpp similarity index 99% rename from tests/header_tests/source/trampoline.cpp rename to tests/inclusion/source/trampoline.cpp index e1daec2a..aacc216d 100644 --- a/tests/header_tests/source/trampoline.cpp +++ b/tests/inclusion/source/trampoline.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/tuple.cpp b/tests/inclusion/source/tuple.cpp similarity index 99% rename from tests/header_tests/source/tuple.cpp rename to tests/inclusion/source/tuple.cpp index 5272fd4b..eaabdc2c 100644 --- a/tests/header_tests/source/tuple.cpp +++ b/tests/inclusion/source/tuple.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/types.cpp b/tests/inclusion/source/types.cpp similarity index 99% rename from tests/header_tests/source/types.cpp rename to tests/inclusion/source/types.cpp index f32517a8..87537866 100644 --- a/tests/header_tests/source/types.cpp +++ b/tests/inclusion/source/types.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/unicode.cpp b/tests/inclusion/source/unicode.cpp similarity index 99% rename from tests/header_tests/source/unicode.cpp rename to tests/inclusion/source/unicode.cpp index fedc5469..ce5941fe 100644 --- a/tests/header_tests/source/unicode.cpp +++ b/tests/inclusion/source/unicode.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/unique_usertype_traits.cpp b/tests/inclusion/source/unique_usertype_traits.cpp similarity index 97% rename from tests/header_tests/source/unique_usertype_traits.cpp rename to tests/inclusion/source/unique_usertype_traits.cpp index ad297058..e59ab57a 100644 --- a/tests/header_tests/source/unique_usertype_traits.cpp +++ b/tests/inclusion/source/unique_usertype_traits.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/unsafe_function.cpp b/tests/inclusion/source/unsafe_function.cpp similarity index 99% rename from tests/header_tests/source/unsafe_function.cpp rename to tests/inclusion/source/unsafe_function.cpp index 4f88ab8c..d9a5f32e 100644 --- a/tests/header_tests/source/unsafe_function.cpp +++ b/tests/inclusion/source/unsafe_function.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/unsafe_function_result.cpp b/tests/inclusion/source/unsafe_function_result.cpp similarity index 99% rename from tests/header_tests/source/unsafe_function_result.cpp rename to tests/inclusion/source/unsafe_function_result.cpp index f4402627..c7acdf20 100644 --- a/tests/header_tests/source/unsafe_function_result.cpp +++ b/tests/inclusion/source/unsafe_function_result.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/userdata.cpp b/tests/inclusion/source/userdata.cpp similarity index 99% rename from tests/header_tests/source/userdata.cpp rename to tests/inclusion/source/userdata.cpp index 4b88b1df..0329a04f 100644 --- a/tests/header_tests/source/userdata.cpp +++ b/tests/inclusion/source/userdata.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/usertype.cpp b/tests/inclusion/source/usertype.cpp similarity index 99% rename from tests/header_tests/source/usertype.cpp rename to tests/inclusion/source/usertype.cpp index 296dc6d6..69a181ab 100644 --- a/tests/header_tests/source/usertype.cpp +++ b/tests/inclusion/source/usertype.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/usertype_container.cpp b/tests/inclusion/source/usertype_container.cpp similarity index 99% rename from tests/header_tests/source/usertype_container.cpp rename to tests/inclusion/source/usertype_container.cpp index 6f97a08a..29237ad2 100644 --- a/tests/header_tests/source/usertype_container.cpp +++ b/tests/inclusion/source/usertype_container.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/usertype_container_launch.cpp b/tests/inclusion/source/usertype_container_launch.cpp similarity index 99% rename from tests/header_tests/source/usertype_container_launch.cpp rename to tests/inclusion/source/usertype_container_launch.cpp index 7ee5065a..cb5c4ee6 100644 --- a/tests/header_tests/source/usertype_container_launch.cpp +++ b/tests/inclusion/source/usertype_container_launch.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/usertype_core.cpp b/tests/inclusion/source/usertype_core.cpp similarity index 99% rename from tests/header_tests/source/usertype_core.cpp rename to tests/inclusion/source/usertype_core.cpp index 310c3e81..d5f4046c 100644 --- a/tests/header_tests/source/usertype_core.cpp +++ b/tests/inclusion/source/usertype_core.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/usertype_proxy.cpp b/tests/inclusion/source/usertype_proxy.cpp similarity index 99% rename from tests/header_tests/source/usertype_proxy.cpp rename to tests/inclusion/source/usertype_proxy.cpp index 27fee3f7..8692fdf2 100644 --- a/tests/header_tests/source/usertype_proxy.cpp +++ b/tests/inclusion/source/usertype_proxy.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/usertype_storage.cpp b/tests/inclusion/source/usertype_storage.cpp similarity index 99% rename from tests/header_tests/source/usertype_storage.cpp rename to tests/inclusion/source/usertype_storage.cpp index 54504ca9..08cc70cb 100644 --- a/tests/header_tests/source/usertype_storage.cpp +++ b/tests/inclusion/source/usertype_storage.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/usertype_traits.cpp b/tests/inclusion/source/usertype_traits.cpp similarity index 99% rename from tests/header_tests/source/usertype_traits.cpp rename to tests/inclusion/source/usertype_traits.cpp index 7e87b649..73067dd7 100644 --- a/tests/header_tests/source/usertype_traits.cpp +++ b/tests/inclusion/source/usertype_traits.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/variadic_args.cpp b/tests/inclusion/source/variadic_args.cpp similarity index 99% rename from tests/header_tests/source/variadic_args.cpp rename to tests/inclusion/source/variadic_args.cpp index 87aa4ad5..9588f41b 100644 --- a/tests/header_tests/source/variadic_args.cpp +++ b/tests/inclusion/source/variadic_args.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/variadic_results.cpp b/tests/inclusion/source/variadic_results.cpp similarity index 99% rename from tests/header_tests/source/variadic_results.cpp rename to tests/inclusion/source/variadic_results.cpp index a6c6bdfd..37907a95 100644 --- a/tests/header_tests/source/variadic_results.cpp +++ b/tests/inclusion/source/variadic_results.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/version.cpp b/tests/inclusion/source/version.cpp similarity index 97% rename from tests/header_tests/source/version.cpp rename to tests/inclusion/source/version.cpp index 17596301..ee87cdeb 100644 --- a/tests/header_tests/source/version.cpp +++ b/tests/inclusion/source/version.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/header_tests/source/wrapper.cpp b/tests/inclusion/source/wrapper.cpp similarity index 99% rename from tests/header_tests/source/wrapper.cpp rename to tests/inclusion/source/wrapper.cpp index b311efc6..0507b6ee 100644 --- a/tests/header_tests/source/wrapper.cpp +++ b/tests/inclusion/source/wrapper.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/regression_tests/1011/CMakeLists.txt b/tests/regression_tests/1011/CMakeLists.txt index 397ae9b5..d6e1f495 100644 --- a/tests/regression_tests/1011/CMakeLists.txt +++ b/tests/regression_tests/1011/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3 tests - simple regression tests +# # # # sol2 tests - simple regression tests file(GLOB test_sources source/*.cpp) source_group(sources FILES ${test_sources}) @@ -29,14 +29,13 @@ function(CREATE_TEST test_target_name test_name target_sol) add_executable(${test_target_name} ${test_sources}) set_target_properties(${test_target_name} PROPERTIES - OUTPUT_NAME ${test_name} - EXPORT_NAME sol2::${test_name}) - target_link_libraries(${test_target_name} - PUBLIC Threads::Threads ${LUA_LIBRARIES} ${target_sol} ${CMAKE_DL_LIBS}) + OUTPUT_NAME ${test_name}) + target_link_libraries(${test_target_name} + PUBLIC Threads::Threads ${LUA_LIBRARIES} ${target_sol} Catch2::Catch2 ${CMAKE_DL_LIBS}) if (MSVC) if (NOT CMAKE_COMPILER_ID MATCHES "Clang") - target_compile_options(${test_target_name} + target_compile_options(${test_target_name} PRIVATE /bigobj /W4) endif() else() @@ -66,11 +65,11 @@ function(CREATE_TEST test_target_name test_name target_sol) target_compile_options(${test_target_name} PRIVATE /EHsc /std:c++latest) target_compile_definitions(${test_target_name} - PRIVATE UNICODE _UNICODE + PRIVATE UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE) else() target_compile_options(${test_target_name} - PRIVATE -std=c++1z -Wno-unknown-warning -Wno-unknown-warning-option + PRIVATE -std=c++1z -Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) endif() diff --git a/tests/regression_tests/CMakeLists.txt b/tests/regression_tests/CMakeLists.txt index 40206f47..46fb19fd 100644 --- a/tests/regression_tests/CMakeLists.txt +++ b/tests/regression_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3 tests +# # # # sol2 tests add_subdirectory(1011) add_subdirectory(simple) diff --git a/tests/regression_tests/simple/CMakeLists.txt b/tests/regression_tests/simple/CMakeLists.txt index 8319538a..8be818c2 100644 --- a/tests/regression_tests/simple/CMakeLists.txt +++ b/tests/regression_tests/simple/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3 tests - simple regression tests +# # # # sol2 tests - simple regression tests file(GLOB simple_test_sources source/*.cpp) source_group(test_sources FILES ${simple_test_sources}) @@ -29,11 +29,10 @@ function(CREATE_TEST test_target_name test_name target_sol) add_executable(${test_target_name} ${simple_test_sources}) set_target_properties(${test_target_name} PROPERTIES - OUTPUT_NAME ${test_name} - EXPORT_NAME sol2::${test_name}) + OUTPUT_NAME ${test_name}) target_link_libraries(${test_target_name} - PUBLIC Threads::Threads ${LUA_LIBRARIES} ${target_sol} ${CMAKE_DL_LIBS}) - target_compile_definitions(${test_target_name} + PUBLIC Threads::Threads ${LUA_LIBRARIES} ${target_sol} Catch2::Catch2 ${CMAKE_DL_LIBS}) + target_compile_definitions(${test_target_name} PRIVATE SOL_ALL_SAFETIES_ON) if (MSVC) target_compile_options(${test_target_name} diff --git a/tests/runtime_tests/CMakeLists.txt b/tests/runtime_tests/CMakeLists.txt index cc08ae63..48bab432 100644 --- a/tests/runtime_tests/CMakeLists.txt +++ b/tests/runtime_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# # # # sol3 +# # # # sol2 # The MIT License (MIT) # # Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# # # # sol3 tests - runtime tests +# # # # sol2 tests - runtime tests file(GLOB SOL2_RUNTIME_TEST_SOURCES source/*.cpp) source_group(test_sources FILES ${SOL2_RUNTIME_TEST_SOURCES}) diff --git a/tests/runtime_tests/source/abort_clean.cpp b/tests/runtime_tests/source/abort_clean.cpp deleted file mode 100644 index 821333b0..00000000 --- a/tests/runtime_tests/source/abort_clean.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -struct pre_main { - pre_main() { -#ifdef SOL2_CI -#ifdef _MSC_VER - _set_abort_behavior(0, _WRITE_ABORT_MSG); -#endif -#endif - } -} pm; diff --git a/tests/runtime_tests/source/basic.cpp b/tests/runtime_tests/source/basic.cpp index ea14feab..eb8c1a3b 100644 --- a/tests/runtime_tests/source/basic.cpp +++ b/tests/runtime_tests/source/basic.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/common_classes.hpp b/tests/runtime_tests/source/common_classes.hpp index 74ccbc9e..7de5290d 100644 --- a/tests/runtime_tests/source/common_classes.hpp +++ b/tests/runtime_tests/source/common_classes.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/container.usertype_check.cpp b/tests/runtime_tests/source/container.usertype_check.cpp index 8f931bd5..cc65a414 100644 --- a/tests/runtime_tests/source/container.usertype_check.cpp +++ b/tests/runtime_tests/source/container.usertype_check.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/container_semantics.cpp b/tests/runtime_tests/source/container_semantics.cpp index 1e7b6ca5..83444a03 100644 --- a/tests/runtime_tests/source/container_semantics.cpp +++ b/tests/runtime_tests/source/container_semantics.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/container_semantics.custom.cpp b/tests/runtime_tests/source/container_semantics.custom.cpp index e0c1e856..a55ddf9d 100644 --- a/tests/runtime_tests/source/container_semantics.custom.cpp +++ b/tests/runtime_tests/source/container_semantics.custom.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/container_semantics.ordered.cpp b/tests/runtime_tests/source/container_semantics.ordered.cpp index 748c177a..d62f2484 100644 --- a/tests/runtime_tests/source/container_semantics.ordered.cpp +++ b/tests/runtime_tests/source/container_semantics.ordered.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/container_semantics.unordered.cpp b/tests/runtime_tests/source/container_semantics.unordered.cpp index d40ba59e..b5ca750c 100644 --- a/tests/runtime_tests/source/container_semantics.unordered.cpp +++ b/tests/runtime_tests/source/container_semantics.unordered.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/container_shims.cpp b/tests/runtime_tests/source/container_shims.cpp index abbc4e97..e20ae2cf 100644 --- a/tests/runtime_tests/source/container_shims.cpp +++ b/tests/runtime_tests/source/container_shims.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/container_table.cpp b/tests/runtime_tests/source/container_table.cpp index a27e75b1..04841ca5 100644 --- a/tests/runtime_tests/source/container_table.cpp +++ b/tests/runtime_tests/source/container_table.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/containers.cpp b/tests/runtime_tests/source/containers.cpp index 79853244..e992fe3a 100644 --- a/tests/runtime_tests/source/containers.cpp +++ b/tests/runtime_tests/source/containers.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/containers.roundtrip.cpp b/tests/runtime_tests/source/containers.roundtrip.cpp index 5b7d3805..fcb67653 100644 --- a/tests/runtime_tests/source/containers.roundtrip.cpp +++ b/tests/runtime_tests/source/containers.roundtrip.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/containers.table.cpp b/tests/runtime_tests/source/containers.table.cpp index 9f6e8e56..7e7350f6 100644 --- a/tests/runtime_tests/source/containers.table.cpp +++ b/tests/runtime_tests/source/containers.table.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/coroutines.cpp b/tests/runtime_tests/source/coroutines.cpp index a45f789b..36dda247 100644 --- a/tests/runtime_tests/source/coroutines.cpp +++ b/tests/runtime_tests/source/coroutines.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) @@ -610,7 +610,7 @@ end REQUIRE(s5 == 0); } -TEST_CASE("coroutines/yielding", "test that a sol3 bound function can yield when marked yieldable") { +TEST_CASE("coroutines/yielding", "test that a sol2 bound function can yield when marked yieldable") { SECTION("regular functions") { sol::state lua; lua.open_libraries(sol::lib::base, sol::lib::coroutine); @@ -702,7 +702,7 @@ TEST_CASE("coroutines/yielding", "test that a sol3 bound function can yield when } } -TEST_CASE("coroutines/error_handler_state_transfer", "test that sol3 coroutines with their error handlers are properly sourced") { +TEST_CASE("coroutines/error_handler_state_transfer", "test that sol2 coroutines with their error handlers are properly sourced") { sol::state lua; lua.open_libraries(sol::lib::base, sol::lib::coroutine); diff --git a/tests/runtime_tests/source/customizations.cpp b/tests/runtime_tests/source/customizations.cpp index dd046580..0c63fa1a 100644 --- a/tests/runtime_tests/source/customizations.cpp +++ b/tests/runtime_tests/source/customizations.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/customizations_private.cpp b/tests/runtime_tests/source/customizations_private.cpp index 58851842..d97d9bef 100644 --- a/tests/runtime_tests/source/customizations_private.cpp +++ b/tests/runtime_tests/source/customizations_private.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) @@ -40,7 +40,7 @@ struct number_shim { // HEY: // Don't do this. -// The code below is for sol3 to specialize things, +// The code below is for sol2 to specialize things, // not for YOU to specialize things. // If you customize things in this fashion, // I will break your code sometime in the future when fixing things. diff --git a/tests/runtime_tests/source/dump.cpp b/tests/runtime_tests/source/dump.cpp index 8f8c5b0f..649ed365 100644 --- a/tests/runtime_tests/source/dump.cpp +++ b/tests/runtime_tests/source/dump.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/environments.cpp b/tests/runtime_tests/source/environments.cpp index a1d5bb4c..19dfc8d2 100644 --- a/tests/runtime_tests/source/environments.cpp +++ b/tests/runtime_tests/source/environments.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/functions.cpp b/tests/runtime_tests/source/functions.cpp index 9bfce6a8..30cc225e 100644 --- a/tests/runtime_tests/source/functions.cpp +++ b/tests/runtime_tests/source/functions.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) @@ -1441,7 +1441,7 @@ TEST_CASE("functions/lua style default arguments", "allow default arguments usin #if !defined(_MSC_VER) || !(defined(_WIN32) && !defined(_WIN64)) -TEST_CASE("functions/noexcept", "allow noexcept functions to be serialized properly into Lua using sol3") { +TEST_CASE("functions/noexcept", "allow noexcept functions to be serialized properly into Lua using sol2") { struct T { static int noexcept_function() noexcept { return 0x61; diff --git a/tests/runtime_tests/source/functions.std.cpp b/tests/runtime_tests/source/functions.std.cpp index 71d4d566..12f58279 100644 --- a/tests/runtime_tests/source/functions.std.cpp +++ b/tests/runtime_tests/source/functions.std.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/gc.cpp b/tests/runtime_tests/source/gc.cpp index c089d892..3e87f113 100644 --- a/tests/runtime_tests/source/gc.cpp +++ b/tests/runtime_tests/source/gc.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/large_integer.cpp b/tests/runtime_tests/source/large_integer.cpp index aab4fc08..010959cf 100644 --- a/tests/runtime_tests/source/large_integer.cpp +++ b/tests/runtime_tests/source/large_integer.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/lua_value.cpp b/tests/runtime_tests/source/lua_value.cpp index 12142d6c..428e15d3 100644 --- a/tests/runtime_tests/source/lua_value.cpp +++ b/tests/runtime_tests/source/lua_value.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/operators.cpp b/tests/runtime_tests/source/operators.cpp index b32a3734..efa6a840 100644 --- a/tests/runtime_tests/source/operators.cpp +++ b/tests/runtime_tests/source/operators.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/overflow.cpp b/tests/runtime_tests/source/overflow.cpp index 4a36765c..ca63a891 100644 --- a/tests/runtime_tests/source/overflow.cpp +++ b/tests/runtime_tests/source/overflow.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/plain_types.cpp b/tests/runtime_tests/source/plain_types.cpp index f2d4a457..5b6a23c0 100644 --- a/tests/runtime_tests/source/plain_types.cpp +++ b/tests/runtime_tests/source/plain_types.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/policies.cpp b/tests/runtime_tests/source/policies.cpp index 62a4315d..e8fb4d8e 100644 --- a/tests/runtime_tests/source/policies.cpp +++ b/tests/runtime_tests/source/policies.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/proxies.cpp b/tests/runtime_tests/source/proxies.cpp index 2701be4d..16d3a169 100644 --- a/tests/runtime_tests/source/proxies.cpp +++ b/tests/runtime_tests/source/proxies.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/sol_test.hpp b/tests/runtime_tests/source/sol_test.hpp index 082f9e0e..958e6e74 100644 --- a/tests/runtime_tests/source/sol_test.hpp +++ b/tests/runtime_tests/source/sol_test.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/state.cpp b/tests/runtime_tests/source/state.cpp index 94fdf7b8..833cb2fe 100644 --- a/tests/runtime_tests/source/state.cpp +++ b/tests/runtime_tests/source/state.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/storage.cpp b/tests/runtime_tests/source/storage.cpp index 5a1ab5f6..39dd1eb2 100644 --- a/tests/runtime_tests/source/storage.cpp +++ b/tests/runtime_tests/source/storage.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/strings.cpp b/tests/runtime_tests/source/strings.cpp index edcdcb56..9857ceab 100644 --- a/tests/runtime_tests/source/strings.cpp +++ b/tests/runtime_tests/source/strings.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/tables.checks.cpp b/tests/runtime_tests/source/tables.checks.cpp index 53ed22da..7dcf5bc8 100644 --- a/tests/runtime_tests/source/tables.checks.cpp +++ b/tests/runtime_tests/source/tables.checks.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/tables.clear.cpp b/tests/runtime_tests/source/tables.clear.cpp index b4bf8c60..7f9677bc 100644 --- a/tests/runtime_tests/source/tables.clear.cpp +++ b/tests/runtime_tests/source/tables.clear.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/tables.cpp b/tests/runtime_tests/source/tables.cpp index c4b25627..acf7fb55 100644 --- a/tests/runtime_tests/source/tables.cpp +++ b/tests/runtime_tests/source/tables.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/tables.enums.cpp b/tests/runtime_tests/source/tables.enums.cpp index 2de12f25..229eba08 100644 --- a/tests/runtime_tests/source/tables.enums.cpp +++ b/tests/runtime_tests/source/tables.enums.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/tables.indexing.cpp b/tests/runtime_tests/source/tables.indexing.cpp index f76a86a5..18015349 100644 --- a/tests/runtime_tests/source/tables.indexing.cpp +++ b/tests/runtime_tests/source/tables.indexing.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/tables.insertion.cpp b/tests/runtime_tests/source/tables.insertion.cpp index e2f33da3..a0a4acff 100644 --- a/tests/runtime_tests/source/tables.insertion.cpp +++ b/tests/runtime_tests/source/tables.insertion.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/tables.traversal.cpp b/tests/runtime_tests/source/tables.traversal.cpp index 87d754c4..9b9b2fc6 100644 --- a/tests/runtime_tests/source/tables.traversal.cpp +++ b/tests/runtime_tests/source/tables.traversal.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.auxiliary_keys.cpp b/tests/runtime_tests/source/usertypes.auxiliary_keys.cpp index fd1b0087..26606b2a 100644 --- a/tests/runtime_tests/source/usertypes.auxiliary_keys.cpp +++ b/tests/runtime_tests/source/usertypes.auxiliary_keys.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.basic.cpp b/tests/runtime_tests/source/usertypes.basic.cpp index a4b13b8e..d8720ae3 100644 --- a/tests/runtime_tests/source/usertypes.basic.cpp +++ b/tests/runtime_tests/source/usertypes.basic.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.constructors.cpp b/tests/runtime_tests/source/usertypes.constructors.cpp index a095936c..cd245c62 100644 --- a/tests/runtime_tests/source/usertypes.constructors.cpp +++ b/tests/runtime_tests/source/usertypes.constructors.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.cpp b/tests/runtime_tests/source/usertypes.cpp index b7684822..4ea7bc7b 100644 --- a/tests/runtime_tests/source/usertypes.cpp +++ b/tests/runtime_tests/source/usertypes.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.inheritance.cpp b/tests/runtime_tests/source/usertypes.inheritance.cpp index b4bcca13..8bfd6b68 100644 --- a/tests/runtime_tests/source/usertypes.inheritance.cpp +++ b/tests/runtime_tests/source/usertypes.inheritance.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.inheritance.multi.cpp b/tests/runtime_tests/source/usertypes.inheritance.multi.cpp index 47183afe..f2eb3458 100644 --- a/tests/runtime_tests/source/usertypes.inheritance.multi.cpp +++ b/tests/runtime_tests/source/usertypes.inheritance.multi.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.member_variables.cpp b/tests/runtime_tests/source/usertypes.member_variables.cpp index 941d3a58..7838817b 100644 --- a/tests/runtime_tests/source/usertypes.member_variables.cpp +++ b/tests/runtime_tests/source/usertypes.member_variables.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.overload.cpp b/tests/runtime_tests/source/usertypes.overload.cpp index 0eebe76d..72c094c5 100644 --- a/tests/runtime_tests/source/usertypes.overload.cpp +++ b/tests/runtime_tests/source/usertypes.overload.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.properties.cpp b/tests/runtime_tests/source/usertypes.properties.cpp index 789dcae1..31d4ec64 100644 --- a/tests/runtime_tests/source/usertypes.properties.cpp +++ b/tests/runtime_tests/source/usertypes.properties.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.runtime.cpp b/tests/runtime_tests/source/usertypes.runtime.cpp index bb81b71f..761a7bee 100644 --- a/tests/runtime_tests/source/usertypes.runtime.cpp +++ b/tests/runtime_tests/source/usertypes.runtime.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/usertypes.unique.cpp b/tests/runtime_tests/source/usertypes.unique.cpp index de8ddce3..51100a51 100644 --- a/tests/runtime_tests/source/usertypes.unique.cpp +++ b/tests/runtime_tests/source/usertypes.unique.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) @@ -231,7 +231,7 @@ TEST_CASE("usertype/unique_usertype-check", "make sure unique usertypes don't ge }()); } -TEST_CASE("usertype/unique void pointers", "can compile shared_ptr types and not trip the compiler or sol3's internals") { +TEST_CASE("usertype/unique void pointers", "can compile shared_ptr types and not trip the compiler or sol2's internals") { sol::state lua; lua.set_function("f", [](std::shared_ptr d) { int* pi = static_cast(d.get()); diff --git a/tests/runtime_tests/source/usertypes.unregister.cpp b/tests/runtime_tests/source/usertypes.unregister.cpp index 52a9cf78..85d82ec1 100644 --- a/tests/runtime_tests/source/usertypes.unregister.cpp +++ b/tests/runtime_tests/source/usertypes.unregister.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/utility.cpp b/tests/runtime_tests/source/utility.cpp index 966d57a9..ee225f12 100644 --- a/tests/runtime_tests/source/utility.cpp +++ b/tests/runtime_tests/source/utility.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT) diff --git a/tests/runtime_tests/source/variadics.cpp b/tests/runtime_tests/source/variadics.cpp index 4e9c4518..0e9e56fe 100644 --- a/tests/runtime_tests/source/variadics.cpp +++ b/tests/runtime_tests/source/variadics.cpp @@ -1,4 +1,4 @@ -// sol3 +// sol2 // The MIT License (MIT)