Make GingerBill happy #96

Merged
MartinFouilleul merged 3 commits from flip_oc_str8 into main 2023-09-11 12:21:35 +00:00
4 changed files with 15 additions and 15 deletions
Showing only changes of commit 3e2f550b68 - Show all commits

View File

@ -629,7 +629,7 @@ oc_str32 oc_font_get_glyph_indices_from_font_data(oc_font_data* fontData, oc_str
} }
backing.ptr[i] = glyphIndex; backing.ptr[i] = glyphIndex;
} }
oc_str32 res = { .len = count, .ptr = backing.ptr }; oc_str32 res = {.ptr = backing.ptr , .len = count};
return (res); return (res);
} }
@ -1428,7 +1428,7 @@ oc_rect oc_glyph_outlines_from_font_data(oc_font_data* fontData, oc_str32 glyphI
if(missingGlyphIndex) if(missingGlyphIndex)
{ {
oc_font_get_glyph_metrics_from_font_data(fontData, (oc_str32){ .len = 1, .ptr = &missingGlyphIndex }, &missingGlyphMetrics); oc_font_get_glyph_metrics_from_font_data(fontData, (oc_str32){.ptr = &missingGlyphIndex , .len = 1}, &missingGlyphMetrics);
} }
else else
{ {

View File

@ -14,13 +14,13 @@
oc_str8 oc_str8_from_buffer(u64 len, char* buffer) oc_str8 oc_str8_from_buffer(u64 len, char* buffer)
{ {
return ((oc_str8){ .len = len, .ptr = buffer }); return ((oc_str8){.ptr = buffer , .len = len});
} }
oc_str8 oc_str8_slice(oc_str8 s, u64 start, u64 end) oc_str8 oc_str8_slice(oc_str8 s, u64 start, u64 end)
{ {
OC_ASSERT(start <= end && start <= s.len && end <= s.len); OC_ASSERT(start <= end && start <= s.len && end <= s.len);
return ((oc_str8){ .len = end - start, .ptr = s.ptr + start }); return ((oc_str8){.ptr = s.ptr + start , .len = end - start});
} }
oc_str8 oc_str8_push_buffer(oc_arena* arena, u64 len, char* buffer) oc_str8 oc_str8_push_buffer(oc_arena* arena, u64 len, char* buffer)
@ -158,7 +158,7 @@ oc_str8 oc_str8_list_collate(oc_arena* arena, oc_str8_list list, oc_str8 prefix,
oc_str8 oc_str8_list_join(oc_arena* arena, oc_str8_list list) oc_str8 oc_str8_list_join(oc_arena* arena, oc_str8_list list)
{ {
oc_str8 empty = { .len = 0, .ptr = 0 }; oc_str8 empty = {.ptr = 0 , .len = 0};
return (oc_str8_list_collate(arena, list, empty, empty, empty)); return (oc_str8_list_collate(arena, list, empty, empty, empty));
} }
@ -221,13 +221,13 @@ oc_str8_list oc_str8_split(oc_arena* arena, oc_str8 str, oc_str8_list separators
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
oc_str16 oc_str16_from_buffer(u64 len, u16* buffer) oc_str16 oc_str16_from_buffer(u64 len, u16* buffer)
{ {
return ((oc_str16){ .len = len, .ptr = buffer }); return ((oc_str16){.ptr = buffer , .len = len});
} }
oc_str16 oc_str16_slice(oc_str16 s, u64 start, u64 end) oc_str16 oc_str16_slice(oc_str16 s, u64 start, u64 end)
{ {
OC_ASSERT(start <= end && start <= s.len && end <= s.len); OC_ASSERT(start <= end && start <= s.len && end <= s.len);
return ((oc_str16){ .len = end - start, .ptr = s.ptr + start }); return ((oc_str16){.ptr = s.ptr + start , .len = end - start});
} }
oc_str16 oc_str16_push_buffer(oc_arena* arena, u64 len, u16* buffer) oc_str16 oc_str16_push_buffer(oc_arena* arena, u64 len, u16* buffer)
@ -298,7 +298,7 @@ oc_str16 oc_str16_list_collate(oc_arena* arena, oc_str16_list list, oc_str16 pre
oc_str16 oc_str16_list_join(oc_arena* arena, oc_str16_list list) oc_str16 oc_str16_list_join(oc_arena* arena, oc_str16_list list)
{ {
oc_str16 empty = { .len = 0, .ptr = 0 }; oc_str16 empty = {.ptr = 0 , .len = 0};
return (oc_str16_list_collate(arena, list, empty, empty, empty)); return (oc_str16_list_collate(arena, list, empty, empty, empty));
} }
@ -307,13 +307,13 @@ oc_str16 oc_str16_list_join(oc_arena* arena, oc_str16_list list)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
oc_str32 oc_str32_from_buffer(u64 len, u32* buffer) oc_str32 oc_str32_from_buffer(u64 len, u32* buffer)
{ {
return ((oc_str32){ .len = len, .ptr = buffer }); return ((oc_str32){.ptr = buffer , .len = len});
} }
oc_str32 oc_str32_slice(oc_str32 s, u64 start, u64 end) oc_str32 oc_str32_slice(oc_str32 s, u64 start, u64 end)
{ {
OC_ASSERT(start <= end && start <= s.len && end <= s.len); OC_ASSERT(start <= end && start <= s.len && end <= s.len);
return ((oc_str32){ .len = end - start, .ptr = s.ptr + start }); return ((oc_str32){.ptr = s.ptr + start , .len = end - start});
} }
oc_str32 oc_str32_push_buffer(oc_arena* arena, u64 len, u32* buffer) oc_str32 oc_str32_push_buffer(oc_arena* arena, u64 len, u32* buffer)
@ -384,6 +384,6 @@ oc_str32 oc_str32_list_collate(oc_arena* arena, oc_str32_list list, oc_str32 pre
oc_str32 oc_str32_list_join(oc_arena* arena, oc_str32_list list) oc_str32 oc_str32_list_join(oc_arena* arena, oc_str32_list list)
{ {
oc_str32 empty = { .len = 0, .ptr = 0 }; oc_str32 empty = {.ptr = 0 , .len = 0};
return (oc_str32_list_collate(arena, list, empty, empty, empty)); return (oc_str32_list_collate(arena, list, empty, empty, empty));
} }

View File

@ -38,7 +38,7 @@ typedef struct oc_str8
size_t len; size_t len;
} oc_str8; } oc_str8;
#define OC_STR8(s) ((oc_str8){ .len = (s) ? strlen(s) : 0, .ptr = (char*)s }) #define OC_STR8(s) ((oc_str8){.ptr = (char*)s , .len = (s) ? strlen(s) : 0})
//NOTE: this only works with string literals, but is sometimes necessary to generate compile-time constants //NOTE: this only works with string literals, but is sometimes necessary to generate compile-time constants
#define OC_STR8_LIT(s) \ #define OC_STR8_LIT(s) \

View File

@ -225,7 +225,7 @@ oc_str8 oc_utf8_encode(char* dest, oc_utf32 codePoint)
dest[3] = (codePoint & 0x3F) | 0x80; dest[3] = (codePoint & 0x3F) | 0x80;
sz = 4; sz = 4;
} }
oc_str8 res = { .len = sz, .ptr = dest }; oc_str8 res = {.ptr = dest , .len = sz};
return (res); return (res);
} }
@ -239,7 +239,7 @@ oc_str32 oc_utf8_to_codepoints(u64 maxCount, oc_utf32* backing, oc_str8 string)
backing[codePointIndex] = decode.codepoint; backing[codePointIndex] = decode.codepoint;
byteOffset += decode.size; byteOffset += decode.size;
} }
oc_str32 res = { .len = codePointIndex, .ptr = backing }; oc_str32 res = {.ptr = backing , .len = codePointIndex};
return (res); return (res);
} }
@ -257,7 +257,7 @@ oc_str8 oc_utf8_from_codepoints(u64 maxBytes, char* backing, oc_str32 codePoints
oc_utf8_encode(backing + byteOffset, codePoint); oc_utf8_encode(backing + byteOffset, codePoint);
byteOffset += byteCount; byteOffset += byteCount;
} }
oc_str8 res = { .len = byteOffset, .ptr = backing }; oc_str8 res = {.ptr = backing , .len = byteOffset};
return (res); return (res);
} }