mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Merge branch 'main' into volume-renderer
This commit is contained in:
commit
cf69d3e8f4
4 changed files with 18 additions and 17 deletions
|
|
@ -231,44 +231,45 @@ local function FFIBytearray_as_string(bytes)
|
|||
end
|
||||
|
||||
local function create_FFIview_class(name, typename, typesize)
|
||||
local FFIU16view_mt = {
|
||||
local ptrtype = typename .. "*"
|
||||
local FFIview_mt = {
|
||||
__index = function(self, key)
|
||||
if key <= 0 or key > self.size then
|
||||
if key == 'size' then
|
||||
return self.bytes.size / typesize
|
||||
end
|
||||
if key <= 0 or key > self.bytes.size / typesize then
|
||||
return
|
||||
end
|
||||
return self.ptr[key - 1]
|
||||
local ptr = FFI.cast(ptrtype, self.bytes.bytes)
|
||||
return ptr[key - 1]
|
||||
end,
|
||||
__newindex = function(self, key, value)
|
||||
if key == self.size + 1 then
|
||||
return append(self, value)
|
||||
elseif key <= 0 or key > self.size then
|
||||
if key <= 0 or key > self.bytes.size / typesize then
|
||||
return
|
||||
end
|
||||
self.ptr[key - 1] = value
|
||||
local ptr = FFI.cast(ptrtype, self.bytes.bytes)
|
||||
ptr[key - 1] = value
|
||||
end,
|
||||
__len = function(self)
|
||||
return self.size
|
||||
return self.bytes.size / typesize
|
||||
end,
|
||||
__tostring = function(self)
|
||||
return string.format(name .. "[%s]{...}", tonumber(self.size))
|
||||
return string.format(name .. "[%s]{...}", tonumber(self.bytes.size / typesize))
|
||||
end,
|
||||
__ipairs = function(self)
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
if i <= self.size then
|
||||
if i <= self.bytes.size / typesize then
|
||||
return i, self.ptr[i - 1]
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
return function (bytes)
|
||||
local ptr = FFI.cast(typename .. "*", bytes.bytes)
|
||||
local x = setmetatable({
|
||||
bytes=bytes,
|
||||
ptr=ptr,
|
||||
size=math.floor(bytes.size / typesize),
|
||||
}, FFIU16view_mt)
|
||||
}, FFIview_mt)
|
||||
return x
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ function events.emit(event, ...)
|
|||
for _, func in ipairs(handlers) do
|
||||
local status, newres = xpcall(func, __vc__error, ...)
|
||||
if not status then
|
||||
debug.error("error in event ("..event..") handler: "..newres)
|
||||
debug.error("error in event ("..event..") handler"..(newres and (": "..tostring(newres)) or ""))
|
||||
else
|
||||
result = result or newres
|
||||
end
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ function io_stream:read_line()
|
|||
end
|
||||
|
||||
function io_stream:write_line(str)
|
||||
self:__write(utf8.tobytes(str .. LF))
|
||||
self:__write(utf8.tobytes(str .. "\n"))
|
||||
end
|
||||
|
||||
function io_stream:read(arg, useTable)
|
||||
|
|
|
|||
|
|
@ -538,7 +538,7 @@ audio.__reset_fetch_buffer = nil
|
|||
core.get_core_token = audio.input.__get_core_token
|
||||
|
||||
local function __vc__process_post_runnables()
|
||||
if #__post_runnables then
|
||||
if #__post_runnables > 0 then
|
||||
for _, func in ipairs(__post_runnables) do
|
||||
local status, result = xpcall(func, __vc__error)
|
||||
if not status then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue