add byteutil library

This commit is contained in:
MihailRis
2024-12-27 08:33:52 +03:00
parent 83d8254d69
commit cca153b66b
6 changed files with 253 additions and 28 deletions
+11
View File
@@ -720,4 +720,15 @@ namespace lua {
}
}
}
inline std::vector<ubyte> require_bytearray(lua::State* L, int idx) {
if (auto* bytearray = lua::touserdata<LuaBytearray>(L, idx)) {
return bytearray->data();
} else if (lua::istable(L, idx)) {
std::vector<ubyte> bytes;
read_bytes_from_table(L, idx, bytes);
return bytes;
}
throw std::runtime_error("bytearray expected");
}
}