Get rid of getfield/setfield

This commit is contained in:
2021-02-10 16:47:45 -05:00
parent 3883f86dee
commit eefe1bd58a
5 changed files with 63 additions and 61 deletions

View File

@@ -48,10 +48,10 @@ void LuaStack::register_all_userdata(lua_State *L) {
LS.set(classname, name);
if (mode.find('t') != std::string::npos) { // Register type
LS.newtable(tab);
LS.setfield(tab, "type", name);
LS.setfield(tab, "__gc", collect_tagged_pointer);
LS.rawset(tab, "type", name);
LS.rawset(tab, "__gc", collect_tagged_pointer);
LS.makeclass(classtab, classname);
LS.setfield(tab, "__index", classtab);
LS.rawset(tab, "__index", classtab);
LS.setlightuserdata(lud, (void *)tag);
LS.rawset(LuaRegistry, lud, tab);
}
@@ -216,8 +216,8 @@ void LuaStack::makeclass(LuaSlot classtab, LuaSlot classname) const {
}
// Repair the special fields.
setfield(classtab, "__index", classtab);
setfield(classtab, "__class", classname);
rawset(classtab, "__index", classtab);
rawset(classtab, "__class", classname);
}
void LuaStack::makesubtable(LuaSlot sub, LuaSlot tab, const char *name) const {
@@ -254,7 +254,7 @@ LuaDefine(system_type, "f") {
int type = LS.type(obj);
if (type == LUA_TUSERDATA) {
LS.getmetatable(mt, obj);
LS.getfield(tname, mt, "type");
LS.rawget(tname, mt, "type");
} else {
LS.set(tname, lua_typename(L, type));
}