1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 01:34:11 +00:00

Preserve ordering of generated Lua code (#1646)

* Preserve ordering of generated Lua code

This fixes #1645, and (partially) reverts 68ac28.
This commit is contained in:
Brenden Matthews 2023-10-13 09:51:50 -04:00 committed by GitHub
parent 23a1ad3848
commit bbdc7081ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View File

@ -6,6 +6,7 @@ dofile(path.."basic.lua")
dofile(path.."code.lua")
dofile(path.."typedef.lua")
dofile(path.."container.lua")
dofile(path.."ordered_pairs.lua")
dofile(path.."package.lua")
dofile(path.."module.lua")
dofile(path.."namespace.lua")

View File

@ -0,0 +1,18 @@
local P = {}
op = P
function P:ordered_pairs(t)
local i = {}
for k in next, t do
table.insert(i, k)
end
table.sort(i)
return function()
local k = table.remove(i)
if k ~= nil then
return k, t[k]
end
end
end
return op

View File

@ -133,7 +133,7 @@ function classPackage:preamble ()
output('\n')
output('/* function to release collected object via destructor */')
output('#ifdef __cplusplus\n')
for i,v in ipairs(_collect) do
for i,v in op:ordered_pairs(_collect) do
output('\nstatic int '..v..' (lua_State* tolua_S)')
output('{')
output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);')
@ -152,7 +152,7 @@ function classPackage:preamble ()
if flags.t then
output("#ifndef Mtolua_typeid\n#define Mtolua_typeid(L,TI,T)\n#endif\n")
end
for n,v in ipairs(_usertype) do
for n,v in op:ordered_pairs(_usertype) do
if (not _global_classes[v]) or _global_classes[v]:check_public_access() then
output(' tolua_usertype(tolua_S,"',v,'");')
if flags.t then