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 help() function to Lua "builtins." #798

Merged
merged 7 commits into from
Feb 15, 2024
Merged

Conversation

nat-goodspeed
Copy link
Contributor

help() with no argument lists all our viewer builtins.

help(function, function, ...) shows help text for each named function. Each
argument can be either a string or the function in question (e.g. help(help)).

To support Lua-related text containing line breaks, make LLTextEditor::pasteTextWithLinebreaks()
a public template method. Change the existing
implementation, which specifically accepts (const LLWString&), into its
LLWString specialization. The generic template passes llconvert(arg) to that
specialization, the one real implementation.

Make LLFloaterLUADebug methods call pasteTextWithLinebreaks() instead of
insertText(), which ignores newline characters.

To allow help() to accept an actual function as well as a string name, add a
lookup-by-function-pointer map to LuaFunction. (A Lua function does not store
a name.) Make the constructor store an entry in the new lookup map as well as
in the original registry map.

Change LuaFunction::getRegistry() and getRegistered() to getState() and
getRState(), respectively. Each returns a std::pair, but the first binds
non-const references while the second binds const references.

As a function parameter, an assignment expression or a `return` expression,
`ll_convert()` can infer its target type.

When it's important to specify the TOTYPE explicitly, rename the old
`ll_convert()` function template to `ll_convert_to()`. Fix existing usage.
help() with no argument lists all our viewer builtins.

help(function, function, ...) shows help text for each named function. Each
argument can be either a string or the function in question (e.g. help(help)).

To support Lua-related text containing line breaks, make LLTextEditor::
pasteTextWithLinebreaks() a public template method. Change the existing
implementation, which specifically accepts (const LLWString&), into its
LLWString specialization. The generic template passes llconvert(arg) to that
specialization, the one real implementation.

Make LLFloaterLUADebug methods call pasteTextWithLinebreaks() instead of
insertText(), which ignores newline characters.

To allow help() to accept an actual function as well as a string name, add a
lookup-by-function-pointer map to LuaFunction. (A Lua function does not store
a name.) Make the constructor store an entry in the new lookup map as well as
in the original registry map.

Change LuaFunction::getRegistry() and getRegistered() to getState() and
getRState(), respectively. Each returns a std::pair, but the first binds
non-const references while the second binds const references.
@nat-goodspeed
Copy link
Contributor Author

Partially addresses secondlife/viewer-private#189.

leaphelp() (no argument) shows a list of all LEAP APIs.

leaphelp(API) shows further help for a specific API.

Both forms query LuaListener's LeapListener and report its responses. In
future we might reimplement leaphelp() as a Lua function.

Add LuaState::getListener() method, which checks whether there's a LuaListener
associated with this LuaState and returns a pointer if so.

Add LuaState::obtainListener() method, which finds or creates a LuaListener
for this LuaState and returns its pointer.

Both the above use logic migrated from the Lua listen_events() entry point,
which now calls obtainListener() instead.
@nat-goodspeed
Copy link
Contributor Author

Maxim, I also added leaphelp().

@nat-goodspeed
Copy link
Contributor Author

@nat-goodspeed nat-goodspeed merged commit de72b1d into release/luau-scripting Feb 15, 2024
19 checks passed
@nat-goodspeed nat-goodspeed deleted the helpcmd branch February 15, 2024 16:47
@github-actions github-actions bot locked and limited conversation to collaborators Feb 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.

3 participants