## 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:
+109
-109
@@ -7,24 +7,24 @@
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/platform/platform.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define WAPP_DBL_LIST_MAGIC (u64)0x57415f444c5354
|
||||
#define WAPP_DBL_NODE_MAGIC (u64)0x57415f444e44
|
||||
#define WP_DBL_LIST_MAGIC (u64)0x57415f444c5354
|
||||
#define WP_DBL_NODE_MAGIC (u64)0x57415f444e44
|
||||
|
||||
typedef struct GenericNode GenericNode;
|
||||
typedef struct WpDblNode WpDblNode;
|
||||
|
||||
typedef struct {
|
||||
u64 magic;
|
||||
u64 item_size;
|
||||
GenericNode *prev;
|
||||
GenericNode *next;
|
||||
} NodeHeader;
|
||||
WpDblNode *prev;
|
||||
WpDblNode *next;
|
||||
} WpDblNodeHeader;
|
||||
|
||||
struct GenericNode {
|
||||
NodeHeader header;
|
||||
struct WpDblNode {
|
||||
WpDblNodeHeader header;
|
||||
void *item;
|
||||
};
|
||||
|
||||
@@ -32,153 +32,153 @@ typedef struct {
|
||||
u64 magic;
|
||||
u64 node_count;
|
||||
u64 item_size;
|
||||
GenericNode *first;
|
||||
GenericNode *last;
|
||||
} GenericList;
|
||||
WpDblNode *first;
|
||||
WpDblNode *last;
|
||||
} WpDblList;
|
||||
|
||||
// NOTE (Abdelrahman): GenericList typedefs for readability
|
||||
typedef GenericList VoidPtrList;
|
||||
typedef GenericList C8List;
|
||||
typedef GenericList C16List;
|
||||
typedef GenericList C32List;
|
||||
typedef GenericList U8List;
|
||||
typedef GenericList U16List;
|
||||
typedef GenericList U32List;
|
||||
typedef GenericList U64List;
|
||||
typedef GenericList B8List;
|
||||
typedef GenericList I8List;
|
||||
typedef GenericList I16List;
|
||||
typedef GenericList I32List;
|
||||
typedef GenericList I64List;
|
||||
typedef GenericList F32List;
|
||||
typedef GenericList F64List;
|
||||
typedef GenericList F128List;
|
||||
typedef GenericList UptrList;
|
||||
typedef GenericList IptrList;
|
||||
typedef GenericList Str8List;
|
||||
// NOTE (Abdelrahman): WpDblList typedefs for readability
|
||||
typedef WpDblList WpVoidPtrList;
|
||||
typedef WpDblList WpC8List;
|
||||
typedef WpDblList WpC16List;
|
||||
typedef WpDblList WpC32List;
|
||||
typedef WpDblList WpU8List;
|
||||
typedef WpDblList WpU16List;
|
||||
typedef WpDblList WpU32List;
|
||||
typedef WpDblList WpU64List;
|
||||
typedef WpDblList WpB8List;
|
||||
typedef WpDblList WpI8List;
|
||||
typedef WpDblList WpI16List;
|
||||
typedef WpDblList WpI32List;
|
||||
typedef WpDblList WpI64List;
|
||||
typedef WpDblList WpF32List;
|
||||
typedef WpDblList WpF64List;
|
||||
typedef WpDblList WpF128List;
|
||||
typedef WpDblList WpUptrList;
|
||||
typedef WpDblList WpIptrList;
|
||||
typedef WpDblList WpStr8List;
|
||||
|
||||
// NOTE (Abdelrahman): GenericNode typedefs for readability
|
||||
typedef GenericNode VoidPtrNode;
|
||||
typedef GenericNode C8Node;
|
||||
typedef GenericNode C16Node;
|
||||
typedef GenericNode C32Node;
|
||||
typedef GenericNode U8Node;
|
||||
typedef GenericNode U16Node;
|
||||
typedef GenericNode U32Node;
|
||||
typedef GenericNode U64Node;
|
||||
typedef GenericNode B8Node;
|
||||
typedef GenericNode I8Node;
|
||||
typedef GenericNode I16Node;
|
||||
typedef GenericNode I32Node;
|
||||
typedef GenericNode I64Node;
|
||||
typedef GenericNode F32Node;
|
||||
typedef GenericNode F64Node;
|
||||
typedef GenericNode F128Node;
|
||||
typedef GenericNode UptrNode;
|
||||
typedef GenericNode IptrNode;
|
||||
typedef GenericNode Str8Node;
|
||||
// NOTE (Abdelrahman): WpDblNode typedefs for readability
|
||||
typedef WpDblNode WpVoidPtrNode;
|
||||
typedef WpDblNode WpC8Node;
|
||||
typedef WpDblNode WpC16Node;
|
||||
typedef WpDblNode WpC32Node;
|
||||
typedef WpDblNode WpU8Node;
|
||||
typedef WpDblNode WpU16Node;
|
||||
typedef WpDblNode WpU32Node;
|
||||
typedef WpDblNode WpU64Node;
|
||||
typedef WpDblNode WpB8Node;
|
||||
typedef WpDblNode WpI8Node;
|
||||
typedef WpDblNode WpI16Node;
|
||||
typedef WpDblNode WpI32Node;
|
||||
typedef WpDblNode WpI64Node;
|
||||
typedef WpDblNode WpF32Node;
|
||||
typedef WpDblNode WpF64Node;
|
||||
typedef WpDblNode WpF128Node;
|
||||
typedef WpDblNode WpUptrNode;
|
||||
typedef WpDblNode WpIptrNode;
|
||||
typedef WpDblNode WpStr8Node;
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#define wapp_dbl_list(TYPE) \
|
||||
GenericList{WAPP_DBL_LIST_MAGIC, 0, sizeof(TYPE), nullptr, nullptr}
|
||||
#define _dbl_list_node(TYPE, ITEM_PTR) ([&]() { \
|
||||
wapp_persist GenericNode node = { \
|
||||
NodeHeader{WAPP_DBL_NODE_MAGIC, sizeof(TYPE), nullptr, nullptr}, \
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wpDblList(TYPE) \
|
||||
WpDblList{WP_DBL_LIST_MAGIC, 0, sizeof(TYPE), nullptr, nullptr}
|
||||
#define _dblListNode(TYPE, ITEM_PTR) ([&]() { \
|
||||
wp_persist WpDblNode node = { \
|
||||
WpDblNodeHeader{WP_DBL_NODE_MAGIC, sizeof(TYPE), nullptr, nullptr}, \
|
||||
ITEM_PTR, \
|
||||
}; \
|
||||
\
|
||||
return &node; \
|
||||
}())
|
||||
#else
|
||||
#define wapp_dbl_list(TYPE) ( \
|
||||
(GenericList){.magic = WAPP_DBL_LIST_MAGIC, .item_size = sizeof(TYPE)} \
|
||||
#define wpDblList(TYPE) ( \
|
||||
(WpDblList){.magic = WP_DBL_LIST_MAGIC, .item_size = sizeof(TYPE)} \
|
||||
)
|
||||
#define _dbl_list_node(TYPE, ITEM_PTR) ( \
|
||||
&((GenericNode){.header = {.magic = WAPP_DBL_NODE_MAGIC, .item_size = sizeof(TYPE)}, \
|
||||
#define _dblListNode(TYPE, ITEM_PTR) ( \
|
||||
&((WpDblNode){.header = {.magic = WP_DBL_NODE_MAGIC, .item_size = sizeof(TYPE)}, \
|
||||
.item = ITEM_PTR}) \
|
||||
)
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define wapp_dbl_list_alloc(TYPE, ALLOCATOR) \
|
||||
(_dbl_list_alloc(ALLOCATOR, sizeof(TYPE)))
|
||||
#define wapp_dbl_list_get(TYPE, LIST_PTR, ITEM_INDEX) \
|
||||
((TYPE *)(_dbl_list_get(LIST_PTR, ITEM_INDEX, sizeof(TYPE))->item))
|
||||
#define wapp_dbl_list_get_node(TYPE, LIST_PTR, ITEM_INDEX) \
|
||||
(_dbl_list_get(LIST_PTR, ITEM_INDEX, sizeof(TYPE)))
|
||||
#define wapp_dbl_list_get_node_item(TYPE, NODE_PTR) \
|
||||
#define wpDblListAlloc(TYPE, ALLOCATOR) \
|
||||
(_dblListAlloc(ALLOCATOR, sizeof(TYPE)))
|
||||
#define wpDblListGet(TYPE, LIST_PTR, ITEM_INDEX) \
|
||||
((TYPE *)(_dblListGet(LIST_PTR, ITEM_INDEX, sizeof(TYPE))->item))
|
||||
#define wpDblListGetNode(TYPE, LIST_PTR, ITEM_INDEX) \
|
||||
(_dblListGet(LIST_PTR, ITEM_INDEX, sizeof(TYPE)))
|
||||
#define wpDblListGetNodeItem(TYPE, NODE_PTR) \
|
||||
((TYPE *)( \
|
||||
(NODE_PTR == NULL) ? \
|
||||
NULL : \
|
||||
(NODE_PTR)->item \
|
||||
))
|
||||
#define wapp_dbl_list_push_front(TYPE, LIST_PTR, ITEM_PTR) \
|
||||
(_dbl_list_push_front(LIST_PTR, _dbl_list_node(TYPE, ITEM_PTR), sizeof(TYPE)))
|
||||
#define wapp_dbl_list_push_back(TYPE, LIST_PTR, ITEM_PTR) \
|
||||
(_dbl_list_push_back(LIST_PTR, _dbl_list_node(TYPE, ITEM_PTR), sizeof(TYPE)))
|
||||
#define wapp_dbl_list_insert(TYPE, LIST_PTR, ITEM_PTR, ITEM_INDEX) \
|
||||
(_dbl_list_insert(LIST_PTR, _dbl_list_node(TYPE, ITEM_PTR), \
|
||||
#define wpDblListPushFront(TYPE, LIST_PTR, ITEM_PTR) \
|
||||
(_dblListPushFront(LIST_PTR, _dblListNode(TYPE, ITEM_PTR), sizeof(TYPE)))
|
||||
#define wpDblListPushBack(TYPE, LIST_PTR, ITEM_PTR) \
|
||||
(_dblListPushBack(LIST_PTR, _dblListNode(TYPE, ITEM_PTR), sizeof(TYPE)))
|
||||
#define wpDblListInsert(TYPE, LIST_PTR, ITEM_PTR, ITEM_INDEX) \
|
||||
(_dblListInsert(LIST_PTR, _dblListNode(TYPE, ITEM_PTR), \
|
||||
ITEM_INDEX, sizeof(TYPE)))
|
||||
#define wapp_dbl_list_push_front_alloc(TYPE, ALLOCATOR, LIST_PTR, ITEM_PTR) \
|
||||
(_dbl_list_push_front(LIST_PTR, _dbl_list_node_alloc(ALLOCATOR, ITEM_PTR, sizeof(TYPE)), \
|
||||
#define wpDblListPushFrontAlloc(TYPE, ALLOCATOR, LIST_PTR, ITEM_PTR) \
|
||||
(_dblListPushFront(LIST_PTR, _dblListNodeAlloc(ALLOCATOR, ITEM_PTR, sizeof(TYPE)), \
|
||||
sizeof(TYPE)))
|
||||
#define wapp_dbl_list_push_back_alloc(TYPE, ALLOCATOR, LIST_PTR, ITEM_PTR) \
|
||||
(_dbl_list_push_back(LIST_PTR, _dbl_list_node_alloc(ALLOCATOR, ITEM_PTR, sizeof(TYPE)), \
|
||||
#define wpDblListPushBackAlloc(TYPE, ALLOCATOR, LIST_PTR, ITEM_PTR) \
|
||||
(_dblListPushBack(LIST_PTR, _dblListNodeAlloc(ALLOCATOR, ITEM_PTR, sizeof(TYPE)), \
|
||||
sizeof(TYPE)))
|
||||
#define wapp_dbl_list_insert_alloc(TYPE, ALLOCATOR, LIST_PTR, ITEM_PTR, ITEM_INDEX) \
|
||||
(_dbl_list_insert(LIST_PTR, _dbl_list_node_alloc(ALLOCATOR, ITEM_PTR, sizeof(TYPE)), \
|
||||
#define wpDblListInsertAlloc(TYPE, ALLOCATOR, LIST_PTR, ITEM_PTR, ITEM_INDEX) \
|
||||
(_dblListInsert(LIST_PTR, _dblListNodeAlloc(ALLOCATOR, ITEM_PTR, sizeof(TYPE)), \
|
||||
ITEM_INDEX, sizeof(TYPE)))
|
||||
#define wapp_dbl_list_pop_front(TYPE, LIST_PTR) \
|
||||
#define wpDblListPopFront(TYPE, LIST_PTR) \
|
||||
((TYPE *)( \
|
||||
(LIST_PTR == NULL || (LIST_PTR)->node_count == 0) ? \
|
||||
NULL : \
|
||||
_dbl_list_pop_front(LIST_PTR, sizeof(TYPE))->item \
|
||||
_dblListPopFront(LIST_PTR, sizeof(TYPE))->item \
|
||||
))
|
||||
#define wapp_dbl_list_pop_back(TYPE, LIST_PTR) \
|
||||
#define wpDblListPopBack(TYPE, LIST_PTR) \
|
||||
((TYPE *)( \
|
||||
(LIST_PTR == NULL || (LIST_PTR)->node_count == 0) ? \
|
||||
NULL : \
|
||||
_dbl_list_pop_back(LIST_PTR, sizeof(TYPE))->item \
|
||||
_dblListPopBack(LIST_PTR, sizeof(TYPE))->item \
|
||||
))
|
||||
#define wapp_dbl_list_remove(TYPE, LIST_PTR, ITEM_INDEX) \
|
||||
#define wpDblListRemove(TYPE, LIST_PTR, ITEM_INDEX) \
|
||||
((TYPE *)( \
|
||||
(LIST_PTR == NULL || (LIST_PTR)->node_count == 0 || ITEM_INDEX >= (LIST_PTR)->node_count) ? \
|
||||
NULL : \
|
||||
_dbl_list_remove(LIST_PTR, ITEM_INDEX, sizeof(TYPE))->item \
|
||||
_dblListRemove(LIST_PTR, ITEM_INDEX, sizeof(TYPE))->item \
|
||||
))
|
||||
#define wapp_dbl_list_pop_front_node(TYPE, LIST_PTR) \
|
||||
#define wpDblListPopFrontNode(TYPE, LIST_PTR) \
|
||||
( \
|
||||
(LIST_PTR == NULL || (LIST_PTR)->node_count == 0) ? \
|
||||
NULL : \
|
||||
_dbl_list_pop_front(LIST_PTR, sizeof(TYPE)) \
|
||||
_dblListPopFront(LIST_PTR, sizeof(TYPE)) \
|
||||
)
|
||||
#define wapp_dbl_list_pop_back_node(TYPE, LIST_PTR) \
|
||||
#define wpDblListPopBackNode(TYPE, LIST_PTR) \
|
||||
( \
|
||||
(LIST_PTR == NULL || (LIST_PTR)->node_count == 0) ? \
|
||||
NULL : \
|
||||
_dbl_list_pop_back(LIST_PTR, sizeof(TYPE)) \
|
||||
_dblListPopBack(LIST_PTR, sizeof(TYPE)) \
|
||||
)
|
||||
#define wapp_dbl_list_remove_node(TYPE, LIST_PTR, ITEM_INDEX) \
|
||||
#define wpDblListRemoveNode(TYPE, LIST_PTR, ITEM_INDEX) \
|
||||
( \
|
||||
(LIST_PTR == NULL || (LIST_PTR)->node_count == 0 || ITEM_INDEX >= (LIST_PTR)->node_count) ? \
|
||||
NULL : \
|
||||
_dbl_list_remove(LIST_PTR, ITEM_INDEX, sizeof(TYPE)) \
|
||||
_dblListRemove(LIST_PTR, ITEM_INDEX, sizeof(TYPE)) \
|
||||
)
|
||||
#define wapp_dbl_list_empty(TYPE, LIST_PTR) \
|
||||
(_dbl_list_empty(LIST_PTR, sizeof(TYPE)))
|
||||
#define wpDblListEmpty(TYPE, LIST_PTR) \
|
||||
(_dblListEmpty(LIST_PTR, sizeof(TYPE)))
|
||||
|
||||
GenericList *_dbl_list_alloc(const Allocator *allocator, u64 item_size);
|
||||
GenericNode *_dbl_list_node_alloc(const Allocator *allocator, void *item, u64 item_size);
|
||||
GenericNode *_dbl_list_get(const GenericList *list, u64 index, u64 item_size);
|
||||
void _dbl_list_push_front(GenericList *list, GenericNode *node, u64 item_size);
|
||||
void _dbl_list_push_back(GenericList *list, GenericNode *node, u64 item_size);
|
||||
void _dbl_list_insert(GenericList *list, GenericNode *node, u64 index, u64 item_size);
|
||||
GenericNode *_dbl_list_pop_front(GenericList *list, u64 item_size);
|
||||
GenericNode *_dbl_list_pop_back(GenericList *list, u64 item_size);
|
||||
GenericNode *_dbl_list_remove(GenericList *list, u64 index, u64 item_size);
|
||||
void _dbl_list_empty(GenericList *list, u64 item_size);
|
||||
WpDblList *_dblListAlloc(const WpAllocator *allocator, u64 item_size);
|
||||
WpDblNode *_dblListNodeAlloc(const WpAllocator *allocator, void *item, u64 item_size);
|
||||
WpDblNode *_dblListGet(const WpDblList *list, u64 index, u64 item_size);
|
||||
void _dblListPushFront(WpDblList *list, WpDblNode *node, u64 item_size);
|
||||
void _dblListPushBack(WpDblList *list, WpDblNode *node, u64 item_size);
|
||||
void _dblListInsert(WpDblList *list, WpDblNode *node, u64 index, u64 item_size);
|
||||
WpDblNode *_dblListPopFront(WpDblList *list, u64 item_size);
|
||||
WpDblNode *_dblListPopBack(WpDblList *list, u64 item_size);
|
||||
WpDblNode *_dblListRemove(WpDblList *list, u64 index, u64 item_size);
|
||||
void _dblListEmpty(WpDblList *list, u64 item_size);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !DBL_LIST_H
|
||||
|
||||
Reference in New Issue
Block a user