Final refactor of basebuffer
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
// Read a serialized LuaValue value from the
|
||||
// streambuffer and push it onto the lua stack.
|
||||
void push_simple_dynamic(lua_State *L, StreamBuffer *sb) {
|
||||
LuaValueType type = sb->read_simple_dynamic_tag();
|
||||
LuaValueType type = sb->read_lua_value_type();
|
||||
switch (type) {
|
||||
case LuaValueType::STRING: {
|
||||
std::string_view s = sb->read_string_view();
|
||||
@@ -56,25 +56,25 @@ void push_simple_dynamic(lua_State *L, StreamBuffer *sb) {
|
||||
bool encode_simple_dynamic(LuaCoreStack &LS, LuaSlot &slot, StreamBuffer *sb) {
|
||||
switch (LS.type(slot)) {
|
||||
case LUA_TSTRING:
|
||||
sb->write_simple_dynamic_tag(LuaValueType::STRING);
|
||||
sb->write_lua_value_type(LuaValueType::STRING);
|
||||
sb->write_string(LS.ckstringview(slot));
|
||||
return true;
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
sb->write_simple_dynamic_tag(LuaValueType::TOKEN);
|
||||
sb->write_lua_value_type(LuaValueType::TOKEN);
|
||||
sb->write_string(LS.cktoken(slot).str());
|
||||
return true;
|
||||
case LUA_TNUMBER:
|
||||
sb->write_simple_dynamic_tag(LuaValueType::NUMBER);
|
||||
sb->write_lua_value_type(LuaValueType::NUMBER);
|
||||
sb->write_double(LS.cknumber(slot));
|
||||
return true;
|
||||
case LUA_TBOOLEAN:
|
||||
sb->write_simple_dynamic_tag(LuaValueType::BOOLEAN);
|
||||
sb->write_lua_value_type(LuaValueType::BOOLEAN);
|
||||
sb->write_bool(LS.ckboolean(slot));
|
||||
return true;
|
||||
case LUA_TTABLE: {
|
||||
std::optional<util::DXYZ> xyz = LS.tryxyz(slot);
|
||||
if (!xyz.has_value()) return false;
|
||||
sb->write_simple_dynamic_tag(LuaValueType::VECTOR);
|
||||
sb->write_lua_value_type(LuaValueType::VECTOR);
|
||||
sb->write_dxyz(xyz.value());
|
||||
return true;
|
||||
}
|
||||
@@ -480,7 +480,7 @@ void World::probe_lua_call(int64_t actor_id, int64_t place_id, std::string_view
|
||||
// return value of the function.
|
||||
//
|
||||
int64_t rv_base = retvals->total_writes();
|
||||
retvals->write_simple_dynamic_tag(LuaValueType::STRING);
|
||||
retvals->write_lua_value_type(LuaValueType::STRING);
|
||||
retvals->write_string(msg);
|
||||
|
||||
if (msg.empty()) {
|
||||
@@ -509,7 +509,7 @@ void World::probe_lua_call(int64_t actor_id, int64_t place_id, std::string_view
|
||||
if (!ok) {
|
||||
msg = util::ss("Lua function ",classname,".",funcname," returned a non-serializable value");
|
||||
retvals->unwrite_to(rv_base);
|
||||
retvals->write_simple_dynamic_tag(LuaValueType::STRING);
|
||||
retvals->write_lua_value_type(LuaValueType::STRING);
|
||||
retvals->write_string(msg);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user