diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-02-13 12:24:13 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-02-13 12:24:13 -0500 |
commit | 3044a6e62e628fdb3c4b8832fd23e566216d7bb9 (patch) | |
tree | 9a398d435bf16afae597add1204cc1e9742778ef /indra/llcommon/lua_function.h | |
parent | c8ca31de41b29a43789a8213645fcdf52c9a29a9 (diff) |
Add help() function to Lua "builtins."
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.
Diffstat (limited to 'indra/llcommon/lua_function.h')
-rw-r--r-- | indra/llcommon/lua_function.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/indra/llcommon/lua_function.h b/indra/llcommon/lua_function.h index 3129b5eaca..b3a0bb0d7e 100644 --- a/indra/llcommon/lua_function.h +++ b/indra/llcommon/lua_function.h @@ -131,11 +131,13 @@ public: static lua_CFunction get(const std::string& key); +protected: using Registry = std::map<std::string, std::pair<lua_CFunction, std::string>>; - static const Registry& getRegistered() { return getRegistry(); } + using Lookup = std::map<lua_CFunction, std::string>; + static std::pair<const Registry&, const Lookup&> getRState() { return getState(); } private: - static Registry& getRegistry(); + static std::pair<Registry&, Lookup&> getState(); }; /** |