File utilities and datatype implementation for a C-based code generator #5

Merged
abdelrahman merged 18 commits from ccodegen into main 2025-09-20 13:48:08 +00:00
Showing only changes of commit 757eadeec9 - Show all commits

View File

@@ -12,6 +12,21 @@
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#ifdef WAPP_PLATFORM_CPP
#define wapp_file_item_to_array(ITEM) (GenericArray{&(ITEM), 1, 1, sizeof(ITEM)})
#define wapp_file_array_to_item(TYPE, ARRAY) (sizeof(TYPE) == (ARRAY).item_size && (ARRAY).count == 1 ? \
*((TYPE *)((ARRAY).items)) : \
TYPE{})
#else
#define wapp_file_item_to_array(ITEM) ((GenericArray){.items = &(ITEM), \
.count = 1, \
.capacity = 1, \
.item_size = sizeof(ITEM)})
#define wapp_file_array_to_item(TYPE, ARRAY) (sizeof(TYPE) == (ARRAY).item_size && (ARRAY).count == 1 ? \
*((TYPE *)((ARRAY).items)) : \
(TYPE){0})
#endif // !WAPP_PLATFORM_CPP
typedef FILE File;
typedef enum {