Add support for LuaToken to the LuaCall unreal pipeline

This commit is contained in:
2025-02-05 16:08:34 -05:00
parent 07dbec4bef
commit 4023d19247
4 changed files with 59 additions and 13 deletions

View File

@@ -13,6 +13,16 @@
void push_simple_dynamic(lua_State *L, StreamBuffer *sb) {
SimpleDynamicTag type = sb->read_simple_dynamic_tag();
switch (type) {
case SimpleDynamicTag::STRING: {
std::string_view s = sb->read_string_view();
lua_pushlstring(L, s.data(), s.size());
break;
}
case SimpleDynamicTag::TOKEN: {
LuaToken token(sb->read_string_view());
lua_pushlightuserdata(L, token.voidvalue());
break;
}
case SimpleDynamicTag::NUMBER: {
lua_pushnumber(L, sb->read_double());
break;
@@ -21,11 +31,6 @@ void push_simple_dynamic(lua_State *L, StreamBuffer *sb) {
lua_pushboolean(L, sb->read_bool() ? 1:0);
break;
}
case SimpleDynamicTag::STRING: {
std::string_view s = sb->read_string_view();
lua_pushlstring(L, s.data(), s.size());
break;
}
case SimpleDynamicTag::VECTOR: {
double x = sb->read_double();
double y = sb->read_double();
@@ -46,14 +51,18 @@ void push_simple_dynamic(lua_State *L, StreamBuffer *sb) {
// Given a lua value, try to pack it into the stream buffer as a simple dynamic.
bool encode_simple_dynamic(LuaCoreStack &LS, LuaSlot &slot, StreamBuffer *sb) {
switch (LS.type(slot)) {
case LUA_TNUMBER:
sb->write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
sb->write_double(LS.cknumber(slot));
return true;
case LUA_TSTRING:
sb->write_simple_dynamic_tag(SimpleDynamicTag::STRING);
sb->write_string(LS.ckstringview(slot));
return true;
case LUA_TLIGHTUSERDATA:
sb->write_simple_dynamic_tag(SimpleDynamicTag::TOKEN);
sb->write_string(LS.cktoken(slot).str());
return true;
case LUA_TNUMBER:
sb->write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
sb->write_double(LS.cknumber(slot));
return true;
case LUA_TBOOLEAN:
sb->write_simple_dynamic_tag(SimpleDynamicTag::BOOLEAN);
sb->write_bool(LS.ckboolean(slot));