## Summary Standardize naming conventions across the entire wizapp-stdlib codebase by replacing inconsistent prefixes and snake_case with a unified `wp` prefix + CamelCase scheme. ## Changes ### Naming convention applied | Pattern | Before | After | |---|---|---| | Public functions | `wapp_module_function` | `wpModuleFunction` | | Public types | `GenericXxx`, bare `Xxx` | `WpXxx` | | Constants / enum values | `WAPP_XXX`, `SHELL_XXX` | `WP_XXX`, `WP_SHELL_XXX` | | Internal functions | `_module_function` | `_moduleFunction` | | Storage-class macros | `wapp_extern`, `wapp_intern` | `wp_extern`, `wp_intern` | ### Modules affected All 20 modules were renamed: `arena`, `array`, `dbl_list`, `queue`, `str8`, `mem_allocator`, `mem_utils`, `mem_os`, `file`, `cpath`, `log`, `shell_commander`, `shell_termcolour`, `shell_utils`, `prng/xorshift`, `uuid`, `tester`, `aliases`, `assert`, `misc_utils`, `platform` — plus their test files. ### Backward compatibility Added `src/oldnames.h` with `#define OLD_NAME NEW_NAME` for every renamed symbol, organized by module under Constants → Types → Functions sections. Existing code that includes this file will compile without changes. Reviewed-on: #12 Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com> Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
This commit was merged in pull request #12.
This commit is contained in:
+62
-62
@@ -4,143 +4,143 @@
|
||||
|
||||
#define ARENA_CAPACITY KiB(16)
|
||||
#define ARENA_BUF_SIZE KiB(4)
|
||||
// NOTE (Abdelrahman): Cannot query size of Arena here so it's hardcoded. Similarly, since arena
|
||||
// NOTE (Abdelrahman): Cannot query size of WpArena here so it's hardcoded. Similarly, since arena
|
||||
// allocation are aligned to power of 2 boundaries, the number of i32 values needed is hardcoded.
|
||||
#define TEMP_BUF_SIZE (40 + sizeof(i32) * 8)
|
||||
|
||||
wapp_intern Arena *arena = NULL;
|
||||
wapp_intern i32 count = 20;
|
||||
wapp_intern i32 *array = NULL;
|
||||
wapp_intern Arena *buf_arena = NULL;
|
||||
wapp_intern u8 buf[ARENA_BUF_SIZE] = {};
|
||||
wapp_intern Arena *temp_arena = NULL;
|
||||
wapp_intern u8 temp_buf[TEMP_BUF_SIZE] = {};
|
||||
wp_intern WpArena *arena = NULL;
|
||||
wp_intern i32 count = 20;
|
||||
wp_intern i32 *array = NULL;
|
||||
wp_intern WpArena *buf_arena = NULL;
|
||||
wp_intern u8 buf[ARENA_BUF_SIZE] = {};
|
||||
wp_intern WpArena *temp_arena = NULL;
|
||||
wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {};
|
||||
|
||||
TestFuncResult test_arena_init_buffer(void) {
|
||||
b8 result = wapp_mem_arena_init_buffer(&buf_arena, buf, ARENA_BUF_SIZE);
|
||||
return wapp_tester_result(result);
|
||||
WpTestFuncResult test_arena_init_buffer(void) {
|
||||
b8 result = wpMemArenaInitBuffer(&buf_arena, buf, ARENA_BUF_SIZE);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_init_allocated(void) {
|
||||
b8 result = wapp_mem_arena_init_allocated(&arena, ARENA_CAPACITY);
|
||||
WpTestFuncResult test_arena_init_allocated(void) {
|
||||
b8 result = wpMemArenaInitAllocated(&arena, ARENA_CAPACITY);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
Arena *large_arena = nullptr;
|
||||
WpTestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
WpArena *large_arena = nullptr;
|
||||
u64 capacity = GiB(512);
|
||||
b8 result = wapp_mem_arena_init_allocated(&large_arena, capacity);
|
||||
b8 result = wpMemArenaInitAllocated(&large_arena, capacity);
|
||||
if (result) {
|
||||
wapp_mem_arena_destroy(&large_arena);
|
||||
wpMemArenaDestroy(&large_arena);
|
||||
}
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_alloc_with_buffer(void) {
|
||||
i32 *arr = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
WpTestFuncResult test_arena_alloc_with_buffer(void) {
|
||||
i32 *arr = (i32 *)wpMemArenaAlloc(arena, count * sizeof(i32));
|
||||
b8 result = arr != NULL;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
arr[i] = i * 10;
|
||||
}
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
array = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
WpTestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
array = (i32 *)wpMemArenaAlloc(arena, count * sizeof(i32));
|
||||
b8 result = array != nullptr;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
array[i] = i * 10;
|
||||
}
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
u8 *bytes = (u8 *)wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
|
||||
WpTestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
u8 *bytes = (u8 *)wpMemArenaAlloc(arena, ARENA_CAPACITY * 2);
|
||||
b8 result = bytes == nullptr;
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_realloc_bigger_size(void) {
|
||||
WpTestFuncResult test_arena_realloc_bigger_size(void) {
|
||||
u64 old_count = 10;
|
||||
u64 new_count = 20;
|
||||
i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
|
||||
i32 *bytes = (i32 *)wpMemArenaAlloc(arena, old_count * sizeof(i32));
|
||||
|
||||
for (u64 i = 0; i < old_count; ++i) {
|
||||
bytes[i] = (i32)i;
|
||||
}
|
||||
|
||||
i32 *new_bytes = (i32 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
i32 *new_bytes = (i32 *)wpMemArenaRealloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
if (!new_bytes) {
|
||||
return wapp_tester_result(false);
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
|
||||
for (u64 i = 0; i < new_count; ++i) {
|
||||
if (i < old_count && new_bytes[i] != bytes[i]) {
|
||||
return wapp_tester_result(false);
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
}
|
||||
|
||||
return wapp_tester_result(true);
|
||||
return wpTesterResult(true);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_realloc_smaller_size(void) {
|
||||
WpTestFuncResult test_arena_realloc_smaller_size(void) {
|
||||
u64 old_count = 10;
|
||||
u64 new_count = 5;
|
||||
i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
|
||||
i32 *bytes = (i32 *)wpMemArenaAlloc(arena, old_count * sizeof(i32));
|
||||
|
||||
for (u64 i = 0; i < old_count; ++i) {
|
||||
bytes[i] = (i32)i;
|
||||
}
|
||||
|
||||
i32 *new_bytes = (i32 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
i32 *new_bytes = (i32 *)wpMemArenaRealloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
if (!new_bytes) {
|
||||
return wapp_tester_result(false);
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
|
||||
for (u64 i = 0; i < new_count; ++i) {
|
||||
if (i < new_count && new_bytes[i] != bytes[i]) {
|
||||
return wapp_tester_result(false);
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
}
|
||||
|
||||
return wapp_tester_result(true);
|
||||
return wpTesterResult(true);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_temp_begin(void) {
|
||||
b8 result = wapp_mem_arena_init_buffer(&temp_arena, temp_buf, TEMP_BUF_SIZE);
|
||||
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
WpTestFuncResult test_arena_temp_begin(void) {
|
||||
b8 result = wpMemArenaInitBuffer(&temp_arena, temp_buf, TEMP_BUF_SIZE);
|
||||
i32 *num1 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num1 != NULL;
|
||||
|
||||
wapp_mem_arena_temp_begin(temp_arena);
|
||||
i32 *num2 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
wpMemArenaTempBegin(temp_arena);
|
||||
i32 *num2 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num2 != NULL;
|
||||
i32 *num3 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
i32 *num3 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num3 == NULL;
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_temp_end(void) {
|
||||
wapp_mem_arena_temp_end(temp_arena);
|
||||
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
WpTestFuncResult test_arena_temp_end(void) {
|
||||
wpMemArenaTempEnd(temp_arena);
|
||||
i32 *num1 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
b8 result = num1 != NULL;
|
||||
i32 *num2 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
i32 *num2 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num2 == NULL;
|
||||
|
||||
wapp_mem_arena_destroy(&temp_arena);
|
||||
wpMemArenaDestroy(&temp_arena);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_clear(void) {
|
||||
wapp_mem_arena_clear(arena);
|
||||
WpTestFuncResult test_arena_clear(void) {
|
||||
wpMemArenaClear(arena);
|
||||
b8 result = true;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
@@ -150,19 +150,19 @@ TestFuncResult test_arena_clear(void) {
|
||||
}
|
||||
}
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_destroy_buffer(void) {
|
||||
wapp_mem_arena_destroy(&buf_arena);
|
||||
WpTestFuncResult test_arena_destroy_buffer(void) {
|
||||
wpMemArenaDestroy(&buf_arena);
|
||||
b8 result = buf_arena == NULL;
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_destroy_allocated(void) {
|
||||
wapp_mem_arena_destroy(&arena);
|
||||
WpTestFuncResult test_arena_destroy_allocated(void) {
|
||||
wpMemArenaDestroy(&arena);
|
||||
b8 result = arena == nullptr;
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user