Reintroduce C++ support and add usage tests for C++ (#4)
Reviewed-on: #4 Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com> Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
This commit is contained in:
@@ -11,6 +11,373 @@
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#define wapp_str8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((Str8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(Str8)))
|
||||
#define wapp_void_ptr_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((VoidPArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(void *)))
|
||||
#define wapp_b32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((B32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(b32)))
|
||||
#define wapp_char_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((CharArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(char)))
|
||||
#define wapp_c8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((C8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(c8)))
|
||||
#define wapp_c16_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((C16Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(c16)))
|
||||
#define wapp_c32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((C32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(c32)))
|
||||
#define wapp_i8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((I8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(i8)))
|
||||
#define wapp_i16_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((I16Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(i16)))
|
||||
#define wapp_i32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((I32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(i32)))
|
||||
#define wapp_i64_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((I64Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(i64)))
|
||||
#define wapp_u8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((U8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(u8)))
|
||||
#define wapp_u16_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((U16Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(u16)))
|
||||
#define wapp_u32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((U32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(u32)))
|
||||
#define wapp_u64_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((U64Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(u64)))
|
||||
#define wapp_f32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((F32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(f32)))
|
||||
#define wapp_f64_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((F64Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(f64)))
|
||||
#define wapp_f128_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((F128Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(f128)))
|
||||
#define wapp_iptr_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((IptrArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(iptr)))
|
||||
#define wapp_uptr_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((UptrArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(uptr)))
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#define wapp_str8_array(...) ([&]() { \
|
||||
persistent Str8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return Str8Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(Str8, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2), \
|
||||
sizeof(Str8) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_str8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent Str8 buf[CAPACITY] = {}; \
|
||||
return Str8Array{buf, 0, CAPACITY, sizeof(Str8)}; \
|
||||
}())
|
||||
#define wapp_str8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_str8_array_pop(ARRAY_PTR) : \
|
||||
Str8{} \
|
||||
)
|
||||
#define wapp_void_ptr_array(...) ([&]() { \
|
||||
persistent void * buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(void *, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return VoidPArray{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(void *, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(void *, __VA_ARGS__) * 2), \
|
||||
sizeof(void *) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_void_ptr_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent void * buf[CAPACITY] = {}; \
|
||||
return VoidPArray{buf, 0, 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 *{} \
|
||||
)
|
||||
#define wapp_b32_array(...) ([&]() { \
|
||||
persistent b32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return B32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(b32, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2), \
|
||||
sizeof(b32) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_b32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent b32 buf[CAPACITY] = {}; \
|
||||
return B32Array{buf, 0, CAPACITY, sizeof(b32)}; \
|
||||
}())
|
||||
#define wapp_b32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b32_array_pop(ARRAY_PTR) : \
|
||||
b32{} \
|
||||
)
|
||||
#define wapp_char_array(...) ([&]() { \
|
||||
persistent char buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return CharArray{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(char, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2), \
|
||||
sizeof(char) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_char_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent char buf[CAPACITY] = {}; \
|
||||
return CharArray{buf, 0, CAPACITY, sizeof(char)}; \
|
||||
}())
|
||||
#define wapp_char_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_char_array_pop(ARRAY_PTR) : \
|
||||
char{} \
|
||||
)
|
||||
#define wapp_c8_array(...) ([&]() { \
|
||||
persistent c8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return C8Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(c8, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c8, __VA_ARGS__) * 2), \
|
||||
sizeof(c8) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_c8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent c8 buf[CAPACITY] = {}; \
|
||||
return C8Array{buf, 0, CAPACITY, sizeof(c8)}; \
|
||||
}())
|
||||
#define wapp_c8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_c8_array_pop(ARRAY_PTR) : \
|
||||
c8{} \
|
||||
)
|
||||
#define wapp_c16_array(...) ([&]() { \
|
||||
persistent c16 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c16, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return C16Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(c16, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c16, __VA_ARGS__) * 2), \
|
||||
sizeof(c16) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_c16_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent c16 buf[CAPACITY] = {}; \
|
||||
return C16Array{buf, 0, CAPACITY, sizeof(c16)}; \
|
||||
}())
|
||||
#define wapp_c16_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_c16_array_pop(ARRAY_PTR) : \
|
||||
c16{} \
|
||||
)
|
||||
#define wapp_c32_array(...) ([&]() { \
|
||||
persistent c32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return C32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(c32, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(c32, __VA_ARGS__) * 2), \
|
||||
sizeof(c32) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_c32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent c32 buf[CAPACITY] = {}; \
|
||||
return C32Array{buf, 0, CAPACITY, sizeof(c32)}; \
|
||||
}())
|
||||
#define wapp_c32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_c32_array_pop(ARRAY_PTR) : \
|
||||
c32{} \
|
||||
)
|
||||
#define wapp_i8_array(...) ([&]() { \
|
||||
persistent i8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return I8Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(i8, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i8, __VA_ARGS__) * 2), \
|
||||
sizeof(i8) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_i8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent i8 buf[CAPACITY] = {}; \
|
||||
return I8Array{buf, 0, CAPACITY, sizeof(i8)}; \
|
||||
}())
|
||||
#define wapp_i8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_i8_array_pop(ARRAY_PTR) : \
|
||||
i8{} \
|
||||
)
|
||||
#define wapp_i16_array(...) ([&]() { \
|
||||
persistent i16 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i16, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return I16Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(i16, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i16, __VA_ARGS__) * 2), \
|
||||
sizeof(i16) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_i16_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent i16 buf[CAPACITY] = {}; \
|
||||
return I16Array{buf, 0, CAPACITY, sizeof(i16)}; \
|
||||
}())
|
||||
#define wapp_i16_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_i16_array_pop(ARRAY_PTR) : \
|
||||
i16{} \
|
||||
)
|
||||
#define wapp_i32_array(...) ([&]() { \
|
||||
persistent i32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return I32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(i32, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i32, __VA_ARGS__) * 2), \
|
||||
sizeof(i32) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_i32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent i32 buf[CAPACITY] = {}; \
|
||||
return I32Array{buf, 0, CAPACITY, sizeof(i32)}; \
|
||||
}())
|
||||
#define wapp_i32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_i32_array_pop(ARRAY_PTR) : \
|
||||
i32{} \
|
||||
)
|
||||
#define wapp_i64_array(...) ([&]() { \
|
||||
persistent i64 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i64, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return I64Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(i64, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(i64, __VA_ARGS__) * 2), \
|
||||
sizeof(i64) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_i64_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent i64 buf[CAPACITY] = {}; \
|
||||
return I64Array{buf, 0, CAPACITY, sizeof(i64)}; \
|
||||
}())
|
||||
#define wapp_i64_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_i64_array_pop(ARRAY_PTR) : \
|
||||
i64{} \
|
||||
)
|
||||
#define wapp_u8_array(...) ([&]() { \
|
||||
persistent u8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return U8Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(u8, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u8, __VA_ARGS__) * 2), \
|
||||
sizeof(u8) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_u8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent u8 buf[CAPACITY] = {}; \
|
||||
return U8Array{buf, 0, CAPACITY, sizeof(u8)}; \
|
||||
}())
|
||||
#define wapp_u8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_u8_array_pop(ARRAY_PTR) : \
|
||||
u8{} \
|
||||
)
|
||||
#define wapp_u16_array(...) ([&]() { \
|
||||
persistent u16 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u16, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return U16Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(u16, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u16, __VA_ARGS__) * 2), \
|
||||
sizeof(u16) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_u16_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent u16 buf[CAPACITY] = {}; \
|
||||
return U16Array{buf, 0, CAPACITY, sizeof(u16)}; \
|
||||
}())
|
||||
#define wapp_u16_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_u16_array_pop(ARRAY_PTR) : \
|
||||
u16{} \
|
||||
)
|
||||
#define wapp_u32_array(...) ([&]() { \
|
||||
persistent u32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return U32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(u32, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u32, __VA_ARGS__) * 2), \
|
||||
sizeof(u32) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_u32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent u32 buf[CAPACITY] = {}; \
|
||||
return U32Array{buf, 0, CAPACITY, sizeof(u32)}; \
|
||||
}())
|
||||
#define wapp_u32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_u32_array_pop(ARRAY_PTR) : \
|
||||
u32{} \
|
||||
)
|
||||
#define wapp_u64_array(...) ([&]() { \
|
||||
persistent u64 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u64, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return U64Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(u64, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(u64, __VA_ARGS__) * 2), \
|
||||
sizeof(u64) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_u64_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent u64 buf[CAPACITY] = {}; \
|
||||
return U64Array{buf, 0, CAPACITY, sizeof(u64)}; \
|
||||
}())
|
||||
#define wapp_u64_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_u64_array_pop(ARRAY_PTR) : \
|
||||
u64{} \
|
||||
)
|
||||
#define wapp_f32_array(...) ([&]() { \
|
||||
persistent f32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return F32Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(f32, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f32, __VA_ARGS__) * 2), \
|
||||
sizeof(f32) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_f32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent f32 buf[CAPACITY] = {}; \
|
||||
return F32Array{buf, 0, CAPACITY, sizeof(f32)}; \
|
||||
}())
|
||||
#define wapp_f32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_f32_array_pop(ARRAY_PTR) : \
|
||||
f32{} \
|
||||
)
|
||||
#define wapp_f64_array(...) ([&]() { \
|
||||
persistent f64 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f64, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return F64Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(f64, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f64, __VA_ARGS__) * 2), \
|
||||
sizeof(f64) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_f64_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent f64 buf[CAPACITY] = {}; \
|
||||
return F64Array{buf, 0, CAPACITY, sizeof(f64)}; \
|
||||
}())
|
||||
#define wapp_f64_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_f64_array_pop(ARRAY_PTR) : \
|
||||
f64{} \
|
||||
)
|
||||
#define wapp_f128_array(...) ([&]() { \
|
||||
persistent f128 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f128, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return F128Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(f128, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(f128, __VA_ARGS__) * 2), \
|
||||
sizeof(f128) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_f128_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent f128 buf[CAPACITY] = {}; \
|
||||
return F128Array{buf, 0, CAPACITY, sizeof(f128)}; \
|
||||
}())
|
||||
#define wapp_f128_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_f128_array_pop(ARRAY_PTR) : \
|
||||
f128{} \
|
||||
)
|
||||
#define wapp_iptr_array(...) ([&]() { \
|
||||
persistent iptr buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(iptr, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return IptrArray{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(iptr, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(iptr, __VA_ARGS__) * 2), \
|
||||
sizeof(iptr) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_iptr_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent iptr buf[CAPACITY] = {}; \
|
||||
return IptrArray{buf, 0, CAPACITY, sizeof(iptr)}; \
|
||||
}())
|
||||
#define wapp_iptr_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_iptr_array_pop(ARRAY_PTR) : \
|
||||
iptr{} \
|
||||
)
|
||||
#define wapp_uptr_array(...) ([&]() { \
|
||||
persistent uptr buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(uptr, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return UptrArray{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(uptr, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(uptr, __VA_ARGS__) * 2), \
|
||||
sizeof(uptr) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_uptr_array_with_capacity(CAPACITY) ([&]() { \
|
||||
persistent uptr buf[CAPACITY] = {}; \
|
||||
return UptrArray{buf, 0, CAPACITY, sizeof(uptr)}; \
|
||||
}())
|
||||
#define wapp_uptr_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_uptr_array_pop(ARRAY_PTR) : \
|
||||
uptr{} \
|
||||
)
|
||||
#else
|
||||
#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__}, \
|
||||
.count = wapp_misc_utils_va_args_count(Str8, __VA_ARGS__), \
|
||||
@@ -18,7 +385,6 @@
|
||||
.item_size = sizeof(Str8) \
|
||||
})
|
||||
#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} \
|
||||
@@ -30,7 +396,6 @@
|
||||
.item_size = sizeof(void *) \
|
||||
})
|
||||
#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} \
|
||||
@@ -42,7 +407,6 @@
|
||||
.item_size = sizeof(b32) \
|
||||
})
|
||||
#define wapp_b32_array_with_capacity(CAPACITY) ((B32Array){.items = (b32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(b32)})
|
||||
#define wapp_b32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((B32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(b32)))
|
||||
#define wapp_b32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b32_array_pop(ARRAY_PTR) : \
|
||||
(b32){0} \
|
||||
@@ -54,7 +418,6 @@
|
||||
.item_size = sizeof(char) \
|
||||
})
|
||||
#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} \
|
||||
@@ -66,7 +429,6 @@
|
||||
.item_size = sizeof(c8) \
|
||||
})
|
||||
#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} \
|
||||
@@ -78,7 +440,6 @@
|
||||
.item_size = sizeof(c16) \
|
||||
})
|
||||
#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} \
|
||||
@@ -90,7 +451,6 @@
|
||||
.item_size = sizeof(c32) \
|
||||
})
|
||||
#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} \
|
||||
@@ -102,7 +462,6 @@
|
||||
.item_size = sizeof(i8) \
|
||||
})
|
||||
#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} \
|
||||
@@ -114,7 +473,6 @@
|
||||
.item_size = sizeof(i16) \
|
||||
})
|
||||
#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} \
|
||||
@@ -126,7 +484,6 @@
|
||||
.item_size = sizeof(i32) \
|
||||
})
|
||||
#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} \
|
||||
@@ -138,7 +495,6 @@
|
||||
.item_size = sizeof(i64) \
|
||||
})
|
||||
#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} \
|
||||
@@ -150,7 +506,6 @@
|
||||
.item_size = sizeof(u8) \
|
||||
})
|
||||
#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} \
|
||||
@@ -162,7 +517,6 @@
|
||||
.item_size = sizeof(u16) \
|
||||
})
|
||||
#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} \
|
||||
@@ -174,7 +528,6 @@
|
||||
.item_size = sizeof(u32) \
|
||||
})
|
||||
#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} \
|
||||
@@ -186,7 +539,6 @@
|
||||
.item_size = sizeof(u64) \
|
||||
})
|
||||
#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} \
|
||||
@@ -198,7 +550,6 @@
|
||||
.item_size = sizeof(f32) \
|
||||
})
|
||||
#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} \
|
||||
@@ -210,7 +561,6 @@
|
||||
.item_size = sizeof(f64) \
|
||||
})
|
||||
#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} \
|
||||
@@ -222,7 +572,6 @@
|
||||
.item_size = sizeof(f128) \
|
||||
})
|
||||
#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} \
|
||||
@@ -234,7 +583,6 @@
|
||||
.item_size = sizeof(iptr) \
|
||||
})
|
||||
#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} \
|
||||
@@ -246,11 +594,11 @@
|
||||
.item_size = sizeof(uptr) \
|
||||
})
|
||||
#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} \
|
||||
)
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
typedef struct str8 Str8;
|
||||
|
||||
@@ -616,4 +964,8 @@ UptrArray *wapp_uptr_array_copy_alloc(const Allocator *allocator, const UptrArra
|
||||
uptr *_uptr_array_pop(UptrArray *array);
|
||||
VoidPArray *_array_alloc_capacity(const Allocator *allocator, u64 capacity, u64 item_size);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#endif // !ARRAY_H
|
||||
|
Reference in New Issue
Block a user