mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 22:11: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
|
end
|
||||||
|
|
||||||
local function create_FFIview_class(name, typename, typesize)
|
local function create_FFIview_class(name, typename, typesize)
|
||||||
local FFIU16view_mt = {
|
local ptrtype = typename .. "*"
|
||||||
|
local FFIview_mt = {
|
||||||
__index = function(self, key)
|
__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
|
return
|
||||||
end
|
end
|
||||||
return self.ptr[key - 1]
|
local ptr = FFI.cast(ptrtype, self.bytes.bytes)
|
||||||
|
return ptr[key - 1]
|
||||||
end,
|
end,
|
||||||
__newindex = function(self, key, value)
|
__newindex = function(self, key, value)
|
||||||
if key == self.size + 1 then
|
if key <= 0 or key > self.bytes.size / typesize then
|
||||||
return append(self, value)
|
|
||||||
elseif key <= 0 or key > self.size then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.ptr[key - 1] = value
|
local ptr = FFI.cast(ptrtype, self.bytes.bytes)
|
||||||
|
ptr[key - 1] = value
|
||||||
end,
|
end,
|
||||||
__len = function(self)
|
__len = function(self)
|
||||||
return self.size
|
return self.bytes.size / typesize
|
||||||
end,
|
end,
|
||||||
__tostring = function(self)
|
__tostring = function(self)
|
||||||
return string.format(name .. "[%s]{...}", tonumber(self.size))
|
return string.format(name .. "[%s]{...}", tonumber(self.bytes.size / typesize))
|
||||||
end,
|
end,
|
||||||
__ipairs = function(self)
|
__ipairs = function(self)
|
||||||
local i = 0
|
local i = 0
|
||||||
return function()
|
return function()
|
||||||
i = i + 1
|
i = i + 1
|
||||||
if i <= self.size then
|
if i <= self.bytes.size / typesize then
|
||||||
return i, self.ptr[i - 1]
|
return i, self.ptr[i - 1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
return function (bytes)
|
return function (bytes)
|
||||||
local ptr = FFI.cast(typename .. "*", bytes.bytes)
|
|
||||||
local x = setmetatable({
|
local x = setmetatable({
|
||||||
bytes=bytes,
|
bytes=bytes,
|
||||||
ptr=ptr,
|
}, FFIview_mt)
|
||||||
size=math.floor(bytes.size / typesize),
|
|
||||||
}, FFIU16view_mt)
|
|
||||||
return x
|
return x
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ function events.emit(event, ...)
|
||||||
for _, func in ipairs(handlers) do
|
for _, func in ipairs(handlers) do
|
||||||
local status, newres = xpcall(func, __vc__error, ...)
|
local status, newres = xpcall(func, __vc__error, ...)
|
||||||
if not status then
|
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
|
else
|
||||||
result = result or newres
|
result = result or newres
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ function io_stream:read_line()
|
||||||
end
|
end
|
||||||
|
|
||||||
function io_stream:write_line(str)
|
function io_stream:write_line(str)
|
||||||
self:__write(utf8.tobytes(str .. LF))
|
self:__write(utf8.tobytes(str .. "\n"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function io_stream:read(arg, useTable)
|
function io_stream:read(arg, useTable)
|
||||||
|
|
|
||||||
|
|
@ -538,7 +538,7 @@ audio.__reset_fetch_buffer = nil
|
||||||
core.get_core_token = audio.input.__get_core_token
|
core.get_core_token = audio.input.__get_core_token
|
||||||
|
|
||||||
local function __vc__process_post_runnables()
|
local function __vc__process_post_runnables()
|
||||||
if #__post_runnables then
|
if #__post_runnables > 0 then
|
||||||
for _, func in ipairs(__post_runnables) do
|
for _, func in ipairs(__post_runnables) do
|
||||||
local status, result = xpcall(func, __vc__error)
|
local status, result = xpcall(func, __vc__error)
|
||||||
if not status then
|
if not status then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue