Fix unorded_map derp

This commit is contained in:
ThePhD 2020-10-03 17:34:34 -04:00
parent 48eea7b573
commit 48e5fc9e44
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
13 changed files with 41 additions and 52 deletions

View File

@ -1,4 +1,6 @@
Read these guidelines. They are relatively simple and will allow me to help you better: Read these guidelines. They are relatively simple and will allow me to help you better!
For Error Reports:
1. Produce a simple, short, compilable test case that reproduces your problem. 1. Produce a simple, short, compilable test case that reproduces your problem.
2. Make a descriptive title that summarises the bug as a whole. 2. Make a descriptive title that summarises the bug as a whole.
@ -11,4 +13,4 @@ If you want to request a feature:
2. Include a description and title of what you would like. 2. Include a description and title of what you would like.
3. Annotate and describe the behavior through comments, asserts or just a small write up. 3. Annotate and describe the behavior through comments, asserts or just a small write up.
Thanks for helping sol grow! Thanks for helping sol2 grow!

View File

@ -213,8 +213,8 @@ if (SOL2_IS_TOP_LEVEL AND (SOL2_DO_TESTS OR SOL2_DO_EXAMPLES))
set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE)
else() else()
string(REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
if (BUILD_LUA_AS_DLL) if (BUILD_LUA_AS_DLL)
string(REGEX REPLACE "/MT" "/MD" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) string(REGEX REPLACE "/MT" "/MD" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
string(REGEX REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REGEX REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})

View File

@ -12,6 +12,7 @@ After that, make sure you grab either the `single header file release`_, or just
When you're ready, try compiling this short snippet: When you're ready, try compiling this short snippet:
.. literalinclude:: ../../../examples/source/tutorials/first_snippet.cpp .. literalinclude:: ../../../examples/source/tutorials/first_snippet.cpp
:lines: 1-4, 8-
:linenos: :linenos:
:caption: hello_lua.cpp :caption: hello_lua.cpp
:name: hello-lua :name: hello-lua
@ -31,6 +32,7 @@ If this works, you're ready to start! The first line creates the ``lua_State`` a
The second line opens a single lua-provided library, "base". There are several other libraries that come with lua that you can open by default, and those are included in the :ref:`sol::lib<lib-enum>` enumeration. You can open multiple base libraries by specifying multiple ``sol::lib`` arguments: The second line opens a single lua-provided library, "base". There are several other libraries that come with lua that you can open by default, and those are included in the :ref:`sol::lib<lib-enum>` enumeration. You can open multiple base libraries by specifying multiple ``sol::lib`` arguments:
.. literalinclude:: ../../../examples/source/tutorials/open_multiple_libraries.cpp .. literalinclude:: ../../../examples/source/tutorials/open_multiple_libraries.cpp
:lines: 1-4, 8-
:linenos: :linenos:
:caption: multiple_libraries.cpp :caption: multiple_libraries.cpp
:name: open-multiple-libraries :name: open-multiple-libraries

View File

@ -2,6 +2,7 @@
#include <sol/sol.hpp> #include <sol/sol.hpp>
#include <iostream> #include <iostream>
#include <unordered_map>
#include "assert.hpp" #include "assert.hpp"
// use as-is, // use as-is,
@ -39,12 +40,12 @@ int main() {
lua.open_libraries(sol::lib::base); lua.open_libraries(sol::lib::base);
lua.new_usertype<dynamic_object>("dynamic_object", lua.new_usertype<dynamic_object>("dynamic_object",
sol::meta_function::index, &dynamic_object::dynamic_get, sol::meta_function::index,
sol::meta_function::new_index, &dynamic_object::dynamic_set, &dynamic_object::dynamic_get,
sol::meta_function::length, [](dynamic_object& d) { sol::meta_function::new_index,
return d.entries.size(); &dynamic_object::dynamic_set,
} sol::meta_function::length,
); [](dynamic_object& d) { return d.entries.size(); });
lua.safe_script(R"( lua.safe_script(R"(
d1 = dynamic_object.new() d1 = dynamic_object.new()

View File

@ -2,6 +2,7 @@
#include <sol/sol.hpp> #include <sol/sol.hpp>
#include <iostream> #include <iostream>
#include <unordered_map>
struct thing { struct thing {
int member_variable = 5; int member_variable = 5;
@ -21,11 +22,11 @@ static std::unordered_map<sol::string_view, sol::object> thing_variable_associat
void register_thing_type(sol::state& lua) { 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<TEMPLATE_AUTO(&thing::member_variable)>) "member_variable",
); sol::object(lua.lua_state(), sol::in_place, &sol::c_call<TEMPLATE_AUTO(&thing::member_variable)>));
thing_function_associations.emplace_hint(thing_function_associations.cend(), thing_function_associations.emplace_hint(thing_function_associations.cend(),
"member_function", sol::object(lua.lua_state(), sol::in_place, &sol::c_call<TEMPLATE_AUTO(&thing::member_function)>) "member_function",
); sol::object(lua.lua_state(), sol::in_place, &sol::c_call<TEMPLATE_AUTO(&thing::member_function)>));
struct call_handler { struct call_handler {
static int lookup_function(lua_State* L) { static int lookup_function(lua_State* L) {

View File

@ -2,6 +2,9 @@
#include <sol/sol.hpp> // or #include "sol.hpp", whichever suits your needs #include <sol/sol.hpp> // or #include "sol.hpp", whichever suits your needs
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
// silence unused warnings
(void)argc;
(void)argv;
sol::state lua; sol::state lua;
lua.open_libraries(sol::lib::base); lua.open_libraries(sol::lib::base);

View File

@ -2,7 +2,9 @@
#include <sol/sol.hpp> #include <sol/sol.hpp>
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
// silence unused warnings
(void)argc;
(void)argv;
sol::state lua; 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);

View File

@ -27,6 +27,8 @@
#include <sol/stack.hpp> #include <sol/stack.hpp>
#include <sol/usertype_container.hpp> #include <sol/usertype_container.hpp>
#include <unordered_map>
namespace sol { namespace sol {
namespace container_detail { namespace container_detail {

View File

@ -28,6 +28,7 @@
#include <sol/make_reference.hpp> #include <sol/make_reference.hpp>
#include <bitset> #include <bitset>
#include <unordered_map>
namespace sol { namespace u_detail { namespace sol { namespace u_detail {

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2020-09-26 13:38:14.149661 UTC // Generated 2020-10-03 21:34:25.034794 UTC
// This header was generated with sol v3.2.1 (revision 1fb483d) // This header was generated with sol v3.2.1 (revision 48eea7b5)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_CONFIG_HPP #ifndef SOL_SINGLE_CONFIG_HPP

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2020-09-26 13:38:14.123663 UTC // Generated 2020-10-03 21:34:25.022965 UTC
// This header was generated with sol v3.2.1 (revision 1fb483d) // This header was generated with sol v3.2.1 (revision 48eea7b5)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2020-09-26 13:38:13.096661 UTC // Generated 2020-10-03 21:34:24.496436 UTC
// This header was generated with sol v3.2.1 (revision 1fb483d) // This header was generated with sol v3.2.1 (revision 48eea7b5)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
@ -21137,6 +21137,8 @@ namespace sol {
// end of sol/usertype_container.hpp // end of sol/usertype_container.hpp
#include <unordered_map>
namespace sol { namespace sol {
namespace container_detail { namespace container_detail {
@ -21709,6 +21711,7 @@ namespace sol {
// beginning of sol/usertype_storage.hpp // beginning of sol/usertype_storage.hpp
#include <bitset> #include <bitset>
#include <unordered_map>
namespace sol { namespace u_detail { namespace sol { namespace u_detail {

View File

@ -34,34 +34,6 @@ function(CREATE_TEST test_target_name test_name target_sol)
target_link_libraries(${test_target_name} target_link_libraries(${test_target_name}
PUBLIC Threads::Threads ${LUA_LIBRARIES} ${target_sol}) PUBLIC Threads::Threads ${LUA_LIBRARIES} ${target_sol})
if (MSVC)
if (NOT CMAKE_COMPILER_ID MATCHES "Clang")
target_compile_options(${test_target_name}
PRIVATE /bigobj /W4)
endif()
else()
target_compile_options(${test_target_name}
PRIVATE -std=c++1z -pthread
-Wno-unknown-warning -Wno-unknown-warning-option
-Wall -Wpedantic -Werror -pedantic -pedantic-errors
-Wno-noexcept-type)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# For another day, when C++ is not so crap
# and we have time to audit the entire lib
# for all uses of `detail::swallow`...
#target_compile_options(${test_target_name}
# PRIVATE -Wcomma)
endif()
if (IS_X86)
if(MINGW)
set_target_properties(${test_target_name}
PROPERTIES
LINK_FLAGS -static-libstdc++)
endif()
endif()
endif()
if (MSVC) if (MSVC)
target_compile_options(${test_target_name} target_compile_options(${test_target_name}
PRIVATE /EHsc /std:c++latest) PRIVATE /EHsc /std:c++latest)