Compare commits

..

13 Commits

66 changed files with 1406 additions and 2495 deletions

View File

@ -51,10 +51,6 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
header=str(convert_to_relative(WAPP_SRC_ROOT / "primitives" / "mem_allocator" / "mem_allocator.h", out_dir)).replace("\\", "/"), header=str(convert_to_relative(WAPP_SRC_ROOT / "primitives" / "mem_allocator" / "mem_allocator.h", out_dir)).replace("\\", "/"),
local=True, local=True,
), ),
CInclude(
header=str(convert_to_relative(WAPP_SRC_ROOT / "primitives" / "strings" / "str8" / "str8.h", out_dir)).replace("\\", "/"),
local=True,
),
CInclude( CInclude(
header=str(convert_to_relative(WAPP_SRC_ROOT / "common" / "misc" / "misc_utils.h", out_dir)).replace("\\", "/"), header=str(convert_to_relative(WAPP_SRC_ROOT / "common" / "misc" / "misc_utils.h", out_dir)).replace("\\", "/"),
local=True, local=True,
@ -66,6 +62,9 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
datatypes: dict[CDataType, ArrayData] = { datatypes: dict[CDataType, ArrayData] = {
"Str8": ArrayData( "Str8": ArrayData(
array_typename="Str8Array", array_typename="Str8Array",
hdr_decl_types=[
CStruct(name="str8", cargs=[], typedef_name="Str8"),
],
), ),
} }
@ -101,7 +100,11 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
source = CSource( source = CSource(
name=header.name, name=header.name,
decl_types=[*common_decl_types], decl_types=[*common_decl_types],
includes=[CInclude(header, local=True, same_dir=True), CInclude(header="stddef.h")], includes=[
CInclude(header, local=True, same_dir=True),
CInclude(header="stddef.h"),
CInclude(header="assert.h"),
],
internal_funcs=[], internal_funcs=[],
funcs=header.funcs funcs=header.funcs
) )
@ -111,6 +114,8 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
source.includes.extend(common_includes) source.includes.extend(common_includes)
generic_funcs = []
for _type, array_data in datatypes.items(): for _type, array_data in datatypes.items():
type_string = get_datatype_string(_type) type_string = get_datatype_string(_type)
clean_type_string = type_string.replace(" ", "").replace("*", "_ptr") clean_type_string = type_string.replace(" ", "").replace("*", "_ptr")
@ -123,9 +128,30 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
CArg(name="items", _type=type_string, pointer=CPointer(_type=CPointerType.SINGLE)), CArg(name="items", _type=type_string, pointer=CPointer(_type=CPointerType.SINGLE)),
CArg(name="count", _type=CType.U64), CArg(name="count", _type=CType.U64),
CArg(name="capacity", _type=CType.U64), CArg(name="capacity", _type=CType.U64),
CArg(name="item_size", _type=CType.U64),
], ],
) )
if isinstance(_type, str) and _type == "void *":
alloc_capacity_func = CFunc(
name=f"_array_alloc_capacity",
ret_type=array,
args=[
CArg(name="allocator", _type="Allocator", pointer=CPointer(CPointerType.SINGLE), qualifier=CQualifier.CONST),
CArg(name="capacity", _type=CType.U64),
CArg(name="item_size", _type=CType.U64),
],
body=__format_func_body(
filename=snippets_dir / "alloc_capacity",
type_string=type_string,
type_string_upper=type_string_upper,
type_string_lower=type_string_lower,
array_typename=array_data.array_typename,
),
pointer=CPointer(CPointerType.SINGLE),
)
generic_funcs.append(alloc_capacity_func)
stack_array_macro = CMacro( stack_array_macro = CMacro(
name=f"wapp_{type_string_lower}_array(...)", name=f"wapp_{type_string_lower}_array(...)",
value=__format_func_body( value=__format_func_body(
@ -148,6 +174,28 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
), ),
) )
alloc_capacity_array_macro = CMacro(
name=f"wapp_{type_string_lower}_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY)",
value=__format_func_body(
filename=snippets_dir / "alloc_capacity_macro",
type_string=type_string,
type_string_upper=type_string_upper,
type_string_lower=type_string_lower,
array_typename=array_data.array_typename,
),
)
array_pop_macro = CMacro(
name=f"wapp_{type_string_lower}_array_pop(ARRAY_PTR)",
value=__format_func_body(
filename=snippets_dir / "array_pop_macro",
type_string=type_string,
type_string_upper=type_string_upper,
type_string_lower=type_string_lower,
array_typename=array_data.array_typename,
),
)
get_func = CFunc( get_func = CFunc(
name=f"wapp_{type_string_lower}_array_get", name=f"wapp_{type_string_lower}_array_get",
ret_type=type_string, ret_type=type_string,
@ -171,7 +219,7 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
args=[ args=[
CArg(name="array", _type=array, pointer=CPointer(CPointerType.SINGLE)), CArg(name="array", _type=array, pointer=CPointer(CPointerType.SINGLE)),
CArg(name="index", _type=CType.U64), CArg(name="index", _type=CType.U64),
CArg(name="item", _type=type_string), CArg(name="item", _type=type_string, pointer=CPointer(CPointerType.SINGLE)),
], ],
body=__format_func_body( body=__format_func_body(
filename=snippets_dir / "array_set", filename=snippets_dir / "array_set",
@ -187,7 +235,7 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
ret_type=CType.VOID, ret_type=CType.VOID,
args=[ args=[
CArg(name="array", _type=array, pointer=CPointer(CPointerType.SINGLE)), CArg(name="array", _type=array, pointer=CPointer(CPointerType.SINGLE)),
CArg(name="item", _type=type_string), CArg(name="item", _type=type_string, pointer=CPointer(CPointerType.SINGLE)),
], ],
body=__format_func_body( body=__format_func_body(
filename=snippets_dir / "append_capped", filename=snippets_dir / "append_capped",
@ -229,21 +277,6 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
), ),
) )
pop_func = CFunc(
name=f"wapp_{type_string_lower}_array_pop",
ret_type=type_string,
args=[
CArg(name="array", _type=array, pointer=CPointer(CPointerType.SINGLE)),
],
body=__format_func_body(
filename=snippets_dir / "array_pop",
type_string=type_string,
type_string_upper=type_string_upper,
type_string_lower=type_string_lower,
array_typename=array_data.array_typename,
),
)
copy_capped_func = CFunc( copy_capped_func = CFunc(
name=f"wapp_{type_string_lower}_array_copy_capped", name=f"wapp_{type_string_lower}_array_copy_capped",
ret_type=CType.VOID, ret_type=CType.VOID,
@ -260,30 +293,13 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
), ),
) )
alloc_capacity_func = CFunc(
name=f"wapp_{type_string_lower}_array_alloc_capacity",
ret_type=array,
args=[
CArg(name="allocator", _type="Allocator", pointer=CPointer(CPointerType.SINGLE), qualifier=CQualifier.CONST),
CArg(name="capacity", _type=CType.U64),
],
body=__format_func_body(
filename=snippets_dir / "alloc_capacity",
type_string=type_string,
type_string_upper=type_string_upper,
type_string_lower=type_string_lower,
array_typename=array_data.array_typename,
),
pointer=CPointer(CPointerType.SINGLE),
)
append_alloc_func = CFunc( append_alloc_func = CFunc(
name=f"wapp_{type_string_lower}_array_append_alloc", name=f"wapp_{type_string_lower}_array_append_alloc",
ret_type=array, ret_type=array,
args=[ args=[
CArg(name="allocator", _type="Allocator", pointer=CPointer(CPointerType.SINGLE), qualifier=CQualifier.CONST), CArg(name="allocator", _type="Allocator", pointer=CPointer(CPointerType.SINGLE), qualifier=CQualifier.CONST),
CArg(name="array", _type=array, pointer=CPointer(CPointerType.SINGLE)), CArg(name="array", _type=array, pointer=CPointer(CPointerType.SINGLE)),
CArg(name="item", _type=type_string), CArg(name="item", _type=type_string, pointer=CPointer(CPointerType.SINGLE)),
], ],
body=__format_func_body( body=__format_func_body(
filename=snippets_dir / "append_alloc", filename=snippets_dir / "append_alloc",
@ -331,8 +347,29 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
pointer=CPointer(CPointerType.SINGLE), pointer=CPointer(CPointerType.SINGLE),
) )
pop_func = CFunc(
name=f"_{type_string_lower}_array_pop",
ret_type=type_string,
args=[
CArg(name="array", _type=array, pointer=CPointer(CPointerType.SINGLE)),
],
body=__format_func_body(
filename=snippets_dir / "array_pop",
type_string=type_string,
type_string_upper=type_string_upper,
type_string_lower=type_string_lower,
array_typename=array_data.array_typename,
),
pointer=CPointer(CPointerType.SINGLE),
)
header.decl_types.extend(array_data.hdr_decl_types) header.decl_types.extend(array_data.hdr_decl_types)
header.macros.extend([stack_array_macro, stack_capacity_array_macro]) header.macros.extend([
stack_array_macro,
stack_capacity_array_macro,
alloc_capacity_array_macro,
array_pop_macro,
])
header.types.extend([array]) header.types.extend([array])
header.funcs.extend([ header.funcs.extend([
get_func, get_func,
@ -340,16 +377,17 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}):
append_capped_func, append_capped_func,
extend_capped_func, extend_capped_func,
clear_func, clear_func,
pop_func,
copy_capped_func, copy_capped_func,
alloc_capacity_func,
append_alloc_func, append_alloc_func,
extend_alloc_func, extend_alloc_func,
copy_alloc_func, copy_alloc_func,
pop_func,
]) ])
source.decl_types.extend(array_data.src_decl_types) source.decl_types.extend(array_data.src_decl_types)
source.funcs = header.funcs source.funcs = header.funcs
header.funcs.extend(generic_funcs)
header.save(out_dir) header.save(out_dir)
source.save(out_dir) source.save(out_dir)

View File

@ -1,18 +1,15 @@
u64 allocation_size = sizeof({ArrayType}) + sizeof({T}) * capacity; assert(allocator != NULL);
{ArrayType} *array = NULL;
if (!allocator) {{ u64 allocation_size = sizeof({ArrayType}) + item_size * capacity;
goto RETURN_{Tupper}_ARRAY_ALLOC; {ArrayType} *array = wapp_mem_allocator_alloc(allocator, allocation_size);
}}
array = wapp_mem_allocator_alloc(allocator, allocation_size);
if (!array) {{ if (!array) {{
goto RETURN_{Tupper}_ARRAY_ALLOC; goto RETURN_GENERIC_ARRAY_ALLOC;
}} }}
array->items = ({T} *)((u8 *)array + sizeof({ArrayType})); array->items = ({T} *)((u8 *)array + sizeof({ArrayType}));
array->count = 0; array->count = 0;
array->capacity = capacity; array->capacity = capacity;
array->item_size = item_size;
RETURN_{Tupper}_ARRAY_ALLOC: RETURN_GENERIC_ARRAY_ALLOC:
return array; return array;

View File

@ -0,0 +1 @@
(({ArrayType} *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof({T})))

View File

@ -1,12 +1,10 @@
{ArrayType} *output = array; assert(allocator != NULL && array != NULL);
if (!allocator || !array) {{ {ArrayType} *output = array;
goto RETURN_{Tupper}_ARRAY_APPEND_ALLOC;
}}
if (array->count >= array->capacity) {{ if (array->count >= array->capacity) {{
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2); u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2);
output = wapp_{Tlower}_array_alloc_capacity(allocator, new_capacity); output = ({ArrayType} *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
if (!output) {{ if (!output) {{
output = array; output = array;
goto RETURN_{Tupper}_ARRAY_APPEND_ALLOC; goto RETURN_{Tupper}_ARRAY_APPEND_ALLOC;

View File

@ -1,5 +1,4 @@
if (!array || array->count >= array->capacity) {{ assert(array != NULL && array->count < array->capacity);
return;
}}
array->items[(array->count)++] = item; u64 index = (array->count)++;
wapp_{Tlower}_array_set(array, index, item);

View File

@ -1,5 +1,4 @@
if (!array || index >= array->count) {{ assert(array != NULL && index < array->count);
return NULL;
}}
return &(array->items[index]); u8 *ptr = (u8 *)(array->items) + (array->item_size * index);
return ({T} *)ptr;

View File

@ -1,5 +1,4 @@
if (!array || array->count == 0) {{ u64 index = array->count - 1;
return ({T}){{0}}; {T} *out = wapp_{Tlower}_array_get(array, index);
}} --(array->count);
return out;
return array->items[--(array->count)];

View File

@ -0,0 +1,4 @@
(ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_{Tlower}_array_pop(ARRAY_PTR) : \
({T}){{0}} \
)

View File

@ -1,5 +1,3 @@
if (!array || index >= array->count) {{ {T} *ptr = wapp_{Tlower}_array_get(array, index);
return;
}}
array->items[index] = item; memcpy((void *)ptr, (void *)item, array->item_size);

View File

@ -1,5 +1,2 @@
if (!array) {{ assert(array != NULL);
return;
}}
array->count = 0; array->count = 0;

View File

@ -1,12 +1,10 @@
{ArrayType} *output = dst; assert(allocator != NULL && src != NULL && dst != NULL);
if (!allocator || !src || !dst) {{ {ArrayType} *output = dst;
goto RETURN_{Tupper}_ARRAY_COPY_ALLOC;
}}
if (src->count >= dst->capacity) {{ if (src->count >= dst->capacity) {{
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(dst->capacity * 2); u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(dst->capacity * 2);
output = wapp_{Tlower}_array_alloc_capacity(allocator, new_capacity); output = ({ArrayType} *)_array_alloc_capacity(allocator, new_capacity, src->item_size);
if (!output) {{ if (!output) {{
output = dst; output = dst;
goto RETURN_{Tupper}_ARRAY_COPY_ALLOC; goto RETURN_{Tupper}_ARRAY_COPY_ALLOC;

View File

@ -1,6 +1,4 @@
if (!src || !dst) {{ assert(src != NULL && dst != NULL);
return;
}}
wapp_{Tlower}_array_clear(dst); wapp_{Tlower}_array_clear(dst);
@ -20,5 +18,5 @@
continue; continue;
}} }}
wapp_{Tlower}_array_append_capped(dst, *item); wapp_{Tlower}_array_append_capped(dst, item);
}} }}

View File

@ -1,13 +1,11 @@
{ArrayType} *output = array; assert(allocator != NULL && array != NULL && other != NULL);
if (!allocator || !array || !other) {{ {ArrayType} *output = array;
goto RETURN_{Tupper}_ARRAY_EXTEND_ALLOC;
}}
u64 remaining_capacity = array->capacity - array->count; u64 remaining_capacity = array->capacity - array->count;
if (other->count >= remaining_capacity) {{ if (other->count >= remaining_capacity) {{
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2); u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2);
output = wapp_{Tlower}_array_alloc_capacity(allocator, new_capacity); output = ({ArrayType} *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
if (!output) {{ if (!output) {{
output = array; output = array;
goto RETURN_{Tupper}_ARRAY_EXTEND_ALLOC; goto RETURN_{Tupper}_ARRAY_EXTEND_ALLOC;

View File

@ -1,11 +1,7 @@
if (!array || !other) {{ assert(array != NULL && other != NULL);
return;
}}
u64 remaining_capacity = array->capacity - array->count; u64 remaining_capacity = array->capacity - array->count;
if (other->count >= remaining_capacity) {{ assert(other->count < remaining_capacity);
return;
}}
{T} *item; {T} *item;
@ -23,5 +19,5 @@
continue; continue;
}} }}
wapp_{Tlower}_array_append_capped(array, *item); wapp_{Tlower}_array_append_capped(array, item);
}} }}

View File

@ -1,5 +1,6 @@
(({ArrayType}){{ \ (({ArrayType}){{ \
.items = ({T}[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count({T}, __VA_ARGS__) * 2)]){{__VA_ARGS__}}, \ .items = ({T}[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count({T}, __VA_ARGS__) * 2)]){{__VA_ARGS__}}, \
.count = wapp_misc_utils_va_args_count({T}, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count({T}, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count({T}, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count({T}, __VA_ARGS__) * 2), \
.item_size = sizeof({T}) \
}}) }})

View File

@ -1 +1 @@
(({ArrayType}){{.items = ({T}[CAPACITY]){{0}}, .count = 0, .capacity = CAPACITY}}) (({ArrayType}){{.items = ({T}[CAPACITY]){{0}}, .count = 0, .capacity = CAPACITY, .item_size = sizeof({T})}})

View File

@ -246,10 +246,7 @@ class CHeader(CFile):
name_upper = self.name.upper() name_upper = self.name.upper()
header_guard_name = f"{name_upper}_H" header_guard_name = f"{name_upper}_H"
header_guard_open = f"#ifndef {header_guard_name}\n#define {header_guard_name}\n\n" header_guard_open = f"#ifndef {header_guard_name}\n#define {header_guard_name}\n\n"
header_guard_close = f"#endif // !{header_guard_name}\n" header_guard_close = f"\n#endif // !{header_guard_name}\n"
c_linkage_open = "#ifdef WAPP_PLATFORM_CPP\nBEGIN_C_LINKAGE\n#endif // !WAPP_PLATFORM_CPP\n\n"
c_linkage_close = "\n#ifdef WAPP_PLATFORM_CPP\nEND_C_LINKAGE\n#endif // !WAPP_PLATFORM_CPP\n\n"
includes = _get_includes_string(self.includes) includes = _get_includes_string(self.includes)
@ -277,12 +274,10 @@ class CHeader(CFile):
super().__str__() + super().__str__() +
header_guard_open + header_guard_open +
includes + includes +
c_linkage_open +
macros + macros +
forward_declarations + forward_declarations +
types + types +
funcs + funcs +
c_linkage_close +
header_guard_close header_guard_close
) )

View File

@ -93,7 +93,11 @@ def make_dbl_list(user_datatypes: Dict[CDataType, DblListData] = {}):
source = CSource( source = CSource(
name=header.name, name=header.name,
decl_types=[*common_decl_types], decl_types=[*common_decl_types],
includes=[CInclude(header, local=True, same_dir=True), CInclude(header="stddef.h")], includes=[
CInclude(header, local=True, same_dir=True),
CInclude(header="stddef.h"),
CInclude(header="assert.h"),
],
internal_funcs=[], internal_funcs=[],
funcs=header.funcs funcs=header.funcs
) )

View File

@ -1,6 +1,4 @@
if (!list) {{ assert(list != NULL);
return;
}}
u64 count = list->node_count; u64 count = list->node_count;
for (u64 i = 0; i < count; ++i) {{ for (u64 i = 0; i < count; ++i) {{

View File

@ -1,6 +1,4 @@
if (index >= list->node_count) {{ assert(index < list->node_count);
return NULL;
}}
{NodeType} *output = NULL; {NodeType} *output = NULL;
{NodeType} *current = list->first; {NodeType} *current = list->first;

View File

@ -1,6 +1,4 @@
if (!list || !node || !(node->item)) {{ assert(list != NULL && node != NULL && (node->item) != NULL);
return;
}}
if (index == 0) {{ if (index == 0) {{
wapp_{Tlower}_list_push_front(list, node); wapp_{Tlower}_list_push_front(list, node);

View File

@ -1,6 +1,8 @@
assert(list != NULL);
{NodeType} *output = NULL; {NodeType} *output = NULL;
if (!list || list->node_count == 0) {{ if (list->node_count == 0) {{
goto RETURN_{Tupper}_LIST_POP_BACK; goto RETURN_{Tupper}_LIST_POP_BACK;
}} }}

View File

@ -1,6 +1,8 @@
assert(list != NULL);
{NodeType} *output = NULL; {NodeType} *output = NULL;
if (!list || list->node_count == 0) {{ if (list->node_count == 0) {{
goto RETURN_{Tupper}_LIST_POP_FRONT; goto RETURN_{Tupper}_LIST_POP_FRONT;
}} }}

View File

@ -1,6 +1,4 @@
if (!list || !node || !(node->item)) {{ assert(list != NULL && node != NULL && (node->item) != NULL);
return;
}}
{ListType} node_list = {Tlower}_node_to_list(node); {ListType} node_list = {Tlower}_node_to_list(node);

View File

@ -1,6 +1,4 @@
if (!list || !node || !(node->item)) {{ assert(list != NULL && node != NULL && (node->item) != NULL);
return;
}}
{ListType} node_list = {Tlower}_node_to_list(node); {ListType} node_list = {Tlower}_node_to_list(node);

View File

@ -1,7 +1,6 @@
assert(list != NULL);
{NodeType} *output = NULL; {NodeType} *output = NULL;
if (!list) {{
goto RETURN_{Tupper}_LIST_REMOVE;
}}
if (index == 0) {{ if (index == 0) {{
output = wapp_{Tlower}_list_pop_front(list); output = wapp_{Tlower}_list_pop_front(list);

View File

@ -4,9 +4,22 @@
#include "../platform/platform.h" #include "../platform/platform.h"
#include <stdint.h> #include <stdint.h>
#if WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C11_VERSION && !defined(WAPP_PLATFORM_APPLE)
#include <uchar.h>
#if WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C23_VERSION
#define c8 char8_t
#else
#define c8 uint8_t
#endif // !WAPP_PLATFORM_C23_VERSION
#define c16 char16_t
#define c32 char32_t
#else
#define c8 uint8_t #define c8 uint8_t
#define c16 uint16_t #define c16 uint16_t
#define c32 uint32_t #define c32 uint32_t
#endif // !WAPP_PLATFORM_C11_VERSION
#define u8 uint8_t #define u8 uint8_t
#define u16 uint16_t #define u16 uint16_t
@ -29,10 +42,4 @@
#define internal static #define internal static
#define persistent static #define persistent static
#ifdef WAPP_PLATFORM_CPP
#define class_mem static
#define BEGIN_C_LINKAGE extern "C" {
#define END_C_LINKAGE }
#endif // WAPP_PLATFORM_CPP
#endif // !ALIASES_H #endif // !ALIASES_H

View File

@ -59,30 +59,7 @@
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
#define WAPP_PLATFORM_CPP #error "WAPP is a C only library"
#define WAPP_PLATFORM_CPP_VERSION __cplusplus
#define WAPP_PLATFORM_CPP98_VERSION 199711L
#define WAPP_PLATFORM_CPP11_VERSION 201103L
#define WAPP_PLATFORM_CPP14_VERSION 201402L
#define WAPP_PLATFORM_CPP17_VERSION 201703L
#define WAPP_PLATFORM_CPP20_VERSION 202002L
#define WAPP_PLATFORM_CPP23_VERSION 202302L
#if WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP98_VERSION
#define WAPP_PLATFORM_CPP98
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP11_VERSION
#define WAPP_PLATFORM_CPP11
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP14_VERSION
#define WAPP_PLATFORM_CPP14
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP17_VERSION
#define WAPP_PLATFORM_CPP17
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP20_VERSION
#define WAPP_PLATFORM_CPP20
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP23_VERSION
#define WAPP_PLATFORM_CPP23
#else
#error "Unrecognised C++ version"
#endif
#else #else
#define WAPP_PLATFORM_C #define WAPP_PLATFORM_C

View File

@ -1,10 +1,12 @@
#include "mem_arena.h" #include "mem_arena.h"
#include "../utils/mem_utils.h"
#include "../../../common/aliases/aliases.h" #include "../../../common/aliases/aliases.h"
#include "../../../common/misc/misc_utils.h" #include "../../../common/misc/misc_utils.h"
#include "../../os/mem/mem_os.h" #include "../../os/mem/mem_os.h"
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h>
#ifndef DEFAULT_ALIGNMENT #ifndef DEFAULT_ALIGNMENT
// Why 2 * sizeof(void *) instead of sizeof(void *) // Why 2 * sizeof(void *) instead of sizeof(void *)
@ -62,9 +64,7 @@ void *wapp_mem_arena_alloc(Arena *arena, u64 size) {
} }
void *wapp_mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment) { void *wapp_mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment) {
if (!arena) { assert(arena != NULL);
return NULL;
}
u8 *alloc_start = arena->offset; u8 *alloc_start = arena->offset;
@ -123,18 +123,14 @@ void *wapp_mem_arena_realloc_aligned(Arena *arena, void *ptr, u64 old_size, u64
} }
void wapp_mem_arena_clear(Arena *arena) { void wapp_mem_arena_clear(Arena *arena) {
if (!arena) { assert(arena != NULL);
return;
}
memset(arena->buf, 0, arena->offset - arena->buf); memset(arena->buf, 0, arena->offset - arena->buf);
arena->offset = arena->buf; arena->offset = arena->buf;
} }
void wapp_mem_arena_destroy(Arena **arena) { void wapp_mem_arena_destroy(Arena **arena) {
if (!arena) { assert(arena != NULL && (*arena) != NULL);
return;
}
Arena *arena_ptr = *arena; Arena *arena_ptr = *arena;
if (arena_ptr->buf) { if (arena_ptr->buf) {

View File

@ -6,10 +6,6 @@
#include "../../os/mem/mem_os.h" #include "../../os/mem/mem_os.h"
#include <stdbool.h> #include <stdbool.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
typedef struct arena Arena; typedef struct arena Arena;
#define wapp_mem_arena_init(arena_dptr, base_capacity) \ #define wapp_mem_arena_init(arena_dptr, base_capacity) \
@ -34,8 +30,4 @@ void *wapp_mem_arena_realloc_aligned(Arena *arena, void *ptr, u64 old_size, u64
void wapp_mem_arena_clear(Arena *arena); void wapp_mem_arena_clear(Arena *arena);
void wapp_mem_arena_destroy(Arena **arena); void wapp_mem_arena_destroy(Arena **arena);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !MEM_ARENA_H #endif // !MEM_ARENA_H

View File

@ -7,10 +7,6 @@
#include "../../os/mem/mem_os.h" #include "../../os/mem/mem_os.h"
#include <stdbool.h> #include <stdbool.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#define wapp_mem_arena_allocator_init(base_capacity) \ #define wapp_mem_arena_allocator_init(base_capacity) \
(wapp_mem_arena_allocator_init_custom(base_capacity, WAPP_MEM_ALLOC_RESERVE, false)) (wapp_mem_arena_allocator_init_custom(base_capacity, WAPP_MEM_ALLOC_RESERVE, false))
#define wapp_mem_arena_allocator_init_commit(base_capacity) \ #define wapp_mem_arena_allocator_init_commit(base_capacity) \
@ -35,8 +31,4 @@ Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags
void wapp_mem_arena_allocator_clear(Allocator *allocator); void wapp_mem_arena_allocator_clear(Allocator *allocator);
void wapp_mem_arena_allocator_destroy(Allocator *allocator); void wapp_mem_arena_allocator_destroy(Allocator *allocator);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !MEM_ARENA_ALLOCATOR_H #endif // !MEM_ARENA_ALLOCATOR_H

View File

@ -7,10 +7,7 @@
internal bool is_power_of_two(u64 num) { return (num & (num - 1)) == 0; } internal bool is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
void *wapp_mem_util_align_forward(void *ptr, u64 alignment) { void *wapp_mem_util_align_forward(void *ptr, u64 alignment) {
if (!ptr) { assert(ptr != NULL);
return NULL;
}
assert(is_power_of_two(alignment)); assert(is_power_of_two(alignment));
uptr p = (uptr)ptr; uptr p = (uptr)ptr;

View File

@ -4,14 +4,6 @@
#include "../../../common/aliases/aliases.h" #include "../../../common/aliases/aliases.h"
#include "../../../common/platform/platform.h" #include "../../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
void *wapp_mem_util_align_forward(void *ptr, u64 alignment); void *wapp_mem_util_align_forward(void *ptr, u64 alignment);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !MEM_UTILS_H #endif // !MEM_UTILS_H

View File

@ -35,7 +35,7 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
// MSVC Spectre mitigation warnings // MSVC Spectre mitigation warnings
const Str8Node *node = first_node; const Str8Node *node = first_node;
u64 node_index = 1; u64 node_index = 1;
bool running = true; bool running = node_index < parts->node_count;
while (running && node->next) { while (running && node->next) {
node = node->next; node = node->next;
if (node->item->size == 0) { if (node->item->size == 0) {

View File

@ -6,10 +6,6 @@
#include "../../../primitives/mem_allocator/mem_allocator.h" #include "../../../primitives/mem_allocator/mem_allocator.h"
#include "../../../primitives/strings/str8/str8.h" #include "../../../primitives/strings/str8/str8.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#ifdef WAPP_PLATFORM_POSIX #ifdef WAPP_PLATFORM_POSIX
#define PATH_SEP '/' #define PATH_SEP '/'
#elif defined(WAPP_PLATFORM_WINDOWS) #elif defined(WAPP_PLATFORM_WINDOWS)
@ -31,8 +27,4 @@ enum {
u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts); u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts);
Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels); Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !CPATH_H #endif // !CPATH_H

View File

@ -4,10 +4,6 @@
#include "../../../common/aliases/aliases.h" #include "../../../common/aliases/aliases.h"
#include "../../../common/platform/platform.h" #include "../../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#include "mem_os_ops.h" #include "mem_os_ops.h"
#if defined(WAPP_PLATFORM_WINDOWS) #if defined(WAPP_PLATFORM_WINDOWS)
@ -18,15 +14,10 @@ BEGIN_C_LINKAGE
#error "Unrecognised platform" #error "Unrecognised platform"
#endif #endif
void *wapp_mem_util_align_forward(void *ptr, u64 alignment);
void *wapp_mem_util_alloc(void *addr, u64 size, MemAccess access, MemAllocFlags flags, MemInitType type); void *wapp_mem_util_alloc(void *addr, u64 size, MemAccess access, MemAllocFlags flags, MemInitType type);
void wapp_mem_util_free(void *ptr, u64 size); void wapp_mem_util_free(void *ptr, u64 size);
external void *mem_util_allocate(void *addr, u64 size, MemAccess access, MemAllocFlags flags, MemInitType type); external void *mem_util_allocate(void *addr, u64 size, MemAccess access, MemAllocFlags flags, MemInitType type);
external void mem_util_free(void *ptr, u64 size); external void mem_util_free(void *ptr, u64 size);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !MEM_OS_H #endif // !MEM_OS_H

View File

@ -3,10 +3,6 @@
#include "../../../common/platform/platform.h" #include "../../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
typedef enum mem_access { typedef enum mem_access {
WAPP_MEM_ACCESS_NONE, WAPP_MEM_ACCESS_NONE,
WAPP_MEM_ACCESS_READ_ONLY, WAPP_MEM_ACCESS_READ_ONLY,
@ -21,8 +17,4 @@ typedef enum mem_init_type {
WAPP_MEM_INIT_INITIALISED, WAPP_MEM_INIT_INITIALISED,
} MemInitType; } MemInitType;
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !MEM_OS_OPS_H #endif // !MEM_OS_OPS_H

View File

@ -3,10 +3,6 @@
#include "../../../../common/platform/platform.h" #include "../../../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#ifdef WAPP_PLATFORM_POSIX #ifdef WAPP_PLATFORM_POSIX
#include <sys/mman.h> #include <sys/mman.h>
@ -26,8 +22,4 @@ typedef enum mem_alloc_flags {
#endif // !WAPP_PLATFORM_POSIX #endif // !WAPP_PLATFORM_POSIX
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !MEM_OS_POSIX_H #endif // !MEM_OS_POSIX_H

View File

@ -3,10 +3,6 @@
#include "../../../../common/platform/platform.h" #include "../../../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#ifdef WAPP_PLATFORM_WINDOWS #ifdef WAPP_PLATFORM_WINDOWS
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
@ -20,8 +16,4 @@ typedef enum mem_alloc_flags {
#endif // !WAPP_PLATFORM_WINDOWS #endif // !WAPP_PLATFORM_WINDOWS
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !MEM_OS_WIN_H #endif // !MEM_OS_WIN_H

View File

@ -9,18 +9,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#define CMD_NO_EXIT(ERR) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR}) #define CMD_NO_EXIT(ERR) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd); CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd);
external CMDError get_output_status(FILE *fp, i32 *status_out); external CMDError get_output_status(FILE *fp, i32 *status_out);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !COMMANDER_H #endif // !COMMANDER_H

View File

@ -5,10 +5,6 @@
#include "../../../../common/platform/platform.h" #include "../../../../common/platform/platform.h"
#include <stdbool.h> #include <stdbool.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
typedef enum { typedef enum {
SHELL_OUTPUT_DISCARD, SHELL_OUTPUT_DISCARD,
SHELL_OUTPUT_PRINT, SHELL_OUTPUT_PRINT,
@ -36,8 +32,4 @@ struct commander_result {
#endif // !WAPP_PLATFORM_WINDOWS #endif // !WAPP_PLATFORM_WINDOWS
}; };
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !COMMANDER_OUTPUT_H #endif // !COMMANDER_OUTPUT_H

View File

@ -6,17 +6,9 @@
#include "../../../../common/platform/platform.h" #include "../../../../common/platform/platform.h"
#include "../../../../primitives/strings/str8/str8.h" #include "../../../../primitives/strings/str8/str8.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour); void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour);
void wapp_shell_termcolour_clear_colour(void); void wapp_shell_termcolour_clear_colour(void);
external void print_coloured_text(Str8RO *text, TerminalColour colour); external void print_coloured_text(Str8RO *text, TerminalColour colour);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TERM_COLOUR_H #endif // !TERM_COLOUR_H

View File

@ -3,10 +3,6 @@
#include "../../../../common/platform/platform.h" #include "../../../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
typedef enum { typedef enum {
WAPP_TERM_COLOUR_FG_BLACK, WAPP_TERM_COLOUR_FG_BLACK,
WAPP_TERM_COLOUR_FG_RED, WAPP_TERM_COLOUR_FG_RED,
@ -29,8 +25,4 @@ typedef enum {
COUNT_TERM_COLOUR, COUNT_TERM_COLOUR,
} TerminalColour; } TerminalColour;
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TERMINAL_COLOURS_H #endif // !TERMINAL_COLOURS_H

File diff suppressed because it is too large Load Diff

View File

@ -6,142 +6,260 @@
#define ARRAY_H #define ARRAY_H
#include "../mem_allocator/mem_allocator.h" #include "../mem_allocator/mem_allocator.h"
#include "../strings/str8/str8.h"
#include "../../common/misc/misc_utils.h" #include "../../common/misc/misc_utils.h"
#include "../../common/aliases/aliases.h" #include "../../common/aliases/aliases.h"
#include "../../common/platform/platform.h" #include "../../common/platform/platform.h"
#include <stdbool.h> #include <stdbool.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#define wapp_str8_array(...) ((Str8Array){ \ #define wapp_str8_array(...) ((Str8Array){ \
.items = (Str8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (Str8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(Str8, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(Str8, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2), \
.item_size = sizeof(Str8) \
}) })
#define wapp_str8_array_with_capacity(CAPACITY) ((Str8Array){.items = (Str8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_str8_array_with_capacity(CAPACITY) ((Str8Array){.items = (Str8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(Str8)})
#define wapp_str8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((Str8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(Str8)))
#define wapp_str8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_str8_array_pop(ARRAY_PTR) : \
(Str8){0} \
)
#define wapp_void_ptr_array(...) ((VoidPArray){ \ #define wapp_void_ptr_array(...) ((VoidPArray){ \
.items = (void *[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(void *, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (void *[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(void *, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(void *, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(void *, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(void *, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(void *, __VA_ARGS__) * 2), \
.item_size = sizeof(void *) \
}) })
#define wapp_void_ptr_array_with_capacity(CAPACITY) ((VoidPArray){.items = (void *[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_void_ptr_array_with_capacity(CAPACITY) ((VoidPArray){.items = (void *[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(void *)})
#define wapp_void_ptr_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((VoidPArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(void *)))
#define wapp_void_ptr_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_void_ptr_array_pop(ARRAY_PTR) : \
(void *){0} \
)
#define wapp_bool_array(...) ((BoolArray){ \ #define wapp_bool_array(...) ((BoolArray){ \
.items = (bool[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(bool, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (bool[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(bool, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(bool, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(bool, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(bool, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(bool, __VA_ARGS__) * 2), \
.item_size = sizeof(bool) \
}) })
#define wapp_bool_array_with_capacity(CAPACITY) ((BoolArray){.items = (bool[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_bool_array_with_capacity(CAPACITY) ((BoolArray){.items = (bool[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(bool)})
#define wapp_bool_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((BoolArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(bool)))
#define wapp_bool_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_bool_array_pop(ARRAY_PTR) : \
(bool){0} \
)
#define wapp_char_array(...) ((CharArray){ \ #define wapp_char_array(...) ((CharArray){ \
.items = (char[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (char[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(char, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(char, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2), \
.item_size = sizeof(char) \
}) })
#define wapp_char_array_with_capacity(CAPACITY) ((CharArray){.items = (char[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_char_array_with_capacity(CAPACITY) ((CharArray){.items = (char[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(char)})
#define wapp_char_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((CharArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(char)))
#define wapp_char_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_char_array_pop(ARRAY_PTR) : \
(char){0} \
)
#define wapp_c8_array(...) ((C8Array){ \ #define wapp_c8_array(...) ((C8Array){ \
.items = (c8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (c8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(c8, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(c8, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c8, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c8, __VA_ARGS__) * 2), \
.item_size = sizeof(c8) \
}) })
#define wapp_c8_array_with_capacity(CAPACITY) ((C8Array){.items = (c8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_c8_array_with_capacity(CAPACITY) ((C8Array){.items = (c8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(c8)})
#define wapp_c8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((C8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(c8)))
#define wapp_c8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_c8_array_pop(ARRAY_PTR) : \
(c8){0} \
)
#define wapp_c16_array(...) ((C16Array){ \ #define wapp_c16_array(...) ((C16Array){ \
.items = (c16[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c16, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (c16[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c16, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(c16, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(c16, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c16, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c16, __VA_ARGS__) * 2), \
.item_size = sizeof(c16) \
}) })
#define wapp_c16_array_with_capacity(CAPACITY) ((C16Array){.items = (c16[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_c16_array_with_capacity(CAPACITY) ((C16Array){.items = (c16[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(c16)})
#define wapp_c16_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((C16Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(c16)))
#define wapp_c16_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_c16_array_pop(ARRAY_PTR) : \
(c16){0} \
)
#define wapp_c32_array(...) ((C32Array){ \ #define wapp_c32_array(...) ((C32Array){ \
.items = (c32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (c32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(c32, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(c32, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c32, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c32, __VA_ARGS__) * 2), \
.item_size = sizeof(c32) \
}) })
#define wapp_c32_array_with_capacity(CAPACITY) ((C32Array){.items = (c32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_c32_array_with_capacity(CAPACITY) ((C32Array){.items = (c32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(c32)})
#define wapp_c32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((C32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(c32)))
#define wapp_c32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_c32_array_pop(ARRAY_PTR) : \
(c32){0} \
)
#define wapp_i8_array(...) ((I8Array){ \ #define wapp_i8_array(...) ((I8Array){ \
.items = (i8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (i8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(i8, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(i8, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i8, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i8, __VA_ARGS__) * 2), \
.item_size = sizeof(i8) \
}) })
#define wapp_i8_array_with_capacity(CAPACITY) ((I8Array){.items = (i8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_i8_array_with_capacity(CAPACITY) ((I8Array){.items = (i8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(i8)})
#define wapp_i8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((I8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(i8)))
#define wapp_i8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_i8_array_pop(ARRAY_PTR) : \
(i8){0} \
)
#define wapp_i16_array(...) ((I16Array){ \ #define wapp_i16_array(...) ((I16Array){ \
.items = (i16[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i16, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (i16[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i16, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(i16, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(i16, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i16, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i16, __VA_ARGS__) * 2), \
.item_size = sizeof(i16) \
}) })
#define wapp_i16_array_with_capacity(CAPACITY) ((I16Array){.items = (i16[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_i16_array_with_capacity(CAPACITY) ((I16Array){.items = (i16[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(i16)})
#define wapp_i16_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((I16Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(i16)))
#define wapp_i16_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_i16_array_pop(ARRAY_PTR) : \
(i16){0} \
)
#define wapp_i32_array(...) ((I32Array){ \ #define wapp_i32_array(...) ((I32Array){ \
.items = (i32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (i32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(i32, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(i32, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i32, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i32, __VA_ARGS__) * 2), \
.item_size = sizeof(i32) \
}) })
#define wapp_i32_array_with_capacity(CAPACITY) ((I32Array){.items = (i32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_i32_array_with_capacity(CAPACITY) ((I32Array){.items = (i32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(i32)})
#define wapp_i32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((I32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(i32)))
#define wapp_i32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_i32_array_pop(ARRAY_PTR) : \
(i32){0} \
)
#define wapp_i64_array(...) ((I64Array){ \ #define wapp_i64_array(...) ((I64Array){ \
.items = (i64[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i64, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (i64[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i64, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(i64, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(i64, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i64, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i64, __VA_ARGS__) * 2), \
.item_size = sizeof(i64) \
}) })
#define wapp_i64_array_with_capacity(CAPACITY) ((I64Array){.items = (i64[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_i64_array_with_capacity(CAPACITY) ((I64Array){.items = (i64[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(i64)})
#define wapp_i64_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((I64Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(i64)))
#define wapp_i64_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_i64_array_pop(ARRAY_PTR) : \
(i64){0} \
)
#define wapp_u8_array(...) ((U8Array){ \ #define wapp_u8_array(...) ((U8Array){ \
.items = (u8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (u8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(u8, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(u8, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u8, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u8, __VA_ARGS__) * 2), \
.item_size = sizeof(u8) \
}) })
#define wapp_u8_array_with_capacity(CAPACITY) ((U8Array){.items = (u8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_u8_array_with_capacity(CAPACITY) ((U8Array){.items = (u8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(u8)})
#define wapp_u8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((U8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(u8)))
#define wapp_u8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_u8_array_pop(ARRAY_PTR) : \
(u8){0} \
)
#define wapp_u16_array(...) ((U16Array){ \ #define wapp_u16_array(...) ((U16Array){ \
.items = (u16[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u16, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (u16[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u16, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(u16, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(u16, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u16, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u16, __VA_ARGS__) * 2), \
.item_size = sizeof(u16) \
}) })
#define wapp_u16_array_with_capacity(CAPACITY) ((U16Array){.items = (u16[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_u16_array_with_capacity(CAPACITY) ((U16Array){.items = (u16[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(u16)})
#define wapp_u16_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((U16Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(u16)))
#define wapp_u16_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_u16_array_pop(ARRAY_PTR) : \
(u16){0} \
)
#define wapp_u32_array(...) ((U32Array){ \ #define wapp_u32_array(...) ((U32Array){ \
.items = (u32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (u32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(u32, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(u32, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u32, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u32, __VA_ARGS__) * 2), \
.item_size = sizeof(u32) \
}) })
#define wapp_u32_array_with_capacity(CAPACITY) ((U32Array){.items = (u32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_u32_array_with_capacity(CAPACITY) ((U32Array){.items = (u32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(u32)})
#define wapp_u32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((U32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(u32)))
#define wapp_u32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_u32_array_pop(ARRAY_PTR) : \
(u32){0} \
)
#define wapp_u64_array(...) ((U64Array){ \ #define wapp_u64_array(...) ((U64Array){ \
.items = (u64[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u64, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (u64[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u64, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(u64, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(u64, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u64, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u64, __VA_ARGS__) * 2), \
.item_size = sizeof(u64) \
}) })
#define wapp_u64_array_with_capacity(CAPACITY) ((U64Array){.items = (u64[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_u64_array_with_capacity(CAPACITY) ((U64Array){.items = (u64[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(u64)})
#define wapp_u64_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((U64Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(u64)))
#define wapp_u64_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_u64_array_pop(ARRAY_PTR) : \
(u64){0} \
)
#define wapp_f32_array(...) ((F32Array){ \ #define wapp_f32_array(...) ((F32Array){ \
.items = (f32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (f32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(f32, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(f32, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f32, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f32, __VA_ARGS__) * 2), \
.item_size = sizeof(f32) \
}) })
#define wapp_f32_array_with_capacity(CAPACITY) ((F32Array){.items = (f32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_f32_array_with_capacity(CAPACITY) ((F32Array){.items = (f32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(f32)})
#define wapp_f32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((F32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(f32)))
#define wapp_f32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_f32_array_pop(ARRAY_PTR) : \
(f32){0} \
)
#define wapp_f64_array(...) ((F64Array){ \ #define wapp_f64_array(...) ((F64Array){ \
.items = (f64[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f64, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (f64[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f64, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(f64, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(f64, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f64, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f64, __VA_ARGS__) * 2), \
.item_size = sizeof(f64) \
}) })
#define wapp_f64_array_with_capacity(CAPACITY) ((F64Array){.items = (f64[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_f64_array_with_capacity(CAPACITY) ((F64Array){.items = (f64[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(f64)})
#define wapp_f64_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((F64Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(f64)))
#define wapp_f64_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_f64_array_pop(ARRAY_PTR) : \
(f64){0} \
)
#define wapp_f128_array(...) ((F128Array){ \ #define wapp_f128_array(...) ((F128Array){ \
.items = (f128[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f128, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (f128[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f128, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(f128, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(f128, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f128, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f128, __VA_ARGS__) * 2), \
.item_size = sizeof(f128) \
}) })
#define wapp_f128_array_with_capacity(CAPACITY) ((F128Array){.items = (f128[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_f128_array_with_capacity(CAPACITY) ((F128Array){.items = (f128[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(f128)})
#define wapp_f128_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((F128Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(f128)))
#define wapp_f128_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_f128_array_pop(ARRAY_PTR) : \
(f128){0} \
)
#define wapp_iptr_array(...) ((IptrArray){ \ #define wapp_iptr_array(...) ((IptrArray){ \
.items = (iptr[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(iptr, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (iptr[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(iptr, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(iptr, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(iptr, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(iptr, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(iptr, __VA_ARGS__) * 2), \
.item_size = sizeof(iptr) \
}) })
#define wapp_iptr_array_with_capacity(CAPACITY) ((IptrArray){.items = (iptr[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_iptr_array_with_capacity(CAPACITY) ((IptrArray){.items = (iptr[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(iptr)})
#define wapp_iptr_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((IptrArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(iptr)))
#define wapp_iptr_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_iptr_array_pop(ARRAY_PTR) : \
(iptr){0} \
)
#define wapp_uptr_array(...) ((UptrArray){ \ #define wapp_uptr_array(...) ((UptrArray){ \
.items = (uptr[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(uptr, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ .items = (uptr[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(uptr, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
.count = wapp_misc_utils_va_args_count(uptr, __VA_ARGS__), \ .count = wapp_misc_utils_va_args_count(uptr, __VA_ARGS__), \
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(uptr, __VA_ARGS__) * 2) \ .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(uptr, __VA_ARGS__) * 2), \
.item_size = sizeof(uptr) \
}) })
#define wapp_uptr_array_with_capacity(CAPACITY) ((UptrArray){.items = (uptr[CAPACITY]){0}, .count = 0, .capacity = CAPACITY}) #define wapp_uptr_array_with_capacity(CAPACITY) ((UptrArray){.items = (uptr[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(uptr)})
#define wapp_uptr_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((UptrArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(uptr)))
#define wapp_uptr_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
*_uptr_array_pop(ARRAY_PTR) : \
(uptr){0} \
)
typedef struct str8 Str8;
typedef struct Str8Array Str8Array; typedef struct Str8Array Str8Array;
struct Str8Array { struct Str8Array {
Str8 *items; Str8 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct VoidPArray VoidPArray; typedef struct VoidPArray VoidPArray;
@ -149,6 +267,7 @@ struct VoidPArray {
void * *items; void * *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct BoolArray BoolArray; typedef struct BoolArray BoolArray;
@ -156,6 +275,7 @@ struct BoolArray {
bool *items; bool *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct CharArray CharArray; typedef struct CharArray CharArray;
@ -163,6 +283,7 @@ struct CharArray {
char *items; char *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct C8Array C8Array; typedef struct C8Array C8Array;
@ -170,6 +291,7 @@ struct C8Array {
c8 *items; c8 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct C16Array C16Array; typedef struct C16Array C16Array;
@ -177,6 +299,7 @@ struct C16Array {
c16 *items; c16 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct C32Array C32Array; typedef struct C32Array C32Array;
@ -184,6 +307,7 @@ struct C32Array {
c32 *items; c32 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct I8Array I8Array; typedef struct I8Array I8Array;
@ -191,6 +315,7 @@ struct I8Array {
i8 *items; i8 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct I16Array I16Array; typedef struct I16Array I16Array;
@ -198,6 +323,7 @@ struct I16Array {
i16 *items; i16 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct I32Array I32Array; typedef struct I32Array I32Array;
@ -205,6 +331,7 @@ struct I32Array {
i32 *items; i32 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct I64Array I64Array; typedef struct I64Array I64Array;
@ -212,6 +339,7 @@ struct I64Array {
i64 *items; i64 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct U8Array U8Array; typedef struct U8Array U8Array;
@ -219,6 +347,7 @@ struct U8Array {
u8 *items; u8 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct U16Array U16Array; typedef struct U16Array U16Array;
@ -226,6 +355,7 @@ struct U16Array {
u16 *items; u16 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct U32Array U32Array; typedef struct U32Array U32Array;
@ -233,6 +363,7 @@ struct U32Array {
u32 *items; u32 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct U64Array U64Array; typedef struct U64Array U64Array;
@ -240,6 +371,7 @@ struct U64Array {
u64 *items; u64 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct F32Array F32Array; typedef struct F32Array F32Array;
@ -247,6 +379,7 @@ struct F32Array {
f32 *items; f32 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct F64Array F64Array; typedef struct F64Array F64Array;
@ -254,6 +387,7 @@ struct F64Array {
f64 *items; f64 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct F128Array F128Array; typedef struct F128Array F128Array;
@ -261,6 +395,7 @@ struct F128Array {
f128 *items; f128 *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct IptrArray IptrArray; typedef struct IptrArray IptrArray;
@ -268,6 +403,7 @@ struct IptrArray {
iptr *items; iptr *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
typedef struct UptrArray UptrArray; typedef struct UptrArray UptrArray;
@ -275,231 +411,209 @@ struct UptrArray {
uptr *items; uptr *items;
u64 count; u64 count;
u64 capacity; u64 capacity;
u64 item_size;
}; };
Str8 *wapp_str8_array_get(const Str8Array *array, u64 index); Str8 *wapp_str8_array_get(const Str8Array *array, u64 index);
void wapp_str8_array_set(Str8Array *array, u64 index, Str8 item); void wapp_str8_array_set(Str8Array *array, u64 index, Str8 *item);
void wapp_str8_array_append_capped(Str8Array *array, Str8 item); void wapp_str8_array_append_capped(Str8Array *array, Str8 *item);
void wapp_str8_array_extend_capped(Str8Array *array, const Str8Array *other); void wapp_str8_array_extend_capped(Str8Array *array, const Str8Array *other);
void wapp_str8_array_clear(Str8Array *array); void wapp_str8_array_clear(Str8Array *array);
Str8 wapp_str8_array_pop(Str8Array *array);
void wapp_str8_array_copy_capped(const Str8Array *src, Str8Array *dst); void wapp_str8_array_copy_capped(const Str8Array *src, Str8Array *dst);
Str8Array *wapp_str8_array_alloc_capacity(const Allocator *allocator, u64 capacity); Str8Array *wapp_str8_array_append_alloc(const Allocator *allocator, Str8Array *array, Str8 *item);
Str8Array *wapp_str8_array_append_alloc(const Allocator *allocator, Str8Array *array, Str8 item);
Str8Array *wapp_str8_array_extend_alloc(const Allocator *allocator, Str8Array *array, const Str8Array *other); Str8Array *wapp_str8_array_extend_alloc(const Allocator *allocator, Str8Array *array, const Str8Array *other);
Str8Array *wapp_str8_array_copy_alloc(const Allocator *allocator, const Str8Array *src, Str8Array *dst); Str8Array *wapp_str8_array_copy_alloc(const Allocator *allocator, const Str8Array *src, Str8Array *dst);
Str8 *_str8_array_pop(Str8Array *array);
void * *wapp_void_ptr_array_get(const VoidPArray *array, u64 index); void * *wapp_void_ptr_array_get(const VoidPArray *array, u64 index);
void wapp_void_ptr_array_set(VoidPArray *array, u64 index, void * item); void wapp_void_ptr_array_set(VoidPArray *array, u64 index, void * *item);
void wapp_void_ptr_array_append_capped(VoidPArray *array, void * item); void wapp_void_ptr_array_append_capped(VoidPArray *array, void * *item);
void wapp_void_ptr_array_extend_capped(VoidPArray *array, const VoidPArray *other); void wapp_void_ptr_array_extend_capped(VoidPArray *array, const VoidPArray *other);
void wapp_void_ptr_array_clear(VoidPArray *array); void wapp_void_ptr_array_clear(VoidPArray *array);
void * wapp_void_ptr_array_pop(VoidPArray *array);
void wapp_void_ptr_array_copy_capped(const VoidPArray *src, VoidPArray *dst); void wapp_void_ptr_array_copy_capped(const VoidPArray *src, VoidPArray *dst);
VoidPArray *wapp_void_ptr_array_alloc_capacity(const Allocator *allocator, u64 capacity); VoidPArray *wapp_void_ptr_array_append_alloc(const Allocator *allocator, VoidPArray *array, void * *item);
VoidPArray *wapp_void_ptr_array_append_alloc(const Allocator *allocator, VoidPArray *array, void * item);
VoidPArray *wapp_void_ptr_array_extend_alloc(const Allocator *allocator, VoidPArray *array, const VoidPArray *other); VoidPArray *wapp_void_ptr_array_extend_alloc(const Allocator *allocator, VoidPArray *array, const VoidPArray *other);
VoidPArray *wapp_void_ptr_array_copy_alloc(const Allocator *allocator, const VoidPArray *src, VoidPArray *dst); VoidPArray *wapp_void_ptr_array_copy_alloc(const Allocator *allocator, const VoidPArray *src, VoidPArray *dst);
void * *_void_ptr_array_pop(VoidPArray *array);
bool *wapp_bool_array_get(const BoolArray *array, u64 index); bool *wapp_bool_array_get(const BoolArray *array, u64 index);
void wapp_bool_array_set(BoolArray *array, u64 index, bool item); void wapp_bool_array_set(BoolArray *array, u64 index, bool *item);
void wapp_bool_array_append_capped(BoolArray *array, bool item); void wapp_bool_array_append_capped(BoolArray *array, bool *item);
void wapp_bool_array_extend_capped(BoolArray *array, const BoolArray *other); void wapp_bool_array_extend_capped(BoolArray *array, const BoolArray *other);
void wapp_bool_array_clear(BoolArray *array); void wapp_bool_array_clear(BoolArray *array);
bool wapp_bool_array_pop(BoolArray *array);
void wapp_bool_array_copy_capped(const BoolArray *src, BoolArray *dst); void wapp_bool_array_copy_capped(const BoolArray *src, BoolArray *dst);
BoolArray *wapp_bool_array_alloc_capacity(const Allocator *allocator, u64 capacity); BoolArray *wapp_bool_array_append_alloc(const Allocator *allocator, BoolArray *array, bool *item);
BoolArray *wapp_bool_array_append_alloc(const Allocator *allocator, BoolArray *array, bool item);
BoolArray *wapp_bool_array_extend_alloc(const Allocator *allocator, BoolArray *array, const BoolArray *other); BoolArray *wapp_bool_array_extend_alloc(const Allocator *allocator, BoolArray *array, const BoolArray *other);
BoolArray *wapp_bool_array_copy_alloc(const Allocator *allocator, const BoolArray *src, BoolArray *dst); BoolArray *wapp_bool_array_copy_alloc(const Allocator *allocator, const BoolArray *src, BoolArray *dst);
bool *_bool_array_pop(BoolArray *array);
char *wapp_char_array_get(const CharArray *array, u64 index); char *wapp_char_array_get(const CharArray *array, u64 index);
void wapp_char_array_set(CharArray *array, u64 index, char item); void wapp_char_array_set(CharArray *array, u64 index, char *item);
void wapp_char_array_append_capped(CharArray *array, char item); void wapp_char_array_append_capped(CharArray *array, char *item);
void wapp_char_array_extend_capped(CharArray *array, const CharArray *other); void wapp_char_array_extend_capped(CharArray *array, const CharArray *other);
void wapp_char_array_clear(CharArray *array); void wapp_char_array_clear(CharArray *array);
char wapp_char_array_pop(CharArray *array);
void wapp_char_array_copy_capped(const CharArray *src, CharArray *dst); void wapp_char_array_copy_capped(const CharArray *src, CharArray *dst);
CharArray *wapp_char_array_alloc_capacity(const Allocator *allocator, u64 capacity); CharArray *wapp_char_array_append_alloc(const Allocator *allocator, CharArray *array, char *item);
CharArray *wapp_char_array_append_alloc(const Allocator *allocator, CharArray *array, char item);
CharArray *wapp_char_array_extend_alloc(const Allocator *allocator, CharArray *array, const CharArray *other); CharArray *wapp_char_array_extend_alloc(const Allocator *allocator, CharArray *array, const CharArray *other);
CharArray *wapp_char_array_copy_alloc(const Allocator *allocator, const CharArray *src, CharArray *dst); CharArray *wapp_char_array_copy_alloc(const Allocator *allocator, const CharArray *src, CharArray *dst);
char *_char_array_pop(CharArray *array);
c8 *wapp_c8_array_get(const C8Array *array, u64 index); c8 *wapp_c8_array_get(const C8Array *array, u64 index);
void wapp_c8_array_set(C8Array *array, u64 index, c8 item); void wapp_c8_array_set(C8Array *array, u64 index, c8 *item);
void wapp_c8_array_append_capped(C8Array *array, c8 item); void wapp_c8_array_append_capped(C8Array *array, c8 *item);
void wapp_c8_array_extend_capped(C8Array *array, const C8Array *other); void wapp_c8_array_extend_capped(C8Array *array, const C8Array *other);
void wapp_c8_array_clear(C8Array *array); void wapp_c8_array_clear(C8Array *array);
c8 wapp_c8_array_pop(C8Array *array);
void wapp_c8_array_copy_capped(const C8Array *src, C8Array *dst); void wapp_c8_array_copy_capped(const C8Array *src, C8Array *dst);
C8Array *wapp_c8_array_alloc_capacity(const Allocator *allocator, u64 capacity); C8Array *wapp_c8_array_append_alloc(const Allocator *allocator, C8Array *array, c8 *item);
C8Array *wapp_c8_array_append_alloc(const Allocator *allocator, C8Array *array, c8 item);
C8Array *wapp_c8_array_extend_alloc(const Allocator *allocator, C8Array *array, const C8Array *other); C8Array *wapp_c8_array_extend_alloc(const Allocator *allocator, C8Array *array, const C8Array *other);
C8Array *wapp_c8_array_copy_alloc(const Allocator *allocator, const C8Array *src, C8Array *dst); C8Array *wapp_c8_array_copy_alloc(const Allocator *allocator, const C8Array *src, C8Array *dst);
c8 *_c8_array_pop(C8Array *array);
c16 *wapp_c16_array_get(const C16Array *array, u64 index); c16 *wapp_c16_array_get(const C16Array *array, u64 index);
void wapp_c16_array_set(C16Array *array, u64 index, c16 item); void wapp_c16_array_set(C16Array *array, u64 index, c16 *item);
void wapp_c16_array_append_capped(C16Array *array, c16 item); void wapp_c16_array_append_capped(C16Array *array, c16 *item);
void wapp_c16_array_extend_capped(C16Array *array, const C16Array *other); void wapp_c16_array_extend_capped(C16Array *array, const C16Array *other);
void wapp_c16_array_clear(C16Array *array); void wapp_c16_array_clear(C16Array *array);
c16 wapp_c16_array_pop(C16Array *array);
void wapp_c16_array_copy_capped(const C16Array *src, C16Array *dst); void wapp_c16_array_copy_capped(const C16Array *src, C16Array *dst);
C16Array *wapp_c16_array_alloc_capacity(const Allocator *allocator, u64 capacity); C16Array *wapp_c16_array_append_alloc(const Allocator *allocator, C16Array *array, c16 *item);
C16Array *wapp_c16_array_append_alloc(const Allocator *allocator, C16Array *array, c16 item);
C16Array *wapp_c16_array_extend_alloc(const Allocator *allocator, C16Array *array, const C16Array *other); C16Array *wapp_c16_array_extend_alloc(const Allocator *allocator, C16Array *array, const C16Array *other);
C16Array *wapp_c16_array_copy_alloc(const Allocator *allocator, const C16Array *src, C16Array *dst); C16Array *wapp_c16_array_copy_alloc(const Allocator *allocator, const C16Array *src, C16Array *dst);
c16 *_c16_array_pop(C16Array *array);
c32 *wapp_c32_array_get(const C32Array *array, u64 index); c32 *wapp_c32_array_get(const C32Array *array, u64 index);
void wapp_c32_array_set(C32Array *array, u64 index, c32 item); void wapp_c32_array_set(C32Array *array, u64 index, c32 *item);
void wapp_c32_array_append_capped(C32Array *array, c32 item); void wapp_c32_array_append_capped(C32Array *array, c32 *item);
void wapp_c32_array_extend_capped(C32Array *array, const C32Array *other); void wapp_c32_array_extend_capped(C32Array *array, const C32Array *other);
void wapp_c32_array_clear(C32Array *array); void wapp_c32_array_clear(C32Array *array);
c32 wapp_c32_array_pop(C32Array *array);
void wapp_c32_array_copy_capped(const C32Array *src, C32Array *dst); void wapp_c32_array_copy_capped(const C32Array *src, C32Array *dst);
C32Array *wapp_c32_array_alloc_capacity(const Allocator *allocator, u64 capacity); C32Array *wapp_c32_array_append_alloc(const Allocator *allocator, C32Array *array, c32 *item);
C32Array *wapp_c32_array_append_alloc(const Allocator *allocator, C32Array *array, c32 item);
C32Array *wapp_c32_array_extend_alloc(const Allocator *allocator, C32Array *array, const C32Array *other); C32Array *wapp_c32_array_extend_alloc(const Allocator *allocator, C32Array *array, const C32Array *other);
C32Array *wapp_c32_array_copy_alloc(const Allocator *allocator, const C32Array *src, C32Array *dst); C32Array *wapp_c32_array_copy_alloc(const Allocator *allocator, const C32Array *src, C32Array *dst);
c32 *_c32_array_pop(C32Array *array);
i8 *wapp_i8_array_get(const I8Array *array, u64 index); i8 *wapp_i8_array_get(const I8Array *array, u64 index);
void wapp_i8_array_set(I8Array *array, u64 index, i8 item); void wapp_i8_array_set(I8Array *array, u64 index, i8 *item);
void wapp_i8_array_append_capped(I8Array *array, i8 item); void wapp_i8_array_append_capped(I8Array *array, i8 *item);
void wapp_i8_array_extend_capped(I8Array *array, const I8Array *other); void wapp_i8_array_extend_capped(I8Array *array, const I8Array *other);
void wapp_i8_array_clear(I8Array *array); void wapp_i8_array_clear(I8Array *array);
i8 wapp_i8_array_pop(I8Array *array);
void wapp_i8_array_copy_capped(const I8Array *src, I8Array *dst); void wapp_i8_array_copy_capped(const I8Array *src, I8Array *dst);
I8Array *wapp_i8_array_alloc_capacity(const Allocator *allocator, u64 capacity); I8Array *wapp_i8_array_append_alloc(const Allocator *allocator, I8Array *array, i8 *item);
I8Array *wapp_i8_array_append_alloc(const Allocator *allocator, I8Array *array, i8 item);
I8Array *wapp_i8_array_extend_alloc(const Allocator *allocator, I8Array *array, const I8Array *other); I8Array *wapp_i8_array_extend_alloc(const Allocator *allocator, I8Array *array, const I8Array *other);
I8Array *wapp_i8_array_copy_alloc(const Allocator *allocator, const I8Array *src, I8Array *dst); I8Array *wapp_i8_array_copy_alloc(const Allocator *allocator, const I8Array *src, I8Array *dst);
i8 *_i8_array_pop(I8Array *array);
i16 *wapp_i16_array_get(const I16Array *array, u64 index); i16 *wapp_i16_array_get(const I16Array *array, u64 index);
void wapp_i16_array_set(I16Array *array, u64 index, i16 item); void wapp_i16_array_set(I16Array *array, u64 index, i16 *item);
void wapp_i16_array_append_capped(I16Array *array, i16 item); void wapp_i16_array_append_capped(I16Array *array, i16 *item);
void wapp_i16_array_extend_capped(I16Array *array, const I16Array *other); void wapp_i16_array_extend_capped(I16Array *array, const I16Array *other);
void wapp_i16_array_clear(I16Array *array); void wapp_i16_array_clear(I16Array *array);
i16 wapp_i16_array_pop(I16Array *array);
void wapp_i16_array_copy_capped(const I16Array *src, I16Array *dst); void wapp_i16_array_copy_capped(const I16Array *src, I16Array *dst);
I16Array *wapp_i16_array_alloc_capacity(const Allocator *allocator, u64 capacity); I16Array *wapp_i16_array_append_alloc(const Allocator *allocator, I16Array *array, i16 *item);
I16Array *wapp_i16_array_append_alloc(const Allocator *allocator, I16Array *array, i16 item);
I16Array *wapp_i16_array_extend_alloc(const Allocator *allocator, I16Array *array, const I16Array *other); I16Array *wapp_i16_array_extend_alloc(const Allocator *allocator, I16Array *array, const I16Array *other);
I16Array *wapp_i16_array_copy_alloc(const Allocator *allocator, const I16Array *src, I16Array *dst); I16Array *wapp_i16_array_copy_alloc(const Allocator *allocator, const I16Array *src, I16Array *dst);
i16 *_i16_array_pop(I16Array *array);
i32 *wapp_i32_array_get(const I32Array *array, u64 index); i32 *wapp_i32_array_get(const I32Array *array, u64 index);
void wapp_i32_array_set(I32Array *array, u64 index, i32 item); void wapp_i32_array_set(I32Array *array, u64 index, i32 *item);
void wapp_i32_array_append_capped(I32Array *array, i32 item); void wapp_i32_array_append_capped(I32Array *array, i32 *item);
void wapp_i32_array_extend_capped(I32Array *array, const I32Array *other); void wapp_i32_array_extend_capped(I32Array *array, const I32Array *other);
void wapp_i32_array_clear(I32Array *array); void wapp_i32_array_clear(I32Array *array);
i32 wapp_i32_array_pop(I32Array *array);
void wapp_i32_array_copy_capped(const I32Array *src, I32Array *dst); void wapp_i32_array_copy_capped(const I32Array *src, I32Array *dst);
I32Array *wapp_i32_array_alloc_capacity(const Allocator *allocator, u64 capacity); I32Array *wapp_i32_array_append_alloc(const Allocator *allocator, I32Array *array, i32 *item);
I32Array *wapp_i32_array_append_alloc(const Allocator *allocator, I32Array *array, i32 item);
I32Array *wapp_i32_array_extend_alloc(const Allocator *allocator, I32Array *array, const I32Array *other); I32Array *wapp_i32_array_extend_alloc(const Allocator *allocator, I32Array *array, const I32Array *other);
I32Array *wapp_i32_array_copy_alloc(const Allocator *allocator, const I32Array *src, I32Array *dst); I32Array *wapp_i32_array_copy_alloc(const Allocator *allocator, const I32Array *src, I32Array *dst);
i32 *_i32_array_pop(I32Array *array);
i64 *wapp_i64_array_get(const I64Array *array, u64 index); i64 *wapp_i64_array_get(const I64Array *array, u64 index);
void wapp_i64_array_set(I64Array *array, u64 index, i64 item); void wapp_i64_array_set(I64Array *array, u64 index, i64 *item);
void wapp_i64_array_append_capped(I64Array *array, i64 item); void wapp_i64_array_append_capped(I64Array *array, i64 *item);
void wapp_i64_array_extend_capped(I64Array *array, const I64Array *other); void wapp_i64_array_extend_capped(I64Array *array, const I64Array *other);
void wapp_i64_array_clear(I64Array *array); void wapp_i64_array_clear(I64Array *array);
i64 wapp_i64_array_pop(I64Array *array);
void wapp_i64_array_copy_capped(const I64Array *src, I64Array *dst); void wapp_i64_array_copy_capped(const I64Array *src, I64Array *dst);
I64Array *wapp_i64_array_alloc_capacity(const Allocator *allocator, u64 capacity); I64Array *wapp_i64_array_append_alloc(const Allocator *allocator, I64Array *array, i64 *item);
I64Array *wapp_i64_array_append_alloc(const Allocator *allocator, I64Array *array, i64 item);
I64Array *wapp_i64_array_extend_alloc(const Allocator *allocator, I64Array *array, const I64Array *other); I64Array *wapp_i64_array_extend_alloc(const Allocator *allocator, I64Array *array, const I64Array *other);
I64Array *wapp_i64_array_copy_alloc(const Allocator *allocator, const I64Array *src, I64Array *dst); I64Array *wapp_i64_array_copy_alloc(const Allocator *allocator, const I64Array *src, I64Array *dst);
i64 *_i64_array_pop(I64Array *array);
u8 *wapp_u8_array_get(const U8Array *array, u64 index); u8 *wapp_u8_array_get(const U8Array *array, u64 index);
void wapp_u8_array_set(U8Array *array, u64 index, u8 item); void wapp_u8_array_set(U8Array *array, u64 index, u8 *item);
void wapp_u8_array_append_capped(U8Array *array, u8 item); void wapp_u8_array_append_capped(U8Array *array, u8 *item);
void wapp_u8_array_extend_capped(U8Array *array, const U8Array *other); void wapp_u8_array_extend_capped(U8Array *array, const U8Array *other);
void wapp_u8_array_clear(U8Array *array); void wapp_u8_array_clear(U8Array *array);
u8 wapp_u8_array_pop(U8Array *array);
void wapp_u8_array_copy_capped(const U8Array *src, U8Array *dst); void wapp_u8_array_copy_capped(const U8Array *src, U8Array *dst);
U8Array *wapp_u8_array_alloc_capacity(const Allocator *allocator, u64 capacity); U8Array *wapp_u8_array_append_alloc(const Allocator *allocator, U8Array *array, u8 *item);
U8Array *wapp_u8_array_append_alloc(const Allocator *allocator, U8Array *array, u8 item);
U8Array *wapp_u8_array_extend_alloc(const Allocator *allocator, U8Array *array, const U8Array *other); U8Array *wapp_u8_array_extend_alloc(const Allocator *allocator, U8Array *array, const U8Array *other);
U8Array *wapp_u8_array_copy_alloc(const Allocator *allocator, const U8Array *src, U8Array *dst); U8Array *wapp_u8_array_copy_alloc(const Allocator *allocator, const U8Array *src, U8Array *dst);
u8 *_u8_array_pop(U8Array *array);
u16 *wapp_u16_array_get(const U16Array *array, u64 index); u16 *wapp_u16_array_get(const U16Array *array, u64 index);
void wapp_u16_array_set(U16Array *array, u64 index, u16 item); void wapp_u16_array_set(U16Array *array, u64 index, u16 *item);
void wapp_u16_array_append_capped(U16Array *array, u16 item); void wapp_u16_array_append_capped(U16Array *array, u16 *item);
void wapp_u16_array_extend_capped(U16Array *array, const U16Array *other); void wapp_u16_array_extend_capped(U16Array *array, const U16Array *other);
void wapp_u16_array_clear(U16Array *array); void wapp_u16_array_clear(U16Array *array);
u16 wapp_u16_array_pop(U16Array *array);
void wapp_u16_array_copy_capped(const U16Array *src, U16Array *dst); void wapp_u16_array_copy_capped(const U16Array *src, U16Array *dst);
U16Array *wapp_u16_array_alloc_capacity(const Allocator *allocator, u64 capacity); U16Array *wapp_u16_array_append_alloc(const Allocator *allocator, U16Array *array, u16 *item);
U16Array *wapp_u16_array_append_alloc(const Allocator *allocator, U16Array *array, u16 item);
U16Array *wapp_u16_array_extend_alloc(const Allocator *allocator, U16Array *array, const U16Array *other); U16Array *wapp_u16_array_extend_alloc(const Allocator *allocator, U16Array *array, const U16Array *other);
U16Array *wapp_u16_array_copy_alloc(const Allocator *allocator, const U16Array *src, U16Array *dst); U16Array *wapp_u16_array_copy_alloc(const Allocator *allocator, const U16Array *src, U16Array *dst);
u16 *_u16_array_pop(U16Array *array);
u32 *wapp_u32_array_get(const U32Array *array, u64 index); u32 *wapp_u32_array_get(const U32Array *array, u64 index);
void wapp_u32_array_set(U32Array *array, u64 index, u32 item); void wapp_u32_array_set(U32Array *array, u64 index, u32 *item);
void wapp_u32_array_append_capped(U32Array *array, u32 item); void wapp_u32_array_append_capped(U32Array *array, u32 *item);
void wapp_u32_array_extend_capped(U32Array *array, const U32Array *other); void wapp_u32_array_extend_capped(U32Array *array, const U32Array *other);
void wapp_u32_array_clear(U32Array *array); void wapp_u32_array_clear(U32Array *array);
u32 wapp_u32_array_pop(U32Array *array);
void wapp_u32_array_copy_capped(const U32Array *src, U32Array *dst); void wapp_u32_array_copy_capped(const U32Array *src, U32Array *dst);
U32Array *wapp_u32_array_alloc_capacity(const Allocator *allocator, u64 capacity); U32Array *wapp_u32_array_append_alloc(const Allocator *allocator, U32Array *array, u32 *item);
U32Array *wapp_u32_array_append_alloc(const Allocator *allocator, U32Array *array, u32 item);
U32Array *wapp_u32_array_extend_alloc(const Allocator *allocator, U32Array *array, const U32Array *other); U32Array *wapp_u32_array_extend_alloc(const Allocator *allocator, U32Array *array, const U32Array *other);
U32Array *wapp_u32_array_copy_alloc(const Allocator *allocator, const U32Array *src, U32Array *dst); U32Array *wapp_u32_array_copy_alloc(const Allocator *allocator, const U32Array *src, U32Array *dst);
u32 *_u32_array_pop(U32Array *array);
u64 *wapp_u64_array_get(const U64Array *array, u64 index); u64 *wapp_u64_array_get(const U64Array *array, u64 index);
void wapp_u64_array_set(U64Array *array, u64 index, u64 item); void wapp_u64_array_set(U64Array *array, u64 index, u64 *item);
void wapp_u64_array_append_capped(U64Array *array, u64 item); void wapp_u64_array_append_capped(U64Array *array, u64 *item);
void wapp_u64_array_extend_capped(U64Array *array, const U64Array *other); void wapp_u64_array_extend_capped(U64Array *array, const U64Array *other);
void wapp_u64_array_clear(U64Array *array); void wapp_u64_array_clear(U64Array *array);
u64 wapp_u64_array_pop(U64Array *array);
void wapp_u64_array_copy_capped(const U64Array *src, U64Array *dst); void wapp_u64_array_copy_capped(const U64Array *src, U64Array *dst);
U64Array *wapp_u64_array_alloc_capacity(const Allocator *allocator, u64 capacity); U64Array *wapp_u64_array_append_alloc(const Allocator *allocator, U64Array *array, u64 *item);
U64Array *wapp_u64_array_append_alloc(const Allocator *allocator, U64Array *array, u64 item);
U64Array *wapp_u64_array_extend_alloc(const Allocator *allocator, U64Array *array, const U64Array *other); U64Array *wapp_u64_array_extend_alloc(const Allocator *allocator, U64Array *array, const U64Array *other);
U64Array *wapp_u64_array_copy_alloc(const Allocator *allocator, const U64Array *src, U64Array *dst); U64Array *wapp_u64_array_copy_alloc(const Allocator *allocator, const U64Array *src, U64Array *dst);
u64 *_u64_array_pop(U64Array *array);
f32 *wapp_f32_array_get(const F32Array *array, u64 index); f32 *wapp_f32_array_get(const F32Array *array, u64 index);
void wapp_f32_array_set(F32Array *array, u64 index, f32 item); void wapp_f32_array_set(F32Array *array, u64 index, f32 *item);
void wapp_f32_array_append_capped(F32Array *array, f32 item); void wapp_f32_array_append_capped(F32Array *array, f32 *item);
void wapp_f32_array_extend_capped(F32Array *array, const F32Array *other); void wapp_f32_array_extend_capped(F32Array *array, const F32Array *other);
void wapp_f32_array_clear(F32Array *array); void wapp_f32_array_clear(F32Array *array);
f32 wapp_f32_array_pop(F32Array *array);
void wapp_f32_array_copy_capped(const F32Array *src, F32Array *dst); void wapp_f32_array_copy_capped(const F32Array *src, F32Array *dst);
F32Array *wapp_f32_array_alloc_capacity(const Allocator *allocator, u64 capacity); F32Array *wapp_f32_array_append_alloc(const Allocator *allocator, F32Array *array, f32 *item);
F32Array *wapp_f32_array_append_alloc(const Allocator *allocator, F32Array *array, f32 item);
F32Array *wapp_f32_array_extend_alloc(const Allocator *allocator, F32Array *array, const F32Array *other); F32Array *wapp_f32_array_extend_alloc(const Allocator *allocator, F32Array *array, const F32Array *other);
F32Array *wapp_f32_array_copy_alloc(const Allocator *allocator, const F32Array *src, F32Array *dst); F32Array *wapp_f32_array_copy_alloc(const Allocator *allocator, const F32Array *src, F32Array *dst);
f32 *_f32_array_pop(F32Array *array);
f64 *wapp_f64_array_get(const F64Array *array, u64 index); f64 *wapp_f64_array_get(const F64Array *array, u64 index);
void wapp_f64_array_set(F64Array *array, u64 index, f64 item); void wapp_f64_array_set(F64Array *array, u64 index, f64 *item);
void wapp_f64_array_append_capped(F64Array *array, f64 item); void wapp_f64_array_append_capped(F64Array *array, f64 *item);
void wapp_f64_array_extend_capped(F64Array *array, const F64Array *other); void wapp_f64_array_extend_capped(F64Array *array, const F64Array *other);
void wapp_f64_array_clear(F64Array *array); void wapp_f64_array_clear(F64Array *array);
f64 wapp_f64_array_pop(F64Array *array);
void wapp_f64_array_copy_capped(const F64Array *src, F64Array *dst); void wapp_f64_array_copy_capped(const F64Array *src, F64Array *dst);
F64Array *wapp_f64_array_alloc_capacity(const Allocator *allocator, u64 capacity); F64Array *wapp_f64_array_append_alloc(const Allocator *allocator, F64Array *array, f64 *item);
F64Array *wapp_f64_array_append_alloc(const Allocator *allocator, F64Array *array, f64 item);
F64Array *wapp_f64_array_extend_alloc(const Allocator *allocator, F64Array *array, const F64Array *other); F64Array *wapp_f64_array_extend_alloc(const Allocator *allocator, F64Array *array, const F64Array *other);
F64Array *wapp_f64_array_copy_alloc(const Allocator *allocator, const F64Array *src, F64Array *dst); F64Array *wapp_f64_array_copy_alloc(const Allocator *allocator, const F64Array *src, F64Array *dst);
f64 *_f64_array_pop(F64Array *array);
f128 *wapp_f128_array_get(const F128Array *array, u64 index); f128 *wapp_f128_array_get(const F128Array *array, u64 index);
void wapp_f128_array_set(F128Array *array, u64 index, f128 item); void wapp_f128_array_set(F128Array *array, u64 index, f128 *item);
void wapp_f128_array_append_capped(F128Array *array, f128 item); void wapp_f128_array_append_capped(F128Array *array, f128 *item);
void wapp_f128_array_extend_capped(F128Array *array, const F128Array *other); void wapp_f128_array_extend_capped(F128Array *array, const F128Array *other);
void wapp_f128_array_clear(F128Array *array); void wapp_f128_array_clear(F128Array *array);
f128 wapp_f128_array_pop(F128Array *array);
void wapp_f128_array_copy_capped(const F128Array *src, F128Array *dst); void wapp_f128_array_copy_capped(const F128Array *src, F128Array *dst);
F128Array *wapp_f128_array_alloc_capacity(const Allocator *allocator, u64 capacity); F128Array *wapp_f128_array_append_alloc(const Allocator *allocator, F128Array *array, f128 *item);
F128Array *wapp_f128_array_append_alloc(const Allocator *allocator, F128Array *array, f128 item);
F128Array *wapp_f128_array_extend_alloc(const Allocator *allocator, F128Array *array, const F128Array *other); F128Array *wapp_f128_array_extend_alloc(const Allocator *allocator, F128Array *array, const F128Array *other);
F128Array *wapp_f128_array_copy_alloc(const Allocator *allocator, const F128Array *src, F128Array *dst); F128Array *wapp_f128_array_copy_alloc(const Allocator *allocator, const F128Array *src, F128Array *dst);
f128 *_f128_array_pop(F128Array *array);
iptr *wapp_iptr_array_get(const IptrArray *array, u64 index); iptr *wapp_iptr_array_get(const IptrArray *array, u64 index);
void wapp_iptr_array_set(IptrArray *array, u64 index, iptr item); void wapp_iptr_array_set(IptrArray *array, u64 index, iptr *item);
void wapp_iptr_array_append_capped(IptrArray *array, iptr item); void wapp_iptr_array_append_capped(IptrArray *array, iptr *item);
void wapp_iptr_array_extend_capped(IptrArray *array, const IptrArray *other); void wapp_iptr_array_extend_capped(IptrArray *array, const IptrArray *other);
void wapp_iptr_array_clear(IptrArray *array); void wapp_iptr_array_clear(IptrArray *array);
iptr wapp_iptr_array_pop(IptrArray *array);
void wapp_iptr_array_copy_capped(const IptrArray *src, IptrArray *dst); void wapp_iptr_array_copy_capped(const IptrArray *src, IptrArray *dst);
IptrArray *wapp_iptr_array_alloc_capacity(const Allocator *allocator, u64 capacity); IptrArray *wapp_iptr_array_append_alloc(const Allocator *allocator, IptrArray *array, iptr *item);
IptrArray *wapp_iptr_array_append_alloc(const Allocator *allocator, IptrArray *array, iptr item);
IptrArray *wapp_iptr_array_extend_alloc(const Allocator *allocator, IptrArray *array, const IptrArray *other); IptrArray *wapp_iptr_array_extend_alloc(const Allocator *allocator, IptrArray *array, const IptrArray *other);
IptrArray *wapp_iptr_array_copy_alloc(const Allocator *allocator, const IptrArray *src, IptrArray *dst); IptrArray *wapp_iptr_array_copy_alloc(const Allocator *allocator, const IptrArray *src, IptrArray *dst);
iptr *_iptr_array_pop(IptrArray *array);
uptr *wapp_uptr_array_get(const UptrArray *array, u64 index); uptr *wapp_uptr_array_get(const UptrArray *array, u64 index);
void wapp_uptr_array_set(UptrArray *array, u64 index, uptr item); void wapp_uptr_array_set(UptrArray *array, u64 index, uptr *item);
void wapp_uptr_array_append_capped(UptrArray *array, uptr item); void wapp_uptr_array_append_capped(UptrArray *array, uptr *item);
void wapp_uptr_array_extend_capped(UptrArray *array, const UptrArray *other); void wapp_uptr_array_extend_capped(UptrArray *array, const UptrArray *other);
void wapp_uptr_array_clear(UptrArray *array); void wapp_uptr_array_clear(UptrArray *array);
uptr wapp_uptr_array_pop(UptrArray *array);
void wapp_uptr_array_copy_capped(const UptrArray *src, UptrArray *dst); void wapp_uptr_array_copy_capped(const UptrArray *src, UptrArray *dst);
UptrArray *wapp_uptr_array_alloc_capacity(const Allocator *allocator, u64 capacity); UptrArray *wapp_uptr_array_append_alloc(const Allocator *allocator, UptrArray *array, uptr *item);
UptrArray *wapp_uptr_array_append_alloc(const Allocator *allocator, UptrArray *array, uptr item);
UptrArray *wapp_uptr_array_extend_alloc(const Allocator *allocator, UptrArray *array, const UptrArray *other); UptrArray *wapp_uptr_array_extend_alloc(const Allocator *allocator, UptrArray *array, const UptrArray *other);
UptrArray *wapp_uptr_array_copy_alloc(const Allocator *allocator, const UptrArray *src, UptrArray *dst); UptrArray *wapp_uptr_array_copy_alloc(const Allocator *allocator, const UptrArray *src, UptrArray *dst);
uptr *_uptr_array_pop(UptrArray *array);
#ifdef WAPP_PLATFORM_CPP VoidPArray *_array_alloc_capacity(const Allocator *allocator, u64 capacity, u64 item_size);
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !ARRAY_H #endif // !ARRAY_H

File diff suppressed because it is too large Load Diff

View File

@ -9,10 +9,6 @@
#include "../../common/platform/platform.h" #include "../../common/platform/platform.h"
#include <stdbool.h> #include <stdbool.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#define wapp_str8_list_node(ITEM_PTR) ((Str8Node){.item = ITEM_PTR}) #define wapp_str8_list_node(ITEM_PTR) ((Str8Node){.item = ITEM_PTR})
#define wapp_void_ptr_list_node(ITEM_PTR) ((VoidPNode){.item = ITEM_PTR}) #define wapp_void_ptr_list_node(ITEM_PTR) ((VoidPNode){.item = ITEM_PTR})
#define wapp_bool_list_node(ITEM_PTR) ((BoolNode){.item = ITEM_PTR}) #define wapp_bool_list_node(ITEM_PTR) ((BoolNode){.item = ITEM_PTR})
@ -477,8 +473,4 @@ UptrNode *wapp_uptr_list_pop_back(UptrList *list);
UptrNode *wapp_uptr_list_remove(UptrList *list, u64 index); UptrNode *wapp_uptr_list_remove(UptrList *list, u64 index);
void wapp_uptr_list_empty(UptrList *list); void wapp_uptr_list_empty(UptrList *list);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !DBL_LIST_H #endif // !DBL_LIST_H

View File

@ -1,37 +1,26 @@
#include "mem_allocator.h" #include "mem_allocator.h"
#include "../../common/aliases/aliases.h" #include "../../common/aliases/aliases.h"
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size) { void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size) {
if (!allocator || !(allocator->alloc)) { assert(allocator != NULL && (allocator->alloc) != NULL);
return NULL;
}
return allocator->alloc(size, allocator->obj); return allocator->alloc(size, allocator->obj);
} }
void *wapp_mem_allocator_alloc_aligned(const Allocator *allocator, u64 size, u64 alignment) { void *wapp_mem_allocator_alloc_aligned(const Allocator *allocator, u64 size, u64 alignment) {
if (!allocator || !(allocator->alloc_aligned)) { assert(allocator != NULL && (allocator->alloc_aligned) != NULL);
return NULL;
}
return allocator->alloc_aligned(size, alignment, allocator->obj); return allocator->alloc_aligned(size, alignment, allocator->obj);
} }
void *wapp_mem_allocator_realloc(const Allocator *allocator, void *ptr, u64 old_size, u64 new_size) { void *wapp_mem_allocator_realloc(const Allocator *allocator, void *ptr, u64 old_size, u64 new_size) {
if (!allocator || !(allocator->realloc)) { assert(allocator != NULL && (allocator->realloc) != NULL);
return NULL;
}
return allocator->realloc(ptr, old_size, new_size, allocator->obj); return allocator->realloc(ptr, old_size, new_size, allocator->obj);
} }
void *wapp_mem_allocator_realloc_aligned(const Allocator *allocator, void *ptr, u64 old_size, void *wapp_mem_allocator_realloc_aligned(const Allocator *allocator, void *ptr, u64 old_size,
u64 new_size, u64 alignment) { u64 new_size, u64 alignment) {
if (!allocator || !(allocator->realloc_aligned)) { assert(allocator != NULL && (allocator->realloc_aligned) != NULL);
return NULL;
}
return allocator->realloc_aligned(ptr, old_size, new_size, alignment, allocator->obj); return allocator->realloc_aligned(ptr, old_size, new_size, alignment, allocator->obj);
} }

View File

@ -5,17 +5,12 @@
#include "../../common/platform/platform.h" #include "../../common/platform/platform.h"
#include <string.h> #include <string.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
typedef void *(MemAllocFunc)(u64 size, void *alloc_obj); typedef void *(MemAllocFunc)(u64 size, void *alloc_obj);
typedef void *(MemAllocAlignedFunc)(u64 size, u64 alignment, void *alloc_obj); typedef void *(MemAllocAlignedFunc)(u64 size, u64 alignment, void *alloc_obj);
typedef void *(MemReallocFunc)(void *ptr, u64 old_size, u64 new_size, void *alloc_obj); typedef void *(MemReallocFunc)(void *ptr, u64 old_size, u64 new_size, void *alloc_obj);
typedef void *(MemReallocAlignedFunc)(void *ptr, u64 old_size, u64 new_size, u64 alignment, void *alloc_obj); typedef void *(MemReallocAlignedFunc)(void *ptr, u64 old_size, u64 new_size, u64 alignment, void *alloc_obj);
typedef void (MemFreeFunc)(void **ptr, u64 size, void *alloc_obj); typedef void (MemFreeFunc)(void **ptr, u64 size, void *alloc_obj);
typedef struct allocator Allocator; typedef struct allocator Allocator;
struct allocator { struct allocator {
void *obj; void *obj;
@ -28,7 +23,6 @@ struct allocator {
#define wapp_mem_allocator_invalid(ALLOCATOR) (memcmp(ALLOCATOR, &((Allocator){0}), sizeof(Allocator)) == 0) #define wapp_mem_allocator_invalid(ALLOCATOR) (memcmp(ALLOCATOR, &((Allocator){0}), sizeof(Allocator)) == 0)
void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size); void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size);
void *wapp_mem_allocator_alloc_aligned(const Allocator *allocator, u64 size, u64 alignment); void *wapp_mem_allocator_alloc_aligned(const Allocator *allocator, u64 size, u64 alignment);
void *wapp_mem_allocator_realloc(const Allocator *allocator, void *ptr, u64 old_size, u64 new_size); void *wapp_mem_allocator_realloc(const Allocator *allocator, void *ptr, u64 old_size, u64 new_size);
@ -36,8 +30,4 @@ void *wapp_mem_allocator_realloc_aligned(const Allocator *allocator, void *ptr,
u64 new_size, u64 alignment); u64 new_size, u64 alignment);
void wapp_mem_allocator_free(const Allocator *allocator, void **ptr, u64 size); void wapp_mem_allocator_free(const Allocator *allocator, void **ptr, u64 size);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !MEM_ALLOCATOR_H #endif // !MEM_ALLOCATOR_H

View File

@ -6,17 +6,14 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <assert.h>
#define STR8_BUF_ALLOC_SIZE(CAPACITY) (sizeof(Str8) + sizeof(c8) * CAPACITY) #define STR8_BUF_ALLOC_SIZE(CAPACITY) (sizeof(Str8) + sizeof(c8) * CAPACITY)
Str8 *wapp_str8_alloc_buf(const Allocator *allocator, u64 capacity) { Str8 *wapp_str8_alloc_buf(const Allocator *allocator, u64 capacity) {
Str8 *str = NULL; assert(allocator != NULL);
if (!allocator) { Str8 *str = wapp_mem_allocator_alloc(allocator, STR8_BUF_ALLOC_SIZE(capacity));
goto RETURN_STR8;
}
str = wapp_mem_allocator_alloc(allocator, STR8_BUF_ALLOC_SIZE(capacity));
if (!str) { if (!str) {
goto RETURN_STR8; goto RETURN_STR8;
} }
@ -30,14 +27,10 @@ RETURN_STR8:
} }
Str8 *wapp_str8_alloc_cstr(const Allocator *allocator, const char *str) { Str8 *wapp_str8_alloc_cstr(const Allocator *allocator, const char *str) {
Str8 *output = NULL; assert(allocator != NULL && str != NULL);
if (!allocator || !str) {
goto RETURN_ALLOC_CSTR;
}
u64 length = strlen(str); u64 length = strlen(str);
output = wapp_str8_alloc_buf(allocator, length * 2); Str8 *output = wapp_str8_alloc_buf(allocator, length * 2);
if (!output) { if (!output) {
goto RETURN_ALLOC_CSTR; goto RETURN_ALLOC_CSTR;
} }
@ -50,13 +43,9 @@ RETURN_ALLOC_CSTR:
} }
Str8 *wapp_str8_alloc_str8(const Allocator *allocator, Str8RO *str) { Str8 *wapp_str8_alloc_str8(const Allocator *allocator, Str8RO *str) {
Str8 *output = NULL; assert(allocator != NULL && str != NULL);
if (!allocator || !str) { Str8 *output = wapp_str8_alloc_buf(allocator, str->capacity);
goto RETURN_ALLOC_STR8;
}
output = wapp_str8_alloc_buf(allocator, str->capacity);
if (!output) { if (!output) {
goto RETURN_ALLOC_STR8; goto RETURN_ALLOC_STR8;
} }
@ -69,10 +58,9 @@ RETURN_ALLOC_STR8:
} }
Str8 *wapp_str8_alloc_substr(const Allocator *allocator, Str8RO *str, u64 start, u64 end) { Str8 *wapp_str8_alloc_substr(const Allocator *allocator, Str8RO *str, u64 start, u64 end) {
assert(allocator != NULL && str != NULL);
Str8 *output = NULL; Str8 *output = NULL;
if (!allocator || !str) {
goto RETURN_ALLOC_SUBSTR;
}
if (start >= str->size || start >= end) { if (start >= str->size || start >= end) {
goto RETURN_ALLOC_SUBSTR; goto RETURN_ALLOC_SUBSTR;
@ -95,10 +83,7 @@ RETURN_ALLOC_SUBSTR:
} }
void wapp_str8_dealloc_buf(const Allocator *allocator, Str8 **str) { void wapp_str8_dealloc_buf(const Allocator *allocator, Str8 **str) {
if (!allocator || !str || !(*str)) { assert(allocator != NULL && str != NULL && (*str) != NULL);
return;
}
wapp_mem_allocator_free(allocator, (void **)str, STR8_BUF_ALLOC_SIZE((*str)->capacity)); wapp_mem_allocator_free(allocator, (void **)str, STR8_BUF_ALLOC_SIZE((*str)->capacity));
} }
@ -161,9 +146,7 @@ Str8 wapp_str8_slice(Str8RO *str, u64 start, u64 end) {
} }
Str8 *wapp_str8_alloc_concat(const Allocator *allocator, Str8 *dst, Str8RO *src) { Str8 *wapp_str8_alloc_concat(const Allocator *allocator, Str8 *dst, Str8RO *src) {
if (!allocator || !dst || !src) { assert(allocator != NULL && dst != NULL && src != NULL);
return NULL;
}
Str8 *output = NULL; Str8 *output = NULL;
u64 remaining = dst->capacity - dst->size; u64 remaining = dst->capacity - dst->size;
@ -189,9 +172,7 @@ RETURN_STR8_CONCAT:
} }
void wapp_str8_concat_capped(Str8 *dst, Str8RO *src) { void wapp_str8_concat_capped(Str8 *dst, Str8RO *src) {
if (!dst || !src) { assert(dst != NULL && src != NULL);
return;
}
u64 remaining = dst->capacity - dst->size; u64 remaining = dst->capacity - dst->size;
u64 to_copy = remaining < src->size ? remaining : src->size; u64 to_copy = remaining < src->size ? remaining : src->size;
@ -201,9 +182,7 @@ void wapp_str8_concat_capped(Str8 *dst, Str8RO *src) {
} }
void wapp_str8_copy_cstr_capped(Str8 *dst, const char *src) { void wapp_str8_copy_cstr_capped(Str8 *dst, const char *src) {
if (!dst || !src) { assert(dst != NULL && src != NULL);
return;
}
u64 length = strlen(src); u64 length = strlen(src);
u64 to_copy = length <= dst->capacity ? length : dst->capacity; u64 to_copy = length <= dst->capacity ? length : dst->capacity;
@ -214,9 +193,7 @@ void wapp_str8_copy_cstr_capped(Str8 *dst, const char *src) {
} }
void wapp_str8_copy_str8_capped(Str8 *dst, Str8RO *src) { void wapp_str8_copy_str8_capped(Str8 *dst, Str8RO *src) {
if (!dst || !src) { assert(dst != NULL && src != NULL);
return;
}
u64 to_copy = src->size <= dst->capacity ? src->size : dst->capacity; u64 to_copy = src->size <= dst->capacity ? src->size : dst->capacity;
@ -226,9 +203,7 @@ void wapp_str8_copy_str8_capped(Str8 *dst, Str8RO *src) {
} }
void wapp_str8_copy_to_cstr(char *dst, Str8RO *src, u64 dst_capacity) { void wapp_str8_copy_to_cstr(char *dst, Str8RO *src, u64 dst_capacity) {
if (!dst || !src) { assert(dst != NULL && src != NULL);
return;
}
u64 to_copy = src->size < dst_capacity ? src->size : dst_capacity - 1; u64 to_copy = src->size < dst_capacity ? src->size : dst_capacity - 1;
@ -237,9 +212,7 @@ void wapp_str8_copy_to_cstr(char *dst, Str8RO *src, u64 dst_capacity) {
} }
void wapp_str8_format(Str8 *dst, const char *format, ...) { void wapp_str8_format(Str8 *dst, const char *format, ...) {
if (!dst || !format) { assert(dst != NULL && format != NULL);
return;
}
va_list args1; va_list args1;
va_list args2; va_list args2;
@ -264,7 +237,7 @@ i64 wapp_str8_find(Str8RO *str, Str8RO substr) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of // NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings // MSVC Spectre mitigation warnings
u64 char_index = 0; u64 char_index = 0;
bool running = true; bool running = char_index < str->size;
while (running) { while (running) {
const c8 *sub = str->buf + char_index; const c8 *sub = str->buf + char_index;
if (memcmp(sub, substr.buf, substr.size) == 0) { if (memcmp(sub, substr.buf, substr.size) == 0) {
@ -286,7 +259,7 @@ i64 wapp_str8_rfind(Str8RO *str, Str8RO substr) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of // NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings // MSVC Spectre mitigation warnings
i64 char_index = str->size - substr.size; i64 char_index = str->size - substr.size;
bool running = true; bool running = char_index >= 0;
while (running) { while (running) {
const c8 *sub = str->buf + char_index; const c8 *sub = str->buf + char_index;
if (memcmp(sub, substr.buf, substr.size) == 0) { if (memcmp(sub, substr.buf, substr.size) == 0) {
@ -301,9 +274,7 @@ i64 wapp_str8_rfind(Str8RO *str, Str8RO substr) {
} }
Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits) { Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits) {
if (!allocator || !str || !delimiter) { assert(allocator != NULL && str != NULL && delimiter != NULL);
return NULL;
}
Str8List *output = wapp_mem_allocator_alloc(allocator, sizeof(Str8List)); Str8List *output = wapp_mem_allocator_alloc(allocator, sizeof(Str8List));
@ -331,7 +302,7 @@ Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8
before_str = wapp_str8_alloc_substr(allocator, str, start, start + end); before_str = wapp_str8_alloc_substr(allocator, str, start, start + end);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node)); Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
if (node) { if (node && before_str) {
node->item = before_str; node->item = before_str;
wapp_str8_list_push_back(output, node); wapp_str8_list_push_back(output, node);
} }
@ -346,7 +317,7 @@ Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8
// Ensure the last part of the string after the delimiter is added to the list // Ensure the last part of the string after the delimiter is added to the list
rest = wapp_str8_alloc_substr(allocator, str, start, str->size); rest = wapp_str8_alloc_substr(allocator, str, start, str->size);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node)); Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
if (node) { if (node && rest) {
node->item = rest; node->item = rest;
wapp_str8_list_push_back(output, node); wapp_str8_list_push_back(output, node);
} }
@ -356,16 +327,14 @@ RETURN_STR8_SPLIT:
} }
Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits) { Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits) {
if (!allocator || !str || !delimiter) { assert(allocator != NULL && str != NULL && delimiter != NULL);
return NULL;
}
Str8List *output = wapp_mem_allocator_alloc(allocator, sizeof(Str8List)); Str8List *output = wapp_mem_allocator_alloc(allocator, sizeof(Str8List));
if (delimiter->size > str->size) { if (delimiter->size > str->size) {
Str8 *full = wapp_str8_alloc_str8(allocator, str); Str8 *full = wapp_str8_alloc_str8(allocator, str);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node)); Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
if (node) { if (node && full) {
node->item = full; node->item = full;
wapp_str8_list_push_back(output, node); wapp_str8_list_push_back(output, node);
} }
@ -398,7 +367,7 @@ Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str
rest = wapp_str8_alloc_substr(allocator, str, 0, rest->size); rest = wapp_str8_alloc_substr(allocator, str, 0, rest->size);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node)); Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
if (node) { if (node && rest) {
node->item = rest; node->item = rest;
wapp_str8_list_push_front(output, node); wapp_str8_list_push_front(output, node);
} }
@ -408,9 +377,7 @@ RETURN_STR8_SPLIT:
} }
Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *delimiter) { Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *delimiter) {
if (!allocator || !list || !delimiter) { assert(allocator != NULL && list != NULL && delimiter != NULL);
return NULL;
}
u64 capacity = wapp_str8_list_total_size(list) + (delimiter->size * (list->node_count - 1)); u64 capacity = wapp_str8_list_total_size(list) + (delimiter->size * (list->node_count - 1));
Str8 *output = wapp_str8_alloc_buf(allocator, capacity * 2); Str8 *output = wapp_str8_alloc_buf(allocator, capacity * 2);
@ -419,7 +386,7 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *d
// MSVC Spectre mitigation warnings // MSVC Spectre mitigation warnings
Str8Node *node; Str8Node *node;
u64 node_index = 0; u64 node_index = 0;
bool running = true; bool running = node_index < list->node_count;
while (running) { while (running) {
node = wapp_str8_list_get(list, node_index); node = wapp_str8_list_get(list, node_index);
if (!node) { if (!node) {
@ -452,7 +419,7 @@ u64 wapp_str8_list_total_size(const Str8List *list) {
Str8Node* node; Str8Node* node;
u64 node_index = 0; u64 node_index = 0;
u64 output = 0; u64 output = 0;
bool running = true; bool running = node_index < list->node_count;
while (running) { while (running) {
node = wapp_str8_list_get(list, node_index); node = wapp_str8_list_get(list, node_index);
if (!node) { if (!node) {

View File

@ -8,10 +8,6 @@
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
typedef struct str8 Str8; typedef struct str8 Str8;
struct str8 { struct str8 {
u64 capacity; u64 capacity;
@ -96,8 +92,4 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8R
#define wapp_str8_node_from_str8(STRING) wapp_str8_list_node(&(STRING)) #define wapp_str8_node_from_str8(STRING) wapp_str8_list_node(&(STRING))
u64 wapp_str8_list_total_size(const Str8List *list); u64 wapp_str8_list_total_size(const Str8List *list);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !STR8_H #endif // !STR8_H

View File

@ -88,12 +88,12 @@ internal u64 split_mix_64(SplitMix64State *state) {
return result ^ (result >> 31); return result ^ (result >> 31);
} }
#if defined(WAPP_PLATFORM_CPP) || (defined(WAPP_PLATFORM_C) && WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C11_VERSION) #if defined(WAPP_PLATFORM_C) && WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C11_VERSION
#ifdef WAPP_PLATFORM_POSIX #ifdef WAPP_PLATFORM_POSIX
internal void seed_os_generator(void) { internal void seed_os_generator(void) {
struct timespec ts = {0}; struct timespec ts = {0};
int result = clock_gettime(CLOCK_MONOTONIC_RAW, &ts); int result = clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
assert(result == 0 && "Failed to get time"); assert(result == 0);
srand48(ts.tv_nsec); srand48(ts.tv_nsec);
} }
@ -105,7 +105,7 @@ internal u64 generate_random_number(void) {
internal void seed_os_generator(void) { internal void seed_os_generator(void) {
struct timespec ts = {0}; struct timespec ts = {0};
int result = timespec_get(&ts, TIME_UTC); int result = timespec_get(&ts, TIME_UTC);
assert(result != 0 && "Failed to get time"); assert(result != 0);
srand(ts.tv_nsec); srand(ts.tv_nsec);
} }
@ -120,7 +120,7 @@ internal u64 generate_random_number(void) {
#else #else
internal void seed_os_generator(void) { internal void seed_os_generator(void) {
time_t result = time(NULL); time_t result = time(NULL);
assert(result != (time_t)(-1) && "Failed to get time"); assert(result != (time_t)(-1));
srand(result); srand(result);
} }
@ -131,4 +131,4 @@ internal u64 generate_random_number(void) {
return (((u64)n1) << 32 | (u64)n2); return (((u64)n1) << 32 | (u64)n2);
} }
#endif // !WAPP_PLATFORM_CPP #endif // !WAPP_PLATFORM_C

View File

@ -4,10 +4,6 @@
#include "../../common/aliases/aliases.h" #include "../../common/aliases/aliases.h"
#include "../../common/platform/platform.h" #include "../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
typedef struct xor_256_state XOR256State; typedef struct xor_256_state XOR256State;
struct xor_256_state { struct xor_256_state {
u64 x; u64 x;
@ -21,8 +17,4 @@ u64 wapp_prng_xorshift_256(XOR256State *state);
u64 wapp_prng_xorshift_256ss(XOR256State *state); u64 wapp_prng_xorshift_256ss(XOR256State *state);
u64 wapp_prng_xorshift_256p(XOR256State *state); u64 wapp_prng_xorshift_256p(XOR256State *state);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !XORSHIFT_H #endif // !XORSHIFT_H

View File

@ -6,10 +6,6 @@
#include "../../primitives/strings/str8/str8.h" #include "../../primitives/strings/str8/str8.h"
#include <stdbool.h> #include <stdbool.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#define wapp_tester_result(PASSED) ((TestFuncResult){.name = wapp_str8_lit_ro(__func__), .passed = PASSED}) #define wapp_tester_result(PASSED) ((TestFuncResult){.name = wapp_str8_lit_ro(__func__), .passed = PASSED})
#define wapp_tester_run_tests(...) run_tests(__VA_ARGS__, NULL) #define wapp_tester_run_tests(...) run_tests(__VA_ARGS__, NULL)
@ -27,8 +23,4 @@ typedef TestFuncResult(TestFunc)(void);
void run_tests(TestFunc *func1, ...); void run_tests(TestFunc *func1, ...);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TESTER_H #endif // !TESTER_H

View File

@ -4,6 +4,7 @@
#include "../prng/xorshift/xorshift.h" #include "../prng/xorshift/xorshift.h"
#include <stdbool.h> #include <stdbool.h>
#include <inttypes.h> #include <inttypes.h>
#include <assert.h>
#define UUID_STR_FORMAT ("%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.12" PRIx64) #define UUID_STR_FORMAT ("%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.12" PRIx64)
@ -17,14 +18,11 @@ internal UUID4 generate_uuid4(void);
internal void uuid4_to_uuid(const UUID4* uuid4, UUID *uuid); internal void uuid4_to_uuid(const UUID4* uuid4, UUID *uuid);
UUID *wapp_uuid_init_uuid4(UUID *uuid) { UUID *wapp_uuid_init_uuid4(UUID *uuid) {
if (!uuid) { assert(uuid != NULL);
goto RETURN_INIT_UUID4;
}
UUID4 uuid4 = generate_uuid4(); UUID4 uuid4 = generate_uuid4();
uuid4_to_uuid(&uuid4, uuid); uuid4_to_uuid(&uuid4, uuid);
RETURN_INIT_UUID4:
return uuid; return uuid;
} }

View File

@ -5,10 +5,6 @@
#include "../common/platform/platform.h" #include "../common/platform/platform.h"
#include "../primitives/strings/str8/str8.h" #include "../primitives/strings/str8/str8.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#define UUID_BUF_LENGTH 48 #define UUID_BUF_LENGTH 48
#define WAPP_UUID_SPEC WAPP_STR8_SPEC #define WAPP_UUID_SPEC WAPP_STR8_SPEC
#define wapp_uuid_varg(UUID) wapp_str8_varg((UUID).uuid) #define wapp_uuid_varg(UUID) wapp_str8_varg((UUID).uuid)
@ -25,11 +21,7 @@ struct uuid {
#define wapp_uuid_create() ((UUID){.uuid = wapp_str8_buf(UUID_BUF_LENGTH)}) #define wapp_uuid_create() ((UUID){.uuid = wapp_str8_buf(UUID_BUF_LENGTH)})
// Just returns the same pointer that was passed in with the UUID initialised. // Just returns the same pointer that was passed in with the UUID initialised.
// If the pointer is NULL, it skips initialisation. // Fails when passed a NULL pointer.
UUID *wapp_uuid_init_uuid4(UUID *uuid); UUID *wapp_uuid_init_uuid4(UUID *uuid);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !UUID_H #endif // !UUID_H

View File

@ -2,7 +2,7 @@
#define WAPP_UUID_C #define WAPP_UUID_C
#include "uuid.c" #include "uuid.c"
#include "../core/wapp_core.c" #include "../primitives/wapp_primitives.c"
#include "../prng/wapp_prng.c" #include "../prng/wapp_prng.c"
#endif // !WAPP_UUID_C #endif // !WAPP_UUID_C

View File

@ -3,7 +3,7 @@
#include "uuid.h" #include "uuid.h"
#include "../common/wapp_common.h" #include "../common/wapp_common.h"
#include "../core/wapp_core.h" #include "../primitives/wapp_primitives.h"
#include "../prng/wapp_prng.h" #include "../prng/wapp_prng.h"
#endif // !WAPP_UUID_H #endif // !WAPP_UUID_H

View File

@ -3,14 +3,6 @@
#include "wapp.h" #include "wapp.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
TestFuncResult test_arena_allocator(void); TestFuncResult test_arena_allocator(void);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TEST_ALLOCATOR_H #endif // !TEST_ALLOCATOR_H

View File

@ -3,10 +3,6 @@
#include "wapp.h" #include "wapp.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
TestFuncResult test_arena_init(void); TestFuncResult test_arena_init(void);
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void); TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void);
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void); TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void);
@ -16,8 +12,4 @@ TestFuncResult test_arena_realloc_smaller_size(void);
TestFuncResult test_arena_clear(void); TestFuncResult test_arena_clear(void);
TestFuncResult test_arena_destroy(void); TestFuncResult test_arena_destroy(void);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TEST_ARENA_H #endif // !TEST_ARENA_H

View File

@ -62,7 +62,8 @@ TestFuncResult test_i32_array_set(void) {
u64 index = 0; u64 index = 0;
bool running = true; bool running = true;
while (running) { while (running) {
wapp_i32_array_set(&array, index, (i32)(index * 2)); i32 num = (i32)(index * 2);
wapp_i32_array_set(&array, index, &num);
item = wapp_i32_array_get(&array, index); item = wapp_i32_array_get(&array, index);
result = result && item && (*item == (i32)(index * 2)); result = result && item && (*item == (i32)(index * 2));
@ -77,15 +78,14 @@ TestFuncResult test_i32_array_append_capped(void) {
bool result; bool result;
I32Array array = wapp_i32_array_with_capacity(64); I32Array array = wapp_i32_array_with_capacity(64);
wapp_i32_array_append_capped(&array, 10); wapp_i32_array_append_capped(&array, &((i32){10}));
result = array.count == 1; result = array.count == 1;
i32 *item = wapp_i32_array_get(&array, 0); i32 *item = wapp_i32_array_get(&array, 0);
result = result && item && *item == 10; result = result && item && *item == 10;
array = wapp_i32_array(1); array = wapp_i32_array(1);
wapp_i32_array_append_capped(&array, 10); wapp_i32_array_append_capped(&array, &((i32){10}));
wapp_i32_array_append_capped(&array, 20);
result = result && array.count == 2; result = result && array.count == 2;
@ -104,10 +104,6 @@ TestFuncResult test_i32_array_extend_capped(void) {
result = result && array1.count == 6; result = result && array1.count == 6;
wapp_i32_array_extend_capped(&array1, &array1);
result = result && array1.count == 6;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
@ -195,14 +191,15 @@ TestFuncResult test_i32_array_append_alloc(void) {
I32Array array1 = wapp_i32_array(1, 2, 3, 4, 5, 6, 7, 8); I32Array array1 = wapp_i32_array(1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_i32_array(1, 2); I32Array array2 = wapp_i32_array(1, 2);
I32Array *arr_ptr = wapp_i32_array_append_alloc(&allocator, &array1, 10); I32Array *arr_ptr = wapp_i32_array_append_alloc(&allocator, &array1, &((i32){10}));
result = arr_ptr == &array1; result = arr_ptr == &array1;
u64 count = 4; u64 count = 4;
u64 index = 0; u64 index = 0;
bool running = true; bool running = true;
while (running) { while (running) {
arr_ptr = wapp_i32_array_append_alloc(&allocator, &array2, (i32)index); i32 num = (i32)index;
arr_ptr = wapp_i32_array_append_alloc(&allocator, &array2, &num);
++index; ++index;
running = index < count; running = index < count;

View File

@ -3,10 +3,6 @@
#include "wapp.h" #include "wapp.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
TestFuncResult test_i32_array(void); TestFuncResult test_i32_array(void);
TestFuncResult test_i32_array_with_capacity(void); TestFuncResult test_i32_array_with_capacity(void);
TestFuncResult test_i32_array_get(void); TestFuncResult test_i32_array_get(void);
@ -21,8 +17,4 @@ TestFuncResult test_i32_array_append_alloc(void);
TestFuncResult test_i32_array_extend_alloc(void); TestFuncResult test_i32_array_extend_alloc(void);
TestFuncResult test_i32_array_copy_alloc(void); TestFuncResult test_i32_array_copy_alloc(void);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TEST_INT_ARRAY_H #endif // !TEST_INT_ARRAY_H

View File

@ -3,16 +3,8 @@
#include "wapp.h" #include "wapp.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
TestFuncResult test_cpath_join_path(void); TestFuncResult test_cpath_join_path(void);
TestFuncResult test_cpath_dirname(void); TestFuncResult test_cpath_dirname(void);
TestFuncResult test_cpath_dirup(void); TestFuncResult test_cpath_dirup(void);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TEST_CPATH_H #endif // !TEST_CPATH_H

View File

@ -3,17 +3,9 @@
#include "wapp.h" #include "wapp.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
TestFuncResult test_commander_cmd_success(void); TestFuncResult test_commander_cmd_success(void);
TestFuncResult test_commander_cmd_failure(void); TestFuncResult test_commander_cmd_failure(void);
TestFuncResult test_commander_cmd_out_buf_success(void); TestFuncResult test_commander_cmd_out_buf_success(void);
TestFuncResult test_commander_cmd_out_buf_failure(void); TestFuncResult test_commander_cmd_out_buf_failure(void);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TEST_SHELL_COMMANDER_H #endif // !TEST_SHELL_COMMANDER_H

View File

@ -3,10 +3,6 @@
#include "wapp.h" #include "wapp.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
TestFuncResult test_str8_lit(void); TestFuncResult test_str8_lit(void);
TestFuncResult test_str8_lit_ro(void); TestFuncResult test_str8_lit_ro(void);
TestFuncResult test_str8_buf(void); TestFuncResult test_str8_buf(void);
@ -33,8 +29,4 @@ TestFuncResult test_str8_rsplit(void);
TestFuncResult test_str8_rsplit_with_max(void); TestFuncResult test_str8_rsplit_with_max(void);
TestFuncResult test_str8_join(void); TestFuncResult test_str8_join(void);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TEST_STR8_H #endif // !TEST_STR8_H

View File

@ -3,10 +3,6 @@
#include "wapp.h" #include "wapp.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
TestFuncResult test_str8_list_get(void); TestFuncResult test_str8_list_get(void);
TestFuncResult test_str8_list_push_front(void); TestFuncResult test_str8_list_push_front(void);
TestFuncResult test_str8_list_push_back(void); TestFuncResult test_str8_list_push_back(void);
@ -16,8 +12,4 @@ TestFuncResult test_str8_list_pop_back(void);
TestFuncResult test_str8_list_remove(void); TestFuncResult test_str8_list_remove(void);
TestFuncResult test_str8_list_empty(void); TestFuncResult test_str8_list_empty(void);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // WAPP_PLATFORM_CPP
#endif // !TEST_STR8_LIST_H #endif // !TEST_STR8_LIST_H