From 4aea28576999d44520af782e35c84b5c0d73e799 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Wed, 10 Aug 2016 07:23:49 -0400 Subject: [PATCH] So we have 'inherited' metatables now. But is it fast? --- sol/usertype_metatable.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sol/usertype_metatable.hpp b/sol/usertype_metatable.hpp index 1f2a5692..3e15fe3a 100644 --- a/sol/usertype_metatable.hpp +++ b/sol/usertype_metatable.hpp @@ -193,6 +193,7 @@ namespace sol { if (sizeof...(Bases) < 1) { return; } + mustindex = true; (void)detail::swallow{ 0, ((detail::has_derived::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."); @@ -297,16 +298,21 @@ namespace sol { template 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(L, found, ret, accessor), 0)... }; } template static int core_indexing_call(lua_State* L) { usertype_metatable& f = toplevel ? stack::get>(L, upvalue_index(1)) : stack::pop>(L); - if (toplevel && stack::get(L, -1) != type::string) { + static const int keyidx = -2 + static_cast(b); + if (toplevel && stack::get(L, keyidx) != type::string) { return b ? f.indexfunc(L) : f.newindexfunc(L); } - string_detail::string_shim accessor = stack::get(L, -1); + string_detail::string_shim accessor = stack::get(L, keyidx); int ret = 0; bool found = false; f.propogating_call(L, found, ret, accessor);