[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 5.1
- From: David Burgess <dburgess@...>
- Date: Sat, 22 Oct 2005 12:11:51 +1000
Mike mentioned an ordinal extractor in
http://lua-users.org/lists/lua-l/2005-09/msg00313.html
> Anyone have a script to autogenerate a .def file
> from the headers?
For anyone who wants it.
--
-- q&d script to generate def file
--
headers = {"lua.h", "lauxlib.h", "lualib.h",
}
disable = {luaI_openlib=1, luaL_getn=1, luaL_setn=1}
n=0
io.write("; generated lua.def\nLIBRARY lua51\nEXPORTS\n")
io.write("DllMain @1\n")
for i, fn in ipairs(headers) do
io.write(string.format(";\n; from header %s\n;\n",fn))
for l in io.lines(fn) do
-- premise is that all lua functions contain an "_"
-- two pass regex for safety
s = string.match(l, "^LUAL?I?B?_API%s+[%w_]+[%W]*(.*)[%;%p%s]+$");
s,w = s and string.match(s, "(lua[%w%d]*_[%w%d]*_*[%w%d]*_*)");
if s then
n = n + 1
s = (disable[s] and ("; " .. s)) or s
io.write(string.format("%s\t@%u\n",s,n+1))
end
end
end
--
-- add some extra ordinals to the def file for Windows
--
if string.match(os.getenv"OS" or "", "Windows") then
io.write[[
;
; extra ordinals for linking luac
; no ordinals are assigned to these
;
luaU_dump
luaM_toobig
luaM_realloc_
luaS_newlstr
luaD_growstack
luaF_newproto
]]
end