minor fixes

This commit is contained in:
ThePhD 2018-09-28 00:55:47 -07:00
parent e56cbc1dc5
commit f42a678d20
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
6 changed files with 40 additions and 28 deletions

View File

@ -31,7 +31,7 @@ include(GNUInstallDirs)
# # # General Project Requirements # # # General Project Requirements
# Set general standard requirements here # Set general standard requirements here
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Features a C++ compiler must have to be used to compile sol2 # Features a C++ compiler must have to be used to compile sol2
# This list is not *complete* as CMake does not support features for # This list is not *complete* as CMake does not support features for
@ -74,6 +74,13 @@ if (MSVC)
add_definitions(/DUNICODE /D_UNICODE /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) add_definitions(/DUNICODE /D_UNICODE /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE)
# Warning level, exceptions # Warning level, exceptions
add_compile_options(/W4 /EHsc) add_compile_options(/W4 /EHsc)
if (MSVC_VERSION GREATER_EQUAL "1900")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("/std:c++latest" _cpp_latest_flag_supported)
if (_cpp_latest_flag_supported)
add_compile_options("/std:c++latest")
endif()
endif()
add_compile_options("$<$<CONFIG:Debug>:/MDd>" add_compile_options("$<$<CONFIG:Debug>:/MDd>"
"$<$<CONFIG:Release>:/MD>" "$<$<CONFIG:Release>:/MD>"
"$<$<CONFIG:RelWithDebInfo>:/MD>" "$<$<CONFIG:RelWithDebInfo>:/MD>"

View File

@ -139,9 +139,9 @@ namespace sol {
#define SOL_BASE_CLASSES(T, ...) \ #define SOL_BASE_CLASSES(T, ...) \
template <> \ template <> \
struct ::sol::base<T> : ::std::true_type { typedef ::sol::types<__VA_ARGS__> type; }; struct ::sol::base<T> : std::true_type { typedef ::sol::types<__VA_ARGS__> type; };
#define SOL_DERIVED_CLASSES(T, ...) \ #define SOL_DERIVED_CLASSES(T, ...) \
template <> \ template <> \
struct ::sol::derive<T> : ::std::true_type { typedef ::sol::types<__VA_ARGS__> type; }; struct ::sol::derive<T> : std::true_type { typedef ::sol::types<__VA_ARGS__> type; };
#endif // SOL_INHERITANCE_HPP #endif // SOL_INHERITANCE_HPP

View File

@ -107,18 +107,12 @@ namespace sol {
} }
template <typename Key, typename Value> template <typename Key, typename Value>
void set(Key&& key, Value&& value) { void set(Key&& key, Value&& value);
optional<usertype_storage_base&> maybe_uts = u_detail::maybe_get_usertype_storage_base(this->lua_state());
if (maybe_uts) {
usertype_storage<T>& uts = *maybe_uts;
uts.set(std::forward<Key>(key), std::forward<Value>(value));
}
}
void unregister() { void unregister() {
lua_State* L = this->lua_state();
int x = lua_gettop(L); int x = lua_gettop(L);
lua_State* L = this->lua_state();
auto pp = stack::push_pop(*this); auto pp = stack::push_pop(*this);
stack_reference mt(L, -1); stack_reference mt(L, -1);
stack::get_field(L, meta_function::gc_names, mt.stack_index()); stack::get_field(L, meta_function::gc_names, mt.stack_index());

View File

@ -39,6 +39,16 @@ namespace sol {
return mt; return mt;
} }
template <typename base_type>
template <typename Key, typename Value>
void basic_metatable<base_type>::set(Key&& key, Value&& value) {
optional<u_detail::usertype_storage_base&> maybe_uts = u_detail::maybe_get_usertype_storage_base(this->lua_state());
if (maybe_uts) {
u_detail::usertype_storage_base& uts = *maybe_uts;
uts.set(std::forward<Key>(key), std::forward<Value>(value));
}
}
namespace stack { namespace stack {
template <> template <>
struct getter<metatable_t> { struct getter<metatable_t> {

View File

@ -45,7 +45,7 @@ namespace sol {
} }
static int real_index_call(lua_State* L) { static int real_index_call(lua_State* L) {
typedef u_detail::map_t<std::string, lua_CFunction> call_map; typedef detail::map_t<std::string, lua_CFunction> call_map;
static const call_map calls{ static const call_map calls{
{ "at", &at_call }, { "at", &at_call },
{ "get", &real_get_call }, { "get", &real_get_call },

View File

@ -36,6 +36,7 @@
#include "usertype_container.hpp" #include "usertype_container.hpp"
#include <sstream> #include <sstream>
#include <type_traits>
namespace sol { namespace sol {
namespace u_detail { namespace u_detail {