Add docs for luaopen_base
This commit is contained in:
@@ -103,10 +103,14 @@ static void source_install_builtins(lua_State *L) {
|
||||
|
||||
// Nuke a few of the builtin functions for sandboxing reasons.
|
||||
LS.getglobaltable(globtab);
|
||||
erase_builtin(LS, globtab, "", "dofile");
|
||||
erase_builtin(LS, globtab, "", "collectgarbage");
|
||||
erase_builtin(LS, globtab, "", "loadfile");
|
||||
erase_builtin(LS, globtab, "", "load");
|
||||
erase_builtin(LS, globtab, "", "loadstring");
|
||||
erase_builtin(LS, globtab, "", "print");
|
||||
erase_builtin(LS, globtab, "", "xpcall");
|
||||
erase_builtin(LS, globtab, "string", "dump");
|
||||
|
||||
|
||||
// Set the metatable for strings.
|
||||
// Normally, this would be done by luaopen_string, but we're
|
||||
@@ -386,6 +390,7 @@ static std::string source_load_lfunctions(lua_State *L) {
|
||||
return errss.str();
|
||||
}
|
||||
|
||||
|
||||
std::string SourceDB::rebuild() {
|
||||
lua_State *L = lua_state_;
|
||||
source_clear_globals(L);
|
||||
@@ -513,6 +518,7 @@ void SourceDB::register_lua_builtins() {
|
||||
lua_close(L);
|
||||
}
|
||||
|
||||
|
||||
std::string SourceDB::function_docs(const LuaStack &LS0, LuaSlot fn) {
|
||||
lua_State *L = LS0.state();
|
||||
LuaVar sourcedb, fname, finfo, code;
|
||||
@@ -702,3 +708,21 @@ LuaDefineBuiltin(string_gmatch, "str, pattern", "iterate over pattern-matched su
|
||||
LuaDefineBuiltin(string_gsub, "str, pattern, replace", "global replace pattern in string");
|
||||
LuaDefineBuiltin(string_match, "str, pattern", "return start and end of pattern in string");
|
||||
LuaDefineBuiltin(string_sub, "str, pos1, pos2", "return substring of str from pos1 to pos2");
|
||||
|
||||
LuaDefineBuiltin(assert, "flag [,message]", "assert that flag is true, if not, raise error");
|
||||
LuaDefineBuiltin(error, "message", "raise an error");
|
||||
LuaDefineBuiltin(getmetatable, "table", "get the metatable of a table");
|
||||
LuaDefineBuiltin(ipairs, "vector", "meant to be used in loops, iterates over a vector");
|
||||
LuaDefineBuiltin(next, "table, k", "returns the key after k and the corresponding value");
|
||||
LuaDefineBuiltin(pairs, "table", "meant to be used in loops, iterates over a table");
|
||||
LuaDefineBuiltin(rawpairs, "table", "meant to be used in loops, iterates over a table");
|
||||
LuaDefineBuiltin(pcall, "function, arg1, arg2, ...", "call the function, catching any errors");
|
||||
LuaDefineBuiltin(rawequal, "val1, val2", "return true if the two values are the same object");
|
||||
LuaDefineBuiltin(rawlen, "obj", "return the length of a vector or string");
|
||||
LuaDefineBuiltin(rawget, "table, key", "get a table entry, ignoring metamethods");
|
||||
LuaDefineBuiltin(rawset, "table, key, value", "set a table entry, ignoring metamethods");
|
||||
LuaDefineBuiltin(select, "n, arg1, arg2, ...", "return the nth argument");
|
||||
LuaDefineBuiltin(setmetatable, "table, meta", "set the metatable of the specified table");
|
||||
LuaDefineBuiltin(tonumber, "str", "convert a string to a number");
|
||||
LuaDefineBuiltin(type, "obj", "return the type of obj as a string");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user