mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 06:21:50 +00:00
eliminated hardcoded types sizes in bytearray-viewers declaratons and replaced on usage ffi.sizeof function
This commit is contained in:
parent
f8a44c023f
commit
3eac247a69
1 changed files with 7 additions and 6 deletions
|
|
@ -298,7 +298,8 @@ local function FFIBytearray_as_string(bytes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function create_FFIview_class(name, typename, typesize)
|
local function create_FFIview_class(name, typename)
|
||||||
|
local typesize = FFI.sizeof(typename)
|
||||||
local ptrtype = typename .. "*"
|
local ptrtype = typename .. "*"
|
||||||
local FFIview_mt = {
|
local FFIview_mt = {
|
||||||
__index = function(self, key)
|
__index = function(self, key)
|
||||||
|
|
@ -343,11 +344,11 @@ local function create_FFIview_class(name, typename, typesize)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local FFII16view = create_FFIview_class("FFII16view", "int16_t", 2)
|
local FFII16view = create_FFIview_class("FFII16view", "int16_t")
|
||||||
local FFIU16view = create_FFIview_class("FFIU16view", "uint16_t", 2)
|
local FFIU16view = create_FFIview_class("FFIU16view", "uint16_t")
|
||||||
local FFII32view = create_FFIview_class("FFII32view", "int32_t", 4)
|
local FFII32view = create_FFIview_class("FFII32view", "int32_t")
|
||||||
local FFIU32view = create_FFIview_class("FFIU32view", "uint32_t", 4)
|
local FFIU32view = create_FFIview_class("FFIU32view", "uint32_t")
|
||||||
local FFIF32view = create_FFIview_class("FFIF32view", "float", 4)
|
local FFIF32view = create_FFIview_class("FFIF32view", "float")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
FFIBytearray = setmetatable(FFIBytearray, FFIBytearray),
|
FFIBytearray = setmetatable(FFIBytearray, FFIBytearray),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue