Change boolean size to 1 byte
This commit is contained in:
125
build.c
Executable file
125
build.c
Executable file
@@ -0,0 +1,125 @@
|
||||
#include "aliases.h"
|
||||
#include "platform.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define COMMAND_BUFFER_SIZE 8192
|
||||
|
||||
typedef enum {
|
||||
BUILD_TYPE_DEBUG,
|
||||
BUILD_TYPE_RELEASE,
|
||||
} BuildType;
|
||||
|
||||
#ifdef RELEASE
|
||||
wapp_intern BuildType build_type = BUILD_TYPE_RELEASE;
|
||||
#else
|
||||
wapp_intern BuildType build_type = BUILD_TYPE_DEBUG;
|
||||
#endif /* ifdef RELEASE */
|
||||
|
||||
wapp_intern int run_command(const char *cmd);
|
||||
|
||||
wapp_intern const char *test_include_directories = "-I./tests/ "
|
||||
"-I./tests/arena/";
|
||||
wapp_intern const char *test_source_files = "./tests/arena/test_arena.c "
|
||||
"./tests/wapptest.c";
|
||||
|
||||
wapp_intern const char *lib_include_directories = "-I./src/ "
|
||||
"-I./src/aliases/ "
|
||||
"-I./src/cpath/ "
|
||||
"-I./src/mem/ "
|
||||
"-I./src/mem/arena/ "
|
||||
"-I./src/mem/util/ "
|
||||
"-I./src/misc/ "
|
||||
"-I./src/platform/ "
|
||||
"-I./src/strings/ "
|
||||
"-I./src/strings/dstr/ "
|
||||
"-I./src/strings/basic_strings/ "
|
||||
"-I./src/termcolour/ "
|
||||
"-I./src/tester/";
|
||||
wapp_intern const char *lib_source_files = "./src/cpath/cpath.c "
|
||||
"./src/mem/arena/mem_arena.c "
|
||||
"./src/mem/util/mem_utils.c "
|
||||
"./src/strings/dstr/dstr.c "
|
||||
"./src/termcolour/termcolour.c "
|
||||
"./src/tester/tester.c";
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
|
||||
int main(void) {
|
||||
const char *compiler = "clang";
|
||||
const char *cflags = "-Wall -Werror -pedantic";
|
||||
const char *libflags = "-fPIC -shared";
|
||||
const char *build_flags = "";
|
||||
|
||||
const char *test_out_name = "wapptest";
|
||||
const char *lib_out_name = "wapp.so";
|
||||
|
||||
switch (build_type) {
|
||||
case BUILD_TYPE_DEBUG:
|
||||
build_flags = "-g -fsanitize=address -fsanitize=undefined";
|
||||
break;
|
||||
case BUILD_TYPE_RELEASE:
|
||||
build_flags = "-O3";
|
||||
break;
|
||||
}
|
||||
|
||||
char cmd[COMMAND_BUFFER_SIZE] = {0};
|
||||
snprintf(cmd, COMMAND_BUFFER_SIZE - 1, "%s %s %s %s %s %s %s -o %s", compiler,
|
||||
cflags, build_flags, lib_include_directories,
|
||||
test_include_directories, lib_source_files, test_source_files,
|
||||
test_out_name);
|
||||
|
||||
int status = run_command(cmd);
|
||||
if (status != EXIT_SUCCESS) {
|
||||
fprintf(stderr, "Failed to build tests\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("Running tests\n");
|
||||
|
||||
snprintf(cmd, COMMAND_BUFFER_SIZE - 1, "./%s", test_out_name);
|
||||
status = run_command(cmd);
|
||||
if (status != EXIT_SUCCESS) {
|
||||
fprintf(stderr, "Tests failed\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
snprintf(cmd, COMMAND_BUFFER_SIZE - 1, "%s %s %s %s %s %s -o %s", compiler,
|
||||
cflags, build_flags, libflags, lib_include_directories,
|
||||
lib_source_files, lib_out_name);
|
||||
status = run_command(cmd);
|
||||
if (status != EXIT_SUCCESS) {
|
||||
fprintf(stderr, "Failed to build library\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#elif defined(WAPP_PLATFORM_WINDOWS)
|
||||
#error "Windows build unimplemented"
|
||||
#else
|
||||
#error "Unrecognised platform"
|
||||
#endif /* ifdef WAPP_PLATFORM_POSIX */
|
||||
|
||||
wapp_intern int run_command(const char *cmd) {
|
||||
printf("%s\n", cmd);
|
||||
|
||||
FILE *fp = popen(cmd, "r");
|
||||
if (!fp) {
|
||||
fprintf(stderr, "Failed to run tests\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
char out[4096];
|
||||
while (fgets(out, 4095, fp)) {
|
||||
printf("%s", out);
|
||||
}
|
||||
|
||||
int st = pclose(fp);
|
||||
if (!WIFEXITED(st)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return WEXITSTATUS(st);
|
||||
}
|
||||
@@ -496,7 +496,7 @@ void csource_to_string(Str8 *dst, const CSource *csource) {
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
}
|
||||
|
||||
b32 cheaderinclude_to_string(Str8 *dst, const CHeaderInclude *cheaderinclude) {
|
||||
b8 cheaderinclude_to_string(Str8 *dst, const CHeaderInclude *cheaderinclude) {
|
||||
wapp_debug_assert(dst != NULL && cheaderinclude != NULL, "`dst` and `cheaderinclude` should not be NULL");
|
||||
|
||||
switch (cheaderinclude->kind) {
|
||||
|
||||
@@ -152,7 +152,7 @@ struct cenumval {
|
||||
struct cenum {
|
||||
Str8 name;
|
||||
CEnumValList values;
|
||||
b32 add_typedef;
|
||||
b8 add_typedef;
|
||||
};
|
||||
|
||||
struct cmacro {
|
||||
@@ -188,7 +188,7 @@ struct carg {
|
||||
CDataType type;
|
||||
CPointer pointer;
|
||||
CQualifier qualifier;
|
||||
b32 is_array;
|
||||
b8 is_array;
|
||||
};
|
||||
|
||||
struct cfunc {
|
||||
@@ -230,8 +230,8 @@ struct cheader_include {
|
||||
|
||||
struct cinclude {
|
||||
CHeaderInclude header;
|
||||
b32 is_local;
|
||||
b32 same_dir;
|
||||
b8 is_local;
|
||||
b8 same_dir;
|
||||
};
|
||||
|
||||
struct cobject {
|
||||
@@ -275,6 +275,6 @@ void define_cfunc(Str8 *dst, const CFunc *cfunc);
|
||||
void cinclude_to_string(Str8 *dst, const CInclude *cinclude);
|
||||
void cheader_to_string(Str8 *dst, const CHeader *cheader);
|
||||
void csource_to_string(Str8 *dst, const CSource *csource);
|
||||
b32 cheaderinclude_to_string(Str8 *dst, const CHeaderInclude *cheaderinclude);
|
||||
b8 cheaderinclude_to_string(Str8 *dst, const CHeaderInclude *cheaderinclude);
|
||||
|
||||
#endif // !DATATYPES_H
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
typedef enum {
|
||||
CTYPE_VOID,
|
||||
CTYPE_B32,
|
||||
CTYPE_B8,
|
||||
CTYPE_CHAR,
|
||||
CTYPE_C8,
|
||||
CTYPE_C16,
|
||||
@@ -30,7 +30,7 @@ typedef enum {
|
||||
} CType;
|
||||
wapp_intern Str8RO ctypes[COUNT_CTYPE] = {
|
||||
[CTYPE_VOID] = wapp_str8_lit_ro("void"),
|
||||
[CTYPE_B32] = wapp_str8_lit_ro("b32"),
|
||||
[CTYPE_B8] = wapp_str8_lit_ro("b8"),
|
||||
[CTYPE_CHAR] = wapp_str8_lit_ro("char"),
|
||||
[CTYPE_C8] = wapp_str8_lit_ro("c8"),
|
||||
[CTYPE_C16] = wapp_str8_lit_ro("c16"),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {{
|
||||
item = wapp_{Tlower}_array_get(src, item_index);
|
||||
++item_index;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {{
|
||||
item = wapp_{Tlower}_array_get(other, item_index);
|
||||
++item_index;
|
||||
|
||||
@@ -67,7 +67,7 @@ class SerialisableDataclass:
|
||||
|
||||
class CType(Enum):
|
||||
VOID = "void"
|
||||
BOOL = "b32"
|
||||
BOOL = "b8"
|
||||
CHAR = "char"
|
||||
C8 = "c8"
|
||||
C16 = "c16"
|
||||
|
||||
@@ -28,16 +28,16 @@
|
||||
#define u32 uint32_t
|
||||
#define u64 uint64_t
|
||||
|
||||
#define b32 uint32_t
|
||||
#define b8 uint8_t
|
||||
|
||||
#ifndef WAPP_PLATFORM_CPP
|
||||
|
||||
#ifndef false
|
||||
#define false (b32)0
|
||||
#define false (b8)0
|
||||
#endif // !false
|
||||
|
||||
#ifndef true
|
||||
#define true (b32)1
|
||||
#define true (b8)1
|
||||
#endif // !true
|
||||
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
@@ -21,14 +21,14 @@ struct arena {
|
||||
u8 *buf;
|
||||
u8 *offset;
|
||||
u64 capacity;
|
||||
b32 committed;
|
||||
b8 committed;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_padding_size(sizeof(u8 *) * 2 + sizeof(u64) + sizeof(b32));
|
||||
wapp_misc_utils_padding_size(sizeof(u8 *) * 2 + sizeof(u64) + sizeof(b8));
|
||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
b32 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b32 zero_buffer) {
|
||||
b8 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b8 zero_buffer) {
|
||||
if (!arena || *arena || base_capacity == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ typedef struct arena Arena;
|
||||
* control over how the Arena is initialised. Wrapper macros are provided for
|
||||
* easier use.
|
||||
*/
|
||||
b32 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b32 zero_buffer);
|
||||
b8 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b8 zero_buffer);
|
||||
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_realloc(Arena *arena, void *ptr, u64 old_size, u64 new_size);
|
||||
|
||||
@@ -12,9 +12,9 @@ wapp_intern inline void *mem_arena_realloc_aligned(void *ptr, u64 old_size, u64
|
||||
void *alloc_obj);
|
||||
|
||||
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b32 zero_buffer) {
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b8 zero_buffer) {
|
||||
Allocator allocator = {0};
|
||||
b32 initialised = wapp_mem_arena_init_custom((Arena **)(&allocator.obj), base_capacity, flags, zero_buffer);
|
||||
b8 initialised = wapp_mem_arena_init_custom((Arena **)(&allocator.obj), base_capacity, flags, zero_buffer);
|
||||
if (!initialised) {
|
||||
return allocator;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ BEGIN_C_LINKAGE
|
||||
* The `wapp_mem_arena_allocator_init_custom` provides the most control over how
|
||||
* the Arena is initialised. Wrapper macros are provided for easier use.
|
||||
*/
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b32 zero_buffer);
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b8 zero_buffer);
|
||||
void wapp_mem_arena_allocator_clear(Allocator *allocator);
|
||||
void wapp_mem_arena_allocator_destroy(Allocator *allocator);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../../../common/assert/assert.h"
|
||||
#include <stddef.h>
|
||||
|
||||
wapp_intern b32 is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
||||
wapp_intern b8 is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
||||
|
||||
void *wapp_mem_util_align_forward(void *ptr, u64 alignment) {
|
||||
wapp_debug_assert(ptr != NULL, "`ptr` should not be NULL");
|
||||
|
||||
@@ -36,7 +36,7 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
const Str8Node *node = first_node;
|
||||
u64 node_index = 1;
|
||||
b32 running = node_index < parts->node_count;
|
||||
b8 running = node_index < parts->node_count;
|
||||
while (running && node->next) {
|
||||
node = node->next;
|
||||
if (node->item->size == 0) {
|
||||
@@ -46,7 +46,7 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
|
||||
if (dst->size > 0) {
|
||||
char dst_last = wapp_str8_get(dst, dst->size - 1);
|
||||
char node_start = wapp_str8_get(node->item, 0);
|
||||
b32 add_path_sep = dst_last != WAPP_PATH_SEP && node_start != WAPP_PATH_SEP;
|
||||
b8 add_path_sep = dst_last != WAPP_PATH_SEP && node_start != WAPP_PATH_SEP;
|
||||
|
||||
if (add_path_sep) {
|
||||
wapp_str8_concat_capped(dst, &separator);
|
||||
@@ -68,7 +68,7 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
|
||||
goto RETURN_DIRUP;
|
||||
}
|
||||
|
||||
b32 absolute = wapp_str8_get(path, 0) == WAPP_PATH_SEP;
|
||||
b8 absolute = wapp_str8_get(path, 0) == WAPP_PATH_SEP;
|
||||
Str8 separator = wapp_str8_buf(4);
|
||||
wapp_str8_push_back(&separator, WAPP_PATH_SEP);
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ typedef struct commander_result CMDResult;
|
||||
struct commander_result {
|
||||
i32 exit_code;
|
||||
CMDError error;
|
||||
b32 exited;
|
||||
b8 exited;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#include "../../../../common/misc/misc_utils.h"
|
||||
wapp_misc_utils_padding_size(sizeof(b32) + sizeof(i32) + sizeof(CMDError));
|
||||
wapp_misc_utils_padding_size(sizeof(b8) + sizeof(i32) + sizeof(CMDError));
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ void wapp_void_ptr_array_extend_capped(VoidPArray *array, const VoidPArray *othe
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_void_ptr_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -74,7 +74,7 @@ void wapp_void_ptr_array_copy_capped(const VoidPArray *src, VoidPArray *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_void_ptr_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -193,7 +193,7 @@ void wapp_str8_array_extend_capped(Str8Array *array, const Str8Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_str8_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -223,7 +223,7 @@ void wapp_str8_array_copy_capped(const Str8Array *src, Str8Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_str8_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -308,43 +308,43 @@ Str8 *_str8_array_pop(Str8Array *array) {
|
||||
return out;
|
||||
}
|
||||
|
||||
b32 *wapp_b32_array_get(const B32Array *array, u64 index) {
|
||||
b8 *wapp_b8_array_get(const B8Array *array, u64 index) {
|
||||
wapp_debug_assert(array != NULL, "`array` should not be NULL");
|
||||
wapp_runtime_assert(index < array->count, "`index` is out of bounds");
|
||||
|
||||
u8 *ptr = (u8 *)(array->items) + (array->item_size * index);
|
||||
return (b32 *)ptr;
|
||||
return (b8 *)ptr;
|
||||
}
|
||||
|
||||
void wapp_b32_array_set(B32Array *array, u64 index, b32 *item) {
|
||||
b32 *ptr = wapp_b32_array_get(array, index);
|
||||
void wapp_b8_array_set(B8Array *array, u64 index, b8 *item) {
|
||||
b8 *ptr = wapp_b8_array_get(array, index);
|
||||
|
||||
memcpy((void *)ptr, (void *)item, array->item_size);
|
||||
}
|
||||
|
||||
void wapp_b32_array_append_capped(B32Array *array, b32 *item) {
|
||||
void wapp_b8_array_append_capped(B8Array *array, b8 *item) {
|
||||
wapp_debug_assert(array != NULL, "`array` should not be NULL");
|
||||
wapp_runtime_assert(array->count < array->capacity, "`array` is full");
|
||||
|
||||
u64 index = (array->count)++;
|
||||
wapp_b32_array_set(array, index, item);
|
||||
wapp_b8_array_set(array, index, item);
|
||||
}
|
||||
|
||||
void wapp_b32_array_extend_capped(B32Array *array, const B32Array *other) {
|
||||
void wapp_b8_array_extend_capped(B8Array *array, const B8Array *other) {
|
||||
wapp_debug_assert(array != NULL && other != NULL, "`array` and `other` should not be NULL");
|
||||
|
||||
u64 remaining_capacity = array->capacity - array->count;
|
||||
wapp_runtime_assert(other->count < remaining_capacity, "`array` does not have enough capacity");
|
||||
|
||||
b32 *item;
|
||||
b8 *item;
|
||||
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_b32_array_get(other, item_index);
|
||||
item = wapp_b8_array_get(other, item_index);
|
||||
++item_index;
|
||||
running = item_index < items_to_add;
|
||||
|
||||
@@ -352,29 +352,29 @@ void wapp_b32_array_extend_capped(B32Array *array, const B32Array *other) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wapp_b32_array_append_capped(array, item);
|
||||
wapp_b8_array_append_capped(array, item);
|
||||
}
|
||||
}
|
||||
|
||||
void wapp_b32_array_clear(B32Array *array) {
|
||||
void wapp_b8_array_clear(B8Array *array) {
|
||||
wapp_debug_assert(array != NULL, "`array` should not be NULL");
|
||||
array->count = 0;
|
||||
}
|
||||
|
||||
void wapp_b32_array_copy_capped(const B32Array *src, B32Array *dst) {
|
||||
void wapp_b8_array_copy_capped(const B8Array *src, B8Array *dst) {
|
||||
wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL");
|
||||
|
||||
wapp_b32_array_clear(dst);
|
||||
wapp_b8_array_clear(dst);
|
||||
|
||||
b32 *item;
|
||||
b8 *item;
|
||||
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_b32_array_get(src, item_index);
|
||||
item = wapp_b8_array_get(src, item_index);
|
||||
++item_index;
|
||||
running = item_index < to_copy;
|
||||
|
||||
@@ -382,77 +382,77 @@ void wapp_b32_array_copy_capped(const B32Array *src, B32Array *dst) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wapp_b32_array_append_capped(dst, item);
|
||||
wapp_b8_array_append_capped(dst, item);
|
||||
}
|
||||
}
|
||||
|
||||
B32Array *wapp_b32_array_append_alloc(const Allocator *allocator, B32Array *array, b32 *item) {
|
||||
B8Array *wapp_b8_array_append_alloc(const Allocator *allocator, B8Array *array, b8 *item) {
|
||||
wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL");
|
||||
|
||||
B32Array *output = array;
|
||||
B8Array *output = array;
|
||||
|
||||
if (array->count >= array->capacity) {
|
||||
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2);
|
||||
output = (B32Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
|
||||
output = (B8Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
|
||||
if (!output) {
|
||||
output = array;
|
||||
goto RETURN_B32_ARRAY_APPEND_ALLOC;
|
||||
goto RETURN_B8_ARRAY_APPEND_ALLOC;
|
||||
}
|
||||
wapp_b32_array_copy_capped(array, output);
|
||||
wapp_b8_array_copy_capped(array, output);
|
||||
}
|
||||
|
||||
wapp_b32_array_append_capped(output, item);
|
||||
wapp_b8_array_append_capped(output, item);
|
||||
|
||||
RETURN_B32_ARRAY_APPEND_ALLOC:
|
||||
RETURN_B8_ARRAY_APPEND_ALLOC:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Array *wapp_b32_array_extend_alloc(const Allocator *allocator, B32Array *array, const B32Array *other) {
|
||||
B8Array *wapp_b8_array_extend_alloc(const Allocator *allocator, B8Array *array, const B8Array *other) {
|
||||
wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL");
|
||||
|
||||
B32Array *output = array;
|
||||
B8Array *output = array;
|
||||
|
||||
u64 remaining_capacity = array->capacity - array->count;
|
||||
if (other->count >= remaining_capacity) {
|
||||
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2);
|
||||
output = (B32Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
|
||||
output = (B8Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
|
||||
if (!output) {
|
||||
output = array;
|
||||
goto RETURN_B32_ARRAY_EXTEND_ALLOC;
|
||||
goto RETURN_B8_ARRAY_EXTEND_ALLOC;
|
||||
}
|
||||
wapp_b32_array_copy_capped(array, output);
|
||||
wapp_b8_array_copy_capped(array, output);
|
||||
}
|
||||
|
||||
wapp_b32_array_extend_capped(output, other);
|
||||
wapp_b8_array_extend_capped(output, other);
|
||||
|
||||
RETURN_B32_ARRAY_EXTEND_ALLOC:
|
||||
RETURN_B8_ARRAY_EXTEND_ALLOC:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Array *wapp_b32_array_copy_alloc(const Allocator *allocator, const B32Array *src, B32Array *dst) {
|
||||
B8Array *wapp_b8_array_copy_alloc(const Allocator *allocator, const B8Array *src, B8Array *dst) {
|
||||
wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL");
|
||||
|
||||
B32Array *output = dst;
|
||||
B8Array *output = dst;
|
||||
|
||||
if (src->count >= dst->capacity) {
|
||||
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(dst->capacity * 2);
|
||||
output = (B32Array *)_array_alloc_capacity(allocator, new_capacity, src->item_size);
|
||||
output = (B8Array *)_array_alloc_capacity(allocator, new_capacity, src->item_size);
|
||||
if (!output) {
|
||||
output = dst;
|
||||
goto RETURN_B32_ARRAY_COPY_ALLOC;
|
||||
goto RETURN_B8_ARRAY_COPY_ALLOC;
|
||||
}
|
||||
}
|
||||
|
||||
wapp_b32_array_clear(output);
|
||||
wapp_b32_array_copy_capped(src, output);
|
||||
wapp_b8_array_clear(output);
|
||||
wapp_b8_array_copy_capped(src, output);
|
||||
|
||||
RETURN_B32_ARRAY_COPY_ALLOC:
|
||||
RETURN_B8_ARRAY_COPY_ALLOC:
|
||||
return output;
|
||||
}
|
||||
|
||||
b32 *_b32_array_pop(B32Array *array) {
|
||||
b8 *_b8_array_pop(B8Array *array) {
|
||||
u64 index = array->count - 1;
|
||||
b32 *out = wapp_b32_array_get(array, index);
|
||||
b8 *out = wapp_b8_array_get(array, index);
|
||||
--(array->count);
|
||||
return out;
|
||||
}
|
||||
@@ -491,7 +491,7 @@ void wapp_char_array_extend_capped(CharArray *array, const CharArray *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_char_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -521,7 +521,7 @@ void wapp_char_array_copy_capped(const CharArray *src, CharArray *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_char_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -640,7 +640,7 @@ void wapp_c8_array_extend_capped(C8Array *array, const C8Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c8_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -670,7 +670,7 @@ void wapp_c8_array_copy_capped(const C8Array *src, C8Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c8_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -789,7 +789,7 @@ void wapp_c16_array_extend_capped(C16Array *array, const C16Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c16_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -819,7 +819,7 @@ void wapp_c16_array_copy_capped(const C16Array *src, C16Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c16_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -938,7 +938,7 @@ void wapp_c32_array_extend_capped(C32Array *array, const C32Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c32_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -968,7 +968,7 @@ void wapp_c32_array_copy_capped(const C32Array *src, C32Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c32_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1087,7 +1087,7 @@ void wapp_i8_array_extend_capped(I8Array *array, const I8Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i8_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1117,7 +1117,7 @@ void wapp_i8_array_copy_capped(const I8Array *src, I8Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i8_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1236,7 +1236,7 @@ void wapp_i16_array_extend_capped(I16Array *array, const I16Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i16_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1266,7 +1266,7 @@ void wapp_i16_array_copy_capped(const I16Array *src, I16Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i16_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1385,7 +1385,7 @@ void wapp_i32_array_extend_capped(I32Array *array, const I32Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1415,7 +1415,7 @@ void wapp_i32_array_copy_capped(const I32Array *src, I32Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1534,7 +1534,7 @@ void wapp_i64_array_extend_capped(I64Array *array, const I64Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i64_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1564,7 +1564,7 @@ void wapp_i64_array_copy_capped(const I64Array *src, I64Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i64_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1683,7 +1683,7 @@ void wapp_u8_array_extend_capped(U8Array *array, const U8Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u8_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1713,7 +1713,7 @@ void wapp_u8_array_copy_capped(const U8Array *src, U8Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u8_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1832,7 +1832,7 @@ void wapp_u16_array_extend_capped(U16Array *array, const U16Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u16_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1862,7 +1862,7 @@ void wapp_u16_array_copy_capped(const U16Array *src, U16Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u16_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1981,7 +1981,7 @@ void wapp_u32_array_extend_capped(U32Array *array, const U32Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u32_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2011,7 +2011,7 @@ void wapp_u32_array_copy_capped(const U32Array *src, U32Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u32_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2130,7 +2130,7 @@ void wapp_u64_array_extend_capped(U64Array *array, const U64Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u64_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2160,7 +2160,7 @@ void wapp_u64_array_copy_capped(const U64Array *src, U64Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u64_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2279,7 +2279,7 @@ void wapp_f32_array_extend_capped(F32Array *array, const F32Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f32_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2309,7 +2309,7 @@ void wapp_f32_array_copy_capped(const F32Array *src, F32Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f32_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2428,7 +2428,7 @@ void wapp_f64_array_extend_capped(F64Array *array, const F64Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f64_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2458,7 +2458,7 @@ void wapp_f64_array_copy_capped(const F64Array *src, F64Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f64_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2577,7 +2577,7 @@ void wapp_f128_array_extend_capped(F128Array *array, const F128Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f128_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2607,7 +2607,7 @@ void wapp_f128_array_copy_capped(const F128Array *src, F128Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f128_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2726,7 +2726,7 @@ void wapp_iptr_array_extend_capped(IptrArray *array, const IptrArray *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_iptr_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2756,7 +2756,7 @@ void wapp_iptr_array_copy_capped(const IptrArray *src, IptrArray *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_iptr_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2875,7 +2875,7 @@ void wapp_uptr_array_extend_capped(UptrArray *array, const UptrArray *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_uptr_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2905,7 +2905,7 @@ void wapp_uptr_array_copy_capped(const UptrArray *src, UptrArray *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_uptr_array_get(src, item_index);
|
||||
++item_index;
|
||||
|
||||
@@ -16,7 +16,7 @@ BEGIN_C_LINKAGE
|
||||
|
||||
#define wapp_void_ptr_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((VoidPArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(void *)))
|
||||
#define wapp_str8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((Str8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(Str8)))
|
||||
#define wapp_b32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((B32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(b32)))
|
||||
#define wapp_b8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((B8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(b8)))
|
||||
#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)))
|
||||
@@ -70,22 +70,22 @@ BEGIN_C_LINKAGE
|
||||
*_str8_array_pop(ARRAY_PTR) : \
|
||||
Str8{} \
|
||||
)
|
||||
#define wapp_b32_array(...) ([&]() { \
|
||||
wapp_persist b32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return B32Array{ \
|
||||
#define wapp_b8_array(...) ([&]() { \
|
||||
wapp_persist b8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return B8Array{ \
|
||||
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) \
|
||||
wapp_misc_utils_va_args_count(b8, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b8, __VA_ARGS__) * 2), \
|
||||
sizeof(b8) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_b32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
wapp_persist b32 buf[CAPACITY] = {}; \
|
||||
return B32Array{buf, 0, CAPACITY, sizeof(b32)}; \
|
||||
#define wapp_b8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
wapp_persist b8 buf[CAPACITY] = {}; \
|
||||
return B8Array{buf, 0, CAPACITY, sizeof(b8)}; \
|
||||
}())
|
||||
#define wapp_b32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b32_array_pop(ARRAY_PTR) : \
|
||||
b32{} \
|
||||
#define wapp_b8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b8_array_pop(ARRAY_PTR) : \
|
||||
b8{} \
|
||||
)
|
||||
#define wapp_char_array(...) ([&]() { \
|
||||
wapp_persist char buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
@@ -399,16 +399,16 @@ BEGIN_C_LINKAGE
|
||||
*_str8_array_pop(ARRAY_PTR) : \
|
||||
(Str8){0} \
|
||||
)
|
||||
#define wapp_b32_array(...) ((B32Array){ \
|
||||
.items = (b32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
|
||||
.count = wapp_misc_utils_va_args_count(b32, __VA_ARGS__), \
|
||||
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2), \
|
||||
.item_size = sizeof(b32) \
|
||||
#define wapp_b8_array(...) ((B8Array){ \
|
||||
.items = (b8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
|
||||
.count = wapp_misc_utils_va_args_count(b8, __VA_ARGS__), \
|
||||
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b8, __VA_ARGS__) * 2), \
|
||||
.item_size = sizeof(b8) \
|
||||
})
|
||||
#define wapp_b32_array_with_capacity(CAPACITY) ((B32Array){.items = (b32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(b32)})
|
||||
#define wapp_b32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b32_array_pop(ARRAY_PTR) : \
|
||||
(b32){0} \
|
||||
#define wapp_b8_array_with_capacity(CAPACITY) ((B8Array){.items = (b8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(b8)})
|
||||
#define wapp_b8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b8_array_pop(ARRAY_PTR) : \
|
||||
(b8){0} \
|
||||
)
|
||||
#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__}, \
|
||||
@@ -625,9 +625,9 @@ struct Str8Array {
|
||||
u64 item_size;
|
||||
};
|
||||
|
||||
typedef struct B32Array B32Array;
|
||||
struct B32Array {
|
||||
b32 *items;
|
||||
typedef struct B8Array B8Array;
|
||||
struct B8Array {
|
||||
b8 *items;
|
||||
u64 count;
|
||||
u64 capacity;
|
||||
u64 item_size;
|
||||
@@ -789,16 +789,16 @@ Str8Array *wapp_str8_array_append_alloc(const Allocator *allocator, Str8Array *a
|
||||
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);
|
||||
Str8 *_str8_array_pop(Str8Array *array);
|
||||
b32 *wapp_b32_array_get(const B32Array *array, u64 index);
|
||||
void wapp_b32_array_set(B32Array *array, u64 index, b32 *item);
|
||||
void wapp_b32_array_append_capped(B32Array *array, b32 *item);
|
||||
void wapp_b32_array_extend_capped(B32Array *array, const B32Array *other);
|
||||
void wapp_b32_array_clear(B32Array *array);
|
||||
void wapp_b32_array_copy_capped(const B32Array *src, B32Array *dst);
|
||||
B32Array *wapp_b32_array_append_alloc(const Allocator *allocator, B32Array *array, b32 *item);
|
||||
B32Array *wapp_b32_array_extend_alloc(const Allocator *allocator, B32Array *array, const B32Array *other);
|
||||
B32Array *wapp_b32_array_copy_alloc(const Allocator *allocator, const B32Array *src, B32Array *dst);
|
||||
b32 *_b32_array_pop(B32Array *array);
|
||||
b8 *wapp_b8_array_get(const B8Array *array, u64 index);
|
||||
void wapp_b8_array_set(B8Array *array, u64 index, b8 *item);
|
||||
void wapp_b8_array_append_capped(B8Array *array, b8 *item);
|
||||
void wapp_b8_array_extend_capped(B8Array *array, const B8Array *other);
|
||||
void wapp_b8_array_clear(B8Array *array);
|
||||
void wapp_b8_array_copy_capped(const B8Array *src, B8Array *dst);
|
||||
B8Array *wapp_b8_array_append_alloc(const Allocator *allocator, B8Array *array, b8 *item);
|
||||
B8Array *wapp_b8_array_extend_alloc(const Allocator *allocator, B8Array *array, const B8Array *other);
|
||||
B8Array *wapp_b8_array_copy_alloc(const Allocator *allocator, const B8Array *src, B8Array *dst);
|
||||
b8 *_b8_array_pop(B8Array *array);
|
||||
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_append_capped(CharArray *array, char *item);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
wapp_intern VoidPList void_ptr_node_to_list(VoidPNode *node);
|
||||
wapp_intern Str8List str8_node_to_list(Str8Node *node);
|
||||
wapp_intern B32List b32_node_to_list(B32Node *node);
|
||||
wapp_intern B8List b8_node_to_list(B8Node *node);
|
||||
wapp_intern CharList char_node_to_list(CharNode *node);
|
||||
wapp_intern C8List c8_node_to_list(C8Node *node);
|
||||
wapp_intern C16List c16_node_to_list(C16Node *node);
|
||||
@@ -375,11 +375,11 @@ void wapp_str8_list_empty(Str8List *list) {
|
||||
}
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_get(const B32List *list, u64 index) {
|
||||
B8Node *wapp_b8_list_get(const B8List *list, u64 index) {
|
||||
wapp_runtime_assert(index < list->node_count, "`index` is out of bounds");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B32Node *current = list->first;
|
||||
B8Node *output = NULL;
|
||||
B8Node *current = list->first;
|
||||
for (u64 i = 1; i <= index; ++i) {
|
||||
current = current->next;
|
||||
}
|
||||
@@ -389,10 +389,10 @@ B32Node *wapp_b32_list_get(const B32List *list, u64 index) {
|
||||
return output;
|
||||
}
|
||||
|
||||
void wapp_b32_list_push_front(B32List *list, B32Node *node) {
|
||||
void wapp_b8_list_push_front(B8List *list, B8Node *node) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
B32List node_list = b32_node_to_list(node);
|
||||
B8List node_list = b8_node_to_list(node);
|
||||
|
||||
if (list->node_count == 0) {
|
||||
*list = node_list;
|
||||
@@ -401,7 +401,7 @@ void wapp_b32_list_push_front(B32List *list, B32Node *node) {
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
B32Node *first = list->first;
|
||||
B8Node *first = list->first;
|
||||
if (first) {
|
||||
first->prev = node_list.last;
|
||||
}
|
||||
@@ -410,10 +410,10 @@ void wapp_b32_list_push_front(B32List *list, B32Node *node) {
|
||||
node_list.last->next = first;
|
||||
}
|
||||
|
||||
void wapp_b32_list_push_back(B32List *list, B32Node *node) {
|
||||
void wapp_b8_list_push_back(B8List *list, B8Node *node) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
B32List node_list = b32_node_to_list(node);
|
||||
B8List node_list = b8_node_to_list(node);
|
||||
|
||||
if (list->node_count == 0) {
|
||||
*list = node_list;
|
||||
@@ -422,7 +422,7 @@ void wapp_b32_list_push_back(B32List *list, B32Node *node) {
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
B32Node *last = list->last;
|
||||
B8Node *last = list->last;
|
||||
if (last) {
|
||||
last->next = node_list.first;
|
||||
}
|
||||
@@ -431,27 +431,27 @@ void wapp_b32_list_push_back(B32List *list, B32Node *node) {
|
||||
node_list.first->prev = last;
|
||||
}
|
||||
|
||||
void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index) {
|
||||
void wapp_b8_list_insert(B8List *list, B8Node *node, u64 index) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
if (index == 0) {
|
||||
wapp_b32_list_push_front(list, node);
|
||||
wapp_b8_list_push_front(list, node);
|
||||
return;
|
||||
} else if (index == list->node_count) {
|
||||
wapp_b32_list_push_back(list, node);
|
||||
wapp_b8_list_push_back(list, node);
|
||||
return;
|
||||
}
|
||||
|
||||
B32Node *dst_node = wapp_b32_list_get(list, index);
|
||||
B8Node *dst_node = wapp_b8_list_get(list, index);
|
||||
if (!dst_node) {
|
||||
return;
|
||||
}
|
||||
|
||||
B32List node_list = b32_node_to_list(node);
|
||||
B8List node_list = b8_node_to_list(node);
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
B32Node *prev = dst_node->prev;
|
||||
B8Node *prev = dst_node->prev;
|
||||
|
||||
dst_node->prev = node_list.last;
|
||||
prev->next = node_list.first;
|
||||
@@ -460,20 +460,20 @@ void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index) {
|
||||
node_list.last->next = dst_node;
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_pop_front(B32List *list) {
|
||||
B8Node *wapp_b8_list_pop_front(B8List *list) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B8Node *output = NULL;
|
||||
|
||||
if (list->node_count == 0) {
|
||||
goto RETURN_B32_LIST_POP_FRONT;
|
||||
goto RETURN_B8_LIST_POP_FRONT;
|
||||
}
|
||||
|
||||
output = list->first;
|
||||
|
||||
if (list->node_count == 1) {
|
||||
*list = (B32List){0};
|
||||
goto RETURN_B32_LIST_POP_FRONT;
|
||||
*list = (B8List){0};
|
||||
goto RETURN_B8_LIST_POP_FRONT;
|
||||
}
|
||||
|
||||
--(list->node_count);
|
||||
@@ -481,24 +481,24 @@ B32Node *wapp_b32_list_pop_front(B32List *list) {
|
||||
|
||||
output->prev = output->next = NULL;
|
||||
|
||||
RETURN_B32_LIST_POP_FRONT:
|
||||
RETURN_B8_LIST_POP_FRONT:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_pop_back(B32List *list) {
|
||||
B8Node *wapp_b8_list_pop_back(B8List *list) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B8Node *output = NULL;
|
||||
|
||||
if (list->node_count == 0) {
|
||||
goto RETURN_B32_LIST_POP_BACK;
|
||||
goto RETURN_B8_LIST_POP_BACK;
|
||||
}
|
||||
|
||||
output = list->last;
|
||||
|
||||
if (list->node_count == 1) {
|
||||
*list = (B32List){0};
|
||||
goto RETURN_B32_LIST_POP_BACK;
|
||||
*list = (B8List){0};
|
||||
goto RETURN_B8_LIST_POP_BACK;
|
||||
}
|
||||
|
||||
--(list->node_count);
|
||||
@@ -506,26 +506,26 @@ B32Node *wapp_b32_list_pop_back(B32List *list) {
|
||||
|
||||
output->prev = output->next = NULL;
|
||||
|
||||
RETURN_B32_LIST_POP_BACK:
|
||||
RETURN_B8_LIST_POP_BACK:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_remove(B32List *list, u64 index) {
|
||||
B8Node *wapp_b8_list_remove(B8List *list, u64 index) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B8Node *output = NULL;
|
||||
|
||||
if (index == 0) {
|
||||
output = wapp_b32_list_pop_front(list);
|
||||
goto RETURN_B32_LIST_REMOVE;
|
||||
output = wapp_b8_list_pop_front(list);
|
||||
goto RETURN_B8_LIST_REMOVE;
|
||||
} else if (index == list->node_count) {
|
||||
output = wapp_b32_list_pop_back(list);
|
||||
goto RETURN_B32_LIST_REMOVE;
|
||||
output = wapp_b8_list_pop_back(list);
|
||||
goto RETURN_B8_LIST_REMOVE;
|
||||
}
|
||||
|
||||
output = wapp_b32_list_get(list, index);
|
||||
output = wapp_b8_list_get(list, index);
|
||||
if (!output) {
|
||||
goto RETURN_B32_LIST_REMOVE;
|
||||
goto RETURN_B8_LIST_REMOVE;
|
||||
}
|
||||
|
||||
output->prev->next = output->next;
|
||||
@@ -535,16 +535,16 @@ B32Node *wapp_b32_list_remove(B32List *list, u64 index) {
|
||||
|
||||
output->prev = output->next = NULL;
|
||||
|
||||
RETURN_B32_LIST_REMOVE:
|
||||
RETURN_B8_LIST_REMOVE:
|
||||
return output;
|
||||
}
|
||||
|
||||
void wapp_b32_list_empty(B32List *list) {
|
||||
void wapp_b8_list_empty(B8List *list) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
u64 count = list->node_count;
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
wapp_b32_list_pop_back(list);
|
||||
wapp_b8_list_pop_back(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3521,8 +3521,8 @@ wapp_intern Str8List str8_node_to_list(Str8Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
wapp_intern B32List b32_node_to_list(B32Node *node) {
|
||||
B32List output = {.first = node, .last = node, .node_count = 1};
|
||||
wapp_intern B8List b8_node_to_list(B8Node *node) {
|
||||
B8List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
output.first = output.first->prev;
|
||||
|
||||
@@ -15,7 +15,7 @@ BEGIN_C_LINKAGE
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#define wapp_void_ptr_list_node(ITEM_PTR) VoidPNode{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_str8_list_node(ITEM_PTR) Str8Node{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_b32_list_node(ITEM_PTR) B32Node{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_b8_list_node(ITEM_PTR) B8Node{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_char_list_node(ITEM_PTR) CharNode{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_c8_list_node(ITEM_PTR) C8Node{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_c16_list_node(ITEM_PTR) C16Node{ITEM_PTR, nullptr, nullptr}
|
||||
@@ -36,7 +36,7 @@ BEGIN_C_LINKAGE
|
||||
#else
|
||||
#define wapp_void_ptr_list_node(ITEM_PTR) ((VoidPNode){.item = ITEM_PTR})
|
||||
#define wapp_str8_list_node(ITEM_PTR) ((Str8Node){.item = ITEM_PTR})
|
||||
#define wapp_b32_list_node(ITEM_PTR) ((B32Node){.item = ITEM_PTR})
|
||||
#define wapp_b8_list_node(ITEM_PTR) ((B8Node){.item = ITEM_PTR})
|
||||
#define wapp_char_list_node(ITEM_PTR) ((CharNode){.item = ITEM_PTR})
|
||||
#define wapp_c8_list_node(ITEM_PTR) ((C8Node){.item = ITEM_PTR})
|
||||
#define wapp_c16_list_node(ITEM_PTR) ((C16Node){.item = ITEM_PTR})
|
||||
@@ -100,17 +100,17 @@ struct Str8List {
|
||||
u64 node_count;
|
||||
};
|
||||
|
||||
typedef struct B32Node B32Node;
|
||||
struct B32Node {
|
||||
b32 *item;
|
||||
B32Node *prev;
|
||||
B32Node *next;
|
||||
typedef struct B8Node B8Node;
|
||||
struct B8Node {
|
||||
b8 *item;
|
||||
B8Node *prev;
|
||||
B8Node *next;
|
||||
};
|
||||
|
||||
typedef struct B32List B32List;
|
||||
struct B32List {
|
||||
B32Node *first;
|
||||
B32Node *last;
|
||||
typedef struct B8List B8List;
|
||||
struct B8List {
|
||||
B8Node *first;
|
||||
B8Node *last;
|
||||
u64 node_count;
|
||||
};
|
||||
|
||||
@@ -368,14 +368,14 @@ Str8Node *wapp_str8_list_pop_front(Str8List *list);
|
||||
Str8Node *wapp_str8_list_pop_back(Str8List *list);
|
||||
Str8Node *wapp_str8_list_remove(Str8List *list, u64 index);
|
||||
void wapp_str8_list_empty(Str8List *list);
|
||||
B32Node *wapp_b32_list_get(const B32List *list, u64 index);
|
||||
void wapp_b32_list_push_front(B32List *list, B32Node *node);
|
||||
void wapp_b32_list_push_back(B32List *list, B32Node *node);
|
||||
void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index);
|
||||
B32Node *wapp_b32_list_pop_front(B32List *list);
|
||||
B32Node *wapp_b32_list_pop_back(B32List *list);
|
||||
B32Node *wapp_b32_list_remove(B32List *list, u64 index);
|
||||
void wapp_b32_list_empty(B32List *list);
|
||||
B8Node *wapp_b8_list_get(const B8List *list, u64 index);
|
||||
void wapp_b8_list_push_front(B8List *list, B8Node *node);
|
||||
void wapp_b8_list_push_back(B8List *list, B8Node *node);
|
||||
void wapp_b8_list_insert(B8List *list, B8Node *node, u64 index);
|
||||
B8Node *wapp_b8_list_pop_front(B8List *list);
|
||||
B8Node *wapp_b8_list_pop_back(B8List *list);
|
||||
B8Node *wapp_b8_list_remove(B8List *list, u64 index);
|
||||
void wapp_b8_list_empty(B8List *list);
|
||||
CharNode *wapp_char_list_get(const CharList *list, u64 index);
|
||||
void wapp_char_list_push_front(CharList *list, CharNode *node);
|
||||
void wapp_char_list_push_back(CharList *list, CharNode *node);
|
||||
|
||||
@@ -123,7 +123,7 @@ void wapp_str8_push_back(Str8 *str, c8 c) {
|
||||
wapp_str8_set(str, index, c);
|
||||
}
|
||||
|
||||
b32 wapp_str8_equal(Str8RO *s1, Str8RO *s2) {
|
||||
b8 wapp_str8_equal(Str8RO *s1, Str8RO *s2) {
|
||||
if (s1->size != s2->size) {
|
||||
return false;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ b32 wapp_str8_equal(Str8RO *s1, Str8RO *s2) {
|
||||
return wapp_str8_equal_to_count(s1, s2, s1->size);
|
||||
}
|
||||
|
||||
b32 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count) {
|
||||
b8 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count) {
|
||||
if (!s1 || !s2) {
|
||||
return false;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ i64 wapp_str8_find(Str8RO *str, Str8RO substr) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 char_index = 0;
|
||||
b32 running = char_index < str->size;
|
||||
b8 running = char_index < str->size;
|
||||
while (running) {
|
||||
const c8 *sub = str->buf + char_index;
|
||||
if (memcmp(sub, substr.buf, substr.size) == 0) {
|
||||
@@ -300,7 +300,7 @@ i64 wapp_str8_rfind(Str8RO *str, Str8RO substr) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
i64 char_index = str->size - substr.size;
|
||||
b32 running = char_index >= 0;
|
||||
b8 running = char_index >= 0;
|
||||
while (running) {
|
||||
const c8 *sub = str->buf + char_index;
|
||||
if (memcmp(sub, substr.buf, substr.size) == 0) {
|
||||
@@ -427,7 +427,7 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *d
|
||||
// MSVC Spectre mitigation warnings
|
||||
Str8Node *node;
|
||||
u64 node_index = 0;
|
||||
b32 running = node_index < list->node_count;
|
||||
b8 running = node_index < list->node_count;
|
||||
while (running) {
|
||||
node = wapp_str8_list_get(list, node_index);
|
||||
if (!node) {
|
||||
@@ -438,7 +438,7 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *d
|
||||
|
||||
// NOTE (Abdelrahman): Comparison extracted to variable to silence
|
||||
// MSVC Spectre mitigation warnings
|
||||
b32 not_last = node_index + 1 < list->node_count;
|
||||
b8 not_last = node_index + 1 < list->node_count;
|
||||
if (not_last) {
|
||||
wapp_str8_concat_capped(output, delimiter);
|
||||
}
|
||||
@@ -460,7 +460,7 @@ u64 wapp_str8_list_total_size(const Str8List *list) {
|
||||
Str8Node* node;
|
||||
u64 node_index = 0;
|
||||
u64 output = 0;
|
||||
b32 running = node_index < list->node_count;
|
||||
b8 running = node_index < list->node_count;
|
||||
while (running) {
|
||||
node = wapp_str8_list_get(list, node_index);
|
||||
if (!node) {
|
||||
|
||||
@@ -89,8 +89,8 @@ void wapp_str8_dealloc_buf(const Allocator *allocator, Str8 **str);
|
||||
c8 wapp_str8_get(Str8RO *str, u64 index);
|
||||
void wapp_str8_set(Str8 *str, u64 index, c8 c);
|
||||
void wapp_str8_push_back(Str8 *str, c8 c);
|
||||
b32 wapp_str8_equal(Str8RO *s1, Str8RO *s2);
|
||||
b32 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count);
|
||||
b8 wapp_str8_equal(Str8RO *s1, Str8RO *s2);
|
||||
b8 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count);
|
||||
Str8 wapp_str8_slice(Str8RO *str, u64 start, u64 end);
|
||||
void wapp_str8_concat_capped(Str8 *dst, Str8RO *src);
|
||||
void wapp_str8_copy_cstr_capped(Str8 *dst, const char *src);
|
||||
|
||||
@@ -18,7 +18,7 @@ wapp_intern void seed_os_generator(void);
|
||||
wapp_intern u64 generate_random_number(void);
|
||||
|
||||
XOR256State wapp_prng_xorshift_init_state(void) {
|
||||
wapp_persist b32 seeded = false;
|
||||
wapp_persist b8 seeded = false;
|
||||
if (!seeded) {
|
||||
seeded = true;
|
||||
seed_os_generator();
|
||||
|
||||
@@ -22,10 +22,10 @@ BEGIN_C_LINKAGE
|
||||
typedef struct test_func_result TestFuncResult;
|
||||
struct test_func_result {
|
||||
Str8RO name;
|
||||
b32 passed;
|
||||
b8 passed;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(b32));
|
||||
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(b8));
|
||||
#endif // WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ UUID *wapp_uuid_init_uuid4(UUID *uuid) {
|
||||
|
||||
wapp_intern UUID4 generate_uuid4(void) {
|
||||
wapp_persist XOR256State state = {0};
|
||||
wapp_persist b32 initialised = false;
|
||||
wapp_persist b8 initialised = false;
|
||||
|
||||
if (!initialised) {
|
||||
initialised = true;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
TestFuncResult test_arena_allocator(void) {
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(4096);
|
||||
b32 result = allocator.obj != NULL && allocator.alloc != NULL &&
|
||||
b8 result = allocator.obj != NULL && allocator.alloc != NULL &&
|
||||
allocator.alloc_aligned != NULL &&
|
||||
allocator.realloc != NULL && allocator.realloc_aligned != NULL &&
|
||||
allocator.free == NULL;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
TestFuncResult test_arena_allocator(void) {
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(4096);
|
||||
b32 result = allocator.obj != nullptr && allocator.alloc != nullptr &&
|
||||
b8 result = allocator.obj != nullptr && allocator.alloc != nullptr &&
|
||||
allocator.alloc_aligned != nullptr &&
|
||||
allocator.realloc != nullptr && allocator.realloc_aligned != nullptr &&
|
||||
allocator.free == nullptr;
|
||||
|
||||
@@ -9,7 +9,7 @@ wapp_intern i32 count = 20;
|
||||
wapp_intern i32 *array = NULL;
|
||||
|
||||
TestFuncResult test_arena_init(void) {
|
||||
b32 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY);
|
||||
b8 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ TestFuncResult test_arena_init(void) {
|
||||
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
Arena *large_arena = NULL;
|
||||
u64 capacity = GB(512);
|
||||
b32 result = wapp_mem_arena_init(&large_arena, capacity);
|
||||
b8 result = wapp_mem_arena_init(&large_arena, capacity);
|
||||
if (result) {
|
||||
wapp_mem_arena_destroy(&large_arena);
|
||||
}
|
||||
@@ -27,7 +27,7 @@ TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
|
||||
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
array = wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
b32 result = array != NULL;
|
||||
b8 result = array != NULL;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
array[i] = i * 10;
|
||||
@@ -38,7 +38,7 @@ TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
|
||||
TestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
u8 *bytes = wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
|
||||
b32 result = bytes == NULL;
|
||||
b8 result = bytes == NULL;
|
||||
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ TestFuncResult test_arena_realloc_smaller_size(void) {
|
||||
|
||||
TestFuncResult test_arena_clear(void) {
|
||||
wapp_mem_arena_clear(arena);
|
||||
b32 result = true;
|
||||
b8 result = true;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
if (array[i] != 0) {
|
||||
@@ -105,7 +105,7 @@ TestFuncResult test_arena_clear(void) {
|
||||
|
||||
TestFuncResult test_arena_destroy(void) {
|
||||
wapp_mem_arena_destroy(&arena);
|
||||
b32 result = arena == NULL;
|
||||
b8 result = arena == NULL;
|
||||
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ wapp_intern i32 count = 20;
|
||||
wapp_intern i32 *array = nullptr;
|
||||
|
||||
TestFuncResult test_arena_init(void) {
|
||||
b32 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY);
|
||||
b8 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ TestFuncResult test_arena_init(void) {
|
||||
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
Arena *large_arena = nullptr;
|
||||
u64 capacity = GB(512);
|
||||
b32 result = wapp_mem_arena_init(&large_arena, capacity);
|
||||
b8 result = wapp_mem_arena_init(&large_arena, capacity);
|
||||
if (result) {
|
||||
wapp_mem_arena_destroy(&large_arena);
|
||||
}
|
||||
@@ -27,7 +27,7 @@ TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
|
||||
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
array = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
b32 result = array != nullptr;
|
||||
b8 result = array != nullptr;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
array[i] = i * 10;
|
||||
@@ -38,7 +38,7 @@ TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
|
||||
TestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
u8 *bytes = (u8 *)wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
|
||||
b32 result = bytes == nullptr;
|
||||
b8 result = bytes == nullptr;
|
||||
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ TestFuncResult test_arena_realloc_smaller_size(void) {
|
||||
|
||||
TestFuncResult test_arena_clear(void) {
|
||||
wapp_mem_arena_clear(arena);
|
||||
b32 result = true;
|
||||
b8 result = true;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
if (array[i] != 0) {
|
||||
@@ -105,7 +105,7 @@ TestFuncResult test_arena_clear(void) {
|
||||
|
||||
TestFuncResult test_arena_destroy(void) {
|
||||
wapp_mem_arena_destroy(&arena);
|
||||
b32 result = arena == nullptr;
|
||||
b8 result = arena == nullptr;
|
||||
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "wapp.h"
|
||||
|
||||
TestFuncResult test_i32_array(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_i32_array(1, 2, 3, 4, 5, 6, 7);
|
||||
result = array.count == 7 && array.capacity == 16;
|
||||
@@ -10,7 +10,7 @@ TestFuncResult test_i32_array(void) {
|
||||
i32 *item;
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(&array, index);
|
||||
result = result && item && (*item == (i32)(index + 1));
|
||||
@@ -23,7 +23,7 @@ TestFuncResult test_i32_array(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_with_capacity(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_i32_array_with_capacity(64);
|
||||
result = array.count == 0 && array.capacity == 64;
|
||||
@@ -32,14 +32,14 @@ TestFuncResult test_i32_array_with_capacity(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_get(void) {
|
||||
b32 result = true;
|
||||
b8 result = true;
|
||||
|
||||
I32Array array = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
i32 *item;
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(&array, index);
|
||||
result = result && item && (*item == (i32)index);
|
||||
@@ -52,14 +52,14 @@ TestFuncResult test_i32_array_get(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_set(void) {
|
||||
b32 result = true;
|
||||
b8 result = true;
|
||||
|
||||
I32Array array = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
i32 *item;
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
i32 num = (i32)(index * 2);
|
||||
wapp_i32_array_set(&array, index, &num);
|
||||
@@ -74,7 +74,7 @@ TestFuncResult test_i32_array_set(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_append_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_i32_array_with_capacity(64);
|
||||
wapp_i32_array_append_capped(&array, &((i32){10}));
|
||||
@@ -92,7 +92,7 @@ TestFuncResult test_i32_array_append_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_extend_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array1 = wapp_i32_array(1, 2, 3, 4);
|
||||
I32Array array2 = wapp_i32_array(10, 20);
|
||||
@@ -107,7 +107,7 @@ TestFuncResult test_i32_array_extend_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_clear(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
result = array.count == 9;
|
||||
@@ -120,7 +120,7 @@ TestFuncResult test_i32_array_clear(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_pop(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array1 = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
I32Array array2 = wapp_i32_array_with_capacity(32);
|
||||
@@ -134,7 +134,7 @@ TestFuncResult test_i32_array_pop(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_copy_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array src = wapp_i32_array(1, 2, 3, 4, 5);
|
||||
I32Array dst1 = wapp_i32_array(1, 2, 3, 4, 5, 6);
|
||||
@@ -145,7 +145,7 @@ TestFuncResult test_i32_array_copy_capped(void) {
|
||||
result = dst1.count == expected_count;
|
||||
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_i32_array_get(&src, index) == *wapp_i32_array_get(&dst1, index));
|
||||
|
||||
@@ -170,7 +170,7 @@ TestFuncResult test_i32_array_copy_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_alloc_capacity(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(MB(4));
|
||||
u64 capacity = 32;
|
||||
@@ -184,7 +184,7 @@ TestFuncResult test_i32_array_alloc_capacity(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_append_alloc(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(MB(4));
|
||||
I32Array array1 = wapp_i32_array(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
@@ -195,7 +195,7 @@ TestFuncResult test_i32_array_append_alloc(void) {
|
||||
|
||||
u64 count = 4;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
i32 num = (i32)index;
|
||||
arr_ptr = wapp_i32_array_append_alloc(&allocator, &array2, &num);
|
||||
@@ -211,7 +211,7 @@ TestFuncResult test_i32_array_append_alloc(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_extend_alloc(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(MB(4));
|
||||
I32Array array1 = wapp_i32_array(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
@@ -230,7 +230,7 @@ TestFuncResult test_i32_array_extend_alloc(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_copy_alloc(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(MB(4));
|
||||
I32Array src = wapp_i32_array(1, 2, 3, 4, 5);
|
||||
@@ -243,7 +243,7 @@ TestFuncResult test_i32_array_copy_alloc(void) {
|
||||
result = array_ptr->count == expected_count && array_ptr == &dst1;
|
||||
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_i32_array_get(&src, index) == *wapp_i32_array_get(array_ptr, index));
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "wapp.h"
|
||||
|
||||
TestFuncResult test_i32_array(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_i32_array(1, 2, 3, 4, 5, 6, 7);
|
||||
result = array.count == 7 && array.capacity == 16;
|
||||
@@ -10,7 +10,7 @@ TestFuncResult test_i32_array(void) {
|
||||
i32 *item;
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(&array, index);
|
||||
result = result && item && (*item == (i32)(index + 1));
|
||||
@@ -23,7 +23,7 @@ TestFuncResult test_i32_array(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_with_capacity(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_i32_array_with_capacity(64);
|
||||
result = array.count == 0 && array.capacity == 64;
|
||||
@@ -32,14 +32,14 @@ TestFuncResult test_i32_array_with_capacity(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_get(void) {
|
||||
b32 result = true;
|
||||
b8 result = true;
|
||||
|
||||
I32Array array = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
i32 *item;
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(&array, index);
|
||||
result = result && item && (*item == (i32)index);
|
||||
@@ -52,14 +52,14 @@ TestFuncResult test_i32_array_get(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_set(void) {
|
||||
b32 result = true;
|
||||
b8 result = true;
|
||||
|
||||
I32Array array = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
i32 *item;
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
i32 num = (i32)(index * 2);
|
||||
wapp_i32_array_set(&array, index, &num);
|
||||
@@ -74,7 +74,7 @@ TestFuncResult test_i32_array_set(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_append_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_i32_array_with_capacity(64);
|
||||
i32 item1 = 10;
|
||||
@@ -94,7 +94,7 @@ TestFuncResult test_i32_array_append_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_extend_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array1 = wapp_i32_array(1, 2, 3, 4);
|
||||
I32Array array2 = wapp_i32_array(10, 20);
|
||||
@@ -109,7 +109,7 @@ TestFuncResult test_i32_array_extend_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_clear(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
result = array.count == 9;
|
||||
@@ -122,7 +122,7 @@ TestFuncResult test_i32_array_clear(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_pop(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array array1 = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
I32Array array2 = wapp_i32_array_with_capacity(32);
|
||||
@@ -136,7 +136,7 @@ TestFuncResult test_i32_array_pop(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_copy_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
I32Array src = wapp_i32_array(1, 2, 3, 4, 5);
|
||||
I32Array dst1 = wapp_i32_array(1, 2, 3, 4, 5, 6);
|
||||
@@ -147,7 +147,7 @@ TestFuncResult test_i32_array_copy_capped(void) {
|
||||
result = dst1.count == expected_count;
|
||||
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_i32_array_get(&src, index) == *wapp_i32_array_get(&dst1, index));
|
||||
|
||||
@@ -172,7 +172,7 @@ TestFuncResult test_i32_array_copy_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_alloc_capacity(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(MB(4));
|
||||
u64 capacity = 32;
|
||||
@@ -186,7 +186,7 @@ TestFuncResult test_i32_array_alloc_capacity(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_append_alloc(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(MB(4));
|
||||
I32Array array1 = wapp_i32_array(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
@@ -198,7 +198,7 @@ TestFuncResult test_i32_array_append_alloc(void) {
|
||||
|
||||
u64 count = 4;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
i32 num = (i32)index;
|
||||
arr_ptr = wapp_i32_array_append_alloc(&allocator, &array2, &num);
|
||||
@@ -214,7 +214,7 @@ TestFuncResult test_i32_array_append_alloc(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_extend_alloc(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(MB(4));
|
||||
I32Array array1 = wapp_i32_array(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
@@ -233,7 +233,7 @@ TestFuncResult test_i32_array_extend_alloc(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_i32_array_copy_alloc(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(MB(4));
|
||||
I32Array src = wapp_i32_array(1, 2, 3, 4, 5);
|
||||
@@ -246,7 +246,7 @@ TestFuncResult test_i32_array_copy_alloc(void) {
|
||||
result = array_ptr->count == expected_count && array_ptr == &dst1;
|
||||
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_i32_array_get(&src, index) == *wapp_i32_array_get(array_ptr, index));
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "test_str8_array.h"
|
||||
|
||||
TestFuncResult test_str8_array(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
|
||||
Str8Array array = wapp_str8_array(wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye"));
|
||||
@@ -12,7 +12,7 @@ TestFuncResult test_str8_array(void) {
|
||||
Str8 *item;
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_str8_array_get(&array, index);
|
||||
result = result && item && (wapp_str8_equal(item, &expected[index]));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "test_str8_array.h"
|
||||
|
||||
TestFuncResult test_str8_array(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
|
||||
|
||||
@@ -17,7 +17,7 @@ TestFuncResult test_str8_array(void) {
|
||||
Str8 *item;
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_str8_array_get(&array, index);
|
||||
result = result && item && (wapp_str8_equal(item, &expected[index]));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define TMP_BUF_SIZE 1024
|
||||
|
||||
TestFuncResult test_cpath_join_path(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 out = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
@@ -86,7 +86,7 @@ TestFuncResult test_cpath_dirname(void) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8 *output = NULL;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
@@ -134,7 +134,7 @@ TestFuncResult test_cpath_dirup(void) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8 *output = NULL;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define TMP_BUF_SIZE 1024
|
||||
|
||||
TestFuncResult test_cpath_join_path(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 out = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
@@ -107,7 +107,7 @@ TestFuncResult test_cpath_dirname(void) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8 *output = nullptr;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
@@ -157,7 +157,7 @@ TestFuncResult test_cpath_dirup(void) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8 *output = nullptr;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
|
||||
@@ -10,7 +10,7 @@ TestFuncResult test_commander_cmd_success(void) {
|
||||
wapp_str8_list_push_back(&cmd, &wapp_str8_node_from_cstr("hello world"));
|
||||
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd);
|
||||
b32 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR;
|
||||
|
||||
return wapp_tester_result(succeeded);
|
||||
@@ -21,7 +21,7 @@ TestFuncResult test_commander_cmd_failure(void) {
|
||||
wapp_str8_list_push_back(&cmd, &wapp_str8_node_from_cstr("grep"));
|
||||
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd);
|
||||
b32 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
b8 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR;
|
||||
|
||||
return wapp_tester_result(failed);
|
||||
@@ -38,7 +38,7 @@ TestFuncResult test_commander_cmd_out_buf_success(void) {
|
||||
wapp_str8_list_push_back(&cmd, &wapp_str8_node_from_cstr(msg));
|
||||
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
|
||||
b32 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg));
|
||||
|
||||
return wapp_tester_result(succeeded);
|
||||
@@ -55,7 +55,7 @@ TestFuncResult test_commander_cmd_out_buf_failure(void) {
|
||||
wapp_str8_list_push_back(&cmd, &wapp_str8_node_from_cstr(msg));
|
||||
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
|
||||
b32 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected);
|
||||
|
||||
return wapp_tester_result(failed);
|
||||
|
||||
@@ -12,7 +12,7 @@ TestFuncResult test_commander_cmd_success(void) {
|
||||
wapp_str8_list_push_back(&cmd, &msg);
|
||||
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd);
|
||||
b32 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR;
|
||||
|
||||
return wapp_tester_result(succeeded);
|
||||
@@ -24,7 +24,7 @@ TestFuncResult test_commander_cmd_failure(void) {
|
||||
wapp_str8_list_push_back(&cmd, &grep);
|
||||
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd);
|
||||
b32 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
b8 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR;
|
||||
|
||||
return wapp_tester_result(failed);
|
||||
@@ -43,7 +43,7 @@ TestFuncResult test_commander_cmd_out_buf_success(void) {
|
||||
wapp_str8_list_push_back(&cmd, &arg);
|
||||
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
|
||||
b32 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg));
|
||||
|
||||
return wapp_tester_result(succeeded);
|
||||
@@ -62,7 +62,7 @@ TestFuncResult test_commander_cmd_out_buf_failure(void) {
|
||||
wapp_str8_list_push_back(&cmd, &arg);
|
||||
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
|
||||
b32 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected);
|
||||
|
||||
return wapp_tester_result(failed);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
|
||||
|
||||
TestFuncResult test_str8_lit(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("Hello world");
|
||||
result = s1.capacity == 22 && s1.capacity != s1.size;
|
||||
@@ -31,7 +31,7 @@ TestFuncResult test_str8_lit(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_lit_ro(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8RO s1 = wapp_str8_lit_ro("Hello world");
|
||||
result = s1.capacity == 11 && s1.capacity == s1.size;
|
||||
@@ -58,7 +58,7 @@ TestFuncResult test_str8_lit_ro(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_buf(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_buf(1024);
|
||||
result = s1.capacity == 1024 && s1.size == 0;
|
||||
@@ -76,7 +76,7 @@ TestFuncResult test_str8_buf(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_buf(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -104,7 +104,7 @@ TEST_ALLOC_BUF_CLEANUP:
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_cstr(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -125,7 +125,7 @@ TestFuncResult test_str8_alloc_cstr(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_str8(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -145,7 +145,7 @@ TestFuncResult test_str8_alloc_str8(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_substr(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -165,7 +165,7 @@ TestFuncResult test_str8_alloc_substr(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_get_index_within_bounds(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8RO s1 = wapp_str8_lit_ro("Hello world");
|
||||
result = wapp_str8_get(&s1, 4) == 'o';
|
||||
@@ -193,12 +193,12 @@ TestFuncResult test_str8_get_index_within_bounds(void) {
|
||||
|
||||
TestFuncResult test_str8_get_index_out_of_bounds(void) {
|
||||
Str8 s1 = wapp_str8_lit("Hello world");
|
||||
b32 result = wapp_str8_get(&s1, 20) == '\0';
|
||||
b8 result = wapp_str8_get(&s1, 20) == '\0';
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_set(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("Hello world");
|
||||
wapp_str8_set(&s1, 4, 'f');
|
||||
@@ -232,7 +232,7 @@ TestFuncResult test_str8_set(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_push_back(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 expected = wapp_str8_lit("Abdelrahman");
|
||||
Str8 buf = wapp_str8_buf(64);
|
||||
@@ -254,7 +254,7 @@ TestFuncResult test_str8_push_back(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_equal(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8RO s1 = wapp_str8_lit_ro("hello");
|
||||
Str8RO s2 = wapp_str8_lit_ro("hell");
|
||||
@@ -269,7 +269,7 @@ TestFuncResult test_str8_equal(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_slice(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8 s = wapp_str8_lit("Different strokes for different folks");
|
||||
|
||||
Str8RO sub1 = wapp_str8_slice(&s, 3, 9);
|
||||
@@ -288,7 +288,7 @@ TestFuncResult test_str8_slice(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_concat(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("Hello world");
|
||||
@@ -311,7 +311,7 @@ TestFuncResult test_str8_alloc_concat(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_concat_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 str = wapp_str8_lit("Hello world");
|
||||
Str8 suffix1 = wapp_str8_lit(" from me.");
|
||||
@@ -329,7 +329,7 @@ TestFuncResult test_str8_concat_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_copy_cstr_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(32);
|
||||
const char *src1 = "Hello world";
|
||||
@@ -347,7 +347,7 @@ TestFuncResult test_str8_copy_cstr_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_copy_str8_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(32);
|
||||
Str8RO src1 = wapp_str8_lit_ro("Hello world");
|
||||
@@ -364,7 +364,7 @@ TestFuncResult test_str8_copy_str8_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_format(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(128);
|
||||
Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old");
|
||||
@@ -377,7 +377,7 @@ TestFuncResult test_str8_format(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_find(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
|
||||
|
||||
result = wapp_str8_find(&s, wapp_str8_lit_ro("d")) != -1;
|
||||
@@ -393,7 +393,7 @@ TestFuncResult test_str8_find(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_rfind(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
|
||||
|
||||
result = wapp_str8_rfind(&s, wapp_str8_lit_ro("d")) != -1;
|
||||
@@ -409,7 +409,7 @@ TestFuncResult test_str8_rfind(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_split(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -431,11 +431,11 @@ TestFuncResult test_str8_split(void) {
|
||||
|
||||
u64 index1 = 0;
|
||||
u64 count1 = ARRLEN(splits1);
|
||||
b32 running1 = true;
|
||||
b8 running1 = true;
|
||||
|
||||
u64 index2 = 0;
|
||||
u64 count2 = ARRLEN(splits2);
|
||||
b32 running2 = true;
|
||||
b8 running2 = true;
|
||||
|
||||
result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3;
|
||||
result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4;
|
||||
@@ -466,7 +466,7 @@ TestFuncResult test_str8_split(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_split_with_max(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -481,7 +481,7 @@ TestFuncResult test_str8_split_with_max(void) {
|
||||
|
||||
u64 index = 0;
|
||||
u64 count = ARRLEN(splits);
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
|
||||
result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2;
|
||||
|
||||
@@ -501,7 +501,7 @@ TestFuncResult test_str8_split_with_max(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_rsplit(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -523,11 +523,11 @@ TestFuncResult test_str8_rsplit(void) {
|
||||
|
||||
u64 index1 = 0;
|
||||
u64 count1 = ARRLEN(splits1);
|
||||
b32 running1 = true;
|
||||
b8 running1 = true;
|
||||
|
||||
u64 index2 = 0;
|
||||
u64 count2 = ARRLEN(splits2);
|
||||
b32 running2 = true;
|
||||
b8 running2 = true;
|
||||
|
||||
result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3;
|
||||
result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4;
|
||||
@@ -558,7 +558,7 @@ TestFuncResult test_str8_rsplit(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_rsplit_with_max(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -573,7 +573,7 @@ TestFuncResult test_str8_rsplit_with_max(void) {
|
||||
|
||||
u64 index = 0;
|
||||
u64 count = ARRLEN(splits);
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
|
||||
result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2;
|
||||
|
||||
@@ -593,7 +593,7 @@ TestFuncResult test_str8_rsplit_with_max(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_join(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -613,7 +613,7 @@ TestFuncResult test_str8_join(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_from_bytes(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 str = wapp_str8_buf(1024);
|
||||
U8Array bytes = wapp_u8_array('W', 'A', 'P', 'P');
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
|
||||
|
||||
TestFuncResult test_str8_lit(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("Hello world");
|
||||
result = s1.capacity == 22 && s1.capacity != s1.size;
|
||||
@@ -31,7 +31,7 @@ TestFuncResult test_str8_lit(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_lit_ro(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8RO s1 = wapp_str8_lit_ro("Hello world");
|
||||
result = s1.capacity == 11 && s1.capacity == s1.size;
|
||||
@@ -58,7 +58,7 @@ TestFuncResult test_str8_lit_ro(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_buf(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_buf(1024);
|
||||
result = s1.capacity == 1024 && s1.size == 0;
|
||||
@@ -76,7 +76,7 @@ TestFuncResult test_str8_buf(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_buf(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -104,7 +104,7 @@ TestFuncResult test_str8_alloc_buf(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_cstr(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -125,7 +125,7 @@ TestFuncResult test_str8_alloc_cstr(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_str8(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -145,7 +145,7 @@ TestFuncResult test_str8_alloc_str8(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_substr(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -165,7 +165,7 @@ TestFuncResult test_str8_alloc_substr(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_get_index_within_bounds(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8RO s1 = wapp_str8_lit_ro("Hello world");
|
||||
result = wapp_str8_get(&s1, 4) == 'o';
|
||||
@@ -193,12 +193,12 @@ TestFuncResult test_str8_get_index_within_bounds(void) {
|
||||
|
||||
TestFuncResult test_str8_get_index_out_of_bounds(void) {
|
||||
Str8 s1 = wapp_str8_lit("Hello world");
|
||||
b32 result = wapp_str8_get(&s1, 20) == '\0';
|
||||
b8 result = wapp_str8_get(&s1, 20) == '\0';
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_set(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("Hello world");
|
||||
wapp_str8_set(&s1, 4, 'f');
|
||||
@@ -232,7 +232,7 @@ TestFuncResult test_str8_set(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_push_back(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 expected = wapp_str8_lit("Abdelrahman");
|
||||
Str8 buf = wapp_str8_buf(64);
|
||||
@@ -254,7 +254,7 @@ TestFuncResult test_str8_push_back(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_equal(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8RO s1 = wapp_str8_lit_ro("hello");
|
||||
Str8RO s2 = wapp_str8_lit_ro("hell");
|
||||
@@ -269,7 +269,7 @@ TestFuncResult test_str8_equal(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_slice(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8 s = wapp_str8_lit("Different strokes for different folks");
|
||||
|
||||
Str8RO sub1 = wapp_str8_slice(&s, 3, 9);
|
||||
@@ -288,7 +288,7 @@ TestFuncResult test_str8_slice(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_concat(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("Hello world");
|
||||
@@ -311,7 +311,7 @@ TestFuncResult test_str8_alloc_concat(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_concat_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 str = wapp_str8_lit("Hello world");
|
||||
Str8 suffix1 = wapp_str8_lit(" from me.");
|
||||
@@ -329,7 +329,7 @@ TestFuncResult test_str8_concat_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_copy_cstr_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(32);
|
||||
const char *src1 = "Hello world";
|
||||
@@ -347,7 +347,7 @@ TestFuncResult test_str8_copy_cstr_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_copy_str8_capped(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(32);
|
||||
Str8RO src1 = wapp_str8_lit_ro("Hello world");
|
||||
@@ -364,7 +364,7 @@ TestFuncResult test_str8_copy_str8_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_format(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(128);
|
||||
Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old");
|
||||
@@ -377,7 +377,7 @@ TestFuncResult test_str8_format(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_find(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
|
||||
|
||||
result = wapp_str8_find(&s, wapp_str8_lit_ro("d")) != -1;
|
||||
@@ -393,7 +393,7 @@ TestFuncResult test_str8_find(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_rfind(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
|
||||
|
||||
result = wapp_str8_rfind(&s, wapp_str8_lit_ro("d")) != -1;
|
||||
@@ -409,7 +409,7 @@ TestFuncResult test_str8_rfind(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_split(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -431,11 +431,11 @@ TestFuncResult test_str8_split(void) {
|
||||
|
||||
u64 index1 = 0;
|
||||
u64 count1 = ARRLEN(splits1);
|
||||
b32 running1 = true;
|
||||
b8 running1 = true;
|
||||
|
||||
u64 index2 = 0;
|
||||
u64 count2 = ARRLEN(splits2);
|
||||
b32 running2 = true;
|
||||
b8 running2 = true;
|
||||
|
||||
result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3;
|
||||
result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4;
|
||||
@@ -466,7 +466,7 @@ TestFuncResult test_str8_split(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_split_with_max(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -481,7 +481,7 @@ TestFuncResult test_str8_split_with_max(void) {
|
||||
|
||||
u64 index = 0;
|
||||
u64 count = ARRLEN(splits);
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
|
||||
result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2;
|
||||
|
||||
@@ -501,7 +501,7 @@ TestFuncResult test_str8_split_with_max(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_rsplit(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -523,11 +523,11 @@ TestFuncResult test_str8_rsplit(void) {
|
||||
|
||||
u64 index1 = 0;
|
||||
u64 count1 = ARRLEN(splits1);
|
||||
b32 running1 = true;
|
||||
b8 running1 = true;
|
||||
|
||||
u64 index2 = 0;
|
||||
u64 count2 = ARRLEN(splits2);
|
||||
b32 running2 = true;
|
||||
b8 running2 = true;
|
||||
|
||||
result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3;
|
||||
result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4;
|
||||
@@ -558,7 +558,7 @@ TestFuncResult test_str8_rsplit(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_rsplit_with_max(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -573,7 +573,7 @@ TestFuncResult test_str8_rsplit_with_max(void) {
|
||||
|
||||
u64 index = 0;
|
||||
u64 count = ARRLEN(splits);
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
|
||||
result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2;
|
||||
|
||||
@@ -593,7 +593,7 @@ TestFuncResult test_str8_rsplit_with_max(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_join(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -613,7 +613,7 @@ TestFuncResult test_str8_join(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_from_bytes(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 str = wapp_str8_buf(1024);
|
||||
Str8 expected = wapp_str8_lit_ro("WAPP");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "wapp.h"
|
||||
|
||||
TestFuncResult test_str8_list_get(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -42,7 +42,7 @@ TestFuncResult test_str8_list_get(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_push_front(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -66,7 +66,7 @@ TestFuncResult test_str8_list_push_front(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_push_back(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -90,7 +90,7 @@ TestFuncResult test_str8_list_push_back(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_insert(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -127,7 +127,7 @@ TestFuncResult test_str8_list_insert(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_pop_front(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -167,7 +167,7 @@ TestFuncResult test_str8_list_pop_front(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_pop_back(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -207,7 +207,7 @@ TestFuncResult test_str8_list_pop_back(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_remove(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -247,7 +247,7 @@ TestFuncResult test_str8_list_remove(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_empty(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8List list = {0};
|
||||
wapp_str8_list_push_back(&list, &wapp_str8_node_from_cstr("Hello"));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "wapp.h"
|
||||
|
||||
TestFuncResult test_str8_list_get(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -42,7 +42,7 @@ TestFuncResult test_str8_list_get(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_push_front(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -66,7 +66,7 @@ TestFuncResult test_str8_list_push_front(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_push_back(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -90,7 +90,7 @@ TestFuncResult test_str8_list_push_back(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_insert(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -127,7 +127,7 @@ TestFuncResult test_str8_list_insert(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_pop_front(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -167,7 +167,7 @@ TestFuncResult test_str8_list_pop_front(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_pop_back(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -207,7 +207,7 @@ TestFuncResult test_str8_list_pop_back(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_remove(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("1");
|
||||
Str8 s2 = wapp_str8_lit("2");
|
||||
@@ -247,7 +247,7 @@ TestFuncResult test_str8_list_remove(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_list_empty(void) {
|
||||
b32 result;
|
||||
b8 result;
|
||||
|
||||
Str8List list = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user