add Bytearray '__pairs` metamethod

This commit is contained in:
MihailRis 2025-05-01 18:20:02 +03:00
parent 50aae8b98b
commit 805e3fdd7d
2 changed files with 3 additions and 2 deletions

View File

@ -166,11 +166,12 @@ local bytearray_mt = {
end
end
}
bytearray_mt.__pairs = bytearray_mt.__ipairs
local bytearray_type = FFI.metatype("bytearray_t", bytearray_mt)
local FFIBytearray = {
__call = function (n)
__call = function (self, n)
local t = type(n)
if t == "string" then
local buffer = malloc(#n)

View File

@ -279,7 +279,7 @@ end
local bytearray = require "core:internal/bytearray"
Bytearray = bytearray.FFIBytearray
Bytearray_as_string = bytearray.FFIBytearray_as_string
Bytearray_construct = Bytearray.__call
Bytearray_construct = function(...) return Bytearray(...) end
ffi = nil
math.randomseed(time.uptime() * 1536227939)