new built-in keysof and rewrote the json parser

This commit is contained in:
cozis
2022-12-06 22:43:13 +01:00
parent 7e3eb6364a
commit 380b8a8917
11 changed files with 521 additions and 219 deletions
+12 -1
View File
@@ -48,7 +48,8 @@ static void walk(Object *self, void (*callback)(Object **referer, void *userp),
static void walkexts(Object *self, void (*callback)(void **referer, unsigned int size, void *userp), void *userp);
static Object *copy(Object *self, Heap *heap, Error *err);
static int hash(Object *self);
static bool istypeof(Object *self, Object *other, Heap *heap, Error *error);
static bool istypeof(Object *self, Object *other, Heap *heap, Error *error);
static Object *keysof(Object *self, Heap *heap, Error *error);
static TypeObject t_map = {
.base = (Object) { .type = &t_type, .flags = Object_STATIC },
@@ -60,11 +61,21 @@ static TypeObject t_map = {
.insert = insert,
.count = count,
.print = print,
.keysof = keysof,
.istypeof = istypeof,
.walk = walk,
.walkexts = walkexts,
};
static Object*
keysof(Object *self,
Heap *heap,
Error *error)
{
MapObject *map = (MapObject*) self;
return Object_NewList2(map->count, map->keys, heap, error);
}
static bool
istypeof(Object *self,
Object *other,