aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/text.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/text.h')
-rw-r--r--src/stdlib/text.h44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/stdlib/text.h b/src/stdlib/text.h
index cb3f1b90..6bedcb60 100644
--- a/src/stdlib/text.h
+++ b/src/stdlib/text.h
@@ -21,22 +21,20 @@ typedef struct {
int64_t stack_index;
} TextIter_t;
-#define NEW_TEXT_ITER_STATE(t) (TextIter_t){.stack={{t, 0}}, .stack_index=0}
+#define NEW_TEXT_ITER_STATE(t) (TextIter_t){.stack = {{t, 0}}, .stack_index = 0}
-#define Text(str) ((Text_t){.length=sizeof(str)-1, .tag=TEXT_ASCII, .ascii="" str})
+#define Text(str) ((Text_t){.length = sizeof(str) - 1, .tag = TEXT_ASCII, .ascii = "" str})
static inline Text_t Text_from_str_literal(const char *str) {
- return (Text_t){.length=strlen(str), .tag=TEXT_ASCII, .ascii=str};
+ return (Text_t){.length = strlen(str), .tag = TEXT_ASCII, .ascii = str};
}
-static inline Text_t Text_from_text(Text_t t) {
- return t;
-}
+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)(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__})
+#define Text$concat(...) Text$_concat(sizeof((Text_t[]){__VA_ARGS__}) / sizeof(Text_t), (Text_t[]){__VA_ARGS__})
#define Texts(...) Text$concat(MAP_LIST(convert_to_text, __VA_ARGS__))
// int Text$print(FILE *stream, Text_t t);
Text_t Text$slice(Text_t text, Int_t first_int, Int_t last_int);
@@ -46,12 +44,12 @@ Text_t Text$reversed(Text_t text);
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(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 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, Text_t language);
-PUREFUNC bool Text$is_none(const void *t, const TypeInfo_t*);
+PUREFUNC bool Text$is_none(const void *t, const TypeInfo_t *);
Text_t Text$upper(Text_t text, Text_t language);
Text_t Text$lower(Text_t text, Text_t language);
Text_t Text$title(Text_t text, Text_t language);
@@ -92,8 +90,7 @@ Text_t Text$layout(Text_t text);
void Text$serialize(const void *obj, FILE *out, Table_t *, const TypeInfo_t *);
void Text$deserialize(FILE *in, void *out, List_t *, const TypeInfo_t *);
-MACROLIKE int32_t Text$get_grapheme(Text_t text, int64_t index)
-{
+MACROLIKE int32_t Text$get_grapheme(Text_t text, int64_t index) {
TextIter_t state = NEW_TEXT_ITER_STATE(text);
return Text$get_grapheme_fast(&state, index);
}
@@ -101,14 +98,15 @@ MACROLIKE int32_t Text$get_grapheme(Text_t text, int64_t index)
extern const TypeInfo_t Text$info;
extern Text_t EMPTY_TEXT;
-#define Text$metamethods { \
- .as_text=Text$as_text, \
- .hash=Text$hash, \
- .compare=Text$compare, \
- .equal=Text$equal, \
- .is_none=Text$is_none, \
- .serialize=Text$serialize, \
- .deserialize=Text$deserialize, \
-}
+#define Text$metamethods \
+ { \
+ .as_text = Text$as_text, \
+ .hash = Text$hash, \
+ .compare = Text$compare, \
+ .equal = Text$equal, \
+ .is_none = Text$is_none, \
+ .serialize = Text$serialize, \
+ .deserialize = Text$deserialize, \
+ }
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0