瀏覽代碼

Sort things more reliably;

bjorn 7 年之前
父節點
當前提交
53d61ee3b8
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      api/main.lua

+ 10 - 0
api/main.lua

@@ -169,6 +169,8 @@ local function processObject(path, parent)
     end
   end
 
+  table.sort(object.methods, function(a, b) return a.key < b.key end)
+
   return object
 end
 
@@ -209,6 +211,10 @@ local function processModule(path)
     end
   end
 
+  table.sort(module.functions, function(a, b) return a.key < b.key end)
+  table.sort(module.objects, function(a, b) return a.key < b.key end)
+  table.sort(module.enums, function(a, b) return a.key < b.key end)
+
   return module
 end
 
@@ -235,6 +241,10 @@ function lovr.load()
     table.insert(api.callbacks, processFunction(callbacks .. '/' .. file:gsub('%.lua', ''), api.modules[1]))
   end
 
+  -- Sort
+  table.sort(api.modules, function(a, b) return a.key < b.key end)
+  table.sort(api.callbacks, function(a, b) return a.key < b.key end)
+
   -- Serialize
   local file = io.open(lovr.filesystem.getSource() .. '/init.lua', 'w')
   assert(file, 'Could not open init.lua for writing')