Add isclass operator, make inspector print classes nicely
This commit is contained in:
@@ -40,6 +40,30 @@ LuaDefine(source_makeclass, "f") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(source_isclass, "f") {
|
||||
LuaArg table;
|
||||
LuaVar classname, globtab, classtab;
|
||||
LuaRet result;
|
||||
LuaStack LS(L, table, classname, globtab, classtab, result);
|
||||
if (!LS.istable(table)) {
|
||||
LS.set(result, false);
|
||||
return LS.result();
|
||||
}
|
||||
LS.rawget(classname, table, "__class");
|
||||
if (!LS.isstring(classname)) {
|
||||
LS.set(result, false);
|
||||
return LS.result();
|
||||
}
|
||||
LS.getglobaltable(globtab);
|
||||
LS.rawget(classtab, globtab, classname);
|
||||
if (!LS.rawequal(classtab, table)) {
|
||||
LS.set(result, false);
|
||||
return LS.result();
|
||||
}
|
||||
LS.set(result, true);
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(source_maketangible, "f") {
|
||||
LuaArg classname;
|
||||
LuaRet classtab;
|
||||
|
||||
@@ -165,6 +165,9 @@ public:
|
||||
//
|
||||
int source_makeclass(lua_State *L);
|
||||
|
||||
// Return true if the specified table is a class created by 'makeclass'
|
||||
//
|
||||
int source_isclass(lua_State *L);
|
||||
|
||||
#endif // SOURCE_HPP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user