Skip to content

Commit

Permalink
Fixed Lua 5.3 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
bkacjios committed Jan 6, 2025
1 parent 722caeb commit 1977bba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions mumble/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@
#define lua_objlen lua_rawlen
#endif

#if LUA_VERSION_NUM >= 502
#define luaL_register(L, libname, l) \
((libname) == NULL ? luaL_setfuncs(L, (l), 0) : \
(lua_newtable(L), luaL_setfuncs(L, (l), 0), lua_pushvalue(L, -1), lua_setglobal(L, (libname))))
#endif

#if LUA_VERSION_NUM >= 503
#define luaL_optlong(L, n, d) ((long)luaL_opt(L, luaL_checkinteger, (n), (lua_Integer)(d)))
#define luaL_checkint(L, n) ((int)luaL_checkinteger(L, (n)))
#define lua_objlen(L, idx) lua_rawlen(L, (idx))
#define lua_dump(L, writer, data) lua_dump(L, writer, data, 1)
#endif

#define lua_stackguard_entry(L) int __lua_stackguard_entry = lua_gettop(L);
#define lua_stackguard_exit(L) assert(__lua_stackguard_entry == lua_gettop(L));

Expand Down
9 changes: 6 additions & 3 deletions mumble/mumble.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,11 @@ int luaopen_mumble(lua_State *l) {
lua_newtable(l);
MUMBLE_DATA_REG = mumble_ref(l);

luaL_register(l, "mumble", mumble);
#if LUA_VERSION_NUM >= 502
luaL_newlib(l, mumble);
#else
luaL_register(l, "mumble", mumble);
#endif
{
// Create a table of all RejectType enums
lua_newtable(l);
Expand Down Expand Up @@ -1710,9 +1714,8 @@ int luaopen_mumble(lua_State *l) {
lua_rawgeti(l, LUA_REGISTRYINDEX, MUMBLE_REGISTRY);
lua_setfield(l, -2, "registry");
}
lua_pop(l, 1);

return 0;
return 1;
}

static void mumble_close() {
Expand Down

0 comments on commit 1977bba

Please sign in to comment.