mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Reduce binary bloat from static_trampoline and check_metatable
This commit is contained in:
parent
a21fef97e9
commit
428767b8cd
|
@ -38,9 +38,7 @@
|
||||||
|
|
||||||
namespace sol { namespace stack {
|
namespace sol { namespace stack {
|
||||||
namespace stack_detail {
|
namespace stack_detail {
|
||||||
template <typename T, bool poptable = true>
|
inline bool impl_check_metatable(lua_State* L, int index, const std::string& metakey, bool poptable) {
|
||||||
inline bool check_metatable(lua_State* L, int index = -2) {
|
|
||||||
const auto& metakey = usertype_traits<T>::metatable();
|
|
||||||
luaL_getmetatable(L, &metakey[0]);
|
luaL_getmetatable(L, &metakey[0]);
|
||||||
const type expectedmetatabletype = static_cast<type>(lua_type(L, -1));
|
const type expectedmetatabletype = static_cast<type>(lua_type(L, -1));
|
||||||
if (expectedmetatabletype != type::lua_nil) {
|
if (expectedmetatabletype != type::lua_nil) {
|
||||||
|
@ -53,6 +51,11 @@ namespace sol { namespace stack {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, bool poptable = true>
|
||||||
|
inline bool check_metatable(lua_State* L, int index = -2) {
|
||||||
|
return impl_check_metatable(L, index, usertype_traits<T>::metatable(), poptable);
|
||||||
|
}
|
||||||
|
|
||||||
template <type expected, int (*check_func)(lua_State*, int)>
|
template <type expected, int (*check_func)(lua_State*, int)>
|
||||||
struct basic_check {
|
struct basic_check {
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
|
|
|
@ -99,8 +99,8 @@ namespace sol {
|
||||||
return trampoline(L, f);
|
return trampoline(L, f);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template <lua_CFunction f>
|
|
||||||
int static_trampoline(lua_State* L) {
|
inline int impl_static_trampoline(lua_State* L, lua_CFunction f) {
|
||||||
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
||||||
return f(L);
|
return f(L);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
catch (...) {
|
catch (...) {
|
||||||
call_exception_handler(L, optional<const std::exception&>(nullopt), "caught (...) exception");
|
call_exception_handler(L, optional<const std::exception&>(nullopt), "caught (...) exception");
|
||||||
|
@ -129,6 +129,11 @@ namespace sol {
|
||||||
#endif // Safe exceptions
|
#endif // Safe exceptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <lua_CFunction f>
|
||||||
|
int static_trampoline(lua_State* L) {
|
||||||
|
return impl_static_trampoline(L, f);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
||||||
#if 0
|
#if 0
|
||||||
// impossible: g++/clang++ choke as they think this function is ambiguous:
|
// impossible: g++/clang++ choke as they think this function is ambiguous:
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2020-06-18 22:17:10.413702 UTC
|
// Generated 2020-06-20 04:08:19.579717 UTC
|
||||||
// This header was generated with sol v3.2.1 (revision 162fdd74)
|
// This header was generated with sol v3.2.1 (revision 5e40ef09)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2020-06-18 22:17:10.286043 UTC
|
// Generated 2020-06-20 04:08:19.416569 UTC
|
||||||
// This header was generated with sol v3.2.1 (revision 162fdd74)
|
// This header was generated with sol v3.2.1 (revision 5e40ef09)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||||
|
@ -7476,8 +7476,8 @@ namespace sol {
|
||||||
return trampoline(L, f);
|
return trampoline(L, f);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template <lua_CFunction f>
|
|
||||||
int static_trampoline(lua_State* L) {
|
inline int impl_static_trampoline(lua_State* L, lua_CFunction f) {
|
||||||
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
||||||
return f(L);
|
return f(L);
|
||||||
|
|
||||||
|
@ -7496,7 +7496,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
catch (...) {
|
catch (...) {
|
||||||
call_exception_handler(L, optional<const std::exception&>(nullopt), "caught (...) exception");
|
call_exception_handler(L, optional<const std::exception&>(nullopt), "caught (...) exception");
|
||||||
|
@ -7506,6 +7506,11 @@ namespace sol {
|
||||||
#endif // Safe exceptions
|
#endif // Safe exceptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <lua_CFunction f>
|
||||||
|
int static_trampoline(lua_State* L) {
|
||||||
|
return impl_static_trampoline(L, f);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
||||||
#if 0
|
#if 0
|
||||||
// impossible: g++/clang++ choke as they think this function is ambiguous:
|
// impossible: g++/clang++ choke as they think this function is ambiguous:
|
||||||
|
@ -10671,9 +10676,7 @@ namespace sol {
|
||||||
|
|
||||||
namespace sol { namespace stack {
|
namespace sol { namespace stack {
|
||||||
namespace stack_detail {
|
namespace stack_detail {
|
||||||
template <typename T, bool poptable = true>
|
inline bool impl_check_metatable(lua_State* L, int index, const std::string& metakey, bool poptable) {
|
||||||
inline bool check_metatable(lua_State* L, int index = -2) {
|
|
||||||
const auto& metakey = usertype_traits<T>::metatable();
|
|
||||||
luaL_getmetatable(L, &metakey[0]);
|
luaL_getmetatable(L, &metakey[0]);
|
||||||
const type expectedmetatabletype = static_cast<type>(lua_type(L, -1));
|
const type expectedmetatabletype = static_cast<type>(lua_type(L, -1));
|
||||||
if (expectedmetatabletype != type::lua_nil) {
|
if (expectedmetatabletype != type::lua_nil) {
|
||||||
|
@ -10686,6 +10689,11 @@ namespace sol { namespace stack {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, bool poptable = true>
|
||||||
|
inline bool check_metatable(lua_State* L, int index = -2) {
|
||||||
|
return impl_check_metatable(L, index, usertype_traits<T>::metatable(), poptable);
|
||||||
|
}
|
||||||
|
|
||||||
template <type expected, int (*check_func)(lua_State*, int)>
|
template <type expected, int (*check_func)(lua_State*, int)>
|
||||||
struct basic_check {
|
struct basic_check {
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user