mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
test direct non-copying reading FFIBytearray in C++ context
This commit is contained in:
parent
d3760d5b7c
commit
dc9ae6e99e
4 changed files with 22 additions and 0 deletions
|
|
@ -215,6 +215,13 @@ FFIBytearray = {
|
|||
}
|
||||
table.merge(FFIBytearray, bytearray_methods)
|
||||
|
||||
local function FFIBytearray_as_ptr(bytes)
|
||||
if type(bytes) == "cdata" then
|
||||
return tostring(bytes.bytes):sub(27), bytes.size
|
||||
end
|
||||
return "0"
|
||||
end
|
||||
|
||||
local function FFIBytearray_as_string(bytes)
|
||||
local t = type(bytes)
|
||||
if t == "cdata" then
|
||||
|
|
@ -283,6 +290,7 @@ local FFIU32view = create_FFIview_class("FFIU32view", "uint32_t", 4)
|
|||
return {
|
||||
FFIBytearray = setmetatable(FFIBytearray, FFIBytearray),
|
||||
FFIBytearray_as_string = FFIBytearray_as_string,
|
||||
FFIBytearray_as_ptr = FFIBytearray_as_ptr,
|
||||
FFIU16view = FFIU16view,
|
||||
FFII16view = FFII16view,
|
||||
FFIU32view = FFIU32view,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue