use Bytearray in lua::pushvalue for byte arrays
This commit is contained in:
parent
e3c86cd1da
commit
79f6dcb171
@ -23,6 +23,7 @@ namespace lua {
|
||||
public:
|
||||
LuaBytearray(size_t capacity);
|
||||
LuaBytearray(std::vector<ubyte> buffer);
|
||||
LuaBytearray(const ubyte* data, size_t size);
|
||||
virtual ~LuaBytearray();
|
||||
|
||||
const std::string& getTypeName() const override {
|
||||
|
||||
@ -60,13 +60,7 @@ int lua::pushvalue(State* L, const dv::value& value) {
|
||||
break;
|
||||
case value_type::bytes: {
|
||||
const auto& bytes = value.asBytes();
|
||||
createtable(L, 0, bytes.size());
|
||||
size_t size = bytes.size();
|
||||
for (size_t i = 0; i < size;) {
|
||||
pushinteger(L, bytes[i]);
|
||||
i++;
|
||||
rawseti(L, i);
|
||||
}
|
||||
newuserdata<LuaBytearray>(L, bytes.data(), bytes.size());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,9 @@ LuaBytearray::LuaBytearray(size_t capacity) : buffer(capacity) {
|
||||
LuaBytearray::LuaBytearray(std::vector<ubyte> buffer) : buffer(std::move(buffer)) {
|
||||
}
|
||||
|
||||
LuaBytearray::LuaBytearray(const ubyte* data, size_t size) : buffer(data, data + size) {
|
||||
}
|
||||
|
||||
LuaBytearray::~LuaBytearray() {
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user