feature: goto definition (#11143) 4f005f715e Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
diff --git a/.rive_head b/.rive_head index 58fcd84..c07112e 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -d4dfc63c3a25171f7915d383e242441f5834f850 +4f005f715eedd281cc911e739b42109fafee0633
diff --git a/src/lua/rive_lua_libs.cpp b/src/lua/rive_lua_libs.cpp index 0684315..b0662dd 100644 --- a/src/lua/rive_lua_libs.cpp +++ b/src/lua/rive_lua_libs.cpp
@@ -137,6 +137,8 @@ {LUA_OSLIBNAME, luaopen_os}, {LUA_STRLIBNAME, luaopen_string}, {LUA_UTF8LIBNAME, luaopen_utf8}, + {LUA_BUFFERLIBNAME, luaopen_buffer}, + {LUA_BITLIBNAME, luaopen_bit32}, {"math", luaopen_rive_math}, {"renderer", luaopen_rive_renderer_library}, {"properties", luaopen_rive_properties},
diff --git a/tests/unit_tests/runtime/scripting/scripting_require_check.cpp b/tests/unit_tests/runtime/scripting/scripting_require_check.cpp index 3333e0b..d3c7e4f 100644 --- a/tests/unit_tests/runtime/scripting/scripting_require_check.cpp +++ b/tests/unit_tests/runtime/scripting/scripting_require_check.cpp
@@ -71,4 +71,72 @@ ScriptingTest vm("return os.date(\"!%Y-%m-%d %H:%M:%S\",1761608005)\n", 1); auto result = lua_tostring(vm.state(), -1); CHECK(result == std::string("2025-10-27 23:33:25")); +} + +TEST_CASE("buffer API is available", "[scripting]") +{ + // Test buffer creation and basic operations + ScriptingTest vm("local buf = buffer.create(10)\n" + "buffer.writei8(buf, 0, 42)\n" + "local value = buffer.readi8(buf, 0)\n" + "return value", + 1); + lua_Number result = lua_tonumber(vm.state(), -1); + CHECK(result == 42); +} + +TEST_CASE("buffer fromstring and tostring work", "[scripting]") +{ + // Test buffer string conversion + ScriptingTest vm("local buf = buffer.fromstring('hello')\n" + "return buffer.tostring(buf)", + 1); + auto result = lua_tostring(vm.state(), -1); + CHECK(result == std::string("hello")); +} + +TEST_CASE("buffer len works", "[scripting]") +{ + // Test buffer length + ScriptingTest vm("local buf = buffer.create(20)\n" + "return buffer.len(buf)", + 1); + lua_Number result = lua_tonumber(vm.state(), -1); + CHECK(result == 20); +} + +TEST_CASE("bit32 API is available", "[scripting]") +{ + // Test bit32 bitwise operations + ScriptingTest vm("local result = bit32.band(5, 3)\n" + "return result", + 1); + lua_Number result = lua_tonumber(vm.state(), -1); + CHECK(result == 1); // 5 & 3 = 1 +} + +TEST_CASE("bit32 bor and bxor work", "[scripting]") +{ + // Test bit32 OR and XOR operations + ScriptingTest vm("local orResult = bit32.bor(5, 3)\n" + "local xorResult = bit32.bxor(5, 3)\n" + "return orResult, xorResult", + 2); + lua_Number orResult = lua_tonumber(vm.state(), -2); + lua_Number xorResult = lua_tonumber(vm.state(), -1); + CHECK(orResult == 7); // 5 | 3 = 7 + CHECK(xorResult == 6); // 5 ^ 3 = 6 +} + +TEST_CASE("bit32 shifts work", "[scripting]") +{ + // Test bit32 shift operations + ScriptingTest vm("local leftShift = bit32.lshift(1, 3)\n" + "local rightShift = bit32.rshift(8, 3)\n" + "return leftShift, rightShift", + 2); + lua_Number leftShift = lua_tonumber(vm.state(), -2); + lua_Number rightShift = lua_tonumber(vm.state(), -1); + CHECK(leftShift == 8); // 1 << 3 = 8 + CHECK(rightShift == 1); // 8 >> 3 = 1 } \ No newline at end of file