Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add leap.lua module to mediate LEAP request/response viewer interactions. #1004

Merged
merged 20 commits into from
Mar 15, 2024

Conversation

nat-goodspeed
Copy link
Collaborator

@nat-goodspeed nat-goodspeed commented Mar 15, 2024

leap.lua depends on coro.lua (to organize Lua coroutines) and ErrorQueue.lua.

ErrorQueue.lua is built on WaitQueue.lua, which is built on Queue.lua. Add qtest.lua to exercise these.

Add an llluamanager_test.cpp test to exercise leap.lua. This needs a special build-test-time require() path to load Lua modules in the viewer's source tree.

Given leap.lua, add viewer API modules LLFloaterAbout.lua (with test_LLFloaterAbout.lua script), LLGesture.lua (with test_LLGesture.lua script) and UI.lua.

Also add util.lua and inspect.lua for general purposes.

Defend against a Lua chunk run by LuaState::expr() returning a Lua object not convertible to LLSD.

This is an unusual use case in which lua_tollsd() is called by C++ code
without the Lua runtime farther up the call stack.
Also qtest.lua to exercise the queue classes and inspect.lua (from
https://github.com/kikito/inspect.lua) for debugging.
For WaitQueue, nail down the mechanism for declaring a subclass and for
calling a base-class method from a subclass override. Break out new
_wake_waiters() method from Enqueue(): we need to do the same from close(), in
case there are waiting consumers. Also, in Lua, 0 is not false.

Instead of bundling a normal/error flag with every queued value, make
ErrorQueue overload its _closed attribute. Once you call ErrorQueue:Error(),
every subsequent Dequeue() call by any consumer will re-raise the same error.

util.count() literally counts entries in a table, since #t is documented to be
unreliable. (If you create a list with 5 entries and delete the middle one, #t
might return 2 or it might return 5, but it won't return 4.)

util.join() fixes a curious omission from Luau's string library: like Python's
str.join(), it concatenates all the strings from a list with an optional
separator. We assume that incrementally building a list of strings and then
doing a single allocation for the desired result string is cheaper than
reallocating each of a sequence of partial concatenated results.

Add qtest test that posts individual items to a WaitQueue, waking waiting
consumers to retrieve the next available result. Add test proving that calling
ErrorQueue:Error() propagates the error to all consumers.
This helps to explain the lengthy delay when running autobuild configure in a
new developer work area.
Sketch in an initial test that requires one of our bundled Lua modules.

Each time we run Lua, report any error returned by the Lua engine.

Use llcoro::suspendUntilEventOn(LLEventMailDrop) as shorthand for initializing
an explicit LLTempBoundListener with a listen() call with a lambda.
That is, skip coroutines that have gone dead since they decided to wait on
Dequeue().
Add usage comments at the top.

Add leap.done() function.

Make leap.process() honor leap.done(), also recognize an incoming nil from the
viewer to mean it's all done.

Support leap.WaitFor with nil priority to mean "don't self-enable." This
obviates leap.WaitForReqid:enable() and disable() overrides that do nothing.

Add diagnostic logging.
coro.resume() checks the ok boolean returned by coroutine.resume() and, if not
ok, propagates the error. This avoids coroutine errors getting swallowed.
request() test ensures that the response for a given reqid is routed to the
correct coroutine even when responses arrive out of order.
We weren't passing the WaitForReqid instance to WaitForReqid:wait().

Also remove 'reqid' from responses returned by leap.request() and generate().
@nat-goodspeed nat-goodspeed merged commit c5dec70 into release/luau-scripting Mar 15, 2024
19 checks passed
@nat-goodspeed nat-goodspeed deleted the lua-leap branch March 15, 2024 18:56
@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants