summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-02 14:02:50 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-02 14:04:41 +0100
commit93dad9d6bb0be1709e18005bfb74b06ea891d366 (patch)
treed24cb44414660a3d3c4fc464b896774eaddf45ef
parentb799fb1959aa30ff126f2770f3f5718cdec2dfed (diff)
elua: objectify unit and redo class retrieval
-rw-r--r--src/bindings/luajit/eolian.lua52
-rw-r--r--src/scripts/elua/apps/docgen/doctree.lua12
-rw-r--r--src/scripts/elua/modules/lualian.lua2
3 files changed, 38 insertions, 28 deletions
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index 4684292218..7c29337511 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -333,14 +333,11 @@ ffi.cdef [[
333 Eina_Iterator *eolian_unit_structs_get(const Eolian_Unit *unit); 333 Eina_Iterator *eolian_unit_structs_get(const Eolian_Unit *unit);
334 Eina_Iterator *eolian_unit_enums_get(const Eolian_Unit *unit); 334 Eina_Iterator *eolian_unit_enums_get(const Eolian_Unit *unit);
335 335
336 const Eolian_Class *eolian_class_get_by_name(const Eolian_Unit *unit, const char *class_name);
337 const Eolian_Class *eolian_class_get_by_file(const Eolian_Unit *unit, const char *file_name);
338 const char *eolian_class_file_get(const Eolian_Class *klass); 336 const char *eolian_class_file_get(const Eolian_Class *klass);
339 const char *eolian_class_full_name_get(const Eolian_Class *klass); 337 const char *eolian_class_full_name_get(const Eolian_Class *klass);
340 const char *eolian_class_name_get(const Eolian_Class *klass); 338 const char *eolian_class_name_get(const Eolian_Class *klass);
341 Eina_Iterator *eolian_class_namespaces_get(const Eolian_Class *klass); 339 Eina_Iterator *eolian_class_namespaces_get(const Eolian_Class *klass);
342 Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass); 340 Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass);
343 Eina_Iterator *eolian_all_classes_get(const Eolian_Unit *unit);
344 const Eolian_Documentation *eolian_class_documentation_get(const Eolian_Class *klass); 341 const Eolian_Documentation *eolian_class_documentation_get(const Eolian_Class *klass);
345 const char *eolian_class_legacy_prefix_get(const Eolian_Class *klass); 342 const char *eolian_class_legacy_prefix_get(const Eolian_Class *klass);
346 const char *eolian_class_eo_prefix_get(const Eolian_Class *klass); 343 const char *eolian_class_eo_prefix_get(const Eolian_Class *klass);
@@ -596,6 +593,23 @@ ffi.metatype("Eolian_State", {
596 593
597 unit_get = function(self) 594 unit_get = function(self)
598 return ffi.cast("Eolian_Unit *", self) 595 return ffi.cast("Eolian_Unit *", self)
596 end,
597
598 class_by_name_get = function(self, cname)
599 local v = eolian.eolian_state_class_by_name_get(self, cname)
600 if v == nil then return nil end
601 return v
602 end,
603
604 class_by_file_get = function(self, fname)
605 local v = eolian.eolian_state_class_by_file_get(self, fname)
606 if v == nil then return nil end
607 return v
608 end,
609
610 classes_get = function(self)
611 return Ptr_Iterator("const Eolian_Class*",
612 eolian.eolian_state_classes_get(self))
599 end 613 end
600 }, 614 },
601 __gc = function(self) 615 __gc = function(self)
@@ -603,6 +617,21 @@ ffi.metatype("Eolian_State", {
603 end 617 end
604}) 618})
605 619
620ffi.metatype("Eolian_Unit", {
621 __index = {
622 class_by_name_get = function(self, cname)
623 local v = eolian.eolian_unit_class_by_name_get(self, cname)
624 if v == nil then return nil end
625 return v
626 end,
627
628 classes_get = function(self)
629 return Ptr_Iterator("const Eolian_Class*",
630 eolian.eolian_unit_classes_get(self))
631 end
632 }
633})
634
606M.new = function() 635M.new = function()
607 return eolian.eolian_state_new() 636 return eolian.eolian_state_new()
608end 637end
@@ -1214,23 +1243,6 @@ ffi.metatype("Eolian_Event", {
1214 } 1243 }
1215}) 1244})
1216 1245
1217M.class_get_by_name = function(unit, cname)
1218 local v = eolian.eolian_class_get_by_name(unit, cname)
1219 if v == nil then return nil end
1220 return v
1221end
1222
1223M.class_get_by_file = function(unit, fname)
1224 local v = eolian.eolian_class_get_by_file(unit, fname)
1225 if v == nil then return nil end
1226 return v
1227end
1228
1229M.all_classes_get = function(unit)
1230 return Ptr_Iterator("const Eolian_Class*",
1231 eolian.eolian_all_classes_get(unit))
1232end
1233
1234M.class_type = { 1246M.class_type = {
1235 UNKNOWN = 0, 1247 UNKNOWN = 0,
1236 REGULAR = 1, 1248 REGULAR = 1,
diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua
index 4e1f906d88..73b456cafa 100644
--- a/src/scripts/elua/apps/docgen/doctree.lua
+++ b/src/scripts/elua/apps/docgen/doctree.lua
@@ -303,8 +303,7 @@ M.Class = Node:clone {
303 if ret then 303 if ret then
304 return ret 304 return ret
305 end 305 end
306 -- FIXME: unit 306 local v = eos:class_by_name_get(name)
307 local v = eolian.class_get_by_name(eos:unit_get(), name)
308 if not v then 307 if not v then
309 return nil 308 return nil
310 end 309 end
@@ -319,8 +318,7 @@ M.Class = Node:clone {
319 if ret then 318 if ret then
320 return ret 319 return ret
321 end 320 end
322 -- FIXME: unit 321 local v = eos:class_by_file_get(name)
323 local v = eolian.class_get_by_file(eos:unit_get(), name)
324 if not v then 322 if not v then
325 return nil 323 return nil
326 end 324 end
@@ -333,7 +331,7 @@ M.Class = Node:clone {
333 local ret, had = get_cache(M.Class, "_cache_all") 331 local ret, had = get_cache(M.Class, "_cache_all")
334 if not had then 332 if not had then
335 -- FIXME: unit 333 -- FIXME: unit
336 for cl in eolian.all_classes_get(eos:unit_get()) do 334 for cl in eos:classes_get() do
337 local cls = M.Class(cl) 335 local cls = M.Class(cl)
338 if matches_filter(cls) then 336 if matches_filter(cls) then
339 ret[#ret + 1] = cls 337 ret[#ret + 1] = cls
@@ -1539,8 +1537,8 @@ M.parse = function(st)
1539 error("failed parsing eo files") 1537 error("failed parsing eo files")
1540 end 1538 end
1541 end 1539 end
1542 -- build reverse inheritance hierarchy, FIXME: unit 1540 -- build reverse inheritance hierarchy
1543 for cl in eolian.all_classes_get(eos:unit_get()) do 1541 for cl in eos:classes_get() do
1544 local cln = cl:full_name_get() 1542 local cln = cl:full_name_get()
1545 for icl in cl:inherits_get() do 1543 for icl in cl:inherits_get() do
1546 local t = revh[icl] 1544 local t = revh[icl]
diff --git a/src/scripts/elua/modules/lualian.lua b/src/scripts/elua/modules/lualian.lua
index 56f3ad3a50..959b4fd837 100644
--- a/src/scripts/elua/modules/lualian.lua
+++ b/src/scripts/elua/modules/lualian.lua
@@ -711,7 +711,7 @@ M.generate = function(fname, fstream)
711 end 711 end
712 gen_unit = unit 712 gen_unit = unit
713 local sfn = fname:match(".*[\\/](.+)$") or fname 713 local sfn = fname:match(".*[\\/](.+)$") or fname
714 local klass = eolian.class_get_by_file(unit, sfn) 714 local klass = get_state():class_by_file_get(sfn)
715 File(fname, klass, { gen_class(klass) }):generate(fstream or io.stdout) 715 File(fname, klass, { gen_class(klass) }):generate(fstream or io.stdout)
716end 716end
717 717