Browse Source

Update macros for list find function

Allow current item pointer to have custom type.
feature/data-structs
TheoryOfNekomata 2 years ago
parent
commit
25eefd8173
3 changed files with 5 additions and 5 deletions
  1. +1
    -1
      src/packages/game/data/IZ_list.h
  2. +3
    -3
      src/packages/game/data/data.test.c
  3. +1
    -1
      src/packages/game/memory/IZ_pool.c

+ 1
- 1
src/packages/game/data/IZ_list.h View File

@@ -22,7 +22,7 @@ void IZ_ListTeardown(IZ_List*);


IZ_ListNode* IZ_ListAppendNode(IZ_List*, void*); 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); void _IZ_ListDeleteFirstNode(IZ_List*, IZ_ListFindFilter);




+ 3
- 3
src/packages/game/data/data.test.c View File

@@ -3,15 +3,15 @@
#include "../../../__mocks__/SDL_stdinc.mock.h" #include "../../../__mocks__/SDL_stdinc.mock.h"
#include "IZ_list.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; 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; 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; return *((u64*) node->value) == 55555;
} }




+ 1
- 1
src/packages/game/memory/IZ_pool.c View File

@@ -37,7 +37,7 @@ IZ_PoolItem* IZ_PoolAllocate(IZ_Pool* pool, IZ_PoolAllocationArgs args) {
return new_item->value; 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; return node->value == __current_item;
} }




Loading…
Cancel
Save