Kajetan Johannes Hammerle 9 сар өмнө
parent
commit
169b332826

+ 2 - 2
include/core/Components.h

@@ -8,8 +8,8 @@ typedef size_t CoreEntity;
 
 typedef struct {
     CoreHashMap entityToIndex;
-    CoreList indexToEntity;
-    CoreList components;
+    List indexToEntity;
+    List components;
 } CoreComponents;
 
 typedef struct {

+ 19 - 41
include/core/List.h

@@ -3,52 +3,30 @@
 
 #include "core/Types.h"
 
-struct CoreListT {
+struct ListT {
     size_t length;
     size_t capacity;
     size_t dataSize;
     void* data;
 };
-typedef struct CoreListT CoreList;
+typedef struct ListT List;
 
-void coreInitList(CoreList* l, size_t dataSize);
-void coreDestroyList(CoreList* l);
-void coreReserveListEntries(CoreList* l, size_t n);
-void coreAddListData(CoreList* l, const void* data);
-#define coreAddListType(l, type, ...) coreAddListData(l, &(type){__VA_ARGS__})
-void coreAddLastListData(CoreList* l);
-void* coreAddEmptyListData(CoreList* l);
-void* coreGetListIndex(const CoreList* l, size_t index);
-#define coreGetTypedListIndex(l, index, type)                                  \
-    (*(type*)coreGetListIndex(l, index))
-void* coreGetListLast(const CoreList* l);
-#define coreGetTypedListLast(l, type) (*(type*)coreGetListLast(l))
-void coreClearList(CoreList* l);
-void coreRemoveListIndexBySwap(CoreList* l, size_t index);
-void coreRemoveListIndex(CoreList* l, size_t index);
-void coreRemoveListLast(CoreList* l);
-void* coreGetListStart(const CoreList* l);
-void* coreGetListEnd(const CoreList* l);
-
-#ifdef IMPORT_CORE
-#define List CoreList
-#define initList coreInitList
-#define destroyList coreDestroyList
-#define reserveListEntries coreReserveListEntries
-#define addListData coreAddListData
-#define addListType coreAddListType
-#define addLastListData coreAddLastListData
-#define addEmptyListData coreAddEmptyListData
-#define getListIndex coreGetListIndex
-#define getTypedListIndex coreGetTypedListIndex
-#define getListLast coreGetListLast
-#define getTypedListLast coreGetTypedListLast
-#define clearList coreClearList
-#define removeListIndexBySwap coreRemoveListIndexBySwap
-#define removeListIndex coreRemoveListIndex
-#define removeListLast coreRemoveListLast
-#define getListStart coreGetListStart
-#define getListEnd coreGetListEnd
-#endif
+void initList(List* l, size_t dataSize);
+void destroyList(List* l);
+void reserveListEntries(List* l, size_t n);
+void addListData(List* l, const void* data);
+#define addListType(l, type, ...) addListData(l, &(type){__VA_ARGS__})
+void addLastListData(List* l);
+void* addEmptyListData(List* l);
+void* getListIndex(const List* l, size_t index);
+#define getTypedListIndex(l, index, type) (*(type*)getListIndex(l, index))
+void* getListLast(const List* l);
+#define getTypedListLast(l, type) (*(type*)getListLast(l))
+void clearList(List* l);
+void removeListIndexBySwap(List* l, size_t index);
+void removeListIndex(List* l, size_t index);
+void removeListLast(List* l);
+void* getListStart(const List* l);
+void* getListEnd(const List* l);
 
 #endif

+ 7 - 3
include/core/ToString.h

@@ -10,8 +10,8 @@ size_t coreToStringSize(const void* p, char* buffer, size_t n);
 size_t coreToStringInt(const void* p, char* buffer, size_t n);
 void coreStringAdd(size_t* w, char** buffer, size_t* n, size_t shift);
 
-struct CoreListT;
-size_t coreToStringList(const struct CoreListT* l, char* buffer, size_t n,
+struct ListT;
+size_t coreToStringList(const struct ListT* l, char* buffer, size_t n,
                         CoreToString c);
 struct CoreQueueT;
 size_t coreToStringQueue(const struct CoreQueueT* r, char* buffer, size_t n,
@@ -49,6 +49,10 @@ CORE_STRUCT_TO_STRING(Plane)
     CORE_PAIR(const struct Core##name##T*, toString##name),                    \
         CORE_PAIR(struct Core##name##T*, toString##name)
 
+#define STRUCT_PAIR(name)                                                      \
+    CORE_PAIR(const struct name##T*, toString##name),                          \
+        CORE_PAIR(struct name##T*, toString##name)
+
 #define toString(t, ...)                                                       \
     _Generic((t),                                                              \
         char*: coreToString,                                                   \
@@ -56,7 +60,7 @@ CORE_STRUCT_TO_STRING(Plane)
         CORE_STRUCT_PAIR(Box),                                                 \
         CORE_STRUCT_PAIR(Matrix),                                              \
         CORE_STRUCT_PAIR(Plane),                                               \
-        CORE_STRUCT_PAIR(List),                                                \
+        STRUCT_PAIR(List),                                                     \
         CORE_STRUCT_PAIR(Queue),                                               \
         CORE_STRUCT_PAIR(HashMap))(t, __VA_ARGS__)
 #endif