diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-01 13:08:11 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-01 13:08:11 -0400 |
| commit | c0c6fe863f8e074cbe8297b5da2a476f455b6518 (patch) | |
| tree | 276bd5a52eec5eb6b2d4980adefb1bf5255951b6 /src/stdlib/text.h | |
| parent | a571ccffd795a595e990a3405dcf977aafc33c6c (diff) | |
Make Texts() macro a bit more flexible.
Diffstat (limited to 'src/stdlib/text.h')
| -rw-r--r-- | src/stdlib/text.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/stdlib/text.h b/src/stdlib/text.h index 5fa95675..23ceefea 100644 --- a/src/stdlib/text.h +++ b/src/stdlib/text.h @@ -7,7 +7,9 @@ #include <stdint.h> #include "datatypes.h" +#include "integers.h" // IWYU pragma: export #include "mapmacro.h" +#include "nums.h" // IWYU pragma: export #include "types.h" #include "util.h" @@ -31,7 +33,17 @@ static inline Text_t Text_from_str_literal(const char *str) { static inline Text_t Text_from_text(Text_t t) { return t; } -#define convert_to_text(x) _Generic(x, Text_t: Text_from_text, char *: Text$from_str, const char *: Text$from_str)(x) +#define convert_to_text(x) \ + _Generic(x, \ + Text_t: Text_from_text, \ + char *: Text$from_str, \ + const char *: Text$from_str, \ + int8_t: Int8$value_as_text, \ + int16_t: Int16$value_as_text, \ + int32_t: Int32$value_as_text, \ + int64_t: Int64$value_as_text, \ + double: Num$value_as_text, \ + float: Num32$value_as_text)(x) Text_t Text$_concat(int n, Text_t items[n]); #define Text$concat(...) Text$_concat(sizeof((Text_t[]){__VA_ARGS__}) / sizeof(Text_t), (Text_t[]){__VA_ARGS__}) |
