Working on diff xmission

This commit is contained in:
2021-08-23 23:34:30 -04:00
parent 7581ac7278
commit 2be6c2c58e
10 changed files with 702 additions and 149 deletions

View File

@@ -215,6 +215,18 @@ using LuaTypeTag = lua_CFunction;
template<typename T>
int LuaTypeTagValue(lua_State *L) { return 0; }
// Lua table types. These deliberately do not overlap
// with lua type values.
//
#define LUA_TT_GENERAL 16
#define LUA_TT_REGISTRY 17
#define LUA_TT_GLOBALENV 18
#define LUA_TT_TANGIBLE 19
#define LUA_TT_TANGIBLEMETA 20
#define LUA_TT_DEADTANGIBLE 21
#define LUA_TT_GLOBALDB 22
#define LUA_TT_CLASS 23
class LuaStack {
private:
int narg_;
@@ -360,6 +372,8 @@ public:
int result();
public:
lua_State *state() const { return L_; }
int type(LuaSlot s) const { return lua_type(L_, s); }
void checktype(LuaSlot s, int type) const { luaL_checktype(L_, s, type); }
@@ -404,17 +418,13 @@ public:
int next(LuaSlot tab, LuaSlot key, LuaSlot value) const;
void makeclass(LuaSlot tab, LuaSlot name) const;
void getclass(LuaSlot tab, LuaSlot name) const;
void makeclass(LuaSlot tab, LuaSlot name) const;
void makeclass(LuaSlot tab, const char *name);
std::string classname(LuaSlot tab);
void movesortablekey(LuaSlot val, lua_State *L);
void movesortablekey(LuaSlot val, LuaStack &other, LuaSlot otherslot);
void makeclass(LuaSlot tab, const char *name) const {
push_any_value(name);
LuaSpecial classname(lua_gettop(L_));
makeclass(tab, classname);
lua_pop(L_, 1);
}
bool rawequal(LuaSlot v1, LuaSlot v2) const {
return lua_rawequal(L_, v1, v2);
@@ -475,21 +485,16 @@ public:
}
// Lua flagbits manipulation: Table types.
enum TableType {
TAB_GENERAL, // A general-purpose table.
TAB_REGISTRY, // The registry table.
TAB_GLOBALENV, // The global environment table.
TAB_TANGIBLE, // A tangible's database.
TAB_TANGIBLEMETA, // A tangible's metatable.
TAB_GLOBALDB, // Part of the globaldb.
TAB_CLASS, // A class which is directly reachable from the global environment.
};
TableType gettabletype(LuaSlot tab);
void settabletype(LuaSlot tab, TableType t);
int gettabletype(LuaSlot tab) const;
void settabletype(LuaSlot tab, int t) const;
// If slot is a table, returns the LUA_TT_XXX table type.
// If slot is not a table, returns the LUA_TXXX general type.
int xtype(LuaSlot slot) const;
// Lua flagbits manipulation: visited bit.
bool getvisited(LuaSlot tab);
void setvisited(LuaSlot tab, bool visited);
bool getvisited(LuaSlot tab) const;
void setvisited(LuaSlot tab, bool visited) const;
};