diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-11-29 12:55:14 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-11-29 12:55:14 -0500 |
| commit | 4b5e4cd1f21582f5e5fa682ab4e4bff252963468 (patch) | |
| tree | e8fecb01f444c1d392c09255adba5cf6b312b326 /stdlib/text.h | |
| parent | 0b0e0a0a1d41e9574de8dc17c688a4894c5e7f92 (diff) | |
Change how types handle metamethods
Diffstat (limited to 'stdlib/text.h')
| -rw-r--r-- | stdlib/text.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/stdlib/text.h b/stdlib/text.h index 4f23834f..04c867c5 100644 --- a/stdlib/text.h +++ b/stdlib/text.h @@ -10,6 +10,7 @@ #include "datatypes.h" #include "integers.h" #include "optionals.h" +#include "types.h" #include "util.h" typedef struct { @@ -31,11 +32,12 @@ Text_t Text$slice(Text_t text, Int_t first_int, Int_t last_int); Text_t Text$cluster(Text_t text, Int_t index_int); OptionalText_t Text$from_str(const char *str); OptionalText_t Text$from_strn(const char *str, size_t len); -PUREFUNC uint64_t Text$hash(Text_t *text); -PUREFUNC int32_t Text$compare(const Text_t *a, const Text_t *b); -PUREFUNC bool Text$equal(const Text_t *a, const Text_t *b); +PUREFUNC uint64_t Text$hash(const void *text, const TypeInfo_t*); +PUREFUNC int32_t Text$compare(const void *va, const void *vb, const TypeInfo_t*); +PUREFUNC bool Text$equal(const void *a, const void *b, const TypeInfo_t*); PUREFUNC bool Text$equal_values(Text_t a, Text_t b); PUREFUNC bool Text$equal_ignoring_case(Text_t a, Text_t b); +PUREFUNC bool Text$is_none(const void *t, const TypeInfo_t*); Text_t Text$upper(Text_t text); Text_t Text$lower(Text_t text); Text_t Text$title(Text_t text); @@ -67,4 +69,12 @@ MACROLIKE int32_t Text$get_grapheme(Text_t text, int64_t index) extern const TypeInfo_t Text$info; +#define Text$metamethods ((metamethods_t){ \ + .as_text=Text$as_text, \ + .hash=Text$hash, \ + .compare=Text$compare, \ + .equal=Text$equal, \ + .is_none=Text$is_none, \ +}) + // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
