## 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:
@@ -7,46 +7,46 @@
|
||||
#include "../../common/platform/platform.h"
|
||||
#include <stddef.h>
|
||||
|
||||
wapp_intern GenericList _node_to_list(GenericNode *node, u64 item_size);
|
||||
wapp_intern inline void _dbl_list_validate(const GenericList *list, u64 item_size);
|
||||
wapp_intern inline void _dbl_list_node_validate(const GenericList *list, const GenericNode *node, u64 item_size);
|
||||
wp_intern WpDblList _node_to_list(WpDblNode *node, u64 item_size);
|
||||
wp_intern inline void _dblListValidate(const WpDblList *list, u64 item_size);
|
||||
wp_intern inline void _dblListNodeValidate(const WpDblList *list, const WpDblNode *node, u64 item_size);
|
||||
|
||||
GenericList *_dbl_list_alloc(const Allocator *allocator, u64 item_size) {
|
||||
wapp_debug_assert(allocator != NULL, "`allocator` should not be NULL");
|
||||
WpDblList *_dblListAlloc(const WpAllocator *allocator, u64 item_size) {
|
||||
wpDebugAssert(allocator != NULL, "`allocator` should not be NULL");
|
||||
|
||||
GenericList *list = wapp_mem_allocator_alloc(allocator, sizeof(GenericList));
|
||||
WpDblList *list = wpMemAllocatorAlloc(allocator, sizeof(WpDblList));
|
||||
if (!list) { goto DBL_LIST_ALLOC_RETURN; }
|
||||
|
||||
memset((void *)list, 0, sizeof(GenericList));
|
||||
list->magic = WAPP_DBL_LIST_MAGIC;
|
||||
memset((void *)list, 0, sizeof(WpDblList));
|
||||
list->magic = WP_DBL_LIST_MAGIC;
|
||||
list->item_size = item_size;
|
||||
|
||||
DBL_LIST_ALLOC_RETURN:
|
||||
return list;
|
||||
}
|
||||
|
||||
GenericNode *_dbl_list_node_alloc(const Allocator *allocator, void *item, u64 item_size) {
|
||||
wapp_debug_assert(allocator != NULL, "`allocator` should not be NULL");
|
||||
WpDblNode *_dblListNodeAlloc(const WpAllocator *allocator, void *item, u64 item_size) {
|
||||
wpDebugAssert(allocator != NULL, "`allocator` should not be NULL");
|
||||
|
||||
GenericNode *node = wapp_mem_allocator_alloc(allocator, sizeof(GenericNode));
|
||||
WpDblNode *node = wpMemAllocatorAlloc(allocator, sizeof(WpDblNode));
|
||||
if (!node) { goto DBL_LIST_NODE_ALLOC_RETURN; }
|
||||
|
||||
memset((void *)node, 0, sizeof(GenericNode));
|
||||
memset((void *)node, 0, sizeof(WpDblNode));
|
||||
node->item = item;
|
||||
node->header.magic = WAPP_DBL_NODE_MAGIC;
|
||||
node->header.magic = WP_DBL_NODE_MAGIC;
|
||||
node->header.item_size = item_size;
|
||||
|
||||
DBL_LIST_NODE_ALLOC_RETURN:
|
||||
return node;
|
||||
}
|
||||
|
||||
GenericNode *_dbl_list_get(const GenericList *list, u64 index, u64 item_size) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
_dbl_list_validate(list, item_size);
|
||||
wapp_runtime_assert(index < list->node_count, "`index` is out of bounds");
|
||||
WpDblNode *_dblListGet(const WpDblList *list, u64 index, u64 item_size) {
|
||||
wpDebugAssert(list != NULL, "`list` should not be NULL");
|
||||
_dblListValidate(list, item_size);
|
||||
wpRuntimeAssert(index < list->node_count, "`index` is out of bounds");
|
||||
|
||||
GenericNode *output = NULL;
|
||||
GenericNode *current = list->first;
|
||||
WpDblNode *output = NULL;
|
||||
WpDblNode *current = list->first;
|
||||
for (u64 i = 1; i <= index; ++i) {
|
||||
current = current->header.next;
|
||||
}
|
||||
@@ -56,12 +56,12 @@ GenericNode *_dbl_list_get(const GenericList *list, u64 index, u64 item_size) {
|
||||
return output;
|
||||
}
|
||||
|
||||
void _dbl_list_push_front(GenericList *list, GenericNode *node, u64 item_size) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
_dbl_list_validate(list, item_size);
|
||||
_dbl_list_node_validate(list, node, item_size);
|
||||
void _dblListPushFront(WpDblList *list, WpDblNode *node, u64 item_size) {
|
||||
wpDebugAssert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
_dblListValidate(list, item_size);
|
||||
_dblListNodeValidate(list, node, item_size);
|
||||
|
||||
GenericList node_list = _node_to_list(node, item_size);
|
||||
WpDblList node_list = _node_to_list(node, item_size);
|
||||
|
||||
if (list->node_count == 0) {
|
||||
*list = node_list;
|
||||
@@ -70,7 +70,7 @@ void _dbl_list_push_front(GenericList *list, GenericNode *node, u64 item_size) {
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
GenericNode *first = list->first;
|
||||
WpDblNode *first = list->first;
|
||||
if (first) {
|
||||
first->header.prev = node_list.last;
|
||||
}
|
||||
@@ -79,12 +79,12 @@ void _dbl_list_push_front(GenericList *list, GenericNode *node, u64 item_size) {
|
||||
node_list.last->header.next = first;
|
||||
}
|
||||
|
||||
void _dbl_list_push_back(GenericList *list, GenericNode *node, u64 item_size) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
_dbl_list_validate(list, item_size);
|
||||
_dbl_list_node_validate(list, node, item_size);
|
||||
void _dblListPushBack(WpDblList *list, WpDblNode *node, u64 item_size) {
|
||||
wpDebugAssert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
_dblListValidate(list, item_size);
|
||||
_dblListNodeValidate(list, node, item_size);
|
||||
|
||||
GenericList node_list = _node_to_list(node, item_size);
|
||||
WpDblList node_list = _node_to_list(node, item_size);
|
||||
|
||||
if (list->node_count == 0) {
|
||||
*list = node_list;
|
||||
@@ -93,7 +93,7 @@ void _dbl_list_push_back(GenericList *list, GenericNode *node, u64 item_size) {
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
GenericNode *last = list->last;
|
||||
WpDblNode *last = list->last;
|
||||
if (last) {
|
||||
last->header.next = node_list.first;
|
||||
}
|
||||
@@ -102,29 +102,29 @@ void _dbl_list_push_back(GenericList *list, GenericNode *node, u64 item_size) {
|
||||
node_list.first->header.prev = last;
|
||||
}
|
||||
|
||||
void _dbl_list_insert(GenericList *list, GenericNode *node, u64 index, u64 item_size) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
_dbl_list_validate(list, item_size);
|
||||
_dbl_list_node_validate(list, node, item_size);
|
||||
void _dblListInsert(WpDblList *list, WpDblNode *node, u64 index, u64 item_size) {
|
||||
wpDebugAssert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
_dblListValidate(list, item_size);
|
||||
_dblListNodeValidate(list, node, item_size);
|
||||
|
||||
if (index == 0) {
|
||||
_dbl_list_push_front(list, node, item_size);
|
||||
_dblListPushFront(list, node, item_size);
|
||||
return;
|
||||
} else if (index == list->node_count) {
|
||||
_dbl_list_push_back(list, node, item_size);
|
||||
_dblListPushBack(list, node, item_size);
|
||||
return;
|
||||
}
|
||||
|
||||
GenericNode *dst_node = _dbl_list_get(list, index, item_size);
|
||||
WpDblNode *dst_node = _dblListGet(list, index, item_size);
|
||||
if (!dst_node) {
|
||||
return;
|
||||
}
|
||||
|
||||
GenericList node_list = _node_to_list(node, item_size);
|
||||
WpDblList node_list = _node_to_list(node, item_size);
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
GenericNode *prev = dst_node->header.prev;
|
||||
WpDblNode *prev = dst_node->header.prev;
|
||||
|
||||
dst_node->header.prev = node_list.last;
|
||||
prev->header.next = node_list.first;
|
||||
@@ -133,11 +133,11 @@ void _dbl_list_insert(GenericList *list, GenericNode *node, u64 index, u64 item_
|
||||
node_list.last->header.next = dst_node;
|
||||
}
|
||||
|
||||
GenericNode *_dbl_list_pop_front(GenericList *list, u64 item_size) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
_dbl_list_validate(list, item_size);
|
||||
WpDblNode *_dblListPopFront(WpDblList *list, u64 item_size) {
|
||||
wpDebugAssert(list != NULL, "`list` should not be NULL");
|
||||
_dblListValidate(list, item_size);
|
||||
|
||||
GenericNode *output = NULL;
|
||||
WpDblNode *output = NULL;
|
||||
|
||||
if (list->node_count == 0) {
|
||||
goto RETURN_LIST_POP_FRONT;
|
||||
@@ -146,7 +146,7 @@ GenericNode *_dbl_list_pop_front(GenericList *list, u64 item_size) {
|
||||
output = list->first;
|
||||
|
||||
if (list->node_count == 1) {
|
||||
*list = (GenericList){.magic = WAPP_DBL_LIST_MAGIC, .item_size = item_size};
|
||||
*list = (WpDblList){.magic = WP_DBL_LIST_MAGIC, .item_size = item_size};
|
||||
goto RETURN_LIST_POP_FRONT;
|
||||
}
|
||||
|
||||
@@ -159,11 +159,11 @@ RETURN_LIST_POP_FRONT:
|
||||
return output;
|
||||
}
|
||||
|
||||
GenericNode *_dbl_list_pop_back(GenericList *list, u64 item_size) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
_dbl_list_validate(list, item_size);
|
||||
WpDblNode *_dblListPopBack(WpDblList *list, u64 item_size) {
|
||||
wpDebugAssert(list != NULL, "`list` should not be NULL");
|
||||
_dblListValidate(list, item_size);
|
||||
|
||||
GenericNode *output = NULL;
|
||||
WpDblNode *output = NULL;
|
||||
|
||||
if (list->node_count == 0) {
|
||||
goto RETURN_LIST_POP_BACK;
|
||||
@@ -172,7 +172,7 @@ GenericNode *_dbl_list_pop_back(GenericList *list, u64 item_size) {
|
||||
output = list->last;
|
||||
|
||||
if (list->node_count == 1) {
|
||||
*list = (GenericList){.magic = WAPP_DBL_LIST_MAGIC, .item_size = item_size};
|
||||
*list = (WpDblList){.magic = WP_DBL_LIST_MAGIC, .item_size = item_size};
|
||||
goto RETURN_LIST_POP_BACK;
|
||||
}
|
||||
|
||||
@@ -185,21 +185,21 @@ RETURN_LIST_POP_BACK:
|
||||
return output;
|
||||
}
|
||||
|
||||
GenericNode *_dbl_list_remove(GenericList *list, u64 index, u64 item_size) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
_dbl_list_validate(list, item_size);
|
||||
WpDblNode *_dblListRemove(WpDblList *list, u64 index, u64 item_size) {
|
||||
wpDebugAssert(list != NULL, "`list` should not be NULL");
|
||||
_dblListValidate(list, item_size);
|
||||
|
||||
GenericNode *output = NULL;
|
||||
WpDblNode *output = NULL;
|
||||
|
||||
if (index == 0) {
|
||||
output = _dbl_list_pop_front(list, item_size);
|
||||
output = _dblListPopFront(list, item_size);
|
||||
goto RETURN_LIST_REMOVE;
|
||||
} else if (index == list->node_count) {
|
||||
output = _dbl_list_pop_back(list, item_size);
|
||||
output = _dblListPopBack(list, item_size);
|
||||
goto RETURN_LIST_REMOVE;
|
||||
}
|
||||
|
||||
output = _dbl_list_get(list, index, item_size);
|
||||
output = _dblListGet(list, index, item_size);
|
||||
if (!output) {
|
||||
goto RETURN_LIST_REMOVE;
|
||||
}
|
||||
@@ -215,19 +215,19 @@ RETURN_LIST_REMOVE:
|
||||
return output;
|
||||
}
|
||||
|
||||
void _dbl_list_empty(GenericList *list, u64 item_size) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
_dbl_list_validate(list, item_size);
|
||||
void _dblListEmpty(WpDblList *list, u64 item_size) {
|
||||
wpDebugAssert(list != NULL, "`list` should not be NULL");
|
||||
_dblListValidate(list, item_size);
|
||||
|
||||
u64 count = list->node_count;
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
_dbl_list_pop_back(list, item_size);
|
||||
_dblListPopBack(list, item_size);
|
||||
}
|
||||
}
|
||||
|
||||
wapp_intern GenericList _node_to_list(GenericNode *node, u64 item_size) {
|
||||
GenericList output = {
|
||||
.magic = WAPP_DBL_LIST_MAGIC,
|
||||
wp_intern WpDblList _node_to_list(WpDblNode *node, u64 item_size) {
|
||||
WpDblList output = {
|
||||
.magic = WP_DBL_LIST_MAGIC,
|
||||
.first = node,
|
||||
.last = node,
|
||||
.node_count = 1,
|
||||
@@ -247,13 +247,13 @@ wapp_intern GenericList _node_to_list(GenericNode *node, u64 item_size) {
|
||||
return output;
|
||||
}
|
||||
|
||||
wapp_intern inline void _dbl_list_validate(const GenericList *list, u64 item_size) {
|
||||
wapp_runtime_assert(list->magic == WAPP_DBL_LIST_MAGIC, "`list` isn't a valid wapp list type");
|
||||
wapp_runtime_assert(list->item_size == item_size, "Invalid item provided");
|
||||
wp_intern inline void _dblListValidate(const WpDblList *list, u64 item_size) {
|
||||
wpRuntimeAssert(list->magic == WP_DBL_LIST_MAGIC, "`list` isn't a valid wp list type");
|
||||
wpRuntimeAssert(list->item_size == item_size, "Invalid item provided");
|
||||
}
|
||||
|
||||
wapp_intern inline void _dbl_list_node_validate(const GenericList *list, const GenericNode *node, u64 item_size) {
|
||||
wapp_runtime_assert(node->header.magic == WAPP_DBL_NODE_MAGIC, "`node` isn't a valid wapp node type");
|
||||
wapp_runtime_assert(list->item_size == node->header.item_size, "Mismatched `list` and `node` types");
|
||||
wapp_runtime_assert(node->header.item_size == item_size, "Invalid item provided");
|
||||
wp_intern inline void _dblListNodeValidate(const WpDblList *list, const WpDblNode *node, u64 item_size) {
|
||||
wpRuntimeAssert(node->header.magic == WP_DBL_NODE_MAGIC, "`node` isn't a valid wp node type");
|
||||
wpRuntimeAssert(list->item_size == node->header.item_size, "Mismatched `list` and `node` types");
|
||||
wpRuntimeAssert(node->header.item_size == item_size, "Invalid item provided");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user