diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-17 22:18:21 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-17 22:18:21 -0400 |
| commit | ca62aa365faee27895f8cb1eccddd7af8a7d15c9 (patch) | |
| tree | 22d191de7f16c889c407ef92f27ef9efb3303998 /stdlib | |
| parent | 80ca0f0b1ba04c1aa3d7bb1a62928dbcecbb3bd8 (diff) | |
Switch types to use wordier syntax `[T]` -> `List(T)` etc
Diffstat (limited to 'stdlib')
| -rw-r--r-- | stdlib/arrays.c | 2 | ||||
| -rw-r--r-- | stdlib/arrays.h | 4 | ||||
| -rw-r--r-- | stdlib/tables.c | 12 |
3 files changed, 9 insertions, 9 deletions
diff --git a/stdlib/arrays.c b/stdlib/arrays.c index 41d46741..1e1ce5f0 100644 --- a/stdlib/arrays.c +++ b/stdlib/arrays.c @@ -555,7 +555,7 @@ public Text_t Array$as_text(const void *obj, bool colorize, const TypeInfo_t *ty { Array_t *arr = (Array_t*)obj; if (!arr) - return Text$concat(Text("["), generic_as_text(NULL, false, type->ArrayInfo.item), Text("]")); + return Text$concat(Text("List("), generic_as_text(NULL, false, type->ArrayInfo.item), Text(")")); const TypeInfo_t *item_type = type->ArrayInfo.item; Text_t text = Text("["); diff --git a/stdlib/arrays.h b/stdlib/arrays.h index 332a1db0..6b88b1ee 100644 --- a/stdlib/arrays.h +++ b/stdlib/arrays.h @@ -36,7 +36,7 @@ #define Array_set(item_type, arr, index, value, start, end) \ Array_lvalue(item_type, arr_expr, index, start, end) = value #define is_atomic(x) _Generic(x, bool: true, int8_t: true, int16_t: true, int32_t: true, int64_t: true, float: true, double: true, default: false) -#define TypedArray(t, ...) ({ t items[] = {__VA_ARGS__}; \ +#define TypedList(t, ...) ({ t items[] = {__VA_ARGS__}; \ (Array_t){.length=sizeof(items)/sizeof(items[0]), \ .stride=(int64_t)&items[1] - (int64_t)&items[0], \ .data=memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \ @@ -48,7 +48,7 @@ .data=memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \ .atomic=0, \ .data_refcount=0}; }) -#define Array(x, ...) ({ __typeof(x) items[] = {x, __VA_ARGS__}; \ +#define List(x, ...) ({ __typeof(x) items[] = {x, __VA_ARGS__}; \ (Array_t){.length=sizeof(items)/sizeof(items[0]), \ .stride=(int64_t)&items[1] - (int64_t)&items[0], \ .data=memcpy(is_atomic(x) ? GC_MALLOC_ATOMIC(sizeof(items)) : GC_MALLOC(sizeof(items)), items, sizeof(items)), \ diff --git a/stdlib/tables.c b/stdlib/tables.c index 97419327..73a3af19 100644 --- a/stdlib/tables.c +++ b/stdlib/tables.c @@ -582,16 +582,16 @@ public Text_t Table$as_text(const void *obj, bool colorize, const TypeInfo_t *ty if (!t) { if (table.value != &Void$info) return Text$concat( - Text("{"), + Text("Table("), generic_as_text(NULL, false, table.key), - Text(","), + Text(", "), generic_as_text(NULL, false, table.value), - Text("}")); + Text(")")); else return Text$concat( - Text("{"), + Text("Set("), generic_as_text(NULL, false, table.key), - Text("}")); + Text(")")); } int64_t val_off = (int64_t)value_offset(type); @@ -606,7 +606,7 @@ public Text_t Table$as_text(const void *obj, bool colorize, const TypeInfo_t *ty } if (t->fallback) { - text = Text$concat(text, Text("; fallback="), Table$as_text(t->fallback, colorize, type)); + text = Text$concat(text, colorize ? Text("; \033[33mfallback\033[m=") : Text("; fallback="), Table$as_text(t->fallback, colorize, type)); } text = Text$concat(text, Text("}")); |
