A little more work on getclass and classname

This commit is contained in:
2026-02-21 23:58:33 -05:00
parent b1a132e252
commit f544888938
2 changed files with 47 additions and 14 deletions

View File

@@ -29,18 +29,42 @@ LuaDefine(makeclass, "classname", "create a class if it doesn't already exist")
return LS.result();
}
LuaDefine(getclass, "x", "get a class table") {
LuaArg classname;
LuaDefine(getclass, "x",
"|Get the class table of X."
"|"
"|The object passed in can be:"
"|"
"| * A valid class table."
"| * A valid, existing class name."
"| * A tangible that has a class."
"| * A normal table with a class metatable."
"|"
"|On success, returns the class table."
"|On failure, throws an error."
) {
LuaArg input;
LuaRet classtab;
LuaDefStack LS(L, classname, classtab);
eng::string err = LS.getclass(classtab, classname);
if (err != "") {
LuaDefStack LS(L, input, classtab);
eng::string err = LS.getclass(classtab, input);
if (!err.empty()) {
luaL_error(L, "%s", err.c_str());
}
return LS.result();
}
LuaDefine(classname, "x", "get a class name") {
LuaDefine(classname, "x",
"|Get the class name of X."
"|"
"|The object passed in can be:"
"|"
"| * A valid class table."
"| * A valid, existing class name."
"| * A tangible that has a class."
"| * A normal table with a class metatable."
"|"
"|If the object is none of these, returns empty string."
"|This function does not throw errors."
) {
LuaArg table;
LuaRet result;
LuaDefStack LS(L, table, result);