mirror of
https://github.com/nicbarker/clay.git
synced 2026-02-06 12:48:49 +00:00
Multi-type elements (#34)
This commit is contained in:
parent
3dffbea2a3
commit
29133bc783
20 changed files with 2296 additions and 2044 deletions
3
generator/array_allocate.template.c
Normal file
3
generator/array_allocate.template.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
$NAME$ $NAME$_Allocate_Arena(uint32_t capacity, Clay_Arena *arena) {
|
||||
return CLAY__INIT($NAME$){.capacity = capacity, .length = 0, .internalArray = ($TYPE$ *)Clay__Array_Allocate_Arena(capacity, sizeof($TYPE$), CLAY__ALIGNMENT($TYPE$), arena)};
|
||||
}
|
||||
|
|
@ -3,8 +3,4 @@ typedef struct
|
|||
uint32_t capacity;
|
||||
uint32_t length;
|
||||
$TYPE$ *internalArray;
|
||||
} $NAME$;
|
||||
|
||||
$NAME$ $NAME$_Allocate_Arena(uint32_t capacity, Clay_Arena *arena) {
|
||||
return CLAY__INIT($NAME$){.capacity = capacity, .length = 0, .internalArray = ($TYPE$ *)Clay__Array_Allocate_Arena(capacity, sizeof($TYPE$), CLAY__ALIGNMENT($TYPE$), arena)};
|
||||
}
|
||||
} $NAME$;
|
||||
5
generator/array_define_slice.template.c
Normal file
5
generator/array_define_slice.template.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
typedef struct
|
||||
{
|
||||
uint32_t length;
|
||||
$TYPE$ *internalArray;
|
||||
} $NAME$Slice;
|
||||
3
generator/array_get_slice.template.c
Normal file
3
generator/array_get_slice.template.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
$TYPE$ *$NAME$Slice_Get($NAME$Slice *slice, int index) {
|
||||
return Clay__Array_RangeCheck(index, slice->length) ? &slice->internalArray[index] : $DEFAULT_VALUE$;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue