Add code generation for array

This commit is contained in:
2025-05-04 23:26:03 +01:00
parent f444911452
commit 12f083edb0
18 changed files with 4466 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
{ArrayType} *output = dst;
if (!allocator || !src || !dst) {{
goto RETURN_{Tupper}_ARRAY_COPY_ALLOC;
}}
if (src->count >= dst->capacity) {{
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(dst->capacity * 2);
output = wapp_{Tlower}_array_alloc_capacity(allocator, new_capacity);
if (!output) {{
output = dst;
goto RETURN_{Tupper}_ARRAY_COPY_ALLOC;
}}
}}
wapp_{Tlower}_array_clear(output);
wapp_{Tlower}_array_copy_capped(src, output);
RETURN_{Tupper}_ARRAY_COPY_ALLOC:
return output;