fix: attempt to index global 'ffi' (a nil value) in stdmin.lua
This commit is contained in:
parent
43c76c92ff
commit
20703e2b94
@ -20,16 +20,17 @@ if not ipairs_mt_supported then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local _ffi = ffi
|
||||||
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)))
|
||||||
end
|
end
|
||||||
local width = self.width
|
local width = self.width
|
||||||
local height = self.height
|
local height = self.height
|
||||||
|
|
||||||
local size = width * height * 4
|
local size = width * height * 4
|
||||||
if size > canvas_ffi_buffer_size then
|
if size > canvas_ffi_buffer_size then
|
||||||
canvas_ffi_buffer = ffi.new(
|
canvas_ffi_buffer = _ffi.new(
|
||||||
string.format("unsigned char[%s]", size)
|
string.format("unsigned char[%s]", size)
|
||||||
)
|
)
|
||||||
canvas_ffi_buffer_size = size
|
canvas_ffi_buffer_size = size
|
||||||
@ -37,7 +38,7 @@ function __vc_Canvas_set_data(self, data)
|
|||||||
for i=0, size - 1 do
|
for i=0, size - 1 do
|
||||||
canvas_ffi_buffer[i] = data[i + 1]
|
canvas_ffi_buffer[i] = data[i + 1]
|
||||||
end
|
end
|
||||||
self:_set_data(tostring(ffi.cast("uintptr_t", canvas_ffi_buffer)))
|
self:_set_data(tostring(_ffi.cast("uintptr_t", canvas_ffi_buffer)))
|
||||||
end
|
end
|
||||||
|
|
||||||
function crc32(bytes, chksum)
|
function crc32(bytes, chksum)
|
||||||
@ -45,14 +46,14 @@ function crc32(bytes, chksum)
|
|||||||
|
|
||||||
local length = #bytes
|
local length = #bytes
|
||||||
if type(bytes) == "table" then
|
if type(bytes) == "table" then
|
||||||
local buffer_len = ffi.new('int[1]', length)
|
local buffer_len = _ffi.new('int[1]', length)
|
||||||
local buffer = ffi.new(
|
local buffer = _ffi.new(
|
||||||
string.format("char[%s]", length)
|
string.format("char[%s]", length)
|
||||||
)
|
)
|
||||||
for i=1, length do
|
for i=1, length do
|
||||||
buffer[i - 1] = bytes[i]
|
buffer[i - 1] = bytes[i]
|
||||||
end
|
end
|
||||||
bytes = ffi.string(buffer, buffer_len[0])
|
bytes = _ffi.string(buffer, buffer_len[0])
|
||||||
end
|
end
|
||||||
return _crc32(bytes, chksum)
|
return _crc32(bytes, chksum)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user