From 0291b7f791b1c667deeb1fc2fdbb39ddd41eaac3 Mon Sep 17 00:00:00 2001 From: James-Livesey Date: Fri, 28 Jun 2024 23:14:53 +0100 Subject: [PATCH] Change `codeLength` to `codeSize` I prefer the use of the word 'size' to refer to raw sizes in bytes, and 'length' for abstract sizes. With strings, the 'size' will be the number of bytes, but the 'length' is the number of Unicode characters, for example. --- dist/libvoxel.h | 8 ++++---- examples/hello.c | 2 +- runtime/voxel.c | 2 +- src/contexts.h | 4 ++-- src/declarations.h | 2 +- src/parser.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/libvoxel.h b/dist/libvoxel.h index e375a90..edd04c5 100644 --- a/dist/libvoxel.h +++ b/dist/libvoxel.h @@ -213,7 +213,7 @@ typedef enum { typedef struct voxel_Context { voxel_Bool isInitialised; char* code; - voxel_Count codeLength; + voxel_Count codeSize; voxel_Builtin* builtins; voxel_Count builtinCount; struct voxel_Scope* globalScope; @@ -2212,7 +2212,7 @@ voxel_Context* voxel_newContext() { context->isInitialised = VOXEL_FALSE; context->code = VOXEL_NULL; - context->codeLength = 0; + context->codeSize = 0; context->builtins = (voxel_Builtin*)VOXEL_MALLOC(0); VOXEL_TAG_MALLOC_SIZE("voxel_Context->builtins", 0); context->builtinCount = 0; context->firstTrackedThing = VOXEL_NULL; @@ -2238,7 +2238,7 @@ VOXEL_ERRORABLE voxel_initContext(voxel_Context* context) { } #ifdef VOXEL_MAGIC - if (context->codeLength < VOXEL_MAGIC_SIZE) { + if (context->codeSize < VOXEL_MAGIC_SIZE) { VOXEL_THROW(VOXEL_ERROR_INVALID_MAGIC); } @@ -4285,7 +4285,7 @@ VOXEL_ERRORABLE voxel_greaterThanOperation(voxel_Context* context, voxel_Thing* // src/parser.h VOXEL_ERRORABLE voxel_safeToRead(voxel_Context* context, voxel_Position* position, voxel_Count bytesToRead) { - if ((*position) + bytesToRead > context->codeLength) { + if ((*position) + bytesToRead > context->codeSize) { VOXEL_THROW(VOXEL_ERROR_TOKENISATION_END); } diff --git a/examples/hello.c b/examples/hello.c index 7844bdc..4ea0a35 100644 --- a/examples/hello.c +++ b/examples/hello.c @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) { voxel_defineBuiltin(context, "add", &builtin_add); context->code = code; - context->codeLength = 1024; + context->codeSize = 1024; VOXEL_MUST_CODE(voxel_initContext(context)); diff --git a/runtime/voxel.c b/runtime/voxel.c index 954ae84..c1c752d 100644 --- a/runtime/voxel.c +++ b/runtime/voxel.c @@ -34,7 +34,7 @@ int main(int argc, char* argv[]) { } context->code = data; - context->codeLength = size; + context->codeSize = size; VOXEL_MUST_CODE(voxel_initContext(context)); diff --git a/src/contexts.h b/src/contexts.h index f8e1100..503cd0f 100644 --- a/src/contexts.h +++ b/src/contexts.h @@ -3,7 +3,7 @@ voxel_Context* voxel_newContext() { context->isInitialised = VOXEL_FALSE; context->code = VOXEL_NULL; - context->codeLength = 0; + context->codeSize = 0; context->builtins = (voxel_Builtin*)VOXEL_MALLOC(0); VOXEL_TAG_MALLOC_SIZE("voxel_Context->builtins", 0); context->builtinCount = 0; context->firstTrackedThing = VOXEL_NULL; @@ -29,7 +29,7 @@ VOXEL_ERRORABLE voxel_initContext(voxel_Context* context) { } #ifdef VOXEL_MAGIC - if (context->codeLength < VOXEL_MAGIC_SIZE) { + if (context->codeSize < VOXEL_MAGIC_SIZE) { VOXEL_THROW(VOXEL_ERROR_INVALID_MAGIC); } diff --git a/src/declarations.h b/src/declarations.h index 9f3b74a..f9fc3f5 100644 --- a/src/declarations.h +++ b/src/declarations.h @@ -18,7 +18,7 @@ typedef enum { typedef struct voxel_Context { voxel_Bool isInitialised; char* code; - voxel_Count codeLength; + voxel_Count codeSize; voxel_Builtin* builtins; voxel_Count builtinCount; struct voxel_Scope* globalScope; diff --git a/src/parser.h b/src/parser.h index 9ddb726..ae11147 100644 --- a/src/parser.h +++ b/src/parser.h @@ -1,5 +1,5 @@ VOXEL_ERRORABLE voxel_safeToRead(voxel_Context* context, voxel_Position* position, voxel_Count bytesToRead) { - if ((*position) + bytesToRead > context->codeLength) { + if ((*position) + bytesToRead > context->codeSize) { VOXEL_THROW(VOXEL_ERROR_TOKENISATION_END); }