diff --git a/3rdparty/toluapp/src/bin/lua/all.lua b/3rdparty/toluapp/src/bin/lua/all.lua index 613698ae..1e0443d1 100644 --- a/3rdparty/toluapp/src/bin/lua/all.lua +++ b/3rdparty/toluapp/src/bin/lua/all.lua @@ -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") diff --git a/3rdparty/toluapp/src/bin/lua/ordered_pairs.lua b/3rdparty/toluapp/src/bin/lua/ordered_pairs.lua new file mode 100644 index 00000000..826b893b --- /dev/null +++ b/3rdparty/toluapp/src/bin/lua/ordered_pairs.lua @@ -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 diff --git a/3rdparty/toluapp/src/bin/lua/package.lua b/3rdparty/toluapp/src/bin/lua/package.lua index c0592e53..e3638337 100644 --- a/3rdparty/toluapp/src/bin/lua/package.lua +++ b/3rdparty/toluapp/src/bin/lua/package.lua @@ -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