Multi-type elements (#34)

This commit is contained in:
Nic Barker 2024-10-22 20:41:35 +13:00 committed by GitHub
parent 3dffbea2a3
commit 29133bc783
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 2296 additions and 2044 deletions

View 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)};
}

View file

@ -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$;

View file

@ -0,0 +1,5 @@
typedef struct
{
uint32_t length;
$TYPE$ *internalArray;
} $NAME$Slice;

View 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$;
}