mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
parent
83f4b4aaa0
commit
143c98450a
|
@ -98,7 +98,15 @@ endfunction(find_lua_build)
|
|||
# Call and then immediately undefine to avoid polluting the global scope
|
||||
if (LuaBuild_FIND_COMPONENTS)
|
||||
list(GET LuaBuild_FIND_COMPONENTS 0 LUA_VERSION)
|
||||
else()
|
||||
endif()
|
||||
if (LuaBuild_VERSION)
|
||||
if (LUA_VERSION)
|
||||
set(LUA_VERSION "${LUA_VERSION}-${LuaBuild_VERSION}")
|
||||
else()
|
||||
set(LUA_VERSION "${LuaBuild_VERSION}")
|
||||
endif()
|
||||
endif()
|
||||
if (NOT LUA_VERSION)
|
||||
set(LUA_VERSION 5.3.4)
|
||||
endif()
|
||||
find_lua_build(${LUA_VERSION})
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2018-01-24 00:50:30.722404 UTC
|
||||
// This header was generated with sol v2.19.0 (revision db9c5d6)
|
||||
// Generated 2018-01-24 05:51:13.838328 UTC
|
||||
// This header was generated with sol v2.19.0 (revision 83f4b4a)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -1481,7 +1481,7 @@ namespace sol {
|
|||
struct is_lookup : meta::all<has_key_type<T>, has_value_type<T>> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_matched_lookup : meta_detail::is_matched_lookup_impl<T, meta::all<has_key_type<T>, has_value_type<T>>::value> {};
|
||||
struct is_matched_lookup : meta_detail::is_matched_lookup_impl<T, is_lookup<T>::value> {};
|
||||
|
||||
template <typename T>
|
||||
using is_string_constructible = any<
|
||||
|
@ -15218,6 +15218,7 @@ namespace sol {
|
|||
> KV;
|
||||
typedef typename KV::first_type K;
|
||||
typedef typename KV::second_type V;
|
||||
typedef std::conditional_t<is_matched_lookup::value, std::ptrdiff_t, K> next_K;
|
||||
typedef decltype(*std::declval<iterator&>()) iterator_return;
|
||||
typedef std::conditional_t<is_associative::value || is_matched_lookup::value,
|
||||
std::add_lvalue_reference_t<V>,
|
||||
|
@ -15613,7 +15614,7 @@ namespace sol {
|
|||
}
|
||||
|
||||
static error_result insert_has(std::true_type, lua_State* L, T& self, stack_object key, stack_object value) {
|
||||
return insert_lookup(meta::all<is_associative, is_lookup>(), L, self, std::move(key), std::move(value));
|
||||
return insert_lookup(meta::any<is_associative, is_lookup>(), L, self, std::move(key), std::move(value));
|
||||
}
|
||||
|
||||
static error_result insert_has(std::false_type, lua_State* L, T& self, stack_object where, stack_object value) {
|
||||
|
@ -15756,21 +15757,12 @@ namespace sol {
|
|||
return p;
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int pairs_associative(std::true_type, lua_State* L) {
|
||||
auto& src = get_src(L);
|
||||
stack::push(L, next<ip>);
|
||||
stack::push<user<iter>>(L, src, deferred_traits::begin(L, src));
|
||||
stack::push(L, lua_nil);
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <bool>
|
||||
static int next_associative(std::false_type, lua_State* L) {
|
||||
iter& i = stack::get<user<iter>>(L, 1);
|
||||
auto& source = i.source;
|
||||
auto& it = i.it;
|
||||
K k = stack::get<K>(L, 2);
|
||||
next_K k = stack::get<next_K>(L, 2);
|
||||
if (it == deferred_traits::end(L, source)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -15781,6 +15773,21 @@ namespace sol {
|
|||
return p;
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int next(lua_State* L) {
|
||||
typedef meta::any<is_associative, meta::all<is_lookup, meta::neg<is_matched_lookup>>> is_assoc;
|
||||
return next_associative<ip>(is_assoc(), L);
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int pairs_associative(std::true_type, lua_State* L) {
|
||||
auto& src = get_src(L);
|
||||
stack::push(L, next<ip>);
|
||||
stack::push<user<iter>>(L, src, deferred_traits::begin(L, src));
|
||||
stack::push(L, lua_nil);
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int pairs_associative(std::false_type, lua_State* L) {
|
||||
auto& src = get_src(L);
|
||||
|
@ -15790,12 +15797,6 @@ namespace sol {
|
|||
return 3;
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int next(lua_State* L) {
|
||||
typedef meta::any<is_associative, meta::all<is_lookup, meta::neg<is_matched_lookup>>> is_assoc;
|
||||
return next_associative<ip>(is_assoc(), L);
|
||||
}
|
||||
|
||||
public:
|
||||
static int get(lua_State* L) {
|
||||
auto& self = get_src(L);
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2018-01-24 00:50:30.920977 UTC
|
||||
// This header was generated with sol v2.19.0 (revision db9c5d6)
|
||||
// Generated 2018-01-24 05:51:14.129707 UTC
|
||||
// This header was generated with sol v2.19.0 (revision 83f4b4a)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
||||
|
|
|
@ -519,6 +519,7 @@ namespace sol {
|
|||
> KV;
|
||||
typedef typename KV::first_type K;
|
||||
typedef typename KV::second_type V;
|
||||
typedef std::conditional_t<is_matched_lookup::value, std::ptrdiff_t, K> next_K;
|
||||
typedef decltype(*std::declval<iterator&>()) iterator_return;
|
||||
typedef std::conditional_t<is_associative::value || is_matched_lookup::value,
|
||||
std::add_lvalue_reference_t<V>,
|
||||
|
@ -914,7 +915,7 @@ namespace sol {
|
|||
}
|
||||
|
||||
static error_result insert_has(std::true_type, lua_State* L, T& self, stack_object key, stack_object value) {
|
||||
return insert_lookup(meta::all<is_associative, is_lookup>(), L, self, std::move(key), std::move(value));
|
||||
return insert_lookup(meta::any<is_associative, is_lookup>(), L, self, std::move(key), std::move(value));
|
||||
}
|
||||
|
||||
static error_result insert_has(std::false_type, lua_State* L, T& self, stack_object where, stack_object value) {
|
||||
|
@ -1057,21 +1058,12 @@ namespace sol {
|
|||
return p;
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int pairs_associative(std::true_type, lua_State* L) {
|
||||
auto& src = get_src(L);
|
||||
stack::push(L, next<ip>);
|
||||
stack::push<user<iter>>(L, src, deferred_traits::begin(L, src));
|
||||
stack::push(L, lua_nil);
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <bool>
|
||||
static int next_associative(std::false_type, lua_State* L) {
|
||||
iter& i = stack::get<user<iter>>(L, 1);
|
||||
auto& source = i.source;
|
||||
auto& it = i.it;
|
||||
K k = stack::get<K>(L, 2);
|
||||
next_K k = stack::get<next_K>(L, 2);
|
||||
if (it == deferred_traits::end(L, source)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1082,6 +1074,21 @@ namespace sol {
|
|||
return p;
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int next(lua_State* L) {
|
||||
typedef meta::any<is_associative, meta::all<is_lookup, meta::neg<is_matched_lookup>>> is_assoc;
|
||||
return next_associative<ip>(is_assoc(), L);
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int pairs_associative(std::true_type, lua_State* L) {
|
||||
auto& src = get_src(L);
|
||||
stack::push(L, next<ip>);
|
||||
stack::push<user<iter>>(L, src, deferred_traits::begin(L, src));
|
||||
stack::push(L, lua_nil);
|
||||
return 3;
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int pairs_associative(std::false_type, lua_State* L) {
|
||||
auto& src = get_src(L);
|
||||
|
@ -1091,12 +1098,6 @@ namespace sol {
|
|||
return 3;
|
||||
}
|
||||
|
||||
template <bool ip>
|
||||
static int next(lua_State* L) {
|
||||
typedef meta::any<is_associative, meta::all<is_lookup, meta::neg<is_matched_lookup>>> is_assoc;
|
||||
return next_associative<ip>(is_assoc(), L);
|
||||
}
|
||||
|
||||
public:
|
||||
static int get(lua_State* L) {
|
||||
auto& self = get_src(L);
|
||||
|
|
|
@ -551,7 +551,7 @@ namespace sol {
|
|||
struct is_lookup : meta::all<has_key_type<T>, has_value_type<T>> {};
|
||||
|
||||
template <typename T>
|
||||
struct is_matched_lookup : meta_detail::is_matched_lookup_impl<T, meta::all<has_key_type<T>, has_value_type<T>>::value> {};
|
||||
struct is_matched_lookup : meta_detail::is_matched_lookup_impl<T, is_lookup<T>::value> {};
|
||||
|
||||
template <typename T>
|
||||
using is_string_constructible = any<
|
||||
|
|
|
@ -790,6 +790,16 @@ end
|
|||
REQUIRE((v3 == 14));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void lookup_container_check(sol::state& lua, T&) {
|
||||
auto result0 = lua.safe_script("assert(c['a'] == 'a')", sol::script_default_on_error);
|
||||
REQUIRE(result0.valid());
|
||||
auto result1 = lua.safe_script("assert(c['b'] == 'b')", sol::script_default_on_error);
|
||||
REQUIRE(result1.valid());
|
||||
auto result2 = lua.safe_script("assert(c['c'] == 'c')", sol::script_default_on_error);
|
||||
REQUIRE(result2.valid());
|
||||
}
|
||||
|
||||
TEST_CASE("containers/sequence containers", "check all of the functinos for every single container") {
|
||||
SECTION("vector") {
|
||||
sol::state lua;
|
||||
|
@ -869,6 +879,14 @@ TEST_CASE("containers/ordered lookup containers", "check ordered container types
|
|||
lua["c"] = &items;
|
||||
ordered_container_check(lua, items);
|
||||
}
|
||||
SECTION("set string") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::set<std::string> items({ "a", "b", "c" });
|
||||
lua["c"] = &items;
|
||||
lookup_container_check(lua, items);
|
||||
}
|
||||
SECTION("multiset") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
@ -877,6 +895,14 @@ TEST_CASE("containers/ordered lookup containers", "check ordered container types
|
|||
lua["c"] = &items;
|
||||
ordered_container_check(lua, items);
|
||||
}
|
||||
SECTION("multiset string") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::multiset<std::string> items({ "a", "b", "c" });
|
||||
lua["c"] = &items;
|
||||
lookup_container_check(lua, items);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("containers/unordered lookup containers", "check ordered container types") {
|
||||
|
@ -888,6 +914,14 @@ TEST_CASE("containers/unordered lookup containers", "check ordered container typ
|
|||
lua["c"] = &items;
|
||||
unordered_container_check(lua, items);
|
||||
}
|
||||
SECTION("unordered_set string") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::unordered_set<std::string> items({ "a", "b", "c" });
|
||||
lua["c"] = &items;
|
||||
lookup_container_check(lua, items);
|
||||
}
|
||||
SECTION("unordered_multiset") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
@ -896,6 +930,14 @@ TEST_CASE("containers/unordered lookup containers", "check ordered container typ
|
|||
lua["c"] = &items;
|
||||
unordered_container_check(lua, items);
|
||||
}
|
||||
SECTION("unordered_multiset string") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::unordered_multiset<std::string> items({ "a", "b", "c" });
|
||||
lua["c"] = &items;
|
||||
lookup_container_check(lua, items);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("containers/associative ordered containers", "check associative (map) containers that are ordered fulfill basic functionality requirements") {
|
||||
|
@ -913,6 +955,18 @@ TEST_CASE("containers/associative ordered containers", "check associative (map)
|
|||
lua["c"] = &items;
|
||||
associative_ordered_container_check(lua, items);
|
||||
}
|
||||
SECTION("map string") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::map<std::string, std::string> items{
|
||||
{ "a", "a" },
|
||||
{ "b", "b" },
|
||||
{ "c", "c" }
|
||||
};
|
||||
lua["c"] = &items;
|
||||
lookup_container_check(lua, items);
|
||||
}
|
||||
SECTION("multimap") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
@ -927,6 +981,18 @@ TEST_CASE("containers/associative ordered containers", "check associative (map)
|
|||
lua["c"] = &items;
|
||||
associative_ordered_container_check(lua, items);
|
||||
}
|
||||
SECTION("multimap string") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::multimap<std::string, std::string> items{
|
||||
{ "a", "a" },
|
||||
{ "b", "b" },
|
||||
{ "c", "c" }
|
||||
};
|
||||
lua["c"] = &items;
|
||||
lookup_container_check(lua, items);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("containers/associative unordered containers", "check associative (map) containers that are ordered that they fulfill basic functionality requirements") {
|
||||
|
@ -944,6 +1010,18 @@ TEST_CASE("containers/associative unordered containers", "check associative (map
|
|||
lua["c"] = &items;
|
||||
associative_unordered_container_check(lua, items);
|
||||
}
|
||||
SECTION("unordered_map string") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::unordered_map<std::string, std::string> items{
|
||||
{ "a", "a" },
|
||||
{ "b", "b" },
|
||||
{ "c", "c" }
|
||||
};
|
||||
lua["c"] = &items;
|
||||
lookup_container_check(lua, items);
|
||||
}
|
||||
SECTION("unordered_multimap") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
@ -958,6 +1036,18 @@ TEST_CASE("containers/associative unordered containers", "check associative (map
|
|||
lua["c"] = &items;
|
||||
associative_unordered_container_check(lua, items);
|
||||
}
|
||||
SECTION("unordered_multimap string") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::unordered_multimap<std::string, std::string> items{
|
||||
{ "a", "a" },
|
||||
{ "b", "b" },
|
||||
{ "c", "c" }
|
||||
};
|
||||
lua["c"] = &items;
|
||||
lookup_container_check(lua, items);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("containers/associative ordered pairs", "check to make sure pairs works properly for key-value types") {
|
||||
|
|
Loading…
Reference in New Issue
Block a user