From 3c52a756339a2d96824d21a7d3ad5de7fc1085a0 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 27 Mar 2025 17:26:51 -0400 Subject: 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. --- src/types.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'src/types.c') 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; -- cgit v1.2.3