mirror of
https://github.com/nicbarker/clay.git
synced 2025-01-23 01:46:02 +00:00
[Core] Standardise number types to int32_t for array indices, lengths and capacities (#152)
Some checks failed
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Failing after 1m44s
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Failing after 13s
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
Some checks failed
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Failing after 1m44s
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Failing after 13s
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
This commit is contained in:
parent
a44423a133
commit
cf12cd6af8
@ -18,7 +18,7 @@ when ODIN_OS == .Windows {
|
||||
}
|
||||
|
||||
String :: struct {
|
||||
length: c.int,
|
||||
length: c.int32_t,
|
||||
chars: [^]c.char,
|
||||
}
|
||||
|
||||
@ -258,8 +258,8 @@ LayoutConfig :: struct {
|
||||
}
|
||||
|
||||
ClayArray :: struct($type: typeid) {
|
||||
capacity: u32,
|
||||
length: u32,
|
||||
capacity: i32,
|
||||
length: i32,
|
||||
internalArray: [^]type,
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -178,6 +178,7 @@
|
||||
}
|
||||
case 'float': return 4;
|
||||
case 'uint32_t': return 4;
|
||||
case 'int32_t': return 4;
|
||||
case 'uint16_t': return 2;
|
||||
case 'uint8_t': return 1;
|
||||
case 'bool': return 1;
|
||||
@ -206,6 +207,7 @@
|
||||
}
|
||||
case 'float': return { value: memoryDataView.getFloat32(address, true), __size: 4 };
|
||||
case 'uint32_t': return { value: memoryDataView.getUint32(address, true), __size: 4 };
|
||||
case 'int32_t': return { value: memoryDataView.getUint32(address, true), __size: 4 };
|
||||
case 'uint16_t': return { value: memoryDataView.getUint16(address, true), __size: 2 };
|
||||
case 'uint8_t': return { value: memoryDataView.getUint8(address, true), __size: 1 };
|
||||
case 'bool': return { value: memoryDataView.getUint8(address, true), __size: 1 };
|
||||
@ -312,7 +314,6 @@
|
||||
|
||||
const importObject = {
|
||||
clay: {
|
||||
|
||||
measureTextFunction: (addressOfDimensions, textToMeasure, addressOfConfig) => {
|
||||
let stringLength = memoryDataView.getUint32(textToMeasure, true);
|
||||
let pointerToString = memoryDataView.getUint32(textToMeasure + 4, true);
|
||||
@ -358,8 +359,8 @@
|
||||
}
|
||||
|
||||
function renderLoopHTML() {
|
||||
let capacity = memoryDataView.getUint32(scratchSpaceAddress, true);
|
||||
let length = memoryDataView.getUint32(scratchSpaceAddress + 4, true);
|
||||
let capacity = memoryDataView.getInt32(scratchSpaceAddress, true);
|
||||
let length = memoryDataView.getInt32(scratchSpaceAddress + 4, true);
|
||||
let arrayOffset = memoryDataView.getUint32(scratchSpaceAddress + 8, true);
|
||||
let scissorStack = [{ nextAllocation: { x: 0, y: 0 }, element: htmlRoot, nextElementIndex: 0 }];
|
||||
let previousId = 0;
|
||||
|
@ -1,3 +1,3 @@
|
||||
$NAME$ $NAME$_Allocate_Arena(uint32_t capacity, Clay_Arena *arena) {
|
||||
$NAME$ $NAME$_Allocate_Arena(int32_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)};
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
$NAME$ $NAME$_Allocate_Arena(uint32_t capacity, Clay_Arena *arena) {
|
||||
$NAME$ $NAME$_Allocate_Arena(int32_t capacity, Clay_Arena *arena) {
|
||||
return CLAY__INIT($NAME$){.capacity = capacity, .length = 0, .internalArray = ($TYPE$ *)Clay__Array_Allocate_Arena(capacity, sizeof($TYPE$), CLAY__POINTER_ALIGNMENT, arena)};
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
CLAY__TYPEDEF($NAME$, struct
|
||||
{
|
||||
uint32_t capacity;
|
||||
uint32_t length;
|
||||
int32_t capacity;
|
||||
int32_t length;
|
||||
$TYPE$ *internalArray;
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
CLAY__TYPEDEF($NAME$Slice, struct
|
||||
{
|
||||
uint32_t length;
|
||||
int32_t length;
|
||||
$TYPE$ *internalArray;
|
||||
});
|
@ -1,3 +1,3 @@
|
||||
$TYPE$ *$NAME$_Get($NAME$ *array, int index) {
|
||||
$TYPE$ *$NAME$_Get($NAME$ *array, int32_t index) {
|
||||
return Clay__Array_RangeCheck(index, array->length) ? &array->internalArray[index] : $DEFAULT_VALUE$;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
$TYPE$ *$NAME$Slice_Get($NAME$Slice *slice, int index) {
|
||||
$TYPE$ *$NAME$Slice_Get($NAME$Slice *slice, int32_t index) {
|
||||
return Clay__Array_RangeCheck(index, slice->length) ? &slice->internalArray[index] : $DEFAULT_VALUE$;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
$TYPE$ $NAME$_Get($NAME$ *array, int index) {
|
||||
$TYPE$ $NAME$_Get($NAME$ *array, int32_t index) {
|
||||
return Clay__Array_RangeCheck(index, array->length) ? array->internalArray[index] : $DEFAULT_VALUE$;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
$TYPE$ $NAME$_RemoveSwapback($NAME$ *array, int index) {
|
||||
$TYPE$ $NAME$_RemoveSwapback($NAME$ *array, int32_t index) {
|
||||
if (Clay__Array_RangeCheck(index, array->length)) {
|
||||
array->length--;
|
||||
$TYPE$ removed = array->internalArray[index];
|
||||
|
@ -1,4 +1,4 @@
|
||||
void $NAME$_Set($NAME$ *array, int index, $TYPE$ value) {
|
||||
void $NAME$_Set($NAME$ *array, int32_t index, $TYPE$ value) {
|
||||
if (Clay__Array_RangeCheck(index, array->capacity)) {
|
||||
array->internalArray[index] = value;
|
||||
array->length = index < array->length ? array->length : index + 1;
|
||||
|
Loading…
Reference in New Issue
Block a user