From 694712ee9e049a732c4620d2269f98bb726b4989 Mon Sep 17 00:00:00 2001 From: halx99 Date: Fri, 18 Feb 2022 23:23:41 +0800 Subject: [PATCH] Use .def export APIs required by luac This can avoid modify any lua src file --- thirdparty/lua/plainlua/CMakeLists.txt | 2 +- thirdparty/lua/plainlua/lmem.h | 2 +- thirdparty/lua/plainlua/luac.c | 4 ++-- thirdparty/lua/plainlua/plainlua.def | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 thirdparty/lua/plainlua/plainlua.def diff --git a/thirdparty/lua/plainlua/CMakeLists.txt b/thirdparty/lua/plainlua/CMakeLists.txt index 121b4b026506..bf18dc6b66af 100644 --- a/thirdparty/lua/plainlua/CMakeLists.txt +++ b/thirdparty/lua/plainlua/CMakeLists.txt @@ -17,7 +17,7 @@ set(LUA_BUILD_AS_DLL ${BUILD_SHARED_LIBS}) if(WIN32) set(LUA_BUILD_AS_DLL TRUE) - add_library(${target_name} SHARED ${LUA_CORE}) + add_library(${target_name} SHARED ${LUA_CORE} ${LUA_SRC_PATH}/plainlua.def) else() add_library(${target_name} ${LUA_CORE}) endif() diff --git a/thirdparty/lua/plainlua/lmem.h b/thirdparty/lua/plainlua/lmem.h index 6fa91675d772..8c75a44beb47 100644 --- a/thirdparty/lua/plainlua/lmem.h +++ b/thirdparty/lua/plainlua/lmem.h @@ -81,7 +81,7 @@ LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, size_t size); LUAI_FUNC void *luaM_saferealloc_ (lua_State *L, void *block, size_t oldsize, size_t size); -LUALIB_API void luaM_free_ (lua_State *L, void *block, size_t osize); +LUAI_FUNC void luaM_free_ (lua_State *L, void *block, size_t osize); LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int nelems, int *size, int size_elem, int limit, const char *what); diff --git a/thirdparty/lua/plainlua/luac.c b/thirdparty/lua/plainlua/luac.c index 1efdcf91e683..f6db9cf656bb 100644 --- a/thirdparty/lua/plainlua/luac.c +++ b/thirdparty/lua/plainlua/luac.c @@ -350,9 +350,9 @@ static void PrintCode(const Proto* f) int sc=GETARG_sC(i); int sbx=GETARG_sBx(i); int isk=GETARG_k(i); - //int line=luaG_getfuncline(f,pc); + int line=luaG_getfuncline(f,pc); printf("\t%d\t",pc+1); - //if (line>0) printf("[%d]\t",line); else printf("[-]\t"); + if (line>0) printf("[%d]\t",line); else printf("[-]\t"); printf("%-9s\t",opnames[o]); switch (o) { diff --git a/thirdparty/lua/plainlua/plainlua.def b/thirdparty/lua/plainlua/plainlua.def new file mode 100644 index 000000000000..383ab72f7cf0 --- /dev/null +++ b/thirdparty/lua/plainlua/plainlua.def @@ -0,0 +1,3 @@ +EXPORTS +luaM_free_ +luaG_getfuncline \ No newline at end of file