From 009eb7d43d9582856c275ad3b16f7e3ff94209cc Mon Sep 17 00:00:00 2001 From: amelia squires Date: Wed, 16 Apr 2025 13:09:46 -0500 Subject: merge thingy --- src/hash/blake2.c | 1 - src/io.c | 1 - src/lua.c | 2 +- src/lua.h | 49 +++++++------------------------------------------ src/net/common.h | 3 --- src/reg.c | 2 +- src/thread.c | 2 -- 7 files changed, 9 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/hash/blake2.c b/src/hash/blake2.c index 5f38bba..adb1419 100644 --- a/src/hash/blake2.c +++ b/src/hash/blake2.c @@ -3,7 +3,6 @@ #include #include #include "../crypto.h" -#include "lua5.4/lua.h" void mix2b(uint64_t* a, uint64_t* b, uint64_t* c, uint64_t* d, int64_t x, int64_t y){ *a = *a + *b + x; diff --git a/src/io.c b/src/io.c index 6cc9e50..0f19933 100644 --- a/src/io.c +++ b/src/io.c @@ -1,5 +1,4 @@ #include -#include "lua5.4/lua.h" #include "types/str.h" #include "io.h" #include "stdlib.h" diff --git a/src/lua.c b/src/lua.c index b87682d..d122b59 100644 --- a/src/lua.c +++ b/src/lua.c @@ -3,8 +3,8 @@ #include "io.h" #include #include -#include "lua5.4/lua.h" #include "types/str.h" +#include #include "types/parray.h" static int ii = 0; diff --git a/src/lua.h b/src/lua.h index 3d58124..cc7a37f 100644 --- a/src/lua.h +++ b/src/lua.h @@ -76,52 +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 lreg(N, FN)\ - lua_pushstring(L, N);\ - luaL_register(L, NULL, FN);\ - lua_settable(L, -3); - - - #define requiref( L, modname, f, glob ) \ - { luaL_requiref( L, modname, f, glob ); lua_pop( L, 1 ); } - #define lua_objlen(L,i) lua_rawlen(L,(i)) - #define luaL_register(L, M, F) luaL_newlib(L, F); -#else - //todo: #define luaL_tolstring(L, idx, n) _luaL_tolstring(L, idx, n) - #define lreg(N, FN)\ - lua_newtable(L);\ - luaL_register(L, NULL, FN);\ - lua_setfield(L, 2, N); + #define luaL_register(L, M, F) luaL_newlib(L, F); +#elif LUA_VERSION_NUM = 501 + #define luaL_tolstring lua_tolstring - //taken straight from luaproc - #define requiref(L, modname, f, glob){\ - lua_pushcfunction(L, f);\ - lua_pushstring(L, modname); \ - lua_call(L, 1, 1);\ - lua_getfield(L, LUA_GLOBALSINDEX, LUA_LOADLIBNAME);\ - if(lua_type(L, -1) == LUA_TTABLE){\ - lua_getfield(L, -1, "loaded");\ - if(lua_type(L, -1) == LUA_TTABLE){\ - lua_getfield(L, -1, modname);\ - if(lua_type(L, -1) == LUA_TNIL) {\ - lua_pushvalue(L, 1);\ - lua_setfield(L, -3, modname);\ - }\ - lua_pop(L, 1);\ - }\ - lua_pop(L, 1);\ - }\ - lua_pop(L, 1);\ - if(glob){\ - lua_setglobal(L, modname);\ - }else{\ - lua_pop(L, 1);\ - }\ - } - + #define lua_dump(A, B, C, D) lua_dump(A, B, C) + #define lua_rawlen lua_objlen + + #define lua_gc(A, B) lua_gc(A, B, 0) #endif diff --git a/src/net/common.h b/src/net/common.h index 6b1a25a..828cb04 100644 --- a/src/net/common.h +++ b/src/net/common.h @@ -1,9 +1,6 @@ #ifndef __common_net_h #define __common_net_h -#include "lua5.4/lauxlib.h" -#include "lua5.4/lua.h" - #include #include #include diff --git a/src/reg.c b/src/reg.c index 64a2c2f..98419bc 100644 --- a/src/reg.c +++ b/src/reg.c @@ -26,7 +26,7 @@ static int lua_exit(lua_State* L){ #define open_common(name)\ int luaopen_lullaby_##name (lua_State* L){\ - luaL_register(L, NULL, name##_function_list);\ + luaL_register(L, #name, name##_function_list);\ int tidx = lua_gettop(L);\ i_config_metatable(L, name##_config);\ lua_settop(L, tidx);\ diff --git a/src/thread.c b/src/thread.c index a6be01b..c5ae933 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1,6 +1,4 @@ #include "thread.h" -#include "lua5.4/lauxlib.h" -#include "lua5.4/lua.h" #include "stdint.h" #include #include -- cgit v1.2.3