Add utilities to convert between item and array when working with files
This commit is contained in:
@@ -12,6 +12,21 @@
|
|||||||
BEGIN_C_LINKAGE
|
BEGIN_C_LINKAGE
|
||||||
#endif // !WAPP_PLATFORM_CPP
|
#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 FILE File;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Reference in New Issue
Block a user