Replace bool, true and false with aliases
This commit is contained in:
		| @@ -77,11 +77,6 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}): | |||||||
|                 array_typename="VoidPArray", |                 array_typename="VoidPArray", | ||||||
|             ) |             ) | ||||||
|             continue |             continue | ||||||
|         elif _type == CType.BOOL: |  | ||||||
|             datatypes[_type.value] = ArrayData( |  | ||||||
|                 array_typename="BoolArray", |  | ||||||
|             ) |  | ||||||
|             continue |  | ||||||
|  |  | ||||||
|         type_title = _type.value.title() |         type_title = _type.value.title() | ||||||
|         datatypes[_type.value] = ArrayData( |         datatypes[_type.value] = ArrayData( | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|   // MSVC Spectre mitigation warnings |   // MSVC Spectre mitigation warnings | ||||||
|   u64 to_copy    = src->count < dst->capacity ? src->count : dst->capacity; |   u64 to_copy    = src->count < dst->capacity ? src->count : dst->capacity; | ||||||
|   u64 item_index = 0; |   u64 item_index = 0; | ||||||
|   bool running   = true; |   b32 running    = true; | ||||||
|   while (running) {{ |   while (running) {{ | ||||||
|     item = wapp_{Tlower}_array_get(src, item_index); |     item = wapp_{Tlower}_array_get(src, item_index); | ||||||
|     ++item_index; |     ++item_index; | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|   // MSVC Spectre mitigation warnings |   // MSVC Spectre mitigation warnings | ||||||
|   u64 items_to_add = other->count; |   u64 items_to_add = other->count; | ||||||
|   u64 item_index   = 0; |   u64 item_index   = 0; | ||||||
|   bool running     = true; |   b32 running      = true; | ||||||
|   while (running) {{ |   while (running) {{ | ||||||
|     item = wapp_{Tlower}_array_get(other, item_index); |     item = wapp_{Tlower}_array_get(other, item_index); | ||||||
|     ++item_index; |     ++item_index; | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ from codegen.utils import convert_to_relative | |||||||
|  |  | ||||||
| class CType(Enum): | class CType(Enum): | ||||||
|     VOID = "void" |     VOID = "void" | ||||||
|     BOOL = "bool" |     BOOL = "b32" | ||||||
|     CHAR = "char" |     CHAR = "char" | ||||||
|     C8   = "c8" |     C8   = "c8" | ||||||
|     C16  = "c16" |     C16  = "c16" | ||||||
|   | |||||||
| @@ -28,6 +28,16 @@ | |||||||
| #define u32 uint32_t | #define u32 uint32_t | ||||||
| #define u64 uint64_t | #define u64 uint64_t | ||||||
|  |  | ||||||
|  | #define b32 uint32_t | ||||||
|  |  | ||||||
|  | #ifndef false | ||||||
|  | #define false (b32)0 | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifndef true | ||||||
|  | #define true (b32)1 | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #define i8 int8_t | #define i8 int8_t | ||||||
| #define i16 int16_t | #define i16 int16_t | ||||||
| #define i32 int32_t | #define i32 int32_t | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -5,11 +5,11 @@ | |||||||
| #ifndef ARRAY_H | #ifndef ARRAY_H | ||||||
| #define ARRAY_H | #define ARRAY_H | ||||||
|  |  | ||||||
|  | #include "../../common/aliases/aliases.h" | ||||||
| #include "../mem_allocator/mem_allocator.h" | #include "../mem_allocator/mem_allocator.h" | ||||||
| #include "../../common/misc/misc_utils.h" | #include "../../common/misc/misc_utils.h" | ||||||
| #include "../../common/aliases/aliases.h" | #include "../../common/aliases/aliases.h" | ||||||
| #include "../../common/platform/platform.h" | #include "../../common/platform/platform.h" | ||||||
| #include <stdbool.h> |  | ||||||
|  |  | ||||||
| #define wapp_str8_array(...) ((Str8Array){ \ | #define wapp_str8_array(...) ((Str8Array){ \ | ||||||
|   .items = (Str8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ |   .items = (Str8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ | ||||||
| @@ -35,17 +35,17 @@ | |||||||
|   *_void_ptr_array_pop(ARRAY_PTR) : \ |   *_void_ptr_array_pop(ARRAY_PTR) : \ | ||||||
|   (void *){0} \ |   (void *){0} \ | ||||||
| ) | ) | ||||||
| #define wapp_bool_array(...) ((BoolArray){ \ | #define wapp_b32_array(...) ((B32Array){ \ | ||||||
|   .items = (bool[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(bool, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ |   .items = (b32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ | ||||||
|   .count = wapp_misc_utils_va_args_count(bool, __VA_ARGS__), \ |   .count = wapp_misc_utils_va_args_count(b32, __VA_ARGS__), \ | ||||||
|   .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(bool, __VA_ARGS__) * 2), \ |   .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2), \ | ||||||
|   .item_size = sizeof(bool) \ |   .item_size = sizeof(b32) \ | ||||||
| }) | }) | ||||||
| #define wapp_bool_array_with_capacity(CAPACITY) ((BoolArray){.items = (bool[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(bool)}) | #define wapp_b32_array_with_capacity(CAPACITY) ((B32Array){.items = (b32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(b32)}) | ||||||
| #define wapp_bool_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((BoolArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(bool))) | #define wapp_b32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((B32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(b32))) | ||||||
| #define wapp_bool_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \ | #define wapp_b32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \ | ||||||
|   *_bool_array_pop(ARRAY_PTR) : \ |   *_b32_array_pop(ARRAY_PTR) : \ | ||||||
|   (bool){0} \ |   (b32){0} \ | ||||||
| ) | ) | ||||||
| #define wapp_char_array(...) ((CharArray){ \ | #define wapp_char_array(...) ((CharArray){ \ | ||||||
|   .items = (char[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ |   .items = (char[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ | ||||||
| @@ -270,9 +270,9 @@ struct VoidPArray { | |||||||
|   u64 item_size; |   u64 item_size; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| typedef struct BoolArray BoolArray; | typedef struct B32Array B32Array; | ||||||
| struct BoolArray { | struct B32Array { | ||||||
|   bool *items; |   b32 *items; | ||||||
|   u64 count; |   u64 count; | ||||||
|   u64 capacity; |   u64 capacity; | ||||||
|   u64 item_size; |   u64 item_size; | ||||||
| @@ -434,16 +434,16 @@ VoidPArray *wapp_void_ptr_array_append_alloc(const Allocator *allocator, VoidPAr | |||||||
| VoidPArray *wapp_void_ptr_array_extend_alloc(const Allocator *allocator, VoidPArray *array, const VoidPArray *other); | VoidPArray *wapp_void_ptr_array_extend_alloc(const Allocator *allocator, VoidPArray *array, const VoidPArray *other); | ||||||
| VoidPArray *wapp_void_ptr_array_copy_alloc(const Allocator *allocator, const VoidPArray *src, VoidPArray *dst); | VoidPArray *wapp_void_ptr_array_copy_alloc(const Allocator *allocator, const VoidPArray *src, VoidPArray *dst); | ||||||
| void * *_void_ptr_array_pop(VoidPArray *array); | void * *_void_ptr_array_pop(VoidPArray *array); | ||||||
| bool *wapp_bool_array_get(const BoolArray *array, u64 index); | b32 *wapp_b32_array_get(const B32Array *array, u64 index); | ||||||
| void wapp_bool_array_set(BoolArray *array, u64 index, bool *item); | void wapp_b32_array_set(B32Array *array, u64 index, b32 *item); | ||||||
| void wapp_bool_array_append_capped(BoolArray *array, bool *item); | void wapp_b32_array_append_capped(B32Array *array, b32 *item); | ||||||
| void wapp_bool_array_extend_capped(BoolArray *array, const BoolArray *other); | void wapp_b32_array_extend_capped(B32Array *array, const B32Array *other); | ||||||
| void wapp_bool_array_clear(BoolArray *array); | void wapp_b32_array_clear(B32Array *array); | ||||||
| void wapp_bool_array_copy_capped(const BoolArray *src, BoolArray *dst); | void wapp_b32_array_copy_capped(const B32Array *src, B32Array *dst); | ||||||
| BoolArray *wapp_bool_array_append_alloc(const Allocator *allocator, BoolArray *array, bool *item); | B32Array *wapp_b32_array_append_alloc(const Allocator *allocator, B32Array *array, b32 *item); | ||||||
| BoolArray *wapp_bool_array_extend_alloc(const Allocator *allocator, BoolArray *array, const BoolArray *other); | B32Array *wapp_b32_array_extend_alloc(const Allocator *allocator, B32Array *array, const B32Array *other); | ||||||
| BoolArray *wapp_bool_array_copy_alloc(const Allocator *allocator, const BoolArray *src, BoolArray *dst); | B32Array *wapp_b32_array_copy_alloc(const Allocator *allocator, const B32Array *src, B32Array *dst); | ||||||
| bool *_bool_array_pop(BoolArray *array); | b32 *_b32_array_pop(B32Array *array); | ||||||
| char *wapp_char_array_get(const CharArray *array, u64 index); | char *wapp_char_array_get(const CharArray *array, u64 index); | ||||||
| void wapp_char_array_set(CharArray *array, u64 index, char *item); | void wapp_char_array_set(CharArray *array, u64 index, char *item); | ||||||
| void wapp_char_array_append_capped(CharArray *array, char *item); | void wapp_char_array_append_capped(CharArray *array, char *item); | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -5,13 +5,13 @@ | |||||||
| #ifndef DBL_LIST_H | #ifndef DBL_LIST_H | ||||||
| #define DBL_LIST_H | #define DBL_LIST_H | ||||||
|  |  | ||||||
|  | #include "../../common/aliases/aliases.h" | ||||||
| #include "../../common/aliases/aliases.h" | #include "../../common/aliases/aliases.h" | ||||||
| #include "../../common/platform/platform.h" | #include "../../common/platform/platform.h" | ||||||
| #include <stdbool.h> |  | ||||||
|  |  | ||||||
| #define wapp_str8_list_node(ITEM_PTR) ((Str8Node){.item = ITEM_PTR}) | #define wapp_str8_list_node(ITEM_PTR) ((Str8Node){.item = ITEM_PTR}) | ||||||
| #define wapp_void_ptr_list_node(ITEM_PTR) ((VoidPNode){.item = ITEM_PTR}) | #define wapp_void_ptr_list_node(ITEM_PTR) ((VoidPNode){.item = ITEM_PTR}) | ||||||
| #define wapp_bool_list_node(ITEM_PTR) ((BoolNode){.item = ITEM_PTR}) | #define wapp_b32_list_node(ITEM_PTR) ((B32Node){.item = ITEM_PTR}) | ||||||
| #define wapp_char_list_node(ITEM_PTR) ((CharNode){.item = ITEM_PTR}) | #define wapp_char_list_node(ITEM_PTR) ((CharNode){.item = ITEM_PTR}) | ||||||
| #define wapp_c8_list_node(ITEM_PTR) ((C8Node){.item = ITEM_PTR}) | #define wapp_c8_list_node(ITEM_PTR) ((C8Node){.item = ITEM_PTR}) | ||||||
| #define wapp_c16_list_node(ITEM_PTR) ((C16Node){.item = ITEM_PTR}) | #define wapp_c16_list_node(ITEM_PTR) ((C16Node){.item = ITEM_PTR}) | ||||||
| @@ -60,17 +60,17 @@ struct VoidPList { | |||||||
|   u64 node_count; |   u64 node_count; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| typedef struct BoolNode BoolNode; | typedef struct B32Node B32Node; | ||||||
| struct BoolNode { | struct B32Node { | ||||||
|   bool *item; |   b32 *item; | ||||||
|   BoolNode *prev; |   B32Node *prev; | ||||||
|   BoolNode *next; |   B32Node *next; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| typedef struct BoolList BoolList; | typedef struct B32List B32List; | ||||||
| struct BoolList { | struct B32List { | ||||||
|   BoolNode *first; |   B32Node *first; | ||||||
|   BoolNode *last; |   B32Node *last; | ||||||
|   u64 node_count; |   u64 node_count; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -328,14 +328,14 @@ VoidPNode *wapp_void_ptr_list_pop_front(VoidPList *list); | |||||||
| VoidPNode *wapp_void_ptr_list_pop_back(VoidPList *list); | VoidPNode *wapp_void_ptr_list_pop_back(VoidPList *list); | ||||||
| VoidPNode *wapp_void_ptr_list_remove(VoidPList *list, u64 index); | VoidPNode *wapp_void_ptr_list_remove(VoidPList *list, u64 index); | ||||||
| void wapp_void_ptr_list_empty(VoidPList *list); | void wapp_void_ptr_list_empty(VoidPList *list); | ||||||
| BoolNode *wapp_bool_list_get(const BoolList *list, u64 index); | B32Node *wapp_b32_list_get(const B32List *list, u64 index); | ||||||
| void wapp_bool_list_push_front(BoolList *list, BoolNode *node); | void wapp_b32_list_push_front(B32List *list, B32Node *node); | ||||||
| void wapp_bool_list_push_back(BoolList *list, BoolNode *node); | void wapp_b32_list_push_back(B32List *list, B32Node *node); | ||||||
| void wapp_bool_list_insert(BoolList *list, BoolNode *node, u64 index); | void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index); | ||||||
| BoolNode *wapp_bool_list_pop_front(BoolList *list); | B32Node *wapp_b32_list_pop_front(B32List *list); | ||||||
| BoolNode *wapp_bool_list_pop_back(BoolList *list); | B32Node *wapp_b32_list_pop_back(B32List *list); | ||||||
| BoolNode *wapp_bool_list_remove(BoolList *list, u64 index); | B32Node *wapp_b32_list_remove(B32List *list, u64 index); | ||||||
| void wapp_bool_list_empty(BoolList *list); | void wapp_b32_list_empty(B32List *list); | ||||||
| CharNode *wapp_char_list_get(const CharList *list, u64 index); | CharNode *wapp_char_list_get(const CharList *list, u64 index); | ||||||
| void wapp_char_list_push_front(CharList *list, CharNode *node); | void wapp_char_list_push_front(CharList *list, CharNode *node); | ||||||
| void wapp_char_list_push_back(CharList *list, CharNode *node); | void wapp_char_list_push_back(CharList *list, CharNode *node); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user