elua: provide a conversion method from list to table

This commit is contained in:
Daniel Kolesa 2014-04-11 11:12:47 +01:00 committed by Daniel Kolesa
parent f55ade5689
commit 0cfc75eb1c
1 changed files with 16 additions and 0 deletions

View File

@ -207,6 +207,22 @@ M.List = util.Object:clone {
local l = self.__list
if l == nil then return nil end
return l:data_get(ptr)
end,
to_array = function(self)
local l = self.__list
if l == nil then return {}, 0 end
local n = 0
local r = {}
while l ~= nil do
n = n + 1
local d = l:data_get()
if d ~= nil then
r[n] = self:data_get(d)
end
l = l:next()
end
return r, n
end
}