Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Apr 26, 2024
1 parent aa05a96 commit 630feb0
Showing 1 changed file with 13 additions and 31 deletions.
44 changes: 13 additions & 31 deletions 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 <close> = 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 <close> = assert(io.open(output, "wb"))
local function writeln(data)
f:write(data)
f:write "\n"
Expand Down

0 comments on commit 630feb0

Please sign in to comment.