From 1ce551e9eebf91a2bafa870410df9955237c708b Mon Sep 17 00:00:00 2001 From: Brent Davis Date: Thu, 18 Jun 2020 17:07:05 -0500 Subject: [PATCH 1/4] Normalize all the paths so string replacement for 'Beginning of'/'End of' comments works in more cases --- single/single.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/single/single.py b/single/single.py index 6fea5018..5f96df1e 100644 --- a/single/single.py +++ b/single/single.py @@ -39,7 +39,7 @@ forward_single_file = '' single_file = os.path.normpath(args.output[0]) if len(args.output) > 1: - forward_single_file = args.output[1] + forward_single_file = os.path.normpath(args.output[1]) else: a, b = os.path.splitext(single_file) a = os.path.dirname(single_file) @@ -49,7 +49,7 @@ else: single_file_dir = os.path.dirname(single_file) forward_single_file_dir = os.path.dirname(forward_single_file) -script_path = args.input +script_path = os.path.normpath(args.input) working_dir = os.getcwd() os.chdir(script_path) From 37c61eb16bd895ea955982180a42b79caf7b7e95 Mon Sep 17 00:00:00 2001 From: Brent Davis Date: Thu, 18 Jun 2020 17:08:49 -0500 Subject: [PATCH 2/4] Move code that doesn't need to be in a template, out of the template, to reduce duplicated binary code --- include/sol/demangle.hpp | 33 ++++++++++++++++++++------------ single/include/sol/forward.hpp | 4 ++-- single/include/sol/sol.hpp | 35 +++++++++++++++++++++------------- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/include/sol/demangle.hpp b/include/sol/demangle.hpp index 2161585a..2e7fc3c2 100644 --- a/include/sol/demangle.hpp +++ b/include/sol/demangle.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol3 // The MIT License (MIT) @@ -49,11 +49,9 @@ namespace detail { #if defined(__GNUC__) || defined(__clang__) - template - inline std::string ctti_get_type_name() { + inline std::string ctti_get_type_name_from_sig(std::string name) { // cardinal sins from MINGW using namespace std; - std::string name = __PRETTY_FUNCTION__; std::size_t start = name.find_first_of('['); start = name.find_first_of('=', start); std::size_t end = name.find_last_of(']'); @@ -83,10 +81,13 @@ namespace detail { return name; } + + template + inline std::string ctti_get_type_name() { + return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__); + } #elif defined(_MSC_VER) - template - std::string ctti_get_type_name() { - std::string name = __FUNCSIG__; + inline std::string ctti_get_type_name_from_sig(std::string name) { std::size_t start = name.find("get_type_name"); if (start == std::string::npos) start = 0; @@ -117,6 +118,11 @@ namespace detail { return name; } + + template + std::string ctti_get_type_name() { + return ctti_get_type_name_from_sig(__FUNCSIG__); + } #else #error Compiler not supported for demangling #endif // compilers @@ -127,9 +133,7 @@ namespace detail { return realname; } - template - std::string short_demangle_once() { - std::string realname = ctti_get_type_name(); + inline std::string short_demangle_from_type_name(std::string realname) { // This isn't the most complete but it'll do for now...? static const std::array ops = {{"operator<", "operator<<", "operator<<=", "operator<=", "operator>", "operator>>", "operator>>=", "operator>=", "operator->", "operator->*"}}; int level = 0; @@ -165,6 +169,12 @@ namespace detail { return realname; } + template + std::string short_demangle_once() { + std::string realname = ctti_get_type_name(); + return short_demangle_from_type_name(realname); + } + template const std::string& demangle() { static const std::string d = demangle_once(); @@ -176,7 +186,6 @@ namespace detail { static const std::string d = short_demangle_once(); return d; } -} -} // namespace sol::detail +}} // namespace sol::detail #endif // SOL_DEMANGLE_HPP diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index 660d0975..727fde07 100644 --- a/single/include/sol/forward.hpp +++ b/single/include/sol/forward.hpp @@ -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 2020-06-06 16:05:17.750133 UTC -// This header was generated with sol v3.2.1 (revision e09d2ff) +// Generated 2020-06-18 21:54:34.473478 UTC +// This header was generated with sol v3.2.1 (revision 62a831cd) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index 65dfd5c2..072509b1 100644 --- a/single/include/sol/sol.hpp +++ b/single/include/sol/sol.hpp @@ -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 2020-06-06 16:05:12.150007 UTC -// This header was generated with sol v3.2.1 (revision e09d2ff) +// Generated 2020-06-18 21:54:34.347814 UTC +// This header was generated with sol v3.2.1 (revision 62a831cd) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -7620,11 +7620,9 @@ namespace detail { "`anonymous namespace'" } }; #if defined(__GNUC__) || defined(__clang__) - template - inline std::string ctti_get_type_name() { + inline std::string ctti_get_type_name_from_sig(std::string name) { // cardinal sins from MINGW using namespace std; - std::string name = __PRETTY_FUNCTION__; std::size_t start = name.find_first_of('['); start = name.find_first_of('=', start); std::size_t end = name.find_last_of(']'); @@ -7654,10 +7652,13 @@ namespace detail { return name; } + + template + inline std::string ctti_get_type_name() { + return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__); + } #elif defined(_MSC_VER) - template - std::string ctti_get_type_name() { - std::string name = __FUNCSIG__; + inline std::string ctti_get_type_name_from_sig(std::string name) { std::size_t start = name.find("get_type_name"); if (start == std::string::npos) start = 0; @@ -7688,6 +7689,11 @@ namespace detail { return name; } + + template + std::string ctti_get_type_name() { + return ctti_get_type_name_from_sig(__FUNCSIG__); + } #else #error Compiler not supported for demangling #endif // compilers @@ -7698,9 +7704,7 @@ namespace detail { return realname; } - template - std::string short_demangle_once() { - std::string realname = ctti_get_type_name(); + inline std::string short_demangle_from_type_name(std::string realname) { // This isn't the most complete but it'll do for now...? static const std::array ops = {{"operator<", "operator<<", "operator<<=", "operator<=", "operator>", "operator>>", "operator>>=", "operator>=", "operator->", "operator->*"}}; int level = 0; @@ -7736,6 +7740,12 @@ namespace detail { return realname; } + template + std::string short_demangle_once() { + std::string realname = ctti_get_type_name(); + return short_demangle_from_type_name(realname); + } + template const std::string& demangle() { static const std::string d = demangle_once(); @@ -7747,8 +7757,7 @@ namespace detail { static const std::string d = short_demangle_once(); return d; } -} -} // namespace sol::detail +}} // namespace sol::detail // end of sol/demangle.hpp From a21fef97e90d717a7f131a7f4ee4d9e8a6fee5ba Mon Sep 17 00:00:00 2001 From: Brent Davis Date: Thu, 18 Jun 2020 17:18:23 -0500 Subject: [PATCH 3/4] Fix formatting in previous commit --- include/sol/demangle.hpp | 3 ++- single/include/sol/forward.hpp | 4 ++-- single/include/sol/sol.hpp | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/sol/demangle.hpp b/include/sol/demangle.hpp index 2e7fc3c2..dc861fbf 100644 --- a/include/sol/demangle.hpp +++ b/include/sol/demangle.hpp @@ -186,6 +186,7 @@ namespace detail { static const std::string d = short_demangle_once(); return d; } -}} // namespace sol::detail +} +} // namespace sol::detail #endif // SOL_DEMANGLE_HPP diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index 727fde07..ba62369b 100644 --- a/single/include/sol/forward.hpp +++ b/single/include/sol/forward.hpp @@ -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 2020-06-18 21:54:34.473478 UTC -// This header was generated with sol v3.2.1 (revision 62a831cd) +// Generated 2020-06-18 22:17:10.413702 UTC +// This header was generated with sol v3.2.1 (revision 162fdd74) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index 072509b1..10285963 100644 --- a/single/include/sol/sol.hpp +++ b/single/include/sol/sol.hpp @@ -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 2020-06-18 21:54:34.347814 UTC -// This header was generated with sol v3.2.1 (revision 62a831cd) +// Generated 2020-06-18 22:17:10.286043 UTC +// This header was generated with sol v3.2.1 (revision 162fdd74) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -7757,7 +7757,8 @@ namespace detail { static const std::string d = short_demangle_once(); return d; } -}} // namespace sol::detail +} +} // namespace sol::detail // end of sol/demangle.hpp From 428767b8cd6d6f7737dd13689154bbf16724901e Mon Sep 17 00:00:00 2001 From: Brent Davis Date: Fri, 19 Jun 2020 23:18:13 -0500 Subject: [PATCH 4/4] Reduce binary bloat from static_trampoline and check_metatable --- include/sol/stack_check_unqualified.hpp | 9 ++++++--- include/sol/trampoline.hpp | 11 ++++++++--- single/include/sol/forward.hpp | 4 ++-- single/include/sol/sol.hpp | 24 ++++++++++++++++-------- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/include/sol/stack_check_unqualified.hpp b/include/sol/stack_check_unqualified.hpp index 8bfe0908..b80297cc 100644 --- a/include/sol/stack_check_unqualified.hpp +++ b/include/sol/stack_check_unqualified.hpp @@ -38,9 +38,7 @@ namespace sol { namespace stack { namespace stack_detail { - template - inline bool check_metatable(lua_State* L, int index = -2) { - const auto& metakey = usertype_traits::metatable(); + inline bool impl_check_metatable(lua_State* L, int index, const std::string& metakey, bool poptable) { luaL_getmetatable(L, &metakey[0]); const type expectedmetatabletype = static_cast(lua_type(L, -1)); if (expectedmetatabletype != type::lua_nil) { @@ -53,6 +51,11 @@ namespace sol { namespace stack { return false; } + template + inline bool check_metatable(lua_State* L, int index = -2) { + return impl_check_metatable(L, index, usertype_traits::metatable(), poptable); + } + template struct basic_check { template diff --git a/include/sol/trampoline.hpp b/include/sol/trampoline.hpp index d0cdad1d..6c685529 100644 --- a/include/sol/trampoline.hpp +++ b/include/sol/trampoline.hpp @@ -99,8 +99,8 @@ namespace sol { return trampoline(L, f); } #else - template - 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) return f(L); @@ -119,7 +119,7 @@ namespace sol { } #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) // 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 catch (...) { call_exception_handler(L, optional(nullopt), "caught (...) exception"); @@ -129,6 +129,11 @@ namespace sol { #endif // Safe exceptions } + template + int static_trampoline(lua_State* L) { + return impl_static_trampoline(L, f); + } + #ifdef SOL_NOEXCEPT_FUNCTION_TYPE #if 0 // impossible: g++/clang++ choke as they think this function is ambiguous: diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index ba62369b..9172a1d2 100644 --- a/single/include/sol/forward.hpp +++ b/single/include/sol/forward.hpp @@ -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 2020-06-18 22:17:10.413702 UTC -// This header was generated with sol v3.2.1 (revision 162fdd74) +// Generated 2020-06-20 04:08:19.579717 UTC +// This header was generated with sol v3.2.1 (revision 5e40ef09) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index 10285963..dbf2658b 100644 --- a/single/include/sol/sol.hpp +++ b/single/include/sol/sol.hpp @@ -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 2020-06-18 22:17:10.286043 UTC -// This header was generated with sol v3.2.1 (revision 162fdd74) +// Generated 2020-06-20 04:08:19.416569 UTC +// This header was generated with sol v3.2.1 (revision 5e40ef09) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -7476,8 +7476,8 @@ namespace sol { return trampoline(L, f); } #else - template - 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) return f(L); @@ -7496,7 +7496,7 @@ namespace sol { } #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) // 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 catch (...) { call_exception_handler(L, optional(nullopt), "caught (...) exception"); @@ -7506,6 +7506,11 @@ namespace sol { #endif // Safe exceptions } + template + int static_trampoline(lua_State* L) { + return impl_static_trampoline(L, f); + } + #ifdef SOL_NOEXCEPT_FUNCTION_TYPE #if 0 // impossible: g++/clang++ choke as they think this function is ambiguous: @@ -10671,9 +10676,7 @@ namespace sol { namespace sol { namespace stack { namespace stack_detail { - template - inline bool check_metatable(lua_State* L, int index = -2) { - const auto& metakey = usertype_traits::metatable(); + inline bool impl_check_metatable(lua_State* L, int index, const std::string& metakey, bool poptable) { luaL_getmetatable(L, &metakey[0]); const type expectedmetatabletype = static_cast(lua_type(L, -1)); if (expectedmetatabletype != type::lua_nil) { @@ -10686,6 +10689,11 @@ namespace sol { namespace stack { return false; } + template + inline bool check_metatable(lua_State* L, int index = -2) { + return impl_check_metatable(L, index, usertype_traits::metatable(), poptable); + } + template struct basic_check { template