Ver código fonte

Add structure inference; stub generator module.

scossu 1 mês atrás
pai
commit
31f9489d24
2 arquivos alterados com 31 adições e 0 exclusões
  1. 13 0
      src/generator.lua
  2. 18 0
      src/submission.lua

+ 13 - 0
src/generator.lua

@@ -0,0 +1,13 @@
+local graph = require "lsup.graph"
+
+local pkar = require "pocket_archive"
+
+
+local M = {}
+
+M.generate = function()
+
+end
+
+
+return M

+ 18 - 0
src/submission.lua

@@ -188,6 +188,24 @@ M.generate_sip_v2 = function(path)
             end
         end
     end
+    -- Infer structure from paths and row ordering.
+    for i, v in ipairs(sip) do
+        for j = i + 1, #sip do
+            --print(string.format("comparing %s : %s", v.path, sip[j].path))
+            if not v["pas:next"] and
+                    sip[j].path:match("(.*/)") == v.path:match("(.*/)") then
+                --print("next match.")
+                v["pas:next"] = sip[j].path
+            end
+            if not v["pas:firstChild"] and
+                    sip[j].path:match("^" .. escape_pattern(v.path)) then
+                --print("First child match.")
+                v["pas:firstChild"] = sip[j].path
+            end
+        end
+        v._sort = nil
+    end
+
 
     return sip
 end