From 25eefd81734e9756f0453fd61d28f360d85119ed Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Sun, 5 Jun 2022 19:05:19 +0800 Subject: [PATCH] Update macros for list find function Allow current item pointer to have custom type. --- src/packages/game/data/IZ_list.h | 2 +- src/packages/game/data/data.test.c | 6 +++--- src/packages/game/memory/IZ_pool.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/packages/game/data/IZ_list.h b/src/packages/game/data/IZ_list.h index d1b0e7d..2b66778 100644 --- a/src/packages/game/data/IZ_list.h +++ b/src/packages/game/data/IZ_list.h @@ -22,7 +22,7 @@ void IZ_ListTeardown(IZ_List*); IZ_ListNode* IZ_ListAppendNode(IZ_List*, void*); -#define IZ_LIST_FILTER_FUNCTION(X) static IZ_PoolItem* X = NULL; +#define IZ_ListFilterFunctionArgs(X) static X = NULL; void _IZ_ListDeleteFirstNode(IZ_List*, IZ_ListFindFilter); diff --git a/src/packages/game/data/data.test.c b/src/packages/game/data/data.test.c index ecfd912..b17b5a7 100644 --- a/src/packages/game/data/data.test.c +++ b/src/packages/game/data/data.test.c @@ -3,15 +3,15 @@ #include "../../../__mocks__/SDL_stdinc.mock.h" #include "IZ_list.h" -bool NodeExists(IZ_ListNode* node, u64 _index) { +IZ_ListFilterFunctionArgs(IZ_ListNode* __current_item_NodeExists) bool NodeExists(IZ_ListNode* node, u64 _index) { return *((u64*) node->value) == 42069; } -bool NodeExists2(IZ_ListNode* node, u64 _index) { +IZ_ListFilterFunctionArgs(IZ_ListNode* __current_item_NodeExists2) bool NodeExists2(IZ_ListNode* node, u64 _index) { return *((u64*) node->value) == 69420; } -bool NodeDoesNotExist(IZ_ListNode* node, u64 _index) { +IZ_ListFilterFunctionArgs(IZ_ListNode* __current_item_NodeDoesNotExist) bool NodeDoesNotExist(IZ_ListNode* node, u64 _index) { return *((u64*) node->value) == 55555; } diff --git a/src/packages/game/memory/IZ_pool.c b/src/packages/game/memory/IZ_pool.c index 1083427..3df2360 100644 --- a/src/packages/game/memory/IZ_pool.c +++ b/src/packages/game/memory/IZ_pool.c @@ -37,7 +37,7 @@ IZ_PoolItem* IZ_PoolAllocate(IZ_Pool* pool, IZ_PoolAllocationArgs args) { return new_item->value; } -IZ_LIST_FILTER_FUNCTION(__current_item) bool IZ_PoolGetSameItem(IZ_ListNode* node, u64 _index) { +IZ_ListFilterFunctionArgs(IZ_PoolItem* __current_item) bool IZ_PoolGetSameItem(IZ_ListNode* node, u64 _index) { return node->value == __current_item; }