Deques now have metatables, fixed deque unit tests

This commit is contained in:
2021-07-12 16:32:58 -04:00
parent 7290beee34
commit 3fc76afc09
2 changed files with 38 additions and 25 deletions

View File

@@ -204,11 +204,11 @@ int deque_make_room(lua_State *L, int deque, int left, int fill, int max) {
return max;
}
LuaDefine(deque_create, "c") {
LuaRet rdeque;
LuaStack LS(L, rdeque);
const int imax = 8;
LuaVar classobj;
LuaStack LS(L, rdeque, classobj);
const int imax = 4;
LS.createtable(rdeque, DEQUE_BASE + imax - 1, 0);
LS.rawseti(rdeque, DEQUE_LEFT, 0);
LS.rawseti(rdeque, DEQUE_FILL, 0);
@@ -216,6 +216,8 @@ LuaDefine(deque_create, "c") {
for (int i = 0; i < imax; i++) {
LS.rawseti(rdeque, DEQUE_BASE + i, 0);
}
LS.makeclass(classobj, "deque");
LS.setmetatable(rdeque, classobj);
return LS.result();
}