q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=93dad9d6bb0be1709e18005bfb74b06ea891d366

commit 93dad9d6bb0be1709e18005bfb74b06ea891d366
Author: Daniel Kolesa <d.kol...@osg.samsung.com>
Date:   Fri Mar 2 14:02:50 2018 +0100

    elua: objectify unit and redo class retrieval
---
 src/bindings/luajit/eolian.lua           | 52 ++++++++++++++++++++------------
 src/scripts/elua/apps/docgen/doctree.lua | 12 +++-----
 src/scripts/elua/modules/lualian.lua     |  2 +-
 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 [[
     Eina_Iterator *eolian_unit_structs_get(const Eolian_Unit *unit);
     Eina_Iterator *eolian_unit_enums_get(const Eolian_Unit *unit);
 
-    const Eolian_Class *eolian_class_get_by_name(const Eolian_Unit *unit, 
const char *class_name);
-    const Eolian_Class *eolian_class_get_by_file(const Eolian_Unit *unit, 
const char *file_name);
     const char *eolian_class_file_get(const Eolian_Class *klass);
     const char *eolian_class_full_name_get(const Eolian_Class *klass);
     const char *eolian_class_name_get(const Eolian_Class *klass);
     Eina_Iterator *eolian_class_namespaces_get(const Eolian_Class *klass);
     Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass);
-    Eina_Iterator *eolian_all_classes_get(const Eolian_Unit *unit);
     const Eolian_Documentation *eolian_class_documentation_get(const 
Eolian_Class *klass);
     const char *eolian_class_legacy_prefix_get(const Eolian_Class *klass);
     const char *eolian_class_eo_prefix_get(const Eolian_Class *klass);
@@ -596,6 +593,23 @@ ffi.metatype("Eolian_State", {
 
         unit_get = function(self)
             return ffi.cast("Eolian_Unit *", self)
+        end,
+
+        class_by_name_get = function(self, cname)
+            local v = eolian.eolian_state_class_by_name_get(self, cname)
+            if v == nil then return nil end
+            return v
+        end,
+
+        class_by_file_get = function(self, fname)
+            local v = eolian.eolian_state_class_by_file_get(self, fname)
+            if v == nil then return nil end
+            return v
+        end,
+
+        classes_get = function(self)
+            return Ptr_Iterator("const Eolian_Class*",
+                eolian.eolian_state_classes_get(self))
         end
     },
     __gc = function(self)
@@ -603,6 +617,21 @@ ffi.metatype("Eolian_State", {
     end
 })
 
+ffi.metatype("Eolian_Unit", {
+    __index = {
+        class_by_name_get = function(self, cname)
+            local v = eolian.eolian_unit_class_by_name_get(self, cname)
+            if v == nil then return nil end
+            return v
+        end,
+
+        classes_get = function(self)
+            return Ptr_Iterator("const Eolian_Class*",
+                eolian.eolian_unit_classes_get(self))
+        end
+    }
+})
+
 M.new = function()
     return eolian.eolian_state_new()
 end
@@ -1214,23 +1243,6 @@ ffi.metatype("Eolian_Event", {
     }
 })
 
-M.class_get_by_name = function(unit, cname)
-    local v = eolian.eolian_class_get_by_name(unit, cname)
-    if v == nil then return nil end
-    return v
-end
-
-M.class_get_by_file = function(unit, fname)
-    local v = eolian.eolian_class_get_by_file(unit, fname)
-    if v == nil then return nil end
-    return v
-end
-
-M.all_classes_get = function(unit)
-    return Ptr_Iterator("const Eolian_Class*",
-        eolian.eolian_all_classes_get(unit))
-end
-
 M.class_type = {
     UNKNOWN   = 0,
     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 {
         if ret then
             return ret
         end
-        -- FIXME: unit
-        local v = eolian.class_get_by_name(eos:unit_get(), name)
+        local v = eos:class_by_name_get(name)
         if not v then
             return nil
         end
@@ -319,8 +318,7 @@ M.Class = Node:clone {
         if ret then
             return ret
         end
-        -- FIXME: unit
-        local v = eolian.class_get_by_file(eos:unit_get(), name)
+        local v = eos:class_by_file_get(name)
         if not v then
             return nil
         end
@@ -333,7 +331,7 @@ M.Class = Node:clone {
         local ret, had = get_cache(M.Class, "_cache_all")
         if not had then
             -- FIXME: unit
-            for cl in eolian.all_classes_get(eos:unit_get()) do
+            for cl in eos:classes_get() do
                 local cls = M.Class(cl)
                 if matches_filter(cls) then
                    ret[#ret + 1] = cls
@@ -1539,8 +1537,8 @@ M.parse = function(st)
             error("failed parsing eo files")
         end
     end
-    -- build reverse inheritance hierarchy, FIXME: unit
-    for cl in eolian.all_classes_get(eos:unit_get()) do
+    -- build reverse inheritance hierarchy
+    for cl in eos:classes_get() do
         local cln = cl:full_name_get()
         for icl in cl:inherits_get() do
             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)
     end
     gen_unit = unit
     local sfn = fname:match(".*[\\/](.+)$") or fname
-    local klass = eolian.class_get_by_file(unit, sfn)
+    local klass = get_state():class_by_file_get(sfn)
     File(fname, klass, { gen_class(klass) }):generate(fstream or io.stdout)
 end
 

-- 


Reply via email to