A little more work on getclass and classname
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user