replace Bytearray with FFI implementation

This commit is contained in:
MihailRis
2025-04-07 20:48:12 +03:00
parent 794aa5b9cd
commit 303e861fbb
16 changed files with 125 additions and 333 deletions
+3 -3
View File
@@ -99,7 +99,7 @@ static int pack(lua::State* L, const char* format, bool usetable) {
}
return 1;
} else {
return lua::newuserdata<lua::LuaBytearray>(L, builder.build());
return lua::create_bytearray(L, builder.build());
}
}
@@ -130,8 +130,8 @@ static int count_elements(const char* format) {
static int l_unpack(lua::State* L) {
const char* format = lua::require_string(L, 1);
int count = count_elements(format);
auto bytes = lua::require_bytearray(L, 2);
ByteReader reader(bytes);
auto bytes = lua::bytearray_as_string(L, 2);
ByteReader reader(reinterpret_cast<const ubyte*>(bytes.data()), bytes.size());
bool bigEndian = false;
for (size_t i = 0; format[i]; i++) {