Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ThePhD/sol2 into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	single/include/sol/forward.hpp
#	single/include/sol/sol.hpp
  • Loading branch information
ThePhD committed Jul 4, 2020
2 parents 862c010 + 428767b commit 7d8532b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
30 changes: 20 additions & 10 deletions include/sol/demangle.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// sol3
// sol3

// The MIT License (MIT)

Expand Down Expand Up @@ -49,11 +49,9 @@ namespace detail {


#if defined(__GNUC__) || defined(__clang__)
template <typename T, class seperator_mark = int>
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(']');
Expand Down Expand Up @@ -83,10 +81,13 @@ namespace detail {

return name;
}

template <typename T, class seperator_mark = int>
inline std::string ctti_get_type_name() {
return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__);
}
#elif defined(_MSC_VER)
template <typename T>
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;
Expand Down Expand Up @@ -117,6 +118,11 @@ namespace detail {

return name;
}

template <typename T>
std::string ctti_get_type_name() {
return ctti_get_type_name_from_sig(__FUNCSIG__);
}
#else
#error Compiler not supported for demangling
#endif // compilers
Expand All @@ -127,9 +133,7 @@ namespace detail {
return realname;
}

template <typename T>
std::string short_demangle_once() {
std::string realname = ctti_get_type_name<T>();
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<std::string, 10> ops = {{"operator<", "operator<<", "operator<<=", "operator<=", "operator>", "operator>>", "operator>>=", "operator>=", "operator->", "operator->*"}};
int level = 0;
Expand Down Expand Up @@ -165,6 +169,12 @@ namespace detail {
return realname;
}

template <typename T>
std::string short_demangle_once() {
std::string realname = ctti_get_type_name<T>();
return short_demangle_from_type_name(realname);
}

template <typename T>
const std::string& demangle() {
static const std::string d = demangle_once<T>();
Expand Down
9 changes: 6 additions & 3 deletions include/sol/stack_check_unqualified.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@

namespace sol { namespace stack {
namespace stack_detail {
template <typename T, bool poptable = true>
inline bool check_metatable(lua_State* L, int index = -2) {
const auto& metakey = usertype_traits<T>::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<type>(lua_type(L, -1));
if (expectedmetatabletype != type::lua_nil) {
Expand All @@ -53,6 +51,11 @@ namespace sol { namespace stack {
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)>
struct basic_check {
template <typename Handler>
Expand Down
11 changes: 8 additions & 3 deletions include/sol/trampoline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ namespace sol {
return trampoline(L, f);
}
#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)
return f(L);

Expand All @@ -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<const std::exception&>(nullopt), "caught (...) exception");
Expand All @@ -129,6 +129,11 @@ namespace sol {
#endif // Safe exceptions
}

template <lua_CFunction f>
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:
Expand Down
4 changes: 2 additions & 2 deletions single/single.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
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)
Expand All @@ -49,7 +49,7 @@
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)

Expand Down

0 comments on commit 7d8532b

Please sign in to comment.