mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
making questionable decisions since 1892
This commit is contained in:
parent
b88a49a8d7
commit
4cde2b6a3b
|
@ -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 2016-08-08 00:57:18.871859 UTC
|
||||
// This header was generated with sol v2.10.5 (revision 49cc3bd)
|
||||
// Generated 2016-08-11 11:25:37.090286 UTC
|
||||
// This header was generated with sol v2.10.5 (revision b88a49a)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -3919,7 +3919,7 @@ namespace sol {
|
|||
typedef meta::all<
|
||||
std::is_lvalue_reference<T>,
|
||||
meta::neg<std::is_const<T>>,
|
||||
meta::neg<is_lua_primitive<T>>
|
||||
meta::neg<is_lua_primitive<meta::unqualified_t<T>>>
|
||||
> use_reference_tag;
|
||||
return pusher<std::conditional_t<use_reference_tag::value, detail::as_reference_tag, meta::unqualified_t<T>>>{}.push(L, std::forward<T>(t), std::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -4367,6 +4367,16 @@ namespace sol {
|
|||
return key;
|
||||
}
|
||||
|
||||
inline decltype(auto) base_class_index_propogation_key() {
|
||||
static const auto& key = u8"\xF0\x9F\x8C\xB2.index";
|
||||
return key;
|
||||
}
|
||||
|
||||
inline decltype(auto) base_class_new_index_propogation_key() {
|
||||
static const auto& key = u8"\xF0\x9F\x8C\xB2.new_index";
|
||||
return key;
|
||||
}
|
||||
|
||||
template <typename T, typename... Bases>
|
||||
struct inheritance {
|
||||
static bool type_check_bases(types<>, std::size_t) {
|
||||
|
@ -5611,10 +5621,18 @@ namespace sol {
|
|||
|
||||
template<>
|
||||
struct pusher<const char*> {
|
||||
static int push(lua_State* L, const char* str) {
|
||||
lua_pushlstring(L, str, std::char_traits<char>::length(str));
|
||||
static int push_sized(lua_State* L, const char* str, std::size_t len) {
|
||||
lua_pushlstring(L, str, len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int push(lua_State* L, const char* str) {
|
||||
return push_sized(L, str, std::char_traits<char>::length(str));
|
||||
}
|
||||
|
||||
static int push(lua_State* L, const char* str, std::size_t len) {
|
||||
return push_sized(L, str, len);
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
|
@ -9063,11 +9081,16 @@ namespace sol {
|
|||
typedef std::tuple<clean_type_t<Tn> ...> Tuple;
|
||||
template <std::size_t Idx>
|
||||
struct check_binding : is_variable_binding<meta::unqualified_tuple_element_t<Idx, Tuple>> {};
|
||||
typedef void (*base_walk)(lua_State*, bool&, int&, string_detail::string_shim&);
|
||||
Tuple functions;
|
||||
lua_CFunction indexfunc;
|
||||
lua_CFunction newindexfunc;
|
||||
lua_CFunction destructfunc;
|
||||
lua_CFunction callconstructfunc;
|
||||
lua_CFunction indexbase;
|
||||
lua_CFunction newindexbase;
|
||||
base_walk indexbaseclasspropogation;
|
||||
base_walk newindexbaseclasspropogation;
|
||||
void* baseclasscheck;
|
||||
void* baseclasscast;
|
||||
bool mustindex;
|
||||
|
@ -9113,12 +9136,15 @@ namespace sol {
|
|||
if (sizeof...(Bases) < 1) {
|
||||
return;
|
||||
}
|
||||
mustindex = true;
|
||||
(void)detail::swallow{ 0, ((detail::has_derived<Bases>::value = true), 0)... };
|
||||
|
||||
static_assert(sizeof(void*) <= sizeof(detail::inheritance_check_function), "The size of this data pointer is too small to fit the inheritance checking function: file a bug report.");
|
||||
static_assert(sizeof(void*) <= sizeof(detail::inheritance_cast_function), "The size of this data pointer is too small to fit the inheritance checking function: file a bug report.");
|
||||
baseclasscheck = (void*)&detail::inheritance<T, Bases...>::type_check;
|
||||
baseclasscast = (void*)&detail::inheritance<T, Bases...>::type_cast;
|
||||
indexbaseclasspropogation = walk_all_bases<true, Bases...>;
|
||||
newindexbaseclasspropogation = walk_all_bases<false, Bases...>;
|
||||
}
|
||||
|
||||
template <std::size_t Idx, typename N, typename F, typename = std::enable_if_t<!meta::any_same<meta::unqualified_t<N>, base_classes_tag, call_construction>::value>>
|
||||
|
@ -9151,7 +9177,10 @@ namespace sol {
|
|||
template <typename... Args, typename = std::enable_if_t<sizeof...(Args) == sizeof...(Tn)>>
|
||||
usertype_metatable(Args&&... args) : functions(std::forward<Args>(args)...),
|
||||
indexfunc(usertype_detail::indexing_fail<true>), newindexfunc(usertype_detail::indexing_fail<false>),
|
||||
destructfunc(nullptr), callconstructfunc(nullptr), baseclasscheck(nullptr), baseclasscast(nullptr),
|
||||
destructfunc(nullptr), callconstructfunc(nullptr),
|
||||
indexbase(&core_indexing_call<true>), newindexbase(&core_indexing_call<false>),
|
||||
indexbaseclasspropogation(walk_all_bases<true>), newindexbaseclasspropogation(walk_all_bases<false>),
|
||||
baseclasscheck(nullptr), baseclasscast(nullptr),
|
||||
mustindex(contains_variable() || contains_index()), secondarymeta(contains_variable()) {
|
||||
}
|
||||
|
||||
|
@ -9176,32 +9205,77 @@ namespace sol {
|
|||
ret = real_find_call<I0, I1>(idx, L);
|
||||
}
|
||||
|
||||
static int real_index_call(lua_State* L) {
|
||||
usertype_metatable& f = stack::get<light<usertype_metatable>>(L, upvalue_index(1));
|
||||
if (stack::get<type>(L, -1) == type::string) {
|
||||
string_detail::string_shim accessor = stack::get<string_detail::string_shim>(L, -1);
|
||||
bool found = false;
|
||||
template <bool b>
|
||||
void propogating_call(lua_State* L, bool& found, int& ret, string_detail::string_shim& accessor) {
|
||||
(void)detail::swallow{ 0, (find_call<I * 2, I * 2 + 1>(std::integral_constant<bool, b>(), L, found, ret, accessor), 0)... };
|
||||
}
|
||||
|
||||
template <bool b, typename Base>
|
||||
static void walk_single_base(lua_State* L, bool& found, int& ret, string_detail::string_shim&) {
|
||||
if (found)
|
||||
return;
|
||||
const char* metakey = &usertype_traits<Base>::metatable[0];
|
||||
const char* gcmetakey = &usertype_traits<Base>::gc_table[0];
|
||||
const char* basewalkkey = b ? detail::base_class_index_propogation_key() : detail::base_class_new_index_propogation_key();
|
||||
|
||||
luaL_getmetatable(L, metakey);
|
||||
if (type_of(L, -1) == type::nil) {
|
||||
lua_pop(L, 1);
|
||||
return;
|
||||
}
|
||||
stack::get_field(L, basewalkkey);
|
||||
if (type_of(L, -1) == type::nil) {
|
||||
lua_pop(L, 2);
|
||||
return;
|
||||
}
|
||||
lua_CFunction basewalkfunc = stack::pop<lua_CFunction>(L);
|
||||
lua_pop(L, 1);
|
||||
|
||||
stack::get_field<true>(L, gcmetakey);
|
||||
int value = basewalkfunc(L);
|
||||
if (value > -1) {
|
||||
found = true;
|
||||
ret = value;
|
||||
}
|
||||
}
|
||||
|
||||
template <bool b, typename... Bases>
|
||||
static void walk_all_bases(lua_State* L, bool& found, int& ret, string_detail::string_shim& accessor) {
|
||||
(void)L;
|
||||
(void)found;
|
||||
(void)ret;
|
||||
(void)accessor;
|
||||
(void)detail::swallow{ 0, (walk_single_base<b, Bases>(L, found, ret, accessor), 0)... };
|
||||
}
|
||||
|
||||
template <bool b, bool toplevel = false>
|
||||
static int core_indexing_call(lua_State* L) {
|
||||
usertype_metatable& f = toplevel ? stack::get<light<usertype_metatable>>(L, upvalue_index(1)) : stack::pop<light<usertype_metatable>>(L);
|
||||
static const int keyidx = -2 + static_cast<int>(b);
|
||||
if (toplevel && stack::get<type>(L, keyidx) != type::string) {
|
||||
return b ? f.indexfunc(L) : f.newindexfunc(L);
|
||||
}
|
||||
string_detail::string_shim accessor = stack::get<string_detail::string_shim>(L, keyidx);
|
||||
int ret = 0;
|
||||
(void)detail::swallow{ 0, (f.find_call<I * 2, I * 2 + 1>(std::true_type(), L, found, ret, accessor), 0)... };
|
||||
bool found = false;
|
||||
f.propogating_call<b>(L, found, ret, accessor);
|
||||
if (found) {
|
||||
return ret;
|
||||
}
|
||||
// Otherwise, we need to do propagating calls through the bases
|
||||
f.indexbaseclasspropogation(L, found, ret, accessor);
|
||||
if (found) {
|
||||
return ret;
|
||||
}
|
||||
return f.indexfunc(L);
|
||||
return toplevel ? (b ? f.indexfunc(L) : f.newindexfunc(L)) : -1;
|
||||
}
|
||||
|
||||
static int real_index_call(lua_State* L) {
|
||||
return core_indexing_call<true, true>(L);
|
||||
}
|
||||
|
||||
static int real_new_index_call(lua_State* L) {
|
||||
usertype_metatable& f = stack::get<light<usertype_metatable>>(L, upvalue_index(1));
|
||||
if (stack::get<type>(L, -2) == type::string) {
|
||||
string_detail::string_shim accessor = stack::get<string_detail::string_shim>(L, -2);
|
||||
bool found = false;
|
||||
int ret = 0;
|
||||
(void)detail::swallow{ 0, (f.find_call<I * 2, I * 2 + 1>(std::false_type(), L, found, ret, accessor), 0)... };
|
||||
if (found) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return f.newindexfunc(L);
|
||||
return core_indexing_call<false, true>(L);
|
||||
}
|
||||
|
||||
template <std::size_t Idx, bool is_index = true, bool is_variable = false>
|
||||
|
@ -9320,6 +9394,9 @@ namespace sol {
|
|||
stack::set_field(L, detail::base_class_cast_key(), nil, t.stack_index());
|
||||
}
|
||||
|
||||
stack::set_field(L, detail::base_class_index_propogation_key(), make_closure(um.indexbase, make_light(um)), t.stack_index());
|
||||
stack::set_field(L, detail::base_class_new_index_propogation_key(), make_closure(um.newindexbase, make_light(um)), t.stack_index());
|
||||
|
||||
if (mustindex) {
|
||||
// Basic index pushing: specialize
|
||||
// index and newindex to give variables and stuff
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace sol {
|
|||
typedef meta::all<
|
||||
std::is_lvalue_reference<T>,
|
||||
meta::neg<std::is_const<T>>,
|
||||
meta::neg<is_lua_primitive<T>>
|
||||
meta::neg<is_lua_primitive<meta::unqualified_t<T>>>
|
||||
> use_reference_tag;
|
||||
return pusher<std::conditional_t<use_reference_tag::value, detail::as_reference_tag, meta::unqualified_t<T>>>{}.push(L, std::forward<T>(t), std::forward<Args>(args)...);
|
||||
}
|
||||
|
|
|
@ -338,10 +338,18 @@ namespace sol {
|
|||
|
||||
template<>
|
||||
struct pusher<const char*> {
|
||||
static int push(lua_State* L, const char* str) {
|
||||
lua_pushlstring(L, str, std::char_traits<char>::length(str));
|
||||
static int push_sized(lua_State* L, const char* str, std::size_t len) {
|
||||
lua_pushlstring(L, str, len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int push(lua_State* L, const char* str) {
|
||||
return push_sized(L, str, std::char_traits<char>::length(str));
|
||||
}
|
||||
|
||||
static int push(lua_State* L, const char* str, std::size_t len) {
|
||||
return push_sized(L, str, len);
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
|
@ -377,8 +385,6 @@ namespace sol {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Reference in New Issue
Block a user