Reformat
This commit is contained in:
@@ -50,41 +50,41 @@ BEGIN_C_LINKAGE
|
|||||||
\
|
\
|
||||||
return (TYPE *)(header + 1); \
|
return (TYPE *)(header + 1); \
|
||||||
}())
|
}())
|
||||||
#define wapp_array_pop(TYPE, ARRAY_PTR) \
|
#define wapp_array_pop(TYPE, ARRAY_PTR) \
|
||||||
(ARRAY_PTR != NULL && _array_count((u8 *)ARRAY_PTR, sizeof(TYPE)) > 0 ? \
|
(ARRAY_PTR != NULL && _array_count((u8 *)ARRAY_PTR, sizeof(TYPE)) > 0 ? \
|
||||||
*((TYPE *)_array_pop((u8 *)ARRAY_PTR, sizeof(TYPE))) : \
|
*((TYPE *)_array_pop((u8 *)ARRAY_PTR, sizeof(TYPE))) : \
|
||||||
TYPE{} \
|
TYPE{} \
|
||||||
)
|
)
|
||||||
#else
|
#else
|
||||||
#define _stack_array(TYPE, SIZE) struct { ArrayHeader header; TYPE items[SIZE]; }
|
#define _stack_array(TYPE, SIZE) struct { ArrayHeader header; TYPE items[SIZE]; }
|
||||||
#define wapp_array(TYPE, ...) \
|
#define wapp_array(TYPE, ...) \
|
||||||
(TYPE *)( \
|
(TYPE *)( \
|
||||||
(_stack_array(TYPE, _calc_array_capacity(TYPE, __VA_ARGS__))){ \
|
(_stack_array(TYPE, _calc_array_capacity(TYPE, __VA_ARGS__))){ \
|
||||||
.header = { \
|
.header = { \
|
||||||
.magic = WAPP_ARRAY_MAGIC, \
|
.magic = WAPP_ARRAY_MAGIC, \
|
||||||
.count = _calc_array_count(TYPE, __VA_ARGS__), \
|
.count = _calc_array_count(TYPE, __VA_ARGS__), \
|
||||||
.capacity = _calc_array_capacity(TYPE, __VA_ARGS__), \
|
.capacity = _calc_array_capacity(TYPE, __VA_ARGS__), \
|
||||||
.item_size = sizeof(TYPE), \
|
.item_size = sizeof(TYPE), \
|
||||||
}, \
|
}, \
|
||||||
.items = {__VA_ARGS__}, \
|
.items = {__VA_ARGS__}, \
|
||||||
}.items \
|
}.items \
|
||||||
)
|
)
|
||||||
#define wapp_array_with_capacity(TYPE, CAPACITY) \
|
#define wapp_array_with_capacity(TYPE, CAPACITY) \
|
||||||
(TYPE *)( \
|
(TYPE *)( \
|
||||||
(_stack_array(TYPE, CAPACITY)){ \
|
(_stack_array(TYPE, CAPACITY)){ \
|
||||||
.header = { \
|
.header = { \
|
||||||
.magic = WAPP_ARRAY_MAGIC, \
|
.magic = WAPP_ARRAY_MAGIC, \
|
||||||
.count = 0, \
|
.count = 0, \
|
||||||
.capacity = CAPACITY, \
|
.capacity = CAPACITY, \
|
||||||
.item_size = sizeof(TYPE), \
|
.item_size = sizeof(TYPE), \
|
||||||
}, \
|
}, \
|
||||||
.items = {0}, \
|
.items = {0}, \
|
||||||
}.items \
|
}.items \
|
||||||
)
|
)
|
||||||
#define wapp_array_pop(TYPE, ARRAY_PTR) \
|
#define wapp_array_pop(TYPE, ARRAY_PTR) \
|
||||||
(ARRAY_PTR != NULL && _array_count((u8 *)ARRAY_PTR, sizeof(TYPE)) > 0 ? \
|
(ARRAY_PTR != NULL && _array_count((u8 *)ARRAY_PTR, sizeof(TYPE)) > 0 ? \
|
||||||
*((TYPE *)_array_pop((u8 *)ARRAY_PTR, sizeof(TYPE))) : \
|
*((TYPE *)_array_pop((u8 *)ARRAY_PTR, sizeof(TYPE))) : \
|
||||||
(TYPE){0} \
|
(TYPE){0} \
|
||||||
)
|
)
|
||||||
#endif // !WAPP_PLATFORM_CPP
|
#endif // !WAPP_PLATFORM_CPP
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user