Initial revision of lua 'doc' function

This commit is contained in:
2021-12-15 23:03:43 -05:00
parent e0001127c7
commit 1cfdb4fa09
22 changed files with 301 additions and 199 deletions

View File

@@ -126,7 +126,7 @@
// exposed to lua. It creates a global registry of functions
// created with LuaDefine. You use it like so:
//
// LuaDefine(function_name, "modebits") {
// LuaDefine(function_name, "arguments", "documentation") {
// ...
// }
//
@@ -450,6 +450,9 @@ public:
lua_rawseti(L_, tab, key);
}
// Get function name
std::string get_function_name(LuaSlot ls);
// Lua flagbits manipulation: Table types.
int gettabletype(LuaSlot tab) const;
void settabletype(LuaSlot tab, int t) const;
@@ -466,8 +469,9 @@ public:
class LuaFunctionReg {
private:
const char *mode_;
const char *name_;
const char *args_;
const char *docs_;
lua_CFunction func_;
LuaFunctionReg *next_;
@@ -476,18 +480,20 @@ private:
public:
using List = std::vector<const LuaFunctionReg *>;
LuaFunctionReg(const char *mode, const char *n, lua_CFunction f);
LuaFunctionReg(const char *name, const char *args, const char *docs, lua_CFunction f);
static List all();
static const LuaFunctionReg *lookup(lua_CFunction fn);
const char *get_mode() const { return mode_; }
const char *get_name() const { return name_; }
const char *get_args() const { return args_; }
const char *get_docs() const { return docs_; }
lua_CFunction get_func() const { return func_; }
};
#define LuaDefine(name, mode) \
#define LuaDefine(name, args, docs) \
int lfn_##name(lua_State *L); \
LuaFunctionReg reg_##name(mode, #name, lfn_##name); \
LuaFunctionReg reg_##name(#name, args, docs, lfn_##name); \
int lfn_##name(lua_State *L)