eris: add general purpose 'flag bits' to lua tables'

This commit is contained in:
2021-07-25 20:34:38 -04:00
parent 9f342854e1
commit bcd5f044d2
5 changed files with 50 additions and 9 deletions

View File

@@ -898,6 +898,38 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) {
}
LUA_API void lua_setflagbits (lua_State *L, int idx, unsigned char bits) {
TValue *obj;
Table *tab;
lua_lock(L);
obj = index2addr(L, idx);
api_check(L, ttistable(obj), "table expected");
tab = hvalue(obj);
tab->flagbits = bits;
lua_unlock(L);
}
LUA_API void lua_modflagbits (lua_State *L, int idx, unsigned char set, unsigned char clear) {
TValue *obj;
Table *tab;
lua_lock(L);
obj = index2addr(L, idx);
api_check(L, ttistable(obj), "table expected");
tab = hvalue(obj);
tab->flagbits |= set;
tab->flagbits &= (~clear);
lua_unlock(L);
}
LUA_API unsigned char lua_getflagbits (lua_State *L, int idx) {
TValue *obj;
Table *tab;
obj = index2addr(L, idx);
api_check(L, ttistable(obj), "table expected");
tab = hvalue(obj);
return tab->flagbits;
}
/*
** `load' and `call' functions (run Lua code)
*/