add __ipairs metamethod support if missing in LuaJIT
This commit is contained in:
parent
3e493a4a97
commit
38e0753382
@ -3,6 +3,23 @@
|
|||||||
local canvas_ffi_buffer
|
local canvas_ffi_buffer
|
||||||
local canvas_ffi_buffer_size = 0
|
local canvas_ffi_buffer_size = 0
|
||||||
|
|
||||||
|
local ipairs_mt_supported = false
|
||||||
|
for i, _ in ipairs(setmetatable({l={1}}, {
|
||||||
|
__ipairs=function(self) return ipairs(self.l) end})) do
|
||||||
|
ipairs_mt_supported = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if not ipairs_mt_supported then
|
||||||
|
local raw_ipairs = ipairs
|
||||||
|
ipairs = function(t)
|
||||||
|
local metatable = getmetatable(t)
|
||||||
|
if metatable and metatable.__ipairs then
|
||||||
|
return metatable.__ipairs(t)
|
||||||
|
end
|
||||||
|
return raw_ipairs(t)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function __vc_Canvas_set_data(self, data)
|
function __vc_Canvas_set_data(self, data)
|
||||||
if type(data) == "cdata" then
|
if type(data) == "cdata" then
|
||||||
self:_set_data(tostring(ffi.cast("uintptr_t", data)))
|
self:_set_data(tostring(ffi.cast("uintptr_t", data)))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user