diff options
Diffstat (limited to 'src/stdlib')
| -rw-r--r-- | src/stdlib/lists.c | 4 | ||||
| -rw-r--r-- | src/stdlib/pointers.c | 2 | ||||
| -rw-r--r-- | src/stdlib/tables.c | 6 | ||||
| -rw-r--r-- | src/stdlib/types.h | 22 | ||||
| -rw-r--r-- | src/stdlib/util.h | 4 |
5 files changed, 21 insertions, 17 deletions
diff --git a/src/stdlib/lists.c b/src/stdlib/lists.c index 69ac7026..fb6c4fb9 100644 --- a/src/stdlib/lists.c +++ b/src/stdlib/lists.c @@ -773,7 +773,7 @@ public void List$serialize(const void *obj, FILE *out, Table_t *pointers, const List_t list = *(List_t*)obj; int64_t len = list.length; Int64$serialize(&len, out, pointers, &Int64$info); - auto item_serialize = type->ListInfo.item->metamethods.serialize; + serialize_fn_t item_serialize = type->ListInfo.item->metamethods.serialize; if (item_serialize) { for (int64_t i = 0; i < len; i++) item_serialize(list.data + i*list.stride, out, pointers, type->ListInfo.item); @@ -797,7 +797,7 @@ public void List$deserialize(FILE *in, void *obj, List_t *pointers, const TypeIn .data=GC_MALLOC((size_t)(len*padded_size)), .stride=padded_size, }; - auto item_deserialize = type->ListInfo.item->metamethods.deserialize; + deserialize_fn_t item_deserialize = type->ListInfo.item->metamethods.deserialize; if (item_deserialize) { for (int64_t i = 0; i < len; i++) item_deserialize(in, list.data + i*list.stride, pointers, type->ListInfo.item); diff --git a/src/stdlib/pointers.c b/src/stdlib/pointers.c index b674ac6f..daea2dbd 100644 --- a/src/stdlib/pointers.c +++ b/src/stdlib/pointers.c @@ -15,7 +15,7 @@ #include "util.h" public Text_t Pointer$as_text(const void *x, bool colorize, const TypeInfo_t *type) { - auto ptr_info = type->PointerInfo; + __typeof(type->PointerInfo) ptr_info = type->PointerInfo; if (!x) { Text_t typename = generic_as_text(NULL, false, ptr_info.pointed); if (colorize) diff --git a/src/stdlib/tables.c b/src/stdlib/tables.c index 3cb2e742..780aca83 100644 --- a/src/stdlib/tables.c +++ b/src/stdlib/tables.c @@ -437,7 +437,7 @@ PUREFUNC public int32_t Table$compare(const void *vx, const void *vy, const Type Table_t *x = (Table_t*)vx, *y = (Table_t*)vy; assert(type->tag == TableInfo); - auto table = type->TableInfo; + __typeof(type->TableInfo) table = type->TableInfo; // Sort empty tables before non-empty tables: if (x->entries.length == 0 || y->entries.length == 0) @@ -543,7 +543,7 @@ PUREFUNC public uint64_t Table$hash(const void *obj, const TypeInfo_t *type) // Table hashes are computed as: // hash(t.length, (xor: t.keys), (xor: t.values), t.fallback) // Where fallback and default hash to zero if absent - auto table = type->TableInfo; + __typeof(type->TableInfo) table = type->TableInfo; uint64_t keys_hash = 0, values_hash = 0; size_t offset = value_offset(type); if (table.value->size > 0) { @@ -576,7 +576,7 @@ public Text_t Table$as_text(const void *obj, bool colorize, const TypeInfo_t *ty { Table_t *t = (Table_t*)obj; assert(type->tag == TableInfo); - auto table = type->TableInfo; + __typeof(type->TableInfo) table = type->TableInfo; if (!t) { if (table.value != &Void$info) diff --git a/src/stdlib/types.h b/src/stdlib/types.h index ddece7c9..7d61a524 100644 --- a/src/stdlib/types.h +++ b/src/stdlib/types.h @@ -10,14 +10,22 @@ typedef struct TypeInfo_s TypeInfo_t; +typedef void (*serialize_fn_t)(const void*, FILE*, Table_t*, const TypeInfo_t*); +typedef void (*deserialize_fn_t)(FILE*, void*, List_t*, const TypeInfo_t*); +typedef bool (*is_none_fn_t)(const void*, const TypeInfo_t*); +typedef uint64_t (*hash_fn_t)(const void*, const TypeInfo_t*); +typedef int32_t (*compare_fn_t)(const void*, const void*, const TypeInfo_t*); +typedef bool (*equal_fn_t)(const void*, const void*, const TypeInfo_t*); +typedef Text_t (*as_text_fn_t)(const void*, bool, const TypeInfo_t*); + typedef struct { - uint64_t (*hash)(const void*, const TypeInfo_t*); - int32_t (*compare)(const void*, const void*, const TypeInfo_t*); - bool (*equal)(const void*, const void*, const TypeInfo_t*); - Text_t (*as_text)(const void*, bool, const TypeInfo_t*); - bool (*is_none)(const void*, const TypeInfo_t*); - void (*serialize)(const void*, FILE*, Table_t*, const TypeInfo_t*); - void (*deserialize)(FILE*, void*, List_t*, const TypeInfo_t*); + hash_fn_t hash; + compare_fn_t compare; + equal_fn_t equal; + as_text_fn_t as_text; + is_none_fn_t is_none; + serialize_fn_t serialize; + deserialize_fn_t deserialize; } metamethods_t; typedef struct { diff --git a/src/stdlib/util.h b/src/stdlib/util.h index 4cb1b375..25cd49f9 100644 --- a/src/stdlib/util.h +++ b/src/stdlib/util.h @@ -19,10 +19,6 @@ #define IF_DECLARE(decl, expr, block) if (({ decl; expr ? ({ block; 1; }) : 0; })) {} -#ifndef auto -#define auto __auto_type -#endif - #define WHEN(type, subj, var, body) { type var = subj; switch (var.$tag) body } #ifndef public |
