elua: do not generate entirely new list types
authorDaniel Kolesa <d.kolesa@samsung.com>
Thu, 5 Jun 2014 14:56:31 +0000 (15:56 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Tue, 10 Jun 2014 14:48:53 +0000 (15:48 +0100)
src/bindings/luajit/eina/list.lua
src/bindings/luajit/eolian.lua

index 694235a70440fc6284bf8c7ec639be2bde8eeeb7..54343c9bedd55f0b800073826bdb04bb2bc90aa9 100644 (file)
@@ -277,14 +277,17 @@ local List_Base = util.Readonly_Object:clone {
 }
 M.List_Base = List_Base
 
-M.gen_list_type = function(tp)
-    return List_Base:clone {
-        data_get = function(self, ptr)
-            ptr = List_Base.data_get(self, ptr)
-            return ffi.cast(tp, ptr)
-        end
-    }
-end
+M.Ptr_List = List_Base:clone {
+    __ctor = function(self, selfmt, ptrtype, list, freefunc)
+        List_Base.__ctor(self, selfmt, list, freefunc)
+        selfmt.ptrtype = ptrtype
+    end,
+
+    data_get = function(self, ptr)
+        ptr = List_Base.data_get(self, ptr)
+        return ffi.cast(dgetmt(self).ptrtype, ptr)
+    end
+}
 
 M.String_List = List_Base:clone {
     data_get = function(self, ptr)
index ebf4854cbb864d8fcf4836354e340070b3ea75c9..5b0e66e85ef3f27c92b1f8efa7276043ceea7cd0 100644 (file)
@@ -104,6 +104,8 @@ local util  = require("util")
 
 local list = require("eina.list")
 
+local Ptr_List = list.Ptr_List
+
 local M = {}
 
 local eolian
@@ -162,8 +164,6 @@ M.function_scope = {
     PROTECTED = 1
 }
 
-local Eolian_Parameters_List = list.gen_list_type("Eolian_Function_Parameter*")
-
 M.Function = ffi.metatype("Eolian_Function", {
     __index = {
         type_get = function(self)
@@ -201,17 +201,17 @@ M.Function = ffi.metatype("Eolian_Function", {
         end,
 
         property_keys_list_get = function(self)
-            return Eolian_Parameters_List(
+            return Ptr_List("Eolian_Function_Parameter*",
                 eolian.eolian_property_keys_list_get(self)):to_array()
         end,
 
         property_values_list_get = function(self)
-            return Eolian_Parameters_List(
+            return Ptr_List("Eolian_Function_Parameter*",
                 eolian.eolian_property_values_list_get(self)):to_array()
         end,
 
         parameters_list_get = function(self)
-            return Eolian_Parameters_List(
+            return Ptr_List("Eolian_Function_Parameter*",
                 eolian.eolian_parameters_list_get(self)):to_array()
         end,
 
@@ -354,10 +354,6 @@ M.class_type = {
     INTERFACE = 4
 }
 
-local Eolian_Functions_List  = list.gen_list_type("Eolian_Function*")
-local Eolian_Implements_List = list.gen_list_type("Eolian_Implement*")
-local Eolian_Events_List     = list.gen_list_type("Eolian_Event*")
-
 M.Class = ffi.metatype("Eolian_Class", {
     __index = {
         file_get = function(self)
@@ -417,7 +413,7 @@ M.Class = ffi.metatype("Eolian_Class", {
         end,
 
         functions_list_get = function(self, func_type)
-            return Eolian_Functions_List(
+            return Ptr_List("Eolian_Function*",
                 eolian.eolian_class_functions_list_get(self, func_type))
                     :to_array()
         end,
@@ -430,12 +426,12 @@ M.Class = ffi.metatype("Eolian_Class", {
         end,
 
         implements_list_get = function(self)
-            return Eolian_Implements_List(
+            return Ptr_List("Eolian_Implement*",
                 eolian.eolian_class_implements_list_get(self)):to_array()
         end,
 
         events_list_get = function(self)
-            return Eolian_Events_List(
+            return Ptr_List("Eolian_Event*",
                 eolian.eolian_class_events_list_get(self)):to_array()
         end,