string16 improvements

This commit is contained in:
Krzosa Karol
2025-04-04 08:25:47 +02:00
parent f6d5a1cf81
commit f3aa52ba3d
34 changed files with 637 additions and 699 deletions

View File

@@ -145,7 +145,7 @@ fn_test void test_hash_table(void) {
assert(s8_are_equal(node->kv.key_string, s));
}
ht_node_t *node = ht_search_string_ex(ht, s8_lit("memes"));
ht_node_t *node = ht_search_string_ex(ht, s8("memes"));
assert(node == NULL);
}

View File

@@ -1,7 +1,7 @@
#define lex_error(TOKEN, STRING) do {\
errorf(STRING);\
TOKEN->kind = lex_kind_error;\
TOKEN->string = s8_lit(STRING);\
TOKEN->string = s8(STRING);\
} while (0)
fn lexer_t lex_make(s8_t stream, char *file_name) {
@@ -121,13 +121,13 @@ fn b32 lex_macro(lexer_t *lex, lex_t *token) {
while (char_is_alphabetic(lex->at[0])) lex_advance(lex);
token->len = (i32)(lex->at - token->str);
if (s8_are_equal(token->string, s8_lit("define"))) {
if (s8_are_equal(token->string, s8("define"))) {
token->kind = lex_kind_preproc_define;
} else if (s8_are_equal(token->string, s8_lit("ifdef"))) {
} else if (s8_are_equal(token->string, s8("ifdef"))) {
token->kind = lex_kind_preproc_ifdef;
} else if (s8_are_equal(token->string, s8_lit("ifndef"))) {
} else if (s8_are_equal(token->string, s8("ifndef"))) {
token->kind = lex_kind_preproc_ifndef;
} else if (s8_are_equal(token->string, s8_lit("include"))) {
} else if (s8_are_equal(token->string, s8("include"))) {
token->kind = lex_kind_preproc_include;
lex_eat_macro_whitespace(lex);
char end = 0;
@@ -154,22 +154,22 @@ fn b32 lex_macro(lexer_t *lex, lex_t *token) {
lex_advance(lex);
}
lex_advance(lex);
} else if (s8_are_equal(token->string, s8_lit("if"))) {
} else if (s8_are_equal(token->string, s8("if"))) {
token->kind = lex_kind_preproc_if;
} else if (s8_are_equal(token->string, s8_lit("endif"))) {
} else if (s8_are_equal(token->string, s8("endif"))) {
token->kind = lex_kind_preproc_endif;
} else if (s8_are_equal(token->string, s8_lit("error"))) {
} else if (s8_are_equal(token->string, s8("error"))) {
token->kind = lex_kind_preproc_error;
lex_eat_macro_whitespace(lex);
token->str = lex->at;
lex_eat_until(lex, '\n');
} else if (s8_are_equal(token->string, s8_lit("else"))) {
} else if (s8_are_equal(token->string, s8("else"))) {
token->kind = lex_kind_preproc_else;
} else if (s8_are_equal(token->string, s8_lit("elif"))) {
} else if (s8_are_equal(token->string, s8("elif"))) {
token->kind = lex_kind_preproc_elif;
} else if (s8_are_equal(token->string, s8_lit("pragma"))) {
} else if (s8_are_equal(token->string, s8("pragma"))) {
token->kind = lex_kind_preproc_pragma;
} else if (s8_are_equal(token->string, s8_lit("undef"))) {
} else if (s8_are_equal(token->string, s8("undef"))) {
token->kind = lex_kind_preproc_undef;
} else {
return false;
@@ -329,7 +329,7 @@ fn void lex_token_ex(lexer_t *lex, lex_t *token) {
s8_t string_to_lex = token->string;
if (token->suffix != lex_suffix_none) {
s8_t string_value = ti_enum_value_to_name(token->suffix, type(lex_suffix_t));
s8_t prefix = s8_lit("lex_suffix_");
s8_t prefix = s8("lex_suffix_");
string_to_lex.len -= string_value.len - prefix.len;
}
token->integer = u64_from_s8(string_to_lex, 10);
@@ -337,7 +337,7 @@ fn void lex_token_ex(lexer_t *lex, lex_t *token) {
s8_t string_to_lex = token->string;
if (token->suffix != lex_suffix_none) {
s8_t string_value = ti_enum_value_to_name(token->suffix, type(lex_suffix_t));
s8_t prefix = s8_lit("lex_suffix_");
s8_t prefix = s8("lex_suffix_");
string_to_lex.len -= string_value.len - prefix.len;
}
token->real = f64_from_s8(string_to_lex);
@@ -380,7 +380,7 @@ fn lex_array_t lex_tokens(ma_arena_t *arena, char *file_name, s8_t stream) {
}
gb_read_only s8_t lex_kind_simple_strings[] = {
#define X(KIND, STR, SIMPLE) s8_const_lit(SIMPLE),
#define X(KIND, STR, SIMPLE) s8_const(SIMPLE),
LEX_KIND_XLIST
#undef X
};
@@ -391,7 +391,7 @@ fn s8_t lex_kind_to_simple_s8(lex_kind_t kind) {
}
gb_read_only s8_t lex_kind_strings[] = {
#define X(KIND, STR, SIMPLE) s8_const_lit(STR),
#define X(KIND, STR, SIMPLE) s8_const(STR),
LEX_KIND_XLIST
#undef X
};

View File

@@ -164,14 +164,14 @@ fn void parser_eat_including(parser_t *par, lex_kind_t kind);
gb_read_only lex_t lex_null;
gb_read_only type_member_t members__lex_kind_t[] = {
#define X(KIND, STR, SIMPLE) {.name = s8_const_lit("lex_kind_" #KIND), .value = KIND},
#define X(KIND, STR, SIMPLE) {.name = s8_const("lex_kind_" #KIND), .value = KIND},
LEX_KIND_XLIST
#undef X
};
DEFINE_ENUM(lex_kind_t);
gb_read_only type_member_t members__lex_suffix_t[] = {
#define X(KIND) {.name = s8_const_lit(#KIND), .value = KIND},
#define X(KIND) {.name = s8_const(#KIND), .value = KIND},
LEX_SUFFIX_XLIST
#undef X
};

View File

@@ -399,7 +399,7 @@ fn r2f32_t r2f32_fix(r2f32_t n) {
};
return result;
}
fn r2f64_t r2f64_cut_left(r2f64_t *r, f64 value) {
f64 minx = r->min.x;
@@ -544,7 +544,7 @@ fn r2f64_t r2f64_fix(r2f64_t n) {
};
return result;
}
fn r2i32_t r2i32_cut_left(r2i32_t *r, i32 value) {
i32 minx = r->min.x;
@@ -689,7 +689,7 @@ fn r2i32_t r2i32_fix(r2i32_t n) {
};
return result;
}
fn r2i64_t r2i64_cut_left(r2i64_t *r, i64 value) {
i64 minx = r->min.x;
@@ -834,7 +834,7 @@ fn r2i64_t r2i64_fix(r2i64_t n) {
};
return result;
}
fn_inline v2f64_t v2f32_to_v2f64(v2f32_t v) { return (v2f64_t){ (f64)v.x, (f64)v.y }; }
fn_inline v3f64_t v3f32_to_v3f64(v3f32_t v) { return (v3f64_t){ (f64)v.x, (f64)v.y, (f64)v.z }; }
fn_inline v4f64_t v4f32_to_v4f64(v4f32_t v) { return (v4f64_t){ (f64)v.x, (f64)v.y, (f64)v.z, (f64)v.w }; }

View File

@@ -90,52 +90,52 @@ struct_types = vec_types + rect_types
# };
#
#
# type_t type__v2f64_t = { type_kind_struct, s8_const_lit("v2f64_t"), sizeof(v2f64_t), .count = 2,
# type_t type__v2f64_t = { type_kind_struct, s8_const("v2f64_t"), sizeof(v2f64_t), .count = 2,
# .members = (type_member_t[]){
# {s8_const_lit("x"), &type__f64, .offset = offsetof(v2f64_t, x)},
# {s8_const_lit("y"), &type__f64, .offset = offsetof(v2f64_t, y)},
# {s8_const("x"), &type__f64, .offset = offsetof(v2f64_t, x)},
# {s8_const("y"), &type__f64, .offset = offsetof(v2f64_t, y)},
# }
# };
# type_t type__v3f64_t = { type_kind_struct, s8_const_lit("v3f64_t"), sizeof(v3f64_t), .count = 3,
# type_t type__v3f64_t = { type_kind_struct, s8_const("v3f64_t"), sizeof(v3f64_t), .count = 3,
# .members = (type_member_t[]){
# {s8_const_lit("x"), &type__f64, .offset = offsetof(v3f64_t, x)},
# {s8_const_lit("y"), &type__f64, .offset = offsetof(v3f64_t, y)},
# {s8_const_lit("z"), &type__f64, .offset = offsetof(v3f64_t, z)},
# {s8_const("x"), &type__f64, .offset = offsetof(v3f64_t, x)},
# {s8_const("y"), &type__f64, .offset = offsetof(v3f64_t, y)},
# {s8_const("z"), &type__f64, .offset = offsetof(v3f64_t, z)},
# }
# };
# type_t type__v4f64_t = { type_kind_struct, s8_const_lit("v4f64_t"), sizeof(v4f64_t), .count = 4,
# type_t type__v4f64_t = { type_kind_struct, s8_const("v4f64_t"), sizeof(v4f64_t), .count = 4,
# .members = (type_member_t[]){
# {s8_const_lit("x"), &type__f64, .offset = offsetof(v4f64_t, x)},
# {s8_const_lit("y"), &type__f64, .offset = offsetof(v4f64_t, y)},
# {s8_const_lit("z"), &type__f64, .offset = offsetof(v4f64_t, z)},
# {s8_const_lit("w"), &type__f64, .offset = offsetof(v4f64_t, w)},
# {s8_const("x"), &type__f64, .offset = offsetof(v4f64_t, x)},
# {s8_const("y"), &type__f64, .offset = offsetof(v4f64_t, y)},
# {s8_const("z"), &type__f64, .offset = offsetof(v4f64_t, z)},
# {s8_const("w"), &type__f64, .offset = offsetof(v4f64_t, w)},
# }
# };
# type_t type__r3f64_t = { type_kind_struct, s8_const_lit("r3f64_t"), sizeof(r3f64_t), .count = 6,
# type_t type__r3f64_t = { type_kind_struct, s8_const("r3f64_t"), sizeof(r3f64_t), .count = 6,
# .members = (type_member_t[]){
# {s8_const_lit("x0"), &type__f64, .offset = offsetof(r3f64_t, x0)},
# {s8_const_lit("y0"), &type__f64, .offset = offsetof(r3f64_t, y0)},
# {s8_const_lit("x0"), &type__f64, .offset = offsetof(r3f64_t, z0)},
# {s8_const_lit("x1"), &type__f64, .offset = offsetof(r3f64_t, x1)},
# {s8_const_lit("y1"), &type__f64, .offset = offsetof(r3f64_t, y1)},
# {s8_const_lit("x1"), &type__f64, .offset = offsetof(r3f64_t, z1)},
# {s8_const("x0"), &type__f64, .offset = offsetof(r3f64_t, x0)},
# {s8_const("y0"), &type__f64, .offset = offsetof(r3f64_t, y0)},
# {s8_const("x0"), &type__f64, .offset = offsetof(r3f64_t, z0)},
# {s8_const("x1"), &type__f64, .offset = offsetof(r3f64_t, x1)},
# {s8_const("y1"), &type__f64, .offset = offsetof(r3f64_t, y1)},
# {s8_const("x1"), &type__f64, .offset = offsetof(r3f64_t, z1)},
# }
# };
# type_member_t members__r2f64_t[] = {
# {s8_const_lit("x0"), &type__f64, .offset = offsetof(r2f64_t, x0)},
# {s8_const_lit("y0"), &type__f64, .offset = offsetof(r2f64_t, y0)},
# {s8_const_lit("x1"), &type__f64, .offset = offsetof(r2f64_t, x1)},
# {s8_const_lit("y1"), &type__f64, .offset = offsetof(r2f64_t, y1)},
# {s8_const("x0"), &type__f64, .offset = offsetof(r2f64_t, x0)},
# {s8_const("y0"), &type__f64, .offset = offsetof(r2f64_t, y0)},
# {s8_const("x1"), &type__f64, .offset = offsetof(r2f64_t, x1)},
# {s8_const("y1"), &type__f64, .offset = offsetof(r2f64_t, y1)},
# };
# DEFINE_STRUCT(r2f64_t);
# type_member_t members__r1f64_t[] = {
# {s8_const_lit("x0"), &type__f64, .offset = offsetof(r1f64_t, x0)},
# {s8_const_lit("x1"), &type__f64, .offset = offsetof(r1f64_t, x1)},
# {s8_const("x0"), &type__f64, .offset = offsetof(r1f64_t, x0)},
# {s8_const("x1"), &type__f64, .offset = offsetof(r1f64_t, x1)},
# };
# DEFINE_STRUCT(r1f64_t);
# """

View File

@@ -30,7 +30,7 @@ fn void os_error_box(char *str) {
fn void os_console_log(char *str) {
s8_t string = s8_from_char(str);
if (s8_ends_with(string, s8_lit("\n"))) {
if (s8_ends_with(string, s8("\n"))) {
string = s8_chop(string, 1);
}
wasm_write_to_console((isize)string.str, (i32)string.len);

View File

@@ -63,7 +63,7 @@ fn s8_t s8_copy(ma_arena_t *ma, s8_t string) {
char *copy = (char *)ma_push_size(ma, sizeof(char) * (string.len + 1));
memory_copy(copy, string.str, string.len);
copy[string.len] = 0;
s8_t result = s8(copy, string.len);
s8_t result = s8_make(copy, string.len);
return result;
}
@@ -72,7 +72,7 @@ fn s8_t s8_copy_char(ma_arena_t *ma, char *s) {
char *copy = (char *)ma_push_size(ma, sizeof(char) * (len + 1));
memory_copy(copy, s, len);
copy[len] = 0;
s8_t result = s8(copy, len);
s8_t result = s8_make(copy, len);
return result;
}
@@ -98,26 +98,26 @@ fn b32 s8_are_equal(s8_t a, s8_t b) {
fn s8_t s8_get_postfix(s8_t string, int64_t len) {
len = CLAMP_TOP(len, string.len);
int64_t remain_len = string.len - len;
s8_t result = s8(string.str + remain_len, len);
s8_t result = s8_make(string.str + remain_len, len);
return result;
}
fn s8_t s8_get_prefix(s8_t string, int64_t len) {
len = CLAMP_TOP(len, string.len);
s8_t result = s8(string.str, len);
s8_t result = s8_make(string.str, len);
return result;
}
fn s8_t s8_chop(s8_t string, int64_t len) {
len = CLAMP_TOP(len, string.len);
s8_t result = s8(string.str, string.len - len);
s8_t result = s8_make(string.str, string.len - len);
return result;
}
fn s8_t s8_skip(s8_t string, int64_t len) {
len = CLAMP_TOP(len, string.len);
int64_t remain = string.len - len;
s8_t result = s8(string.str + len, remain);
s8_t result = s8_make(string.str + len, remain);
return result;
}
@@ -171,7 +171,7 @@ fn s8_t s8_cut_end(s8_t *in, i64 size) {
#if 0
s8_t s8_skip_to_p(s8_t string, char *p) {
if (s8_is_pointer_inside(string, p)) {
s8_t result = s8(p, p - string.str);
s8_t result = s8_make(p, p - string.str);
return result;
}
return string;
@@ -179,7 +179,7 @@ s8_t s8_skip_to_p(s8_t string, char *p) {
s8_t s8_skip_past(s8_t string, s8_t a) {
if (s8_is_pointer_inside(string, a.str)) {
s8_t on_p = s8(a.str, a.str - string.str);
s8_t on_p = s8_make(a.str, a.str - string.str);
s8_t result = s8_skip(on_p, a.len);
return result;
}
@@ -290,11 +290,11 @@ fn s8_t s8_chop_last_char(s8_t s, s8_t ch) {
}
fn s8_t s8_chop_last_slash(s8_t s) {
return s8_chop_last_char(s, s8_lit("/"));
return s8_chop_last_char(s, s8("/"));
}
fn s8_t s8_chop_last_period(s8_t s) {
return s8_chop_last_char(s, s8_lit("."));
return s8_chop_last_char(s, s8("."));
}
fn s8_t s8_skip_to_last_char(s8_t s, s8_t ch) {
@@ -307,11 +307,11 @@ fn s8_t s8_skip_to_last_char(s8_t s, s8_t ch) {
}
fn s8_t s8_skip_to_last_slash(s8_t s) {
return s8_skip_to_last_char(s, s8_lit("/"));
return s8_skip_to_last_char(s, s8("/"));
}
fn s8_t s8_skip_to_last_period(s8_t s) {
return s8_skip_to_last_char(s, s8_lit("."));
return s8_skip_to_last_char(s, s8("."));
}
fn s8_t s8_get_name_no_ext(s8_t s) {
@@ -348,7 +348,7 @@ fn s8_t s8_vfmt(ma_arena_t *ma, const char *str, va_list args1) {
char *result = (char *)ma_push_size(ma, sizeof(char) * (len + 1));
s8_vsnprintf(result, (i32)(len + 1), str, args1);
s8_t res = s8(result, len);
s8_t res = s8_make(result, len);
return res;
}
@@ -413,10 +413,10 @@ fn sb8_t s8_split(ma_arena_t *ma, s8_t string, s8_t find, s8_split_t flags) {
s8_seek_t find_flag = flags & s8_split_ignore_case ? s8_seek_ignore_case : s8_seek_none;
while (s8_seek(string, find, find_flag, &index)) {
s8_t before_match = s8(string.str, index);
s8_t before_match = s8_make(string.str, index);
sb8_append(&result, before_match);
if (flags & s8_split_inclusive) {
s8_t match = s8(string.str + index, find.len);
s8_t match = s8_make(string.str + index, find.len);
sb8_append(&result, match);
}
string = s8_skip(string, index + find.len);

View File

@@ -57,11 +57,11 @@ fn f64 f64_from_s8(s8_t string);
//
// string8 constructors
#define s8(str,len) (s8_t){str, len}
#define s8_make(str,len) (s8_t){str, len}
#define s8_null (s8_t){0}
#define s8_invalid s8_lit("<INVALID>")
#define s8_lit(string) (s8_t){(char *)string, sizeof(string) - 1}
#define s8_const_lit(string) { string, sizeof(string) - 1 }
#define s8_invalid s8("<INVALID>")
#define s8(string) (s8_t){(char *)string, sizeof(string) - 1}
#define s8_const(string) { string, sizeof(string) - 1 }
#define s8_struct(DATA) (s8_t){.str = (char *)&(DATA), .len = sizeof(DATA)}
#define s8_array(DATA) (s8_t){.str = (char *)(DATA), .len = lengthof(DATA)}
#define s8_array_lit(DATA) {.str = (char *)(DATA), .len = lengthof(DATA)}
@@ -146,9 +146,9 @@ void *sbin_read_data(stream_t *stream, i64 size);
//
// other
#define s8_fmtspec(string) (int)(string).len, (string).str
#define S8_CODE(...) s8_lit(#__VA_ARGS__)
#define S8_FILE s8_lit(__FILE__)
#define S8_FILE_AND_LINE s8_lit(FILE_AND_LINE)
#define S8_CODE(...) s8(#__VA_ARGS__)
#define S8_FILE s8(__FILE__)
#define S8_FILE_AND_LINE s8(FILE_AND_LINE)
#define S8_FMT(ma, str, result) \
va_list args1; \

View File

@@ -1,4 +1,4 @@
fn i64 wstr_len(wchar_t *string) {
fn i64 str16_len(u16 *string) {
i64 len = 0;
while (*string++ != 0)
len++;
@@ -47,32 +47,24 @@ fn s16_t s16_from_range(u16 *begin, u16 *end) {
return result;
}
fn s16_t s16_from_u16(u16 *string) {
fn s16_t s16_from_str16(u16 *string) {
s16_t result;
result.str = string;
result.len = wstr_len(string);
result.len = str16_len(string);
return result;
}
fn s16_t s16_from_wstr(wchar_t *string) {
return s16_from_u16((u16 *)string);
}
fn s16_t s16_copy(ma_arena_t *ma, s16_t string) {
i64 byte_size = sizeof(u16) * string.len;
u16 *copy = (u16 *)ma_push_size(ma, byte_size + sizeof(u16));
memory_copy(copy, string.str, byte_size);
copy[string.len] = 0;
s16_t result = s16(copy, string.len);
s16_t result = s16_make(copy, string.len);
return result;
}
fn s16_t s16_copy_u16(ma_arena_t *ma, u16 *s) {
return s16_copy(ma, s16(s, wstr_len(s)));
}
fn s16_t s16_copy_wstr(ma_arena_t *ma, wchar_t *s) {
return s16_copy(ma, s16(s, wstr_len(s)));
fn s16_t s16_copy_str16(ma_arena_t *ma, u16 *s) {
return s16_copy(ma, s16_make(s, str16_len(s)));
}
fn b32 s16_are_equal_ex(s16_t a, s16_t b, b32 ignore_case) {
@@ -112,26 +104,26 @@ fn s8_t s8_from_s16(ma_arena_t *ma, s16_t string) {
fn s16_t s16_get_postfix(s16_t string, i64 len) {
len = CLAMP_TOP(len, string.len);
i64 remain_len = string.len - len;
s16_t result = s16(string.str + remain_len, len);
s16_t result = s16_make(string.str + remain_len, len);
return result;
}
fn s16_t s16_get_prefix(s16_t string, i64 len) {
len = CLAMP_TOP(len, string.len);
s16_t result = s16(string.str, len);
s16_t result = s16_make(string.str, len);
return result;
}
fn s16_t s16_chop(s16_t string, i64 len) {
len = CLAMP_TOP(len, string.len);
s16_t result = s16(string.str, string.len - len);
s16_t result = s16_make(string.str, string.len - len);
return result;
}
fn s16_t s16_skip(s16_t string, i64 len) {
len = CLAMP_TOP(len, string.len);
i64 remain = string.len - len;
s16_t result = s16(string.str + len, remain);
s16_t result = s16_make(string.str + len, remain);
return result;
}
@@ -291,11 +283,11 @@ fn s16_t s16_chop_last_char(s16_t s, s16_t ch) {
}
fn s16_t s16_chop_last_slash(s16_t s) {
return s16_chop_last_char(s, s16_lit("/"));
return s16_chop_last_char(s, s16("/"));
}
fn s16_t s16_chop_last_period(s16_t s) {
return s16_chop_last_char(s, s16_lit("."));
return s16_chop_last_char(s, s16("."));
}
fn s16_t s16_skip_to_last_char(s16_t s, s16_t ch) {
@@ -308,11 +300,11 @@ fn s16_t s16_skip_to_last_char(s16_t s, s16_t ch) {
}
fn s16_t s16_skip_to_last_slash(s16_t s) {
return s16_skip_to_last_char(s, s16_lit("/"));
return s16_skip_to_last_char(s, s16("/"));
}
fn s16_t s16_skip_to_last_period(s16_t s) {
return s16_skip_to_last_char(s, s16_lit("."));
return s16_skip_to_last_char(s, s16("."));
}
fn s16_t s16_get_name_no_ext(s16_t s) {
@@ -470,10 +462,10 @@ fn sb16_t s16_split(ma_arena_t *ma, s16_t string, s16_t find, s16_split_t flags)
s16_seek_t find_flag = flags & s16_split_ignore_case ? s16_seek_ignore_case : s16_seek_none;
while (s16_seek(string, find, find_flag, &index)) {
s16_t before_match = s16(string.str, index);
s16_t before_match = s16_make(string.str, index);
sb16_append(&result, before_match);
if (flags & s16_split_inclusive) {
s16_t match = s16(string.str + index, find.len);
s16_t match = s16_make(string.str + index, find.len);
sb16_append(&result, match);
}
string = s16_skip(string, index + find.len);
@@ -487,29 +479,28 @@ fn_test void test_string16(void) {
// string16 lit basic tests
{
s16_t a = s16_lit("memes");
s16_t b = s16_lit("not memes");
s16_t c = s16_lit("MEMES");
s16_t a = s16("memes");
assert(a.len == 5);
assert(a.str[0] == L'm');
assert(a.str[4] == L's');
assert(a.str[0] == char16('m'));
assert(a.str[4] == char16('s'));
s16_t b = s16("not memes");
s16_t c = s16("MEMES");
assert(s16_are_equal(a, b) == false);
assert(s16_are_equal(a, a) == true);
assert(s16_are_equal_ex(a, c, true) == true);
assert(sizeof(wchar_t) == sizeof(u16));
}
{
assert(u16_to_upper_case('a') == L'A');
assert(u16_to_upper_case('a') == char16('A'));
assert(u16_to_upper_case('a') == 'A');
assert(u16_to_upper_case(L'a') == 'A');
assert(u16_to_upper_case(char16('a')) == 'A');
assert(u16_is_digit('3'));
}
{
s16_t a = s16_from_wstr(L"memes");
s16_t a = s16_from_str16(str16("memes"));
assert(a.len == 5);
assert(s16_are_equal(a, s16_lit("memes")) == true);
assert(s16_are_equal(a, s16("memes")) == true);
s16_t b = s16_copy(scratch.arena, a);
assert(a.str != b.str);
@@ -521,40 +512,40 @@ fn_test void test_string16(void) {
}
{
s16_t a = s16_lit("thing itself");
assert(s16_starts_with_ex(a, s16_lit("thing"), false));
assert(!s16_starts_with_ex(a, s16_lit("thing itself and"), false));
assert(!s16_starts_with_ex(a, s16_lit("thing itself "), false));
assert(s16_starts_with_ex(a, s16_lit("THING"), true));
assert(!s16_starts_with_ex(a, s16_lit("a"), false));
s16_t a = s16("thing itself");
assert(s16_starts_with_ex(a, s16("thing"), false));
assert(!s16_starts_with_ex(a, s16("thing itself and"), false));
assert(!s16_starts_with_ex(a, s16("thing itself "), false));
assert(s16_starts_with_ex(a, s16("THING"), true));
assert(!s16_starts_with_ex(a, s16("a"), false));
assert(s16_ends_with_ex(a, s16_lit("itself"), false));
assert(s16_ends_with_ex(a, s16_lit("thing itself"), false));
assert(!s16_ends_with_ex(a, s16_lit("thing itselfa"), false));
assert(s16_ends_with_ex(a, s16("itself"), false));
assert(s16_ends_with_ex(a, s16("thing itself"), false));
assert(!s16_ends_with_ex(a, s16("thing itselfa"), false));
s16_t b = s16_lit("memes");
s16_t b = s16("memes");
assert(s16_is_pointer_inside(b, b.str));
assert(s16_is_pointer_inside(b, b.str + 4));
assert(!s16_is_pointer_inside(b, b.str + 5));
}
{
s16_t a = s16_lit("C:\\Program Files\\Memes");
s16_t a = s16("C:\\Program Files\\Memes");
s16_normalize_path_unsafe(a);
assert(a.str[2] == '/');
}
{
s16_t a = s16_lit(" thing ");
s16_t a = s16(" thing ");
s16_t b = s16_trim(a);
assert(s16_are_equal(b, s16_lit("thing")));
assert(s16_are_equal(b, s16("thing")));
}
{
s16_t a = s16_printf(scratch.arena, "%d", 432);
assert(s16_are_equal(a, s16_lit("432")));
assert(f64_from_s16(s16_lit("432.0")) == 432.0);
assert(u64_from_s16(s16_lit("432"), 10) == 432);
assert(s16_are_equal(a, s16("432")));
assert(f64_from_s16(s16("432.0")) == 432.0);
assert(u64_from_s16(s16("432"), 10) == 432);
}
{
@@ -563,31 +554,31 @@ fn_test void test_string16(void) {
sb16_printf(list, "ter ");
sb16_printf(list, "|");
s16_t string = sb16_serial_end(scratch.arena, list);
assert(s16_are_equal(string, s16_lit("987 ter |")));
assert(s16_are_equal(string, s16("987 ter |")));
}
{
s16_t a = s16_lit("A|B|dek|mek|vek|");
sb16_t b = s16_split(scratch.arena, a, s16_lit("|"), s16_split_none);
assert(s16_are_equal(b.first->string, s16_lit("A")));
assert(s16_are_equal(b.first->next->string, s16_lit("B")));
assert(s16_are_equal(b.first->next->next->string, s16_lit("dek")));
assert(s16_are_equal(b.first->next->next->next->string, s16_lit("mek")));
assert(s16_are_equal(b.first->next->next->next->next->string, s16_lit("vek")));
s16_t a = s16("A|B|dek|mek|vek|");
sb16_t b = s16_split(scratch.arena, a, s16("|"), s16_split_none);
assert(s16_are_equal(b.first->string, s16("A")));
assert(s16_are_equal(b.first->next->string, s16("B")));
assert(s16_are_equal(b.first->next->next->string, s16("dek")));
assert(s16_are_equal(b.first->next->next->next->string, s16("mek")));
assert(s16_are_equal(b.first->next->next->next->next->string, s16("vek")));
assert(b.first->next->next->next->next->next == NULL);
}
{
s16_t a = s16_to_upper_case(scratch.arena, s16_lit("thing Meme"));
assert(s16_are_equal(a, s16_lit("THING MEME")));
s16_t a = s16_to_upper_case(scratch.arena, s16("thing Meme"));
assert(s16_are_equal(a, s16("THING MEME")));
a = s16_to_lower_case(scratch.arena, s16_lit("THING Meme"));
assert(s16_are_equal(a, s16_lit("thing meme")));
a = s16_to_lower_case(scratch.arena, s16("THING Meme"));
assert(s16_are_equal(a, s16("thing meme")));
}
{
s16_t a = s16_lit("C:/thing/itself");
assert(s16_are_equal(s16_chop_last_slash(a), s16_lit("C:/thing")));
s16_t a = s16("C:/thing/itself");
assert(s16_are_equal(s16_chop_last_slash(a), s16("C:/thing")));
}
ma_end_scratch(scratch);

View File

@@ -46,69 +46,16 @@ struct s32_t {
i64 len;
};
#define s16(str,len) (s16_t){str, len}
#define s16_lit(str) (s16_t){L##str, sizeof(L##str) / sizeof(u16) - 1}
#define s16_make(str,len) (s16_t){str, len}
#define s16(str) (s16_t){(u16 *)u##str, lengthof(str) - 1}
#define s16_const(string) { (u16 *)u##string, lengthof(string) - 1 }
#define s16_invalid s16_lit("<INVALID>")
#define s16_null (s16_t){0}
#define str16(str) ((u16 *)u##str)
#define char16(str) ((u16)u##str)
#define sb16(ARENA) &(sb16_t){.arena = arena}
#define sb16_serial_begin(ARENA) &(sb16_t){.arena = ARENA}
#define sb16_serial_end(ARENA, SB) sb16_merge(ARENA, SB)
fn i64 wstr_len(wchar_t *string);
fn u16 u16_to_lower_case(u16 a);
fn u16 u16_to_upper_case(u16 a);
fn b32 u16_is_whitespace(u16 w);
fn b32 u16_is_alphabetic(u16 a);
fn b32 u16_is_ident(u16 a);
fn b32 u16_is_digit(u16 a);
fn b32 u16_is_alphanumeric(u16 a);
fn s16_t s16_from_range(u16 *begin, u16 *end);
fn s16_t s16_from_u16(u16 *string);
fn s16_t s16_from_wstr(wchar_t *string);
fn s16_t s16_copy(ma_arena_t *ma, s16_t string);
fn s16_t s16_copy_u16(ma_arena_t *ma, u16 *s);
fn s16_t s16_copy_wstr(ma_arena_t *ma, wchar_t *s);
fn b32 s16_are_equal_ex(s16_t a, s16_t b, b32 ignore_case);
fn b32 s16_are_equal(s16_t a, s16_t b);
fn s16_t s16_from_s8(ma_arena_t *ma, s8_t string);
fn s8_t s8_from_s16(ma_arena_t *ma, s16_t string);
fn s16_t s16_get_postfix(s16_t string, i64 len);
fn s16_t s16_get_prefix(s16_t string, i64 len);
fn s16_t s16_chop(s16_t string, i64 len);
fn s16_t s16_skip(s16_t string, i64 len);
fn b32 s16_ends_with_ex(s16_t a, s16_t end, b32 ignore_case);
fn b32 s16_starts_with_ex(s16_t a, s16_t start, b32 ignore_case);
fn b32 s16_ends_with(s16_t a, s16_t end);
fn b32 s16_starts_with(s16_t a, s16_t start);
fn void s16_normalize_path_unsafe(s16_t s);
fn s16_t s16_normalize_path(ma_arena_t *ma, s16_t s);
fn b32 s16_is_pointer_inside(s16_t string, u16 *p);
fn s16_t s16_cut_start(s16_t *in, i64 size);
fn s16_t s16_cut_end(s16_t *in, i64 size);
fn s16_t s16_slice(s16_t string, i64 first_index, i64 one_past_last_index);
fn s16_t s16_trim(s16_t string);
fn s16_t s16_trim_end(s16_t string);
fn b32 s16_seek(s16_t string, s16_t find, s16_seek_t flags, int64_t *index_out);
fn int64_t s16_find(s16_t string, s16_t find, s16_seek_t flag);
fn s16_t s16_chop_last_char(s16_t s, s16_t ch);
fn s16_t s16_chop_last_slash(s16_t s);
fn s16_t s16_chop_last_period(s16_t s);
fn s16_t s16_skip_to_last_char(s16_t s, s16_t ch);
fn s16_t s16_skip_to_last_slash(s16_t s);
fn s16_t s16_skip_to_last_period(s16_t s);
fn s16_t s16_get_name_no_ext(s16_t s);
fn s16_t s16_to_lower_case(ma_arena_t *ma, s16_t s);
fn s16_t s16_to_upper_case(ma_arena_t *ma, s16_t s);
fn s16_t s16_printf(ma_arena_t *ma, const char *str, ...);
fn u64 u64_from_s16(s16_t s, u64 base);
fn f64 f64_from_s16(s16_t string);
fn i64 s16_fuzzy_rate(s16_t string, s16_t with);
fn fuzzy_pair_t *s16_fuzzy_rate_array(ma_arena_t *arena, s16_t needle, s16_t *array, i32 len);
fn sb16_node_t *sb16_create_node(ma_arena_t *ma, s16_t str);
fn sb16_node_t *sb16_append(sb16_t *list, s16_t string);
fn s16_t sb16_printf(sb16_t *sb, const char *str, ...);
fn void sb16_indent(sb16_t *sb);
fn s16_t sb16_stmtf(sb16_t *sb, const char *str, ...);
fn int64_t sb16_char_size(sb16_t *sb);
fn s16_t sb16_merge(ma_arena_t *arena, sb16_t *sb);
fn sb16_t s16_split(ma_arena_t *ma, s16_t string, s16_t find, s16_split_t flags);

View File

@@ -6,7 +6,7 @@ fn s8_t ti_enum_value_to_name(i64 value, type_t *type) {
return it->name;
}
}
return s8_lit("invalid");
return s8("invalid");
}
fn i64 ti_enum_name_to_value(s8_t name, type_t *type) {

View File

@@ -80,278 +80,278 @@ fn type_member_t *ti_get_member(s8_t name, type_t *type);
//
// core type info data
#define type(X) (&type__##X)
#define DEFINE_ENUM(x) type_t type__##x = {type_kind_enum, s8_const_lit(#x), sizeof(x), .members = members__##x, .count = lengthof(members__##x)}
#define DEFINE_STRUCT(x) type_t type__##x = {type_kind_struct, s8_const_lit(#x), sizeof(x), .members = members__##x, .count = lengthof(members__##x)}
#define POINTER(x) (type_t){type_kind_pointer, s8_const_lit(#x "*"), sizeof(void *), .base = &type__##x}
#define DEFINE_ENUM(x) type_t type__##x = {type_kind_enum, s8_const(#x), sizeof(x), .members = members__##x, .count = lengthof(members__##x)}
#define DEFINE_STRUCT(x) type_t type__##x = {type_kind_struct, s8_const(#x), sizeof(x), .members = members__##x, .count = lengthof(members__##x)}
#define POINTER(x) (type_t){type_kind_pointer, s8_const(#x "*"), sizeof(void *), .base = &type__##x}
gb_read_only type_t type__i8 = {type_kind_i8, s8_const_lit("i8"), sizeof(i8)};
gb_read_only type_t type__i16 = {type_kind_i16, s8_const_lit("i16"), sizeof(i16)};
gb_read_only type_t type__i32 = {type_kind_i32, s8_const_lit("i32"), sizeof(i32)};
gb_read_only type_t type__i64 = {type_kind_i64, s8_const_lit("i64"), sizeof(i64)};
gb_read_only type_t type__u8 = {type_kind_u8, s8_const_lit("u8"), sizeof(u8)};
gb_read_only type_t type__u16 = {type_kind_u16, s8_const_lit("u16"), sizeof(u16)};
gb_read_only type_t type__u32 = {type_kind_u32, s8_const_lit("u32"), sizeof(u32)};
gb_read_only type_t type__u64 = {type_kind_u64, s8_const_lit("u64"), sizeof(u64)};
gb_read_only type_t type__b8 = {type_kind_b8, s8_const_lit("b8"), sizeof(b8)};
gb_read_only type_t type__b16 = {type_kind_b16, s8_const_lit("b16"), sizeof(b16)};
gb_read_only type_t type__b32 = {type_kind_b32, s8_const_lit("b32"), sizeof(b32)};
gb_read_only type_t type__b64 = {type_kind_b64, s8_const_lit("b64"), sizeof(b64)};
gb_read_only type_t type__f32 = {type_kind_f32, s8_const_lit("f32"), sizeof(f32)};
gb_read_only type_t type__f64 = {type_kind_f64, s8_const_lit("f64"), sizeof(f64)};
gb_read_only type_t type__isize = {type_kind_isize, s8_const_lit("isize"), sizeof(isize)};
gb_read_only type_t type__usize = {type_kind_usize, s8_const_lit("usize"), sizeof(usize)};
gb_read_only type_t type__int = {type_kind_int, s8_const_lit("int"), sizeof(int)};
gb_read_only type_t type__char = {type_kind_char, s8_const_lit("char"), sizeof(char)};
gb_read_only type_t type__void = {type_kind_void, s8_const_lit("void")};
gb_read_only type_t type__i8 = {type_kind_i8, s8_const("i8"), sizeof(i8)};
gb_read_only type_t type__i16 = {type_kind_i16, s8_const("i16"), sizeof(i16)};
gb_read_only type_t type__i32 = {type_kind_i32, s8_const("i32"), sizeof(i32)};
gb_read_only type_t type__i64 = {type_kind_i64, s8_const("i64"), sizeof(i64)};
gb_read_only type_t type__u8 = {type_kind_u8, s8_const("u8"), sizeof(u8)};
gb_read_only type_t type__u16 = {type_kind_u16, s8_const("u16"), sizeof(u16)};
gb_read_only type_t type__u32 = {type_kind_u32, s8_const("u32"), sizeof(u32)};
gb_read_only type_t type__u64 = {type_kind_u64, s8_const("u64"), sizeof(u64)};
gb_read_only type_t type__b8 = {type_kind_b8, s8_const("b8"), sizeof(b8)};
gb_read_only type_t type__b16 = {type_kind_b16, s8_const("b16"), sizeof(b16)};
gb_read_only type_t type__b32 = {type_kind_b32, s8_const("b32"), sizeof(b32)};
gb_read_only type_t type__b64 = {type_kind_b64, s8_const("b64"), sizeof(b64)};
gb_read_only type_t type__f32 = {type_kind_f32, s8_const("f32"), sizeof(f32)};
gb_read_only type_t type__f64 = {type_kind_f64, s8_const("f64"), sizeof(f64)};
gb_read_only type_t type__isize = {type_kind_isize, s8_const("isize"), sizeof(isize)};
gb_read_only type_t type__usize = {type_kind_usize, s8_const("usize"), sizeof(usize)};
gb_read_only type_t type__int = {type_kind_int, s8_const("int"), sizeof(int)};
gb_read_only type_t type__char = {type_kind_char, s8_const("char"), sizeof(char)};
gb_read_only type_t type__void = {type_kind_void, s8_const("void")};
gb_read_only type_t type__s8_t = { type_kind_struct, s8_const_lit("s8_t"), sizeof(s8_t), .count = 2,
gb_read_only type_t type__s8_t = { type_kind_struct, s8_const("s8_t"), sizeof(s8_t), .count = 2,
.members = (type_member_t[]){
{s8_const_lit("str"), &POINTER(char), .offset = offsetof(s8_t, str)},
{s8_const_lit("len"), &type__i64, .offset = offsetof(s8_t, len)},
{s8_const("str"), &POINTER(char), .offset = offsetof(s8_t, str)},
{s8_const("len"), &type__i64, .offset = offsetof(s8_t, len)},
}
};
gb_read_only type_t type__s16_t = { type_kind_struct, s8_const_lit("s16_t"), sizeof(s16_t), .count = 2,
gb_read_only type_t type__s16_t = { type_kind_struct, s8_const("s16_t"), sizeof(s16_t), .count = 2,
.members = (type_member_t[]){
{s8_const_lit("str"), &POINTER(u16), .offset = offsetof(s16_t, str)},
{s8_const_lit("len"), &type__i64, .offset = offsetof(s16_t, len)},
{s8_const("str"), &POINTER(u16), .offset = offsetof(s16_t, str)},
{s8_const("len"), &type__i64, .offset = offsetof(s16_t, len)},
}
};
gb_read_only type_t type__s32_t = { type_kind_struct, s8_const_lit("s32_t"), sizeof(s32_t), .count = 2,
gb_read_only type_t type__s32_t = { type_kind_struct, s8_const("s32_t"), sizeof(s32_t), .count = 2,
.members = (type_member_t[]){
{s8_const_lit("str"), &POINTER(u32), .offset = offsetof(s32_t, str)},
{s8_const_lit("len"), &type__i64, .offset = offsetof(s32_t, len)},
{s8_const("str"), &POINTER(u32), .offset = offsetof(s32_t, str)},
{s8_const("len"), &type__i64, .offset = offsetof(s32_t, len)},
}
};
gb_read_only type_t type__ma_arena_t = { type_kind_struct, s8_const_lit("ma_arena_t"), sizeof(ma_arena_t), .count = 6,
gb_read_only type_t type__ma_arena_t = { type_kind_struct, s8_const("ma_arena_t"), sizeof(ma_arena_t), .count = 6,
.members = (type_member_t[]){
{s8_const_lit("data"), &POINTER(u8), .offset = offsetof(ma_arena_t, data)},
{s8_const_lit("len"), &type__usize, .offset = offsetof(ma_arena_t, len)},
{s8_const_lit("base_len"), &type__usize, .offset = offsetof(ma_arena_t, base_len)},
{s8_const_lit("reserve"), &type__usize, .offset = offsetof(ma_arena_t, reserve)},
{s8_const_lit("commit"), &type__usize, .offset = offsetof(ma_arena_t, commit)},
{s8_const_lit("align"), &type__usize, .offset = offsetof(ma_arena_t, align)},
{s8_const("data"), &POINTER(u8), .offset = offsetof(ma_arena_t, data)},
{s8_const("len"), &type__usize, .offset = offsetof(ma_arena_t, len)},
{s8_const("base_len"), &type__usize, .offset = offsetof(ma_arena_t, base_len)},
{s8_const("reserve"), &type__usize, .offset = offsetof(ma_arena_t, reserve)},
{s8_const("commit"), &type__usize, .offset = offsetof(ma_arena_t, commit)},
{s8_const("align"), &type__usize, .offset = offsetof(ma_arena_t, align)},
}
};
gb_read_only type_t type__sb8_node_t = {type_kind_struct, s8_const_lit("sb8_node_t"), sizeof(sb8_t), .count = 2,
gb_read_only type_t type__sb8_node_t = {type_kind_struct, s8_const("sb8_node_t"), sizeof(sb8_t), .count = 2,
.members = (type_member_t[]){
{s8_const_lit("next"), &POINTER(sb8_node_t), .offset = offsetof(sb8_node_t, next)},
{s8_const_lit("string"), &type__s8_t, .offset = offsetof(sb8_node_t, string)},
{s8_const("next"), &POINTER(sb8_node_t), .offset = offsetof(sb8_node_t, next)},
{s8_const("string"), &type__s8_t, .offset = offsetof(sb8_node_t, string)},
}
};
gb_read_only type_t type__sb8_t = { type_kind_struct, s8_const_lit("sb8_t"), sizeof(sb8_t), .count = 4,
gb_read_only type_t type__sb8_t = { type_kind_struct, s8_const("sb8_t"), sizeof(sb8_t), .count = 4,
.members = (type_member_t[]){
{s8_const_lit("arena"), &POINTER(ma_arena_t), .offset = offsetof(sb8_t, arena)},
{s8_const_lit("first"), &POINTER(sb8_node_t), .offset = offsetof(sb8_t, first)},
{s8_const_lit("last"), &POINTER(sb8_node_t), .offset = offsetof(sb8_t, last)},
{s8_const_lit("indent"), &type__i32, .offset = offsetof(sb8_t, indent)},
{s8_const("arena"), &POINTER(ma_arena_t), .offset = offsetof(sb8_t, arena)},
{s8_const("first"), &POINTER(sb8_node_t), .offset = offsetof(sb8_t, first)},
{s8_const("last"), &POINTER(sb8_node_t), .offset = offsetof(sb8_t, last)},
{s8_const("indent"), &type__i32, .offset = offsetof(sb8_t, indent)},
}
};
gb_read_only type_t type__ma_temp_t = { type_kind_struct, s8_const_lit("ma_temp_t"), sizeof(ma_temp_t), .count = 2,
gb_read_only type_t type__ma_temp_t = { type_kind_struct, s8_const("ma_temp_t"), sizeof(ma_temp_t), .count = 2,
.members = (type_member_t[]){
{s8_const_lit("arena"), &POINTER(ma_arena_t), .offset = offsetof(ma_temp_t, arena)},
{s8_const_lit("len"), &type__usize, .offset = offsetof(ma_temp_t, len)},
{s8_const("arena"), &POINTER(ma_arena_t), .offset = offsetof(ma_temp_t, arena)},
{s8_const("len"), &type__usize, .offset = offsetof(ma_temp_t, len)},
}
};
gb_read_only type_t type__v2f32_t = { type_kind_struct, s8_const_lit("v2f32_t"), sizeof(v2f32_t), .count = 2,
gb_read_only type_t type__v2f32_t = { type_kind_struct, s8_const("v2f32_t"), sizeof(v2f32_t), .count = 2,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__f32, .offset = offsetof(v2f32_t, x)},
{s8_const_lit("y"), &type__f32, .offset = offsetof(v2f32_t, y)},
{s8_const("x"), &type__f32, .offset = offsetof(v2f32_t, x)},
{s8_const("y"), &type__f32, .offset = offsetof(v2f32_t, y)},
}
};
gb_read_only type_t type__v3f32_t = { type_kind_struct, s8_const_lit("v3f32_t"), sizeof(v3f32_t), .count = 3,
gb_read_only type_t type__v3f32_t = { type_kind_struct, s8_const("v3f32_t"), sizeof(v3f32_t), .count = 3,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__f32, .offset = offsetof(v3f32_t, x)},
{s8_const_lit("y"), &type__f32, .offset = offsetof(v3f32_t, y)},
{s8_const_lit("z"), &type__f32, .offset = offsetof(v3f32_t, z)},
{s8_const("x"), &type__f32, .offset = offsetof(v3f32_t, x)},
{s8_const("y"), &type__f32, .offset = offsetof(v3f32_t, y)},
{s8_const("z"), &type__f32, .offset = offsetof(v3f32_t, z)},
}
};
gb_read_only type_t type__v4f32_t = { type_kind_struct, s8_const_lit("v4f32_t"), sizeof(v4f32_t), .count = 4,
gb_read_only type_t type__v4f32_t = { type_kind_struct, s8_const("v4f32_t"), sizeof(v4f32_t), .count = 4,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__f32, .offset = offsetof(v4f32_t, x)},
{s8_const_lit("y"), &type__f32, .offset = offsetof(v4f32_t, y)},
{s8_const_lit("z"), &type__f32, .offset = offsetof(v4f32_t, z)},
{s8_const_lit("w"), &type__f32, .offset = offsetof(v4f32_t, w)},
{s8_const("x"), &type__f32, .offset = offsetof(v4f32_t, x)},
{s8_const("y"), &type__f32, .offset = offsetof(v4f32_t, y)},
{s8_const("z"), &type__f32, .offset = offsetof(v4f32_t, z)},
{s8_const("w"), &type__f32, .offset = offsetof(v4f32_t, w)},
}
};
gb_read_only type_t type__r3f32_t = { type_kind_struct, s8_const_lit("r3f32_t"), sizeof(r3f32_t), .count = 6,
gb_read_only type_t type__r3f32_t = { type_kind_struct, s8_const("r3f32_t"), sizeof(r3f32_t), .count = 6,
.members = (type_member_t[]){
{s8_const_lit("x0"), &type__f32, .offset = offsetof(r3f32_t, x0)},
{s8_const_lit("y0"), &type__f32, .offset = offsetof(r3f32_t, y0)},
{s8_const_lit("x0"), &type__f32, .offset = offsetof(r3f32_t, z0)},
{s8_const_lit("x1"), &type__f32, .offset = offsetof(r3f32_t, x1)},
{s8_const_lit("y1"), &type__f32, .offset = offsetof(r3f32_t, y1)},
{s8_const_lit("x1"), &type__f32, .offset = offsetof(r3f32_t, z1)},
{s8_const("x0"), &type__f32, .offset = offsetof(r3f32_t, x0)},
{s8_const("y0"), &type__f32, .offset = offsetof(r3f32_t, y0)},
{s8_const("x0"), &type__f32, .offset = offsetof(r3f32_t, z0)},
{s8_const("x1"), &type__f32, .offset = offsetof(r3f32_t, x1)},
{s8_const("y1"), &type__f32, .offset = offsetof(r3f32_t, y1)},
{s8_const("x1"), &type__f32, .offset = offsetof(r3f32_t, z1)},
}
};
gb_read_only type_member_t members__r2f32_t[] = {
{s8_const_lit("x0"), &type__f32, .offset = offsetof(r2f32_t, x0)},
{s8_const_lit("y0"), &type__f32, .offset = offsetof(r2f32_t, y0)},
{s8_const_lit("x1"), &type__f32, .offset = offsetof(r2f32_t, x1)},
{s8_const_lit("y1"), &type__f32, .offset = offsetof(r2f32_t, y1)},
{s8_const("x0"), &type__f32, .offset = offsetof(r2f32_t, x0)},
{s8_const("y0"), &type__f32, .offset = offsetof(r2f32_t, y0)},
{s8_const("x1"), &type__f32, .offset = offsetof(r2f32_t, x1)},
{s8_const("y1"), &type__f32, .offset = offsetof(r2f32_t, y1)},
};
gb_read_only DEFINE_STRUCT(r2f32_t);
gb_read_only type_member_t members__r1f32_t[] = {
{s8_const_lit("x0"), &type__f32, .offset = offsetof(r1f32_t, x0)},
{s8_const_lit("x1"), &type__f32, .offset = offsetof(r1f32_t, x1)},
{s8_const("x0"), &type__f32, .offset = offsetof(r1f32_t, x0)},
{s8_const("x1"), &type__f32, .offset = offsetof(r1f32_t, x1)},
};
gb_read_only DEFINE_STRUCT(r1f32_t);
gb_read_only type_t type__v2f64_t = { type_kind_struct, s8_const_lit("v2f64_t"), sizeof(v2f64_t), .count = 2,
gb_read_only type_t type__v2f64_t = { type_kind_struct, s8_const("v2f64_t"), sizeof(v2f64_t), .count = 2,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__f64, .offset = offsetof(v2f64_t, x)},
{s8_const_lit("y"), &type__f64, .offset = offsetof(v2f64_t, y)},
{s8_const("x"), &type__f64, .offset = offsetof(v2f64_t, x)},
{s8_const("y"), &type__f64, .offset = offsetof(v2f64_t, y)},
}
};
gb_read_only type_t type__v3f64_t = { type_kind_struct, s8_const_lit("v3f64_t"), sizeof(v3f64_t), .count = 3,
gb_read_only type_t type__v3f64_t = { type_kind_struct, s8_const("v3f64_t"), sizeof(v3f64_t), .count = 3,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__f64, .offset = offsetof(v3f64_t, x)},
{s8_const_lit("y"), &type__f64, .offset = offsetof(v3f64_t, y)},
{s8_const_lit("z"), &type__f64, .offset = offsetof(v3f64_t, z)},
{s8_const("x"), &type__f64, .offset = offsetof(v3f64_t, x)},
{s8_const("y"), &type__f64, .offset = offsetof(v3f64_t, y)},
{s8_const("z"), &type__f64, .offset = offsetof(v3f64_t, z)},
}
};
gb_read_only type_t type__v4f64_t = { type_kind_struct, s8_const_lit("v4f64_t"), sizeof(v4f64_t), .count = 4,
gb_read_only type_t type__v4f64_t = { type_kind_struct, s8_const("v4f64_t"), sizeof(v4f64_t), .count = 4,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__f64, .offset = offsetof(v4f64_t, x)},
{s8_const_lit("y"), &type__f64, .offset = offsetof(v4f64_t, y)},
{s8_const_lit("z"), &type__f64, .offset = offsetof(v4f64_t, z)},
{s8_const_lit("w"), &type__f64, .offset = offsetof(v4f64_t, w)},
{s8_const("x"), &type__f64, .offset = offsetof(v4f64_t, x)},
{s8_const("y"), &type__f64, .offset = offsetof(v4f64_t, y)},
{s8_const("z"), &type__f64, .offset = offsetof(v4f64_t, z)},
{s8_const("w"), &type__f64, .offset = offsetof(v4f64_t, w)},
}
};
gb_read_only type_t type__r3f64_t = { type_kind_struct, s8_const_lit("r3f64_t"), sizeof(r3f64_t), .count = 6,
gb_read_only type_t type__r3f64_t = { type_kind_struct, s8_const("r3f64_t"), sizeof(r3f64_t), .count = 6,
.members = (type_member_t[]){
{s8_const_lit("x0"), &type__f64, .offset = offsetof(r3f64_t, x0)},
{s8_const_lit("y0"), &type__f64, .offset = offsetof(r3f64_t, y0)},
{s8_const_lit("x0"), &type__f64, .offset = offsetof(r3f64_t, z0)},
{s8_const_lit("x1"), &type__f64, .offset = offsetof(r3f64_t, x1)},
{s8_const_lit("y1"), &type__f64, .offset = offsetof(r3f64_t, y1)},
{s8_const_lit("x1"), &type__f64, .offset = offsetof(r3f64_t, z1)},
{s8_const("x0"), &type__f64, .offset = offsetof(r3f64_t, x0)},
{s8_const("y0"), &type__f64, .offset = offsetof(r3f64_t, y0)},
{s8_const("x0"), &type__f64, .offset = offsetof(r3f64_t, z0)},
{s8_const("x1"), &type__f64, .offset = offsetof(r3f64_t, x1)},
{s8_const("y1"), &type__f64, .offset = offsetof(r3f64_t, y1)},
{s8_const("x1"), &type__f64, .offset = offsetof(r3f64_t, z1)},
}
};
gb_read_only type_member_t members__r2f64_t[] = {
{s8_const_lit("x0"), &type__f64, .offset = offsetof(r2f64_t, x0)},
{s8_const_lit("y0"), &type__f64, .offset = offsetof(r2f64_t, y0)},
{s8_const_lit("x1"), &type__f64, .offset = offsetof(r2f64_t, x1)},
{s8_const_lit("y1"), &type__f64, .offset = offsetof(r2f64_t, y1)},
{s8_const("x0"), &type__f64, .offset = offsetof(r2f64_t, x0)},
{s8_const("y0"), &type__f64, .offset = offsetof(r2f64_t, y0)},
{s8_const("x1"), &type__f64, .offset = offsetof(r2f64_t, x1)},
{s8_const("y1"), &type__f64, .offset = offsetof(r2f64_t, y1)},
};
gb_read_only DEFINE_STRUCT(r2f64_t);
gb_read_only type_member_t members__r1f64_t[] = {
{s8_const_lit("x0"), &type__f64, .offset = offsetof(r1f64_t, x0)},
{s8_const_lit("x1"), &type__f64, .offset = offsetof(r1f64_t, x1)},
{s8_const("x0"), &type__f64, .offset = offsetof(r1f64_t, x0)},
{s8_const("x1"), &type__f64, .offset = offsetof(r1f64_t, x1)},
};
gb_read_only DEFINE_STRUCT(r1f64_t);
gb_read_only type_t type__v2i32_t = { type_kind_struct, s8_const_lit("v2i32_t"), sizeof(v2i32_t), .count = 2,
gb_read_only type_t type__v2i32_t = { type_kind_struct, s8_const("v2i32_t"), sizeof(v2i32_t), .count = 2,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__i32, .offset = offsetof(v2i32_t, x)},
{s8_const_lit("y"), &type__i32, .offset = offsetof(v2i32_t, y)},
{s8_const("x"), &type__i32, .offset = offsetof(v2i32_t, x)},
{s8_const("y"), &type__i32, .offset = offsetof(v2i32_t, y)},
}
};
gb_read_only type_t type__v3i32_t = { type_kind_struct, s8_const_lit("v3i32_t"), sizeof(v3i32_t), .count = 3,
gb_read_only type_t type__v3i32_t = { type_kind_struct, s8_const("v3i32_t"), sizeof(v3i32_t), .count = 3,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__i32, .offset = offsetof(v3i32_t, x)},
{s8_const_lit("y"), &type__i32, .offset = offsetof(v3i32_t, y)},
{s8_const_lit("z"), &type__i32, .offset = offsetof(v3i32_t, z)},
{s8_const("x"), &type__i32, .offset = offsetof(v3i32_t, x)},
{s8_const("y"), &type__i32, .offset = offsetof(v3i32_t, y)},
{s8_const("z"), &type__i32, .offset = offsetof(v3i32_t, z)},
}
};
gb_read_only type_t type__v4i32_t = { type_kind_struct, s8_const_lit("v4i32_t"), sizeof(v4i32_t), .count = 4,
gb_read_only type_t type__v4i32_t = { type_kind_struct, s8_const("v4i32_t"), sizeof(v4i32_t), .count = 4,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__i32, .offset = offsetof(v4i32_t, x)},
{s8_const_lit("y"), &type__i32, .offset = offsetof(v4i32_t, y)},
{s8_const_lit("z"), &type__i32, .offset = offsetof(v4i32_t, z)},
{s8_const_lit("w"), &type__i32, .offset = offsetof(v4i32_t, w)},
{s8_const("x"), &type__i32, .offset = offsetof(v4i32_t, x)},
{s8_const("y"), &type__i32, .offset = offsetof(v4i32_t, y)},
{s8_const("z"), &type__i32, .offset = offsetof(v4i32_t, z)},
{s8_const("w"), &type__i32, .offset = offsetof(v4i32_t, w)},
}
};
gb_read_only type_t type__r3i32_t = { type_kind_struct, s8_const_lit("r3i32_t"), sizeof(r3i32_t), .count = 6,
gb_read_only type_t type__r3i32_t = { type_kind_struct, s8_const("r3i32_t"), sizeof(r3i32_t), .count = 6,
.members = (type_member_t[]){
{s8_const_lit("x0"), &type__i32, .offset = offsetof(r3i32_t, x0)},
{s8_const_lit("y0"), &type__i32, .offset = offsetof(r3i32_t, y0)},
{s8_const_lit("x0"), &type__i32, .offset = offsetof(r3i32_t, z0)},
{s8_const_lit("x1"), &type__i32, .offset = offsetof(r3i32_t, x1)},
{s8_const_lit("y1"), &type__i32, .offset = offsetof(r3i32_t, y1)},
{s8_const_lit("x1"), &type__i32, .offset = offsetof(r3i32_t, z1)},
{s8_const("x0"), &type__i32, .offset = offsetof(r3i32_t, x0)},
{s8_const("y0"), &type__i32, .offset = offsetof(r3i32_t, y0)},
{s8_const("x0"), &type__i32, .offset = offsetof(r3i32_t, z0)},
{s8_const("x1"), &type__i32, .offset = offsetof(r3i32_t, x1)},
{s8_const("y1"), &type__i32, .offset = offsetof(r3i32_t, y1)},
{s8_const("x1"), &type__i32, .offset = offsetof(r3i32_t, z1)},
}
};
gb_read_only type_member_t members__r2i32_t[] = {
{s8_const_lit("x0"), &type__i32, .offset = offsetof(r2i32_t, x0)},
{s8_const_lit("y0"), &type__i32, .offset = offsetof(r2i32_t, y0)},
{s8_const_lit("x1"), &type__i32, .offset = offsetof(r2i32_t, x1)},
{s8_const_lit("y1"), &type__i32, .offset = offsetof(r2i32_t, y1)},
{s8_const("x0"), &type__i32, .offset = offsetof(r2i32_t, x0)},
{s8_const("y0"), &type__i32, .offset = offsetof(r2i32_t, y0)},
{s8_const("x1"), &type__i32, .offset = offsetof(r2i32_t, x1)},
{s8_const("y1"), &type__i32, .offset = offsetof(r2i32_t, y1)},
};
gb_read_only DEFINE_STRUCT(r2i32_t);
gb_read_only type_member_t members__r1i32_t[] = {
{s8_const_lit("x0"), &type__i32, .offset = offsetof(r1i32_t, x0)},
{s8_const_lit("x1"), &type__i32, .offset = offsetof(r1i32_t, x1)},
{s8_const("x0"), &type__i32, .offset = offsetof(r1i32_t, x0)},
{s8_const("x1"), &type__i32, .offset = offsetof(r1i32_t, x1)},
};
gb_read_only DEFINE_STRUCT(r1i32_t);
gb_read_only type_t type__v2i64_t = { type_kind_struct, s8_const_lit("v2i64_t"), sizeof(v2i64_t), .count = 2,
gb_read_only type_t type__v2i64_t = { type_kind_struct, s8_const("v2i64_t"), sizeof(v2i64_t), .count = 2,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__i64, .offset = offsetof(v2i64_t, x)},
{s8_const_lit("y"), &type__i64, .offset = offsetof(v2i64_t, y)},
{s8_const("x"), &type__i64, .offset = offsetof(v2i64_t, x)},
{s8_const("y"), &type__i64, .offset = offsetof(v2i64_t, y)},
}
};
gb_read_only type_t type__v3i64_t = { type_kind_struct, s8_const_lit("v3i64_t"), sizeof(v3i64_t), .count = 3,
gb_read_only type_t type__v3i64_t = { type_kind_struct, s8_const("v3i64_t"), sizeof(v3i64_t), .count = 3,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__i64, .offset = offsetof(v3i64_t, x)},
{s8_const_lit("y"), &type__i64, .offset = offsetof(v3i64_t, y)},
{s8_const_lit("z"), &type__i64, .offset = offsetof(v3i64_t, z)},
{s8_const("x"), &type__i64, .offset = offsetof(v3i64_t, x)},
{s8_const("y"), &type__i64, .offset = offsetof(v3i64_t, y)},
{s8_const("z"), &type__i64, .offset = offsetof(v3i64_t, z)},
}
};
gb_read_only type_t type__v4i64_t = { type_kind_struct, s8_const_lit("v4i64_t"), sizeof(v4i64_t), .count = 4,
gb_read_only type_t type__v4i64_t = { type_kind_struct, s8_const("v4i64_t"), sizeof(v4i64_t), .count = 4,
.members = (type_member_t[]){
{s8_const_lit("x"), &type__i64, .offset = offsetof(v4i64_t, x)},
{s8_const_lit("y"), &type__i64, .offset = offsetof(v4i64_t, y)},
{s8_const_lit("z"), &type__i64, .offset = offsetof(v4i64_t, z)},
{s8_const_lit("w"), &type__i64, .offset = offsetof(v4i64_t, w)},
{s8_const("x"), &type__i64, .offset = offsetof(v4i64_t, x)},
{s8_const("y"), &type__i64, .offset = offsetof(v4i64_t, y)},
{s8_const("z"), &type__i64, .offset = offsetof(v4i64_t, z)},
{s8_const("w"), &type__i64, .offset = offsetof(v4i64_t, w)},
}
};
gb_read_only type_t type__r3i64_t = { type_kind_struct, s8_const_lit("r3i64_t"), sizeof(r3i64_t), .count = 6,
gb_read_only type_t type__r3i64_t = { type_kind_struct, s8_const("r3i64_t"), sizeof(r3i64_t), .count = 6,
.members = (type_member_t[]){
{s8_const_lit("x0"), &type__i64, .offset = offsetof(r3i64_t, x0)},
{s8_const_lit("y0"), &type__i64, .offset = offsetof(r3i64_t, y0)},
{s8_const_lit("x0"), &type__i64, .offset = offsetof(r3i64_t, z0)},
{s8_const_lit("x1"), &type__i64, .offset = offsetof(r3i64_t, x1)},
{s8_const_lit("y1"), &type__i64, .offset = offsetof(r3i64_t, y1)},
{s8_const_lit("x1"), &type__i64, .offset = offsetof(r3i64_t, z1)},
{s8_const("x0"), &type__i64, .offset = offsetof(r3i64_t, x0)},
{s8_const("y0"), &type__i64, .offset = offsetof(r3i64_t, y0)},
{s8_const("x0"), &type__i64, .offset = offsetof(r3i64_t, z0)},
{s8_const("x1"), &type__i64, .offset = offsetof(r3i64_t, x1)},
{s8_const("y1"), &type__i64, .offset = offsetof(r3i64_t, y1)},
{s8_const("x1"), &type__i64, .offset = offsetof(r3i64_t, z1)},
}
};
gb_read_only type_member_t members__r2i64_t[] = {
{s8_const_lit("x0"), &type__i64, .offset = offsetof(r2i64_t, x0)},
{s8_const_lit("y0"), &type__i64, .offset = offsetof(r2i64_t, y0)},
{s8_const_lit("x1"), &type__i64, .offset = offsetof(r2i64_t, x1)},
{s8_const_lit("y1"), &type__i64, .offset = offsetof(r2i64_t, y1)},
{s8_const("x0"), &type__i64, .offset = offsetof(r2i64_t, x0)},
{s8_const("y0"), &type__i64, .offset = offsetof(r2i64_t, y0)},
{s8_const("x1"), &type__i64, .offset = offsetof(r2i64_t, x1)},
{s8_const("y1"), &type__i64, .offset = offsetof(r2i64_t, y1)},
};
gb_read_only DEFINE_STRUCT(r2i64_t);
gb_read_only type_member_t members__r1i64_t[] = {
{s8_const_lit("x0"), &type__i64, .offset = offsetof(r1i64_t, x0)},
{s8_const_lit("x1"), &type__i64, .offset = offsetof(r1i64_t, x1)},
{s8_const("x0"), &type__i64, .offset = offsetof(r1i64_t, x0)},
{s8_const("x1"), &type__i64, .offset = offsetof(r1i64_t, x1)},
};
gb_read_only DEFINE_STRUCT(r1i64_t);