Skip to content

Commit 535b658

Browse files
committed
Add lua 5.5 support
1 parent c1f95a7 commit 535b658

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

include/sol/compatibility/compat-5.4.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ extern "C" {
1717
}
1818
#endif
1919

20-
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 504
20+
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 504
2121

2222
#if !defined(LUA_ERRGCMM)
23-
/* So Lua 5.4 actually removes this, which breaks sol2...
23+
/* So Lua 5.4 or later actually removes this, which breaks sol2...
2424
man, this API is quite unstable...!
2525
*/
2626
# define LUA_ERRGCMM (LUA_ERRERR + 2)
2727
#endif /* LUA_ERRGCMM define */
2828

29-
#endif // Lua 5.4 only
29+
#endif // Lua 5.4 or later
3030

3131
#endif // NOT_KEPLER_PROJECT_COMPAT54_H_

include/sol/state.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
#include <sol/state_view.hpp>
2828
#include <sol/thread.hpp>
2929

30+
#if LUA_VERSION_NUM >= 505
31+
# define sol_lua_newstate(f, ud) lua_newstate(f, ud, 0)
32+
#else
33+
# define sol_lua_newstate(f, ud) lua_newstate(f, ud)
34+
#endif
35+
3036
namespace sol {
3137

3238
class state : private std::unique_ptr<lua_State, detail::state_deleter>, public state_view {
@@ -39,7 +45,7 @@ namespace sol {
3945
}
4046

4147
state(lua_CFunction panic, lua_Alloc alfunc, void* alpointer = nullptr)
42-
: unique_base(lua_newstate(alfunc, alpointer)), state_view(unique_base::get()) {
48+
: unique_base(sol_lua_newstate(alfunc, alpointer)), state_view(unique_base::get()) {
4349
set_default_state(unique_base::get(), panic);
4450
}
4551

0 commit comments

Comments
 (0)