summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-02-24 16:10:00 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-02-24 16:10:00 +0100
commit5cf08ef1a988ec5201374ff64170b4bc86030394 (patch)
treebddc4ec05d5c24564abb7a6bfd9096071b4e6fa2
parent3f92a51b9a6db9a320a94dd6d958ce90c7e6e345 (diff)
docgen: minor speed optimizations and cleanups
-rw-r--r--src/scripts/elua/apps/docgen/doctree.lua18
-rw-r--r--src/scripts/elua/apps/gendoc.lua39
2 files changed, 34 insertions, 23 deletions
diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua
index a3a75737f4..f4db74e085 100644
--- a/src/scripts/elua/apps/docgen/doctree.lua
+++ b/src/scripts/elua/apps/docgen/doctree.lua
@@ -218,7 +218,18 @@ M.Class = Node:clone {
218 end, 218 end,
219 219
220 inherits_get = function(self) 220 inherits_get = function(self)
221 return self.class:inherits_get():to_array() 221 local ret = self._cache_inhc
222 if ret then
223 return ret
224 end
225 ret = {}
226 for cln in self.class:inherits_get() do
227 local cl = self.by_name_get(cln)
228 assert(cl)
229 ret[#ret + 1] = cl
230 end
231 self._cache_inhc = ret
232 return ret
222 end, 233 end,
223 234
224 children_get = function(self) 235 children_get = function(self)
@@ -1480,15 +1491,12 @@ M.parse = function()
1480 for cl in eolian.all_classes_get() do 1491 for cl in eolian.all_classes_get() do
1481 local cln = cl:full_name_get() 1492 local cln = cl:full_name_get()
1482 for icl in cl:inherits_get() do 1493 for icl in cl:inherits_get() do
1483 if icl == "Elm.List" then
1484 print("GOT ELM LIST")
1485 end
1486 local t = revh[icl] 1494 local t = revh[icl]
1487 if not t then 1495 if not t then
1488 t = {} 1496 t = {}
1489 revh[icl] = t 1497 revh[icl] = t
1490 end 1498 end
1491 t[#t + 1] = cln 1499 t[#t + 1] = M.Class.by_name_get(cl:full_name_get())
1492 end 1500 end
1493 end 1501 end
1494end 1502end
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index c45c84366a..1e961a73ed 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -387,11 +387,7 @@ build_inherits = function(cl, t, lvl)
387 lbuf:write_b(lbuf:finish()) 387 lbuf:write_b(lbuf:finish())
388 end 388 end
389 t[#t + 1] = { lvl, lbuf:finish() } 389 t[#t + 1] = { lvl, lbuf:finish() }
390 for i, cln in ipairs(cl:inherits_get()) do 390 for i, acl in ipairs(cl:inherits_get()) do
391 local acl = dtree.Class.by_name_get(cln)
392 if not acl then
393 error("error retrieving inherited class " .. cln)
394 end
395 build_inherits(acl, t, lvl + 1) 391 build_inherits(acl, t, lvl + 1)
396 end 392 end
397 return t 393 return t
@@ -633,13 +629,9 @@ end
633local build_igraph_r 629local build_igraph_r
634build_igraph_r = function(cl, nbuf, ibuf) 630build_igraph_r = function(cl, nbuf, ibuf)
635 local sn = cl:full_name_get():lower():gsub("%.", "_") 631 local sn = cl:full_name_get():lower():gsub("%.", "_")
636 for i, cln in ipairs(cl:inherits_get()) do 632 for i, acl in ipairs(cl:inherits_get()) do
637 local acl = dtree.Class.by_name_get(cln)
638 if not acl then
639 error("error retrieving inherited class " .. cln)
640 end
641 nbuf[#nbuf + 1] = class_to_node(acl) 633 nbuf[#nbuf + 1] = class_to_node(acl)
642 ibuf[#ibuf + 1] = { sn, (cln:lower():gsub("%.", "_")) } 634 ibuf[#ibuf + 1] = { sn, (cl:full_name_get():lower():gsub("%.", "_")) }
643 build_igraph_r(acl, nbuf, ibuf) 635 build_igraph_r(acl, nbuf, ibuf)
644 end 636 end
645end 637end
@@ -669,8 +661,7 @@ end
669 661
670local find_parent_impl 662local find_parent_impl
671find_parent_impl = function(fulln, cl) 663find_parent_impl = function(fulln, cl)
672 for i, inh in ipairs(cl:inherits_get()) do 664 for i, pcl in ipairs(cl:inherits_get()) do
673 local pcl = dtree.Class.by_name_get(inh)
674 for j, impl in ipairs(pcl:implements_get()) do 665 for j, impl in ipairs(pcl:implements_get()) do
675 if impl:full_name_get() == fulln then 666 if impl:full_name_get() == fulln then
676 return impl, pcl 667 return impl, pcl
@@ -738,6 +729,10 @@ local build_functable = function(f, title, tcl, tbl, newm)
738 lbuf:write_i(llbuf:finish()) 729 lbuf:write_i(llbuf:finish())
739 end 730 end
740 731
732 local wt = {}
733 -- name info
734 wt[#wt + 1] = lbuf:finish()
735
741 if over then 736 if over then
742 lbuf:write_raw(" ") 737 lbuf:write_raw(" ")
743 local llbuf = writer.Buffer() 738 local llbuf = writer.Buffer()
@@ -752,6 +747,9 @@ local build_functable = function(f, title, tcl, tbl, newm)
752 lbuf:write_i(llbuf:finish()) 747 lbuf:write_i(llbuf:finish())
753 end 748 end
754 749
750 -- overridde info (or empty)
751 wt[#wt + 1] = lbuf:finish()
752
755 local doc = impl:doc_get(func.METHOD, true) 753 local doc = impl:doc_get(func.METHOD, true)
756 local docf = impl:fallback_doc_get(true) 754 local docf = impl:fallback_doc_get(true)
757 local bdoc 755 local bdoc
@@ -777,7 +775,9 @@ local build_functable = function(f, title, tcl, tbl, newm)
777 lbuf:write_br() 775 lbuf:write_br()
778 end 776 end
779 777
780 nt[#nt + 1] = { lbuf:finish() } 778 -- sigs and description
779 wt[#wt + 1] = lbuf:finish()
780 nt[#nt + 1] = wt
781 781
782 if impl:is_prop_get() or impl:is_prop_set() then 782 if impl:is_prop_get() or impl:is_prop_set() then
783 build_property(impl, cl) 783 build_property(impl, cl)
@@ -787,7 +787,12 @@ local build_functable = function(f, title, tcl, tbl, newm)
787 end 787 end
788 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end) 788 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end)
789 for i, item in ipairs(nt) do 789 for i, item in ipairs(nt) do
790 -- name
790 f:write_raw(item[1]) 791 f:write_raw(item[1])
792 -- override
793 f:write_raw(item[2])
794 -- desc
795 f:write_raw(item[3])
791 f:write_nl() 796 f:write_nl()
792 f:write_br() 797 f:write_br()
793 f:write_nl() 798 f:write_nl()
@@ -799,8 +804,7 @@ end
799-- overrides and not duplicating, does a depth-first search 804-- overrides and not duplicating, does a depth-first search
800local find_callables 805local find_callables
801find_callables = function(cl, omeths, events, written) 806find_callables = function(cl, omeths, events, written)
802 for i, inh in ipairs(cl:inherits_get()) do 807 for i, pcl in ipairs(cl:inherits_get()) do
803 local pcl = dtree.Class.by_name_get(inh)
804 for j, impl in ipairs(pcl:implements_get()) do 808 for j, impl in ipairs(pcl:implements_get()) do
805 local func = impl:function_get() 809 local func = impl:function_get()
806 local fid = func:id_get() 810 local fid = func:id_get()
@@ -1148,8 +1152,7 @@ get_all_impls_of = function(tbl, cl, fn, got)
1148 break 1152 break
1149 end 1153 end
1150 end 1154 end
1151 for i, cln in ipairs(cl:children_get()) do 1155 for i, icl in ipairs(cl:children_get()) do
1152 local icl = dtree.Class.by_name_get(cln)
1153 get_all_impls_of(tbl, icl, fn, got) 1156 get_all_impls_of(tbl, icl, fn, got)
1154 end 1157 end
1155end 1158end