elua: a simple list type generator in eina_list

This commit is contained in:
Daniel Kolesa 2014-06-05 15:47:36 +01:00
parent aeaadae1fe
commit 22d03089fc
2 changed files with 13 additions and 28 deletions

View File

@ -277,6 +277,15 @@ 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.String_List = List_Base:clone {
data_get = function(self, ptr)
ptr = List_Base.data_get(self, ptr)

View File

@ -162,14 +162,7 @@ M.function_scope = {
PROTECTED = 1
}
local List_Base = list.List_Base
local Eolian_Parameters_List = List_Base:clone {
data_get = function(self, ptr)
ptr = List_Base.data_get(self, ptr)
return ffi.cast("Eolian_Function_Parameter*", ptr)
end
}
local Eolian_Parameters_List = list.gen_list_type("Eolian_Function_Parameter*")
M.Function = ffi.metatype("Eolian_Function", {
__index = {
@ -361,26 +354,9 @@ M.class_type = {
INTERFACE = 4
}
local Eolian_Functions_List = List_Base:clone {
data_get = function(self, ptr)
ptr = List_Base.data_get(self, ptr)
return ffi.cast("Eolian_Function*", ptr)
end
}
local Eolian_Implements_List = List_Base:clone {
data_get = function(self, ptr)
ptr = List_Base.data_get(self, ptr)
return ffi.cast("Eolian_Implement*", ptr)
end
}
local Eolian_Events_List = List_Base:clone {
data_get = function(self, ptr)
ptr = List_Base.data_get(self, ptr)
return ffi.cast("Eolian_Event*", ptr)
end
}
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 = {