From 630feb038b28a619a2a4949c3e747d3a3e29474e Mon Sep 17 00:00:00 2001 From: actboy168 Date: Fri, 26 Apr 2024 22:48:24 +0800 Subject: [PATCH] cleanup --- compile/lua/forward_lua.lua | 44 +++++++++++-------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/compile/lua/forward_lua.lua b/compile/lua/forward_lua.lua index 9502617..19332e0 100644 --- a/compile/lua/forward_lua.lua +++ b/compile/lua/forward_lua.lua @@ -1,36 +1,18 @@ -local function parse(folder) - local version - local export = {} - for line in io.lines(folder.."/lua.h") do - local verstr = line:match "^%s*#%s*define%s*LUA_VERSION_NUM%s*([0-9]+)%s*$" - if verstr then - version = tostring(tonumber(verstr:sub(1, -3))) .. tostring(tonumber(verstr:sub(-2, -1))) - end - local api = line:match "^%s*LUA_API[%w%s%*_]+%(([%w_]+)%)" - if api then - export[#export+1] = api - end - end - for line in io.lines(folder.."/lauxlib.h") do - local api = line:match "^%s*LUALIB_API[%w%s%*_]+%(([%w_]+)%)" - if api then - export[#export+1] = api - end - end - for line in io.lines(folder.."/lualib.h") do - local api = line:match "^%s*LUALIB_API[%w%s%*_]+%(([%w_]+)%)" - if api then - export[#export+1] = api - end - end - table.sort(export) - return version, export -end - local input, output, dllname = ... -local _, export = parse(input) -local f = assert(io.open(output, "w")) +local export = {} +for line in io.lines(input.."/lua.h") do + export[#export+1] = line:match "^%s*LUA_API[%w%s%*_]+%(([%w_]+)%)" +end +for line in io.lines(input.."/lauxlib.h") do + export[#export+1] = line:match "^%s*LUALIB_API[%w%s%*_]+%(([%w_]+)%)" +end +for line in io.lines(input.."/lualib.h") do + export[#export+1] = line:match "^%s*LUALIB_API[%w%s%*_]+%(([%w_]+)%)" +end +table.sort(export) + +local f = assert(io.open(output, "wb")) local function writeln(data) f:write(data) f:write "\n"