Skip to content
Snippets Groups Projects
Verified Commit ace843e3 authored by Petr Špaček's avatar Petr Špaček Committed by Tomas Krizek
Browse files

kluautil: table pack and unpack

Helper functions for handling variable length arrays with nil values.
parent 9b86f69d
1 merge request!1000Reimplement map()
......@@ -17,6 +17,18 @@ function kluautil.kr_table_len(t)
return len
end
-- pack varargs including nil arguments into a table
function kluautil.kr_table_pack(...)
local tab = {...}
tab.n = select('#', ...)
return tab
end
-- unpack table produced by kr_table_pack and including nil values
function kluautil.kr_table_unpack(tab)
return unpack(tab, 1, tab.n)
end
-- Fetch over HTTPS
ffi.cdef([[
typedef struct __dirstream DIR;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment