summaryrefslogtreecommitdiff
path: root/indra/llcommon/lua_function.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-02-08 13:59:19 -0500
committerNat Goodspeed <nat@lindenlab.com>2024-02-08 13:59:19 -0500
commit4e9794bd06660baea6d16779f6e354ca99e11b8a (patch)
tree5437fa6948a8a111b77b8bcf726629d419cdcf1d /indra/llcommon/lua_function.h
parent72e680cfae03aa86659b6c2165e16ce46487097b (diff)
Add required helptext parameter to lua_function() macro.
Extend the LuaFunction::Registry map to store helptext as well as the function pointer. Add help text to every existing lua_function() invocation.
Diffstat (limited to 'indra/llcommon/lua_function.h')
-rw-r--r--indra/llcommon/lua_function.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/indra/llcommon/lua_function.h b/indra/llcommon/lua_function.h
index 82cd91984a..26c399cdd1 100644
--- a/indra/llcommon/lua_function.h
+++ b/indra/llcommon/lua_function.h
@@ -124,19 +124,20 @@ struct LuaPopper
class LuaFunction
{
public:
- LuaFunction(const std::string_view& name, lua_CFunction function);
+ LuaFunction(const std::string_view& name, lua_CFunction function,
+ const std::string_view& helptext);
static void init(lua_State* L);
static lua_CFunction get(const std::string& key);
private:
- using Registry = std::map<std::string, lua_CFunction>;
+ using Registry = std::map<std::string, std::pair<lua_CFunction, std::string>>;
static Registry& getRegistry();
};
/**
- * lua_function(name) is a macro to facilitate defining C++ functions
+ * lua_function(name, helptext) is a macro to facilitate defining C++ functions
* available to Lua. It defines a subclass of LuaFunction and declares a
* static instance of that subclass, thereby forcing the compiler to call its
* constructor at module initialization time. The constructor passes the
@@ -145,13 +146,13 @@ private:
* call() method definition header, to be followed by a method body enclosed
* in curly braces as usual.
*/
-#define lua_function(name) \
-static struct name##_luadecl : public LuaFunction \
-{ \
- name##_luadecl(): LuaFunction(#name, &call) {} \
- static int call(lua_State* L); \
-} name##_luadef; \
-int name##_luadecl::call(lua_State* L)
+#define lua_function(name, helptext) \
+static struct name##_luasub : public LuaFunction \
+{ \
+ name##_luasub(): LuaFunction(#name, &call, helptext) {} \
+ static int call(lua_State* L); \
+} name##_luadecl; \
+int name##_luasub::call(lua_State* L)
// {
// ... supply method body here, referencing 'L' ...
// }