aboutsummaryrefslogtreecommitdiff
path: root/src/lua.h
diff options
context:
space:
mode:
authoramelia squires <[email protected]>2025-04-21 20:43:51 -0500
committeramelia squires <[email protected]>2025-04-21 20:43:51 -0500
commitaf975d63f67e6cc2d17f1804acb66328905f8701 (patch)
treeab23744e784044d29cc73cd1da4070011e7e858c /src/lua.h
parentb2ee662b4621282b137a2a2cf1be13bd60073c5a (diff)
better version support, fixes, and memory saftey
Diffstat (limited to 'src/lua.h')
-rw-r--r--src/lua.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lua.h b/src/lua.h
index 47d6757..9f28c06 100644
--- a/src/lua.h
+++ b/src/lua.h
@@ -1,6 +1,6 @@
-#include <lua5.4/lua.h>
-#include <lua5.4/lualib.h>
-#include <lua5.4/lauxlib.h>
+#include <lua.h>
+#include <lualib.h>
+#include <lauxlib.h>
#include <stdlib.h>
#ifndef __lua_h
@@ -76,9 +76,17 @@ int lua_assign_upvalues(lua_State* L, int fidx);
int writer(lua_State*, const void*, size_t, void*);
#if LUA_VERSION_NUM == 504
- #define lua_objlen(L,i) lua_rawlen(L,(i))
+ #define lua_objlen lua_rawlen
#define luaL_register(L, M, F) luaL_newlib(L, F);
+
+#elif LUA_VERSION_NUM == 503
+ #define lua_objlen lua_rawlen
+
+ #define luaL_register(L, M, F) luaL_newlib(L, F);
+
+ #define lua_gc(A, B) lua_gc(A, B, 0)
+
#elif LUA_VERSION_NUM == 501
#define luaL_tolstring lua_tolstring
@@ -88,7 +96,7 @@ int writer(lua_State*, const void*, size_t, void*);
#define lua_gc(A, B) lua_gc(A, B, 0)
- #define lua_pushglobaltable(L) {lua_getglobal(L, "_G");}
+ #define lua_pushglobaltable(L) {lua_getglobal(L, "_G");if(lua_isnil(L, -1)){lua_newtable(L);lua_setglobal(L, "_G");lua_getglobal(L, "_G");}}
#endif