fix up container handling

This commit is contained in:
ThePhD 2019-08-15 02:28:37 -04:00
parent cb3acaa97b
commit 12f8f046cc
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
4 changed files with 98 additions and 20 deletions

View File

@ -35,10 +35,12 @@ include(Common/Core)
set(LUA_VANILLA_5.1_LATEST_VERSION 5.1.5)
set(LUA_VANILLA_5.2_LATEST_VERSION 5.2.4)
set(LUA_VANILLA_5.3_LATEST_VERSION 5.3.5)
set(LUA_VANILLA_5.4_LATEST_VERSION 5.4.0-work1)
set(LUA_VANILLA_5.4_LATEST_VERSION 5.4.0-alpha)
# exact version, coming from CI: pull directly from Lua and use external project to build
# list of known md5 / sha1: must update when there are changes
set(LUA_VANILLA_MD5_5.4.0-alpha d49d30b394794b96ffad53513ac647a5)
set(LUA_VANILLA_SHA1_5.4.0-alpha cf3559dc43cad35463740c6fbedeb1ea501e5e23)
set(LUA_VANILLA_MD5_5.4.0-work2 3cdf2a4eb84dde6b6aaf5d2d1de07be9)
set(LUA_VANILLA_SHA1_5.4.0-work2 e8484e61c5c338e3ec2f75dbe0f6703d079fecf9)
set(LUA_VANILLA_MD5_5.4.0-work1 0ff232b8658884155a43cf72212edbd9)
@ -212,7 +214,7 @@ if (LUA_BUILD_LUA_COMPILER)
endif()
set(LUA_VANILLA_GENERATE_LUA_HPP false)
elseif (LUA_VANILLA_VERSION MATCHES "^5\\.4")
if (LUA_VANILLA_VERSION MATCHES "work")
if (LUA_VANILLA_VERSION MATCHES "work" OR LUA_VANILLA_VERSION MATCHES "alpha")
set(LUA_VANILLA_DOWNLOAD_URL https://www.lua.org/work/lua-${LUA_VANILLA_VERSION}.tar.gz)
endif()
set(LUA_VANILLA_LIB_SOURCES lapi.c lauxlib.c lbaselib.c lcode.c lcorolib.c

View File

@ -709,15 +709,31 @@ namespace sol {
template <typename Iter>
static detail::error_result set_associative_insert(std::true_type, lua_State*, T& self, Iter& it, K& key, stack_object value) {
if constexpr(meta::has_insert<T>::value) {
self.insert(it, value_type(key, value.as<V>()));
return {};
}
else {
(void)self;
(void)it;
(void)key;
return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
}
}
template <typename Iter>
static detail::error_result set_associative_insert(std::false_type, lua_State*, T& self, Iter& it, K& key, stack_object) {
if constexpr(has_insert<T>::value) {
self.insert(it, key);
return {};
}
else {
(void)self;
(void)it;
(void)key;
return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle<T>().c_str());
}
}
static detail::error_result set_associative_find(std::true_type, lua_State* L, T& self, stack_object okey, stack_object value) {
decltype(auto) key = okey.as<K>();
@ -898,9 +914,18 @@ namespace sol {
template <typename Iter>
static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key, Iter& pos) {
if constexpr(meta::has_insert<T>::value) {
self.insert(pos, value_type(key.as<K>(), stack::unqualified_get<V>(L, 3)));
return {};
}
else {
(void)L;
(void)self;
(void)key;
(void)pos;
return detail::error_result("cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
}
}
static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key) {
auto pos = deferred_uc::end(L, self);
@ -1067,10 +1092,23 @@ namespace sol {
return deferred_uc::begin(L, self) == deferred_uc::end(L, self);
}
static detail::error_result get_start(lua_State* L, T& self, K& key) {
static detail::error_result get_associative_find(std::true_type, lua_State* L, T& self, K& key) {
auto it = self.find(key);
if (it == deferred_uc::end(L, self)) {
stack::push(L, lua_nil);
return {};
}
return get_associative(std::true_type(), L, it);
}
static detail::error_result get_associative_find(std::false_type, lua_State* L, T& self, K& key) {
return get_it(is_linear_integral(), L, self, key);
}
static detail::error_result get_start(lua_State* L, T& self, K& key) {
return get_associative_find(std::integral_constant<bool, is_associative::value && has_find<T>::value>(), L, self, key);
}
static detail::error_result set_start(lua_State* L, T& self, stack_object key, stack_object value) {
return set_it(is_linear_integral(), L, self, std::move(key), std::move(value));
}

View File

@ -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 2019-08-15 05:26:10.792424 UTC
// This header was generated with sol v3.0.3 (revision 09f5e86)
// Generated 2019-08-15 06:28:23.273623 UTC
// This header was generated with sol v3.0.3 (revision cb3acaa)
// https://github.com/ThePhD/sol2
#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.
// This file was generated with a script.
// Generated 2019-08-15 05:26:10.095950 UTC
// This header was generated with sol v3.0.3 (revision 09f5e86)
// Generated 2019-08-15 06:28:22.668458 UTC
// This header was generated with sol v3.0.3 (revision cb3acaa)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP
@ -19672,15 +19672,31 @@ namespace sol {
template <typename Iter>
static detail::error_result set_associative_insert(std::true_type, lua_State*, T& self, Iter& it, K& key, stack_object value) {
if constexpr(meta::has_insert<T>::value) {
self.insert(it, value_type(key, value.as<V>()));
return {};
}
else {
(void)self;
(void)it;
(void)key;
return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
}
}
template <typename Iter>
static detail::error_result set_associative_insert(std::false_type, lua_State*, T& self, Iter& it, K& key, stack_object) {
if constexpr(has_insert<T>::value) {
self.insert(it, key);
return {};
}
else {
(void)self;
(void)it;
(void)key;
return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle<T>().c_str());
}
}
static detail::error_result set_associative_find(std::true_type, lua_State* L, T& self, stack_object okey, stack_object value) {
decltype(auto) key = okey.as<K>();
@ -19861,9 +19877,18 @@ namespace sol {
template <typename Iter>
static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key, Iter& pos) {
if constexpr(meta::has_insert<T>::value) {
self.insert(pos, value_type(key.as<K>(), stack::unqualified_get<V>(L, 3)));
return {};
}
else {
(void)L;
(void)self;
(void)key;
(void)pos;
return detail::error_result("cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
}
}
static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key) {
auto pos = deferred_uc::end(L, self);
@ -20030,10 +20055,23 @@ namespace sol {
return deferred_uc::begin(L, self) == deferred_uc::end(L, self);
}
static detail::error_result get_start(lua_State* L, T& self, K& key) {
static detail::error_result get_associative_find(std::true_type, lua_State* L, T& self, K& key) {
auto it = self.find(key);
if (it == deferred_uc::end(L, self)) {
stack::push(L, lua_nil);
return {};
}
return get_associative(std::true_type(), L, it);
}
static detail::error_result get_associative_find(std::false_type, lua_State* L, T& self, K& key) {
return get_it(is_linear_integral(), L, self, key);
}
static detail::error_result get_start(lua_State* L, T& self, K& key) {
return get_associative_find(std::integral_constant<bool, is_associative::value && has_find<T>::value>(), L, self, key);
}
static detail::error_result set_start(lua_State* L, T& self, stack_object key, stack_object value) {
return set_it(is_linear_integral(), L, self, std::move(key), std::move(value));
}