Compare commits

..

9 Commits

Author SHA1 Message Date
Harrison Lambeth
5bb70d9469
Merge 38bb241ced into 3961720ef0 2025-02-11 06:15:02 +00:00
Harrison Lambeth
38bb241ced small fixes 2025-02-10 23:14:44 -07:00
Harrison Lambeth
f4933c6669 small refactor 2025-02-10 23:14:44 -07:00
Harrison Lambeth
61ba36753b Fix Clay_OnHover 2025-02-10 23:14:44 -07:00
Harrison Lambeth
4f4605eff9 Add proper support for function arguments 2025-02-10 23:14:44 -07:00
Harrison Lambeth
7c65f31f46 Some fixes after rebasing 2025-02-10 23:14:44 -07:00
Harrison Lambeth
01025e9157 initial pass 2025-02-10 23:14:44 -07:00
Nic Barker
3961720ef0 [Core & Documentation] Cleanup public / private API and internal document public API via comments
Some checks are pending
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
2025-02-11 17:11:03 +13:00
Nic Barker
dd1f018444 [Documentation] Add inline documentation comments for subfields of Clay_ElementDeclaration 2025-02-11 14:14:55 +13:00
19 changed files with 447 additions and 284 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

609
clay.h

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
$TYPE$ *$NAME$_Add($NAME$ *array, $TYPE$ item) {
if (Clay__Array_AddCapacityCheck(array->length, array->capacity)) {
array->internalArray[array->length++] = item;
return &array->internalArray[array->length - 1];
}
return $DEFAULT_VALUE$;
}

View File

@ -1,5 +0,0 @@
void $NAME$_Add($NAME$ *array, $TYPE$ item) {
if (Clay__Array_AddCapacityCheck(array->length, array->capacity)) {
array->internalArray[array->length++] = item;
}
}

View File

@ -1,3 +0,0 @@
$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)};
}

View File

@ -1,3 +0,0 @@
$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)};
}

View File

@ -1,6 +0,0 @@
CLAY__TYPEDEF($NAME$, struct
{
int32_t capacity;
int32_t length;
$TYPE$ *internalArray;
});

View File

@ -1,5 +0,0 @@
CLAY__TYPEDEF($NAME$Slice, struct
{
int32_t length;
$TYPE$ *internalArray;
});

View File

@ -1,3 +0,0 @@
$TYPE$ *$NAME$_Get($NAME$ *array, int32_t index) {
return Clay__Array_RangeCheck(index, array->length) ? &array->internalArray[index] : $DEFAULT_VALUE$;
}

View File

@ -1,3 +0,0 @@
$TYPE$ *$NAME$Slice_Get($NAME$Slice *slice, int32_t index) {
return Clay__Array_RangeCheck(index, slice->length) ? &slice->internalArray[index] : $DEFAULT_VALUE$;
}

View File

@ -1,3 +0,0 @@
$TYPE$ $NAME$_Get($NAME$ *array, int32_t index) {
return Clay__Array_RangeCheck(index, array->length) ? array->internalArray[index] : $DEFAULT_VALUE$;
}

View File

@ -1,9 +0,0 @@
$TYPE$ $NAME$_RemoveSwapback($NAME$ *array, int32_t index) {
if (Clay__Array_RangeCheck(index, array->length)) {
array->length--;
$TYPE$ removed = array->internalArray[index];
array->internalArray[index] = array->internalArray[array->length];
return removed;
}
return $DEFAULT_VALUE$;
}

View File

@ -1,6 +0,0 @@
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;
}
}

View File

@ -1,69 +0,0 @@
const fs = require('fs');
const path = require('path');
let files = ['../clay.h'];
let templates = ['./'];
function readCTemplatesRecursive(directory) {
fs.readdirSync(directory).forEach(template => {
const absolute = path.join(directory, template);
if (fs.statSync(absolute).isDirectory()) return readCTemplatesRecursive(absolute);
else if (template.endsWith('template.c')) {
return templates.push(absolute);
}
});
}
readCTemplatesRecursive(__dirname);
for (const file of files) {
const contents = fs.readFileSync(file, 'utf8');
const lines = contents.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.startsWith('// __GENERATED__ template')) {
const [comment, generated, templateOpen, templateNames, ...args] = line.split(" ");
let matchingEndingLine = -1;
for (let j = i + 1; j < lines.length; j++) {
if (lines[j].startsWith('// __GENERATED__ template')) {
matchingEndingLine = j;
break;
}
}
if (matchingEndingLine !== -1) {
i++;
lines.splice(i, matchingEndingLine - (i));
lines.splice(i, 0, ['#pragma region generated']);
i++;
for (const templateName of templateNames.split(',')) {
var matchingTemplate = templates.find(t => t.endsWith(`${templateName}.template.c`));
if (matchingTemplate) {
let templateContents = fs.readFileSync(matchingTemplate, 'utf8');
for (const arg of args) {
[argName, argValue] = arg.split('=');
templateContents = templateContents.replaceAll(`\$${argName}\$`, argValue);
}
let remainingTokens = templateContents.split('$');
if (remainingTokens.length > 1) {
console.log(`Error at ${file}:${i}: Template is missing parameter ${remainingTokens[1]}`)
process.exit();
} else {
templateContents = templateContents.split('\n');
lines.splice(i, 0, ...templateContents);
i += templateContents.length;
}
} else {
console.log(`Error at ${file}:${i + 1}: no template with name ${templateName}.template.c was found.`);
process.exit();
}
}
lines.splice(i, 0, ['#pragma endregion']);
i++;
} else {
console.log(`Error at ${file}:${i + 1}: template was opened and not closed again.`);
process.exit();
}
}
}
fs.writeFileSync(file, lines.join('\n'));
}