diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-27 17:26:51 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-27 17:26:51 -0400 |
| commit | 3c52a756339a2d96824d21a7d3ad5de7fc1085a0 (patch) | |
| tree | e5299a25ebb76186d6372b700710d7c8c7fe0728 /src/types.c | |
| parent | 2186e84de0c0fd47ba48eaa35f74ea2754c3b81f (diff) | |
Deprecate custom printf specifiers in favor of print() function that
uses _Generic() to generically convert any value to a string or print as
a string.
Diffstat (limited to 'src/types.c')
| -rw-r--r-- | src/types.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/types.c b/src/types.c index 7e5f262d..e3f3d11c 100644 --- a/src/types.c +++ b/src/types.c @@ -105,6 +105,11 @@ CORD type_to_cord(type_t *t) { } } +const char *type_to_str(type_t *t) +{ + return CORD_to_const_char_star(type_to_cord(t)); +} + PUREFUNC const char *get_type_name(type_t *t) { switch (t->tag) { @@ -115,23 +120,6 @@ PUREFUNC const char *get_type_name(type_t *t) } } -int printf_pointer_size(const struct printf_info *info, size_t n, int argtypes[n], int sizes[n]) -{ - if (n < 1) return -1; - (void)info; - argtypes[0] = PA_POINTER; - sizes[0] = sizeof(void*); - return 1; -} - -int printf_type(FILE *stream, const struct printf_info *info, const void *const args[]) -{ - (void)info; - type_t *t = *(type_t**)args[0]; - if (!t) return fputs("(null)", stream); - return CORD_put(type_to_cord(t), stream); -} - bool type_eq(type_t *a, type_t *b) { if (a == b) return true; |
