Consistency pass: house struct tags, pragma once guards, pack bools into flags

Struct tags throughout duskscript reused the typedef name itself (struct
foo_t { ... }), unlike the rest of dusk which always tags with foo_s and
typedefs foo_t - renames all 15 tagged structs in src/dusk/script and
src/duskscriptcc to match. Also drops a vestigial duplicate forward
declaration of scriptsource_t left over from the port.

Unifies all 144 #ifndef/#define/#endif include guards in the ported code to
#pragma once, matching the rest of the codebase (which was already a mix of
25 files doing it the house way and 144 not).

Packs scriptvmfunction_t's isAsync/isRoot/isScript and scriptfuncnode_t's
isAsync/isInline/isNoInline/isRoot/isScript into single uint8_t flags
fields with bit constants, mirroring the SCRIPT_BINARY_FLAG_ASYNC pattern
the bytecode format already uses and the flags-byte convention used
elsewhere in dusk (animation, display). While there, zero-initializes both
scriptfuncnode_t allocation sites (scriptAlloc never zeroes memory, so
several of its fields - not just the ones being packed here - were
previously read uninitialized before their first explicit write), and
removes scriptfunction_t's dead `plain` field, which was always the exact
inverse of isAsync and never actually read anywhere.

Converts the couple of struct-level doc comments that used the ported
project's Javadoc-with-@param style to dusk's plain // prose convention,
and adds missing rationale comments to scriptruntime_t and scriptstring_t,
which had none at all.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
YourWishesandClaude Sonnet 5 committed 2026-10-14 13:22:39 -05:00
1 parent 703d89a9ac
commit af2f0617e0
152 files changed
+235 -666

No files matched your search

+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_ARRAY_SCRIPTARRAYCOPY_H #pragma once
#define SCRIPT_ARRAY_SCRIPTARRAYCOPY_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -19,5 +18,3 @@
* @returns The new array value. * @returns The new array value.
*/ */
scriptvalue_t scriptArrayCopy(scriptruntime_t *runtime, const scriptarray_t *source); scriptvalue_t scriptArrayCopy(scriptruntime_t *runtime, const scriptarray_t *source);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_ARRAY_SCRIPTARRAYDEEP_H #pragma once
#define SCRIPT_ARRAY_SCRIPTARRAYDEEP_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -31,5 +30,3 @@ scriptvalue_t scriptDeepCopy(scriptruntime_t *runtime, const scriptvalue_t value
* @returns True when they match. * @returns True when they match.
*/ */
bool scriptDeepEqual(const scriptvalue_t a, const scriptvalue_t b, const uint8_t depth); bool scriptDeepEqual(const scriptvalue_t a, const scriptvalue_t b, const uint8_t depth);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_ARRAY_SCRIPTARRAYMODIFY_H #pragma once
#define SCRIPT_ARRAY_SCRIPTARRAYMODIFY_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -75,5 +74,3 @@ void scriptFreeze(scriptruntime_t *runtime, const scriptvalue_t value);
* @param value The value. * @param value The value.
*/ */
void scriptRequireConstant(scriptruntime_t *runtime, const scriptvalue_t value); void scriptRequireConstant(scriptruntime_t *runtime, const scriptvalue_t value);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_ARRAY_SCRIPTARRAYNEW_H #pragma once
#define SCRIPT_ARRAY_SCRIPTARRAYNEW_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -38,5 +37,3 @@ scriptcategory_t scriptCategoryOf(const scriptvalue_t value);
* @param value The value about to be added. * @param value The value about to be added.
*/ */
void scriptArrayCheck(scriptruntime_t *runtime, scriptarray_t *array, const scriptvalue_t value); void scriptArrayCheck(scriptruntime_t *runtime, scriptarray_t *array, const scriptvalue_t value);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_ARRAY_SCRIPTARRAYSORT_H #pragma once
#define SCRIPT_ARRAY_SCRIPTARRAYSORT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -39,5 +38,3 @@ void scriptSortValues(
const bool descending, const bool descending,
const scriptvalue_t comparer const scriptvalue_t comparer
); );
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYBASIC_H #pragma once
#define SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYBASIC_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -29,5 +28,3 @@ SCRIPT_NATIVE(scriptBClone);
SCRIPT_NATIVE(scriptBDeepClone); SCRIPT_NATIVE(scriptBDeepClone);
SCRIPT_NATIVE(scriptBDeepEqual); SCRIPT_NATIVE(scriptBDeepEqual);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYFUNC_H #pragma once
#define SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYFUNC_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -14,5 +13,3 @@
SCRIPT_NATIVE(scriptBMap); SCRIPT_NATIVE(scriptBMap);
SCRIPT_NATIVE(scriptBReduce); SCRIPT_NATIVE(scriptBReduce);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYMODIFY_H #pragma once
#define SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYMODIFY_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -20,5 +19,3 @@ SCRIPT_NATIVE(scriptBSplice);
SCRIPT_NATIVE(scriptBInsert); SCRIPT_NATIVE(scriptBInsert);
SCRIPT_NATIVE(scriptBInsertArr); SCRIPT_NATIVE(scriptBInsertArr);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYORDER_H #pragma once
#define SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYORDER_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -16,5 +15,3 @@ SCRIPT_NATIVE(scriptBSort);
SCRIPT_NATIVE(scriptBReverse); SCRIPT_NATIVE(scriptBReverse);
SCRIPT_NATIVE(scriptBShuffle); SCRIPT_NATIVE(scriptBShuffle);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYSEARCH_H #pragma once
#define SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYSEARCH_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -16,5 +15,3 @@ SCRIPT_NATIVE(scriptBIndexOf);
SCRIPT_NATIVE(scriptBLastIndexOf); SCRIPT_NATIVE(scriptBLastIndexOf);
SCRIPT_NATIVE(scriptBFilter); SCRIPT_NATIVE(scriptBFilter);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYSLICE_H #pragma once
#define SCRIPT_BUILTIN_ARRAY_SCRIPTBARRAYSLICE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -16,5 +15,3 @@ SCRIPT_NATIVE(scriptBSubarr);
SCRIPT_NATIVE(scriptBFlatten); SCRIPT_NATIVE(scriptBFlatten);
SCRIPT_NATIVE(scriptBJoin); SCRIPT_NATIVE(scriptBJoin);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_CORE_SCRIPTBCONVERT_H #pragma once
#define SCRIPT_BUILTIN_CORE_SCRIPTBCONVERT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -18,5 +17,3 @@ SCRIPT_NATIVE(scriptBToBase);
SCRIPT_NATIVE(scriptBToNum); SCRIPT_NATIVE(scriptBToNum);
SCRIPT_NATIVE(scriptBToBool); SCRIPT_NATIVE(scriptBToBool);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_CORE_SCRIPTBINCLUDE_H #pragma once
#define SCRIPT_BUILTIN_CORE_SCRIPTBINCLUDE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -14,5 +13,3 @@
SCRIPT_NATIVE(scriptBInclude); SCRIPT_NATIVE(scriptBInclude);
SCRIPT_NATIVE(scriptBAInclude); SCRIPT_NATIVE(scriptBAInclude);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_CORE_SCRIPTBPRINT_H #pragma once
#define SCRIPT_BUILTIN_CORE_SCRIPTBPRINT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -15,5 +14,3 @@
SCRIPT_NATIVE(scriptBPrint); SCRIPT_NATIVE(scriptBPrint);
SCRIPT_NATIVE(scriptBAssert); SCRIPT_NATIVE(scriptBAssert);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_CORE_SCRIPTBPROMISE_H #pragma once
#define SCRIPT_BUILTIN_CORE_SCRIPTBPROMISE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -24,5 +23,3 @@ SCRIPT_NATIVE(scriptBAny);
SCRIPT_NATIVE(scriptBFirst); SCRIPT_NATIVE(scriptBFirst);
SCRIPT_NATIVE(scriptBWait); SCRIPT_NATIVE(scriptBWait);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_CORE_SCRIPTBTYPE_H #pragma once
#define SCRIPT_BUILTIN_CORE_SCRIPTBTYPE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -20,5 +19,3 @@ SCRIPT_NATIVE(scriptBIsNullOrUndefined);
SCRIPT_NATIVE(scriptBIsFunction); SCRIPT_NATIVE(scriptBIsFunction);
SCRIPT_NATIVE(scriptBIsFunctionAsync); SCRIPT_NATIVE(scriptBIsFunctionAsync);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_MATH_SCRIPTBMATHBASIC_H #pragma once
#define SCRIPT_BUILTIN_MATH_SCRIPTBMATHBASIC_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -25,5 +24,3 @@ SCRIPT_NATIVE(scriptBClamp);
SCRIPT_NATIVE(scriptBPow); SCRIPT_NATIVE(scriptBPow);
SCRIPT_NATIVE(scriptBSqrt); SCRIPT_NATIVE(scriptBSqrt);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_MATH_SCRIPTBMATHRANDOM_H #pragma once
#define SCRIPT_BUILTIN_MATH_SCRIPTBMATHRANDOM_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -24,5 +23,3 @@ SCRIPT_NATIVE(scriptBRand);
SCRIPT_NATIVE(scriptBRandf); SCRIPT_NATIVE(scriptBRandf);
SCRIPT_NATIVE(scriptBRandSeed); SCRIPT_NATIVE(scriptBRandSeed);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_MATH_SCRIPTBMATHROUND_H #pragma once
#define SCRIPT_BUILTIN_MATH_SCRIPTBMATHROUND_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -16,5 +15,3 @@ SCRIPT_NATIVE(scriptBFloor);
SCRIPT_NATIVE(scriptBCeil); SCRIPT_NATIVE(scriptBCeil);
SCRIPT_NATIVE(scriptBRound); SCRIPT_NATIVE(scriptBRound);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_MATH_SCRIPTBMATHTRIG_H #pragma once
#define SCRIPT_BUILTIN_MATH_SCRIPTBMATHTRIG_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -18,5 +17,3 @@ SCRIPT_NATIVE(scriptBCos);
SCRIPT_NATIVE(scriptBTan); SCRIPT_NATIVE(scriptBTan);
SCRIPT_NATIVE(scriptBAtan2); SCRIPT_NATIVE(scriptBAtan2);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_SCRIPTARG_H #pragma once
#define SCRIPT_BUILTIN_SCRIPTARG_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -120,5 +119,3 @@ int32_t scriptArgInteger(scriptruntime_t *runtime, const scriptvalue_t *args, co
* @returns The function value. * @returns The function value.
*/ */
scriptvalue_t scriptArgFunction(scriptruntime_t *runtime, const scriptvalue_t *args, const uint8_t argc, const uint8_t index); scriptvalue_t scriptArgFunction(scriptruntime_t *runtime, const scriptvalue_t *args, const uint8_t argc, const uint8_t index);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_SCRIPTBUILTIN_H #pragma once
#define SCRIPT_BUILTIN_SCRIPTBUILTIN_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -18,5 +17,3 @@
const uint8_t argc, \ const uint8_t argc, \
scriptfunction_t *self \ scriptfunction_t *self \
) )
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_SCRIPTBUILTINREGISTER_H #pragma once
#define SCRIPT_BUILTIN_SCRIPTBUILTINREGISTER_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptfunction.h" #include "value/scriptfunction.h"
@@ -36,5 +35,3 @@ void scriptBuiltinAddInt(scriptruntime_t *runtime, const char *name, const int16
* @param runtime The runtime. * @param runtime The runtime.
*/ */
void scriptBuiltinsRegister(scriptruntime_t *runtime); void scriptBuiltinsRegister(scriptruntime_t *runtime);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_SCRIPTNATIVESIG_H #pragma once
#define SCRIPT_BUILTIN_SCRIPTNATIVESIG_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -57,7 +56,7 @@ typedef struct {
// What the machine finds a native by, for the instruction that calls one by its number. 16 // What the machine finds a native by, for the instruction that calls one by its number. 16
// bytes each on the Super Nintendo, which the assembly counts on. // bytes each on the Super Nintendo, which the assembly counts on.
typedef struct scriptnativeentry_t { typedef struct scriptnativeentry_s {
scriptnative_t function; scriptnative_t function;
const char *name; const char *name;
const scriptnativesig_t *signature; const scriptnativesig_t *signature;
@@ -105,5 +104,3 @@ void scriptNativeCheckArgs(scriptruntime_t *runtime, const scriptnativesig_t *si
#else #else
#define SCRIPT_NATIVE_INT(runtime, args, argc, index) scriptArgInteger((runtime), (args), (argc), (index)) #define SCRIPT_NATIVE_INT(runtime, args, argc, index) scriptArgInteger((runtime), (args), (argc), (index))
#endif #endif
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_STRING_SCRIPTBSTRINGCASE_H #pragma once
#define SCRIPT_BUILTIN_STRING_SCRIPTBSTRINGCASE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -16,5 +15,3 @@ SCRIPT_NATIVE(scriptBChr);
SCRIPT_NATIVE(scriptBDowncase); SCRIPT_NATIVE(scriptBDowncase);
SCRIPT_NATIVE(scriptBUpcase); SCRIPT_NATIVE(scriptBUpcase);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_STRING_SCRIPTBSTRINGSEARCH_H #pragma once
#define SCRIPT_BUILTIN_STRING_SCRIPTBSTRINGSEARCH_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -23,5 +22,3 @@ SCRIPT_NATIVE(scriptBEndsWith);
SCRIPT_NATIVE(scriptBStringEquals); SCRIPT_NATIVE(scriptBStringEquals);
SCRIPT_NATIVE(scriptBStringEqualsInsensitive); SCRIPT_NATIVE(scriptBStringEqualsInsensitive);
#endif
@@ -5,12 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_STRING_SCRIPTBSTRINGSPLIT_H #pragma once
#define SCRIPT_BUILTIN_STRING_SCRIPTBSTRINGSPLIT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
SCRIPT_NATIVE(scriptBSplit); SCRIPT_NATIVE(scriptBSplit);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BUILTIN_STRING_SCRIPTBSTRINGTRIM_H #pragma once
#define SCRIPT_BUILTIN_STRING_SCRIPTBSTRINGTRIM_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "builtin/scriptbuiltin.h" #include "builtin/scriptbuiltin.h"
@@ -16,5 +15,3 @@ SCRIPT_NATIVE(scriptBLtrim);
SCRIPT_NATIVE(scriptBRtrim); SCRIPT_NATIVE(scriptBRtrim);
SCRIPT_NATIVE(scriptBTrim); SCRIPT_NATIVE(scriptBTrim);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BYTECODE_SCRIPTBYTECODE_H #pragma once
#define SCRIPT_BYTECODE_SCRIPTBYTECODE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -187,5 +186,3 @@ typedef enum {
// Set in the token or the mode of an assignment or an increment when its value is // Set in the token or the mode of an assignment or an increment when its value is
// not wanted, which saves putting it on the stack and taking it off again. // not wanted, which saves putting it on the stack and taking it off again.
#define SCRIPT_BC_DISCARD 0x80 #define SCRIPT_BC_DISCARD 0x80
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BYTECODE_SCRIPTBYTECODESIZE_H #pragma once
#define SCRIPT_BYTECODE_SCRIPTBYTECODESIZE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "bytecode/scriptbytecode.h" #include "bytecode/scriptbytecode.h"
@@ -16,5 +15,3 @@
* instruction. * instruction.
*/ */
extern const uint8_t scriptBytecodeSize[SCRIPT_BC_COUNT]; extern const uint8_t scriptBytecodeSize[SCRIPT_BC_COUNT];
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_BYTECODE_SCRIPTVARINT_H #pragma once
#define SCRIPT_BYTECODE_SCRIPTVARINT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -45,5 +44,3 @@ uint16_t scriptZigzag(const int16_t value);
* @returns The signed number. * @returns The signed number.
*/ */
int16_t scriptUnzigzag(const uint16_t value); int16_t scriptUnzigzag(const uint16_t value);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_CALL_SCRIPTCALL_H #pragma once
#define SCRIPT_CALL_SCRIPTCALL_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -66,5 +65,3 @@ scriptvalue_t scriptCallFunction(
const scriptvalue_t *args, const scriptvalue_t *args,
const uint8_t argc const uint8_t argc
); );
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_CORE_SCRIPTCORE_H #pragma once
#define SCRIPT_CORE_SCRIPTCORE_H
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
@@ -53,5 +52,3 @@ typedef struct {
uint8_t frameCount; uint8_t frameCount;
scriptframeinfo_t frames[SCRIPT_ERROR_FRAMES_MAX]; scriptframeinfo_t frames[SCRIPT_ERROR_FRAMES_MAX];
} scripterror_t; } scripterror_t;
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_CORE_SCRIPTPLATFORM_H #pragma once
#define SCRIPT_CORE_SCRIPTPLATFORM_H
// What the platform the script engine is built for can do, and the sizes its // What the platform the script engine is built for can do, and the sizes its
// numbers come in. Every one of the feature switches can be set from the // numbers come in. Every one of the feature switches can be set from the
@@ -159,5 +158,3 @@ typedef size_t scriptoffset_t;
// Most values a function has on its stack at once, the compiler checks it. // Most values a function has on its stack at once, the compiler checks it.
#define SCRIPT_VM_STACK_MAX 64 #define SCRIPT_VM_STACK_MAX 64
#endif
+2 -7
View File
@@ -5,19 +5,14 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_CORE_SCRIPTSOURCE_H #pragma once
#define SCRIPT_CORE_SCRIPTSOURCE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
// A script's text and the name shown for it in errors. // A script's text and the name shown for it in errors.
typedef struct scriptsource_t { typedef struct scriptsource_s {
char name[SCRIPT_FILE_MAX]; char name[SCRIPT_FILE_MAX];
char path[SCRIPT_FILE_MAX]; char path[SCRIPT_FILE_MAX];
const char *text; const char *text;
size_t length; size_t length;
} scriptsource_t; } scriptsource_t;
struct scriptsource_t;
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_COROUTINE_SCRIPTCOROUTINE_H #pragma once
#define SCRIPT_COROUTINE_SCRIPTCOROUTINE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -29,16 +28,16 @@ typedef enum {
// A script that can be paused at an await. Where there is no way to switch stacks // A script that can be paused at an await. Where there is no way to switch stacks
// (SCRIPT_FEATURE_COROUTINES is 0) it runs on the stack of whoever starts it, to // (SCRIPT_FEATURE_COROUTINES is 0) it runs on the stack of whoever starts it, to
// the end, and an await can only wait for what can be run right then. // the end, and an await can only wait for what can be run right then.
typedef struct scriptcoroutine_t { typedef struct scriptcoroutine_s {
struct scriptcoroutine_t *nextAll; struct scriptcoroutine_s *nextAll;
struct scriptcoroutine_t *prevAll; struct scriptcoroutine_s *prevAll;
#if SCRIPT_FEATURE_COROUTINES #if SCRIPT_FEATURE_COROUTINES
ucontext_t context; ucontext_t context;
void *stack; void *stack;
#endif #endif
jmp_buf errorJump; jmp_buf errorJump;
scriptcostate_t state; scriptcostate_t state;
struct scriptcoroutine_t *nextReady; struct scriptcoroutine_s *nextReady;
scriptvalue_t function; scriptvalue_t function;
scriptvalue_t args[SCRIPT_PARAMS_MAX]; scriptvalue_t args[SCRIPT_PARAMS_MAX];
uint8_t argc; uint8_t argc;
@@ -54,6 +53,4 @@ typedef struct scriptcoroutine_t {
uint16_t valuesTop; uint16_t valuesTop;
} scriptcoroutine_t; } scriptcoroutine_t;
struct scriptcoroutine_t; struct scriptcoroutine_s;
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_COROUTINE_SCRIPTCOROUTINEREADY_H #pragma once
#define SCRIPT_COROUTINE_SCRIPTCOROUTINEREADY_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "coroutine/scriptcoroutine.h" #include "coroutine/scriptcoroutine.h"
@@ -18,5 +17,3 @@
* @param coroutine The coroutine, it is marked ready. * @param coroutine The coroutine, it is marked ready.
*/ */
void scriptReadyPush(scriptruntime_t *runtime, scriptcoroutine_t *coroutine); void scriptReadyPush(scriptruntime_t *runtime, scriptcoroutine_t *coroutine);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_COROUTINE_SCRIPTCOROUTINESPAWN_H #pragma once
#define SCRIPT_COROUTINE_SCRIPTCOROUTINESPAWN_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "coroutine/scriptcoroutine.h" #include "coroutine/scriptcoroutine.h"
@@ -71,5 +70,3 @@ scriptcoroutine_t *scriptCoroutineSpawn(
* @param coroutine The coroutine to switch to. * @param coroutine The coroutine to switch to.
*/ */
void scriptCoroutineResume(scriptruntime_t *runtime, scriptcoroutine_t *coroutine); void scriptCoroutineResume(scriptruntime_t *runtime, scriptcoroutine_t *coroutine);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_COROUTINE_SCRIPTFRAME_H #pragma once
#define SCRIPT_COROUTINE_SCRIPTFRAME_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -28,5 +27,3 @@ typedef struct {
void *locateData; void *locateData;
uint8_t padding[SCRIPT_FRAME_PADDING]; // sizeof is a power of two on the SNES, the frames are indexed with a shift uint8_t padding[SCRIPT_FRAME_PADDING]; // sizeof is a power of two on the SNES, the frames are indexed with a shift
} scriptframe_t; } scriptframe_t;
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_COROUTINE_SCRIPTSCHEDULER_H #pragma once
#define SCRIPT_COROUTINE_SCRIPTSCHEDULER_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -39,5 +38,3 @@ void scriptCoroutineReap(scriptruntime_t *runtime, scriptcoroutine_t *co);
*/ */
bool scriptSchedulerStep(scriptruntime_t *runtime); bool scriptSchedulerStep(scriptruntime_t *runtime);
#endif #endif
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_COROUTINE_SCRIPTSETPOSITION_H #pragma once
#define SCRIPT_COROUTINE_SCRIPTSETPOSITION_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -18,5 +17,3 @@
* @param column Column in the script. * @param column Column in the script.
*/ */
void scriptSetPosition(scriptruntime_t *runtime, const uint16_t line, const uint16_t column); void scriptSetPosition(scriptruntime_t *runtime, const uint16_t line, const uint16_t column);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_COROUTINE_SCRIPTSTACKCHECK_H #pragma once
#define SCRIPT_COROUTINE_SCRIPTSTACKCHECK_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -20,5 +19,3 @@
* @param runtime The runtime. * @param runtime The runtime.
*/ */
void scriptStackCheck(scriptruntime_t *runtime); void scriptStackCheck(scriptruntime_t *runtime);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_DUSKSCRIPT_H #pragma once
#define SCRIPT_DUSKSCRIPT_H
// The part of dusk script every runtime shares: values, the heap, the garbage // The part of dusk script every runtime shares: values, the heap, the garbage
// collector, the built in functions and running scripts. The interpreter and the // collector, the built in functions and running scripts. The interpreter and the
@@ -18,5 +17,3 @@
#include "runtime/scriptruntimeconfig.h" #include "runtime/scriptruntimeconfig.h"
#include "runtime/scriptruntimerun.h" #include "runtime/scriptruntimerun.h"
#include "error/scripttrace.h" #include "error/scripttrace.h"
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_DUSKSCRIPTNATIVE_H #pragma once
#define SCRIPT_DUSKSCRIPTNATIVE_H
// What a native function needs, the types, the argument helpers and the value // What a native function needs, the types, the argument helpers and the value
// constructors. // constructors.
@@ -26,5 +25,3 @@
#include "promise/scriptpromisesettle.h" #include "promise/scriptpromisesettle.h"
#include "promise/scripttimer.h" #include "promise/scripttimer.h"
#include "runtime/scriptruntimeload.h" #include "runtime/scriptruntimeload.h"
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_ERROR_SCRIPTRAISE_H #pragma once
#define SCRIPT_ERROR_SCRIPTRAISE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "core/scriptsource.h" #include "core/scriptsource.h"
@@ -39,5 +38,3 @@ void scriptRaiseSyntax(
const char *format, const char *format,
... ...
); );
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_ERROR_SCRIPTTRACE_H #pragma once
#define SCRIPT_ERROR_SCRIPTTRACE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -24,5 +23,3 @@
* @param size Size of the buffer in bytes. * @param size Size of the buffer in bytes.
*/ */
void scriptErrorFormat(const scripterror_t *error, char *buffer, const size_t size); void scriptErrorFormat(const scripterror_t *error, char *buffer, const size_t size);
#endif
+5 -10
View File
@@ -5,19 +5,16 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_EXECUTOR_SCRIPTEXECUTOR_H #pragma once
#define SCRIPT_EXECUTOR_SCRIPTEXECUTOR_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
#include "value/scriptfunction.h" #include "value/scriptfunction.h"
/** // Something that can run the body of a script function. The tree walking
* Something that can run the body of a script function. The tree walking // interpreter is one, the bytecode virtual machine is another, and a function
* interpreter is one, the bytecode virtual machine is another, and a function // remembers which one made it, so both kinds can call each other in one runtime.
* remembers which one made it, so both kinds can call each other in one runtime. typedef struct scriptexecutor_s {
*/
typedef struct scriptexecutor_t {
/** /**
* Runs the body of a script function right now, in the current coroutine. * Runs the body of a script function right now, in the current coroutine.
* *
@@ -42,5 +39,3 @@ typedef struct scriptexecutor_t {
*/ */
void (*locate)(const scriptfunction_t *function, void *data, uint16_t *line, uint16_t *column); void (*locate)(const scriptfunction_t *function, void *data, uint16_t *line, uint16_t *column);
} scriptexecutor_t; } scriptexecutor_t;
#endif
+1 -4
View File
@@ -5,9 +5,6 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_GC_SCRIPTGC_H #pragma once
#define SCRIPT_GC_SCRIPTGC_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_GC_SCRIPTGCCOLLECT_H #pragma once
#define SCRIPT_GC_SCRIPTGCCOLLECT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -26,5 +25,3 @@ void scriptGcCollect(scriptruntime_t *runtime);
* @param runtime The runtime. * @param runtime The runtime.
*/ */
void scriptGcSetThreshold(scriptruntime_t *runtime); void scriptGcSetThreshold(scriptruntime_t *runtime);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_GC_SCRIPTGCMARK_H #pragma once
#define SCRIPT_GC_SCRIPTGCMARK_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -26,5 +25,3 @@ void scriptGcMarkPointer(scriptruntime_t *runtime, const void *pointer);
* @param value The value. * @param value The value.
*/ */
void scriptGcMarkValue(scriptruntime_t *runtime, const scriptvalue_t value); void scriptGcMarkValue(scriptruntime_t *runtime, const scriptvalue_t value);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_GC_SCRIPTGCSCAN_H #pragma once
#define SCRIPT_GC_SCRIPTGCSCAN_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -35,5 +34,3 @@ void scriptGcScanRange(scriptruntime_t *runtime, const void *low, const void *hi
* @param base The top of the stack. * @param base The top of the stack.
*/ */
void scriptGcScanStack(scriptruntime_t *runtime, const char *base); void scriptGcScanStack(scriptruntime_t *runtime, const char *base);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_HEAP_SCRIPTHEAP_H #pragma once
#define SCRIPT_HEAP_SCRIPTHEAP_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -34,5 +33,3 @@ typedef struct {
size_t last; // offset of the last block, the big blocks are looked for from there size_t last; // offset of the last block, the big blocks are looked for from there
size_t rover; // offset of the block where the last small allocation ended, where the next one starts looking size_t rover; // offset of the block where the last small allocation ended, where the next one starts looking
} scriptheap_t; } scriptheap_t;
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_HEAP_SCRIPTHEAPALLOC_H #pragma once
#define SCRIPT_HEAP_SCRIPTHEAPALLOC_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "heap/scriptheap.h" #include "heap/scriptheap.h"
@@ -30,5 +29,3 @@ void *scriptHeapAlloc(scriptheap_t *heap, const size_t size);
* @returns The memory, or NULL if the heap is out of space. * @returns The memory, or NULL if the heap is out of space.
*/ */
void *scriptHeapAllocKind(scriptheap_t *heap, const size_t size, const scriptheapkind_t kind); void *scriptHeapAllocKind(scriptheap_t *heap, const size_t size, const scriptheapkind_t kind);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_HEAP_SCRIPTHEAPBLOCK_H #pragma once
#define SCRIPT_HEAP_SCRIPTHEAPBLOCK_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "heap/scriptheap.h" #include "heap/scriptheap.h"
@@ -94,5 +93,3 @@ void scriptHeapSetScanned(scriptheap_t *heap, void *pointer);
* @returns The block, or NULL when there are no more. * @returns The block, or NULL when there are no more.
*/ */
void *scriptHeapNextPending(const scriptheap_t *heap, void **cursor); void *scriptHeapNextPending(const scriptheap_t *heap, void **cursor);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_HEAP_SCRIPTHEAPFREE_H #pragma once
#define SCRIPT_HEAP_SCRIPTHEAPFREE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "heap/scriptheap.h" #include "heap/scriptheap.h"
@@ -18,5 +17,3 @@
* @param pointer Memory returned by scriptHeapAlloc, NULL is ignored. * @param pointer Memory returned by scriptHeapAlloc, NULL is ignored.
*/ */
void scriptHeapFree(scriptheap_t *heap, void *pointer); void scriptHeapFree(scriptheap_t *heap, void *pointer);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_HEAP_SCRIPTHEAPINIT_H #pragma once
#define SCRIPT_HEAP_SCRIPTHEAPINIT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "heap/scriptheap.h" #include "heap/scriptheap.h"
@@ -19,5 +18,3 @@
* @param size Size of the block in bytes. * @param size Size of the block in bytes.
*/ */
void scriptHeapInit(scriptheap_t *heap, void *memory, const size_t size); void scriptHeapInit(scriptheap_t *heap, void *memory, const size_t size);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_HEAP_SCRIPTHEAPSWEEP_H #pragma once
#define SCRIPT_HEAP_SCRIPTHEAPSWEEP_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "heap/scriptheap.h" #include "heap/scriptheap.h"
@@ -18,5 +17,3 @@
* @param heap The heap. * @param heap The heap.
*/ */
void scriptHeapSweep(scriptheap_t *heap); void scriptHeapSweep(scriptheap_t *heap);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_NUMBER_SCRIPTNUMBER_H #pragma once
#define SCRIPT_NUMBER_SCRIPTNUMBER_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -15,5 +14,3 @@ typedef enum {
SCRIPT_PARSE_INVALID, SCRIPT_PARSE_INVALID,
SCRIPT_PARSE_TOOBIG SCRIPT_PARSE_TOOBIG
} scriptparse_t; } scriptparse_t;
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_NUMBER_SCRIPTNUMBERBINARY_H #pragma once
#define SCRIPT_NUMBER_SCRIPTNUMBERBINARY_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -23,5 +22,3 @@
* @returns The result. * @returns The result.
*/ */
scriptvalue_t scriptNumberBinary(scriptruntime_t *runtime, const scriptoperator_t op, const scriptvalue_t a, const scriptvalue_t b); scriptvalue_t scriptNumberBinary(scriptruntime_t *runtime, const scriptoperator_t op, const scriptvalue_t a, const scriptvalue_t b);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_NUMBER_SCRIPTNUMBERFORMAT_H #pragma once
#define SCRIPT_NUMBER_SCRIPTNUMBERFORMAT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -21,5 +20,3 @@
* @param decimals Number of decimal places, or -1 for as many as are needed, with trailing zeros dropped. * @param decimals Number of decimal places, or -1 for as many as are needed, with trailing zeros dropped.
*/ */
void scriptNumberFormat(scriptruntime_t *runtime, scriptbuf_t *buffer, const scriptvalue_t value, const int decimals); void scriptNumberFormat(scriptruntime_t *runtime, scriptbuf_t *buffer, const scriptvalue_t value, const int decimals);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_NUMBER_SCRIPTNUMBERPARSE_H #pragma once
#define SCRIPT_NUMBER_SCRIPTNUMBERPARSE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -33,5 +32,3 @@ scriptparse_t scriptParseDecimal(const char *text, const size_t length, scriptva
* @returns Whether it was valid and fit. * @returns Whether it was valid and fit.
*/ */
scriptparse_t scriptParseInteger(const char *text, const size_t length, const int base, int32_t *out); scriptparse_t scriptParseInteger(const char *text, const size_t length, const int base, int32_t *out);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_NUMBER_SCRIPTNUMBERUNARY_H #pragma once
#define SCRIPT_NUMBER_SCRIPTNUMBERUNARY_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -37,5 +36,3 @@ scriptvalue_t scriptNumberInvert(scriptruntime_t *runtime, const scriptvalue_t v
* @returns -1, 0 or 1. * @returns -1, 0 or 1.
*/ */
int scriptNumberCompare(const scriptvalue_t a, const scriptvalue_t b); int scriptNumberCompare(const scriptvalue_t a, const scriptvalue_t b);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_OPS_SCRIPTBINARYOP_H #pragma once
#define SCRIPT_OPS_SCRIPTBINARYOP_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "token/scripttoken.h" #include "token/scripttoken.h"
@@ -22,5 +21,3 @@
* @returns The result. * @returns The result.
*/ */
scriptvalue_t scriptBinaryOp(scriptruntime_t *runtime, const scripttokentype_t op, const scriptvalue_t a, const scriptvalue_t b); scriptvalue_t scriptBinaryOp(scriptruntime_t *runtime, const scripttokentype_t op, const scriptvalue_t a, const scriptvalue_t b);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_OPS_SCRIPTINDEX_H #pragma once
#define SCRIPT_OPS_SCRIPTINDEX_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -41,5 +40,3 @@ scriptvalue_t scriptIndexGet(scriptruntime_t *runtime, const scriptvalue_t conta
* @returns The value, undefined when the member is not there. * @returns The value, undefined when the member is not there.
*/ */
scriptvalue_t scriptMemberGet(scriptruntime_t *runtime, const scriptvalue_t container, const char *name, const size_t length); scriptvalue_t scriptMemberGet(scriptruntime_t *runtime, const scriptvalue_t container, const char *name, const size_t length);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_OPS_SCRIPTREF_H #pragma once
#define SCRIPT_OPS_SCRIPTREF_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "scope/scriptscope.h" #include "scope/scriptscope.h"
@@ -46,5 +45,3 @@ scriptvalue_t scriptRefGet(scriptruntime_t *runtime, const scriptref_t *ref);
* @param value The new value. * @param value The new value.
*/ */
void scriptRefSet(scriptruntime_t *runtime, const scriptref_t *ref, const scriptvalue_t value); void scriptRefSet(scriptruntime_t *runtime, const scriptref_t *ref, const scriptvalue_t value);
#endif
+5 -8
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_PROMISE_SCRIPTPROMISE_H #pragma once
#define SCRIPT_PROMISE_SCRIPTPROMISE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -26,14 +25,14 @@ typedef enum {
// Something waiting for a promise to settle: a coroutine to wake up, or a // Something waiting for a promise to settle: a coroutine to wake up, or a
// combinator (all, any, first) that is watching one of its members. // combinator (all, any, first) that is watching one of its members.
typedef struct scriptpromisewaiter_t { typedef struct scriptpromisewaiter_s {
struct scriptcoroutine_t *coroutine; struct scriptcoroutine_s *coroutine;
scriptpromise_t *combinator; scriptpromise_t *combinator;
uint16_t index; uint16_t index;
struct scriptpromisewaiter_t *next; struct scriptpromisewaiter_s *next;
} scriptpromisewaiter_t; } scriptpromisewaiter_t;
struct scriptpromise_t { struct scriptpromise_s {
scriptpromisestate_t state; scriptpromisestate_t state;
scriptvalue_t value; scriptvalue_t value;
scriptpromisewaiter_t *waiters; scriptpromisewaiter_t *waiters;
@@ -54,5 +53,3 @@ struct scriptpromise_t {
bool comboRejected; bool comboRejected;
scriptvalue_t comboReason; scriptvalue_t comboReason;
}; };
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_PROMISE_SCRIPTPROMISEAWAIT_H #pragma once
#define SCRIPT_PROMISE_SCRIPTPROMISEAWAIT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -20,5 +19,3 @@
* @returns The resolved value. * @returns The resolved value.
*/ */
scriptvalue_t scriptAwait(scriptruntime_t *runtime, scriptpromise_t *promise); scriptvalue_t scriptAwait(scriptruntime_t *runtime, scriptpromise_t *promise);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_PROMISE_SCRIPTPROMISECOMBINE_H #pragma once
#define SCRIPT_PROMISE_SCRIPTPROMISECOMBINE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "promise/scriptpromise.h" #include "promise/scriptpromise.h"
@@ -31,5 +30,3 @@ void scriptComboNotify(scriptruntime_t *runtime, scriptpromise_t *combinator, co
* @returns The promise value. * @returns The promise value.
*/ */
scriptvalue_t scriptPromiseCombine(scriptruntime_t *runtime, const scriptcombinator_t kind, scriptarray_t *promises); scriptvalue_t scriptPromiseCombine(scriptruntime_t *runtime, const scriptcombinator_t kind, scriptarray_t *promises);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_PROMISE_SCRIPTPROMISENEW_H #pragma once
#define SCRIPT_PROMISE_SCRIPTPROMISENEW_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -18,5 +17,3 @@
* @returns The promise value. * @returns The promise value.
*/ */
scriptvalue_t scriptPromiseNew(scriptruntime_t *runtime); scriptvalue_t scriptPromiseNew(scriptruntime_t *runtime);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_PROMISE_SCRIPTPROMISESETTLE_H #pragma once
#define SCRIPT_PROMISE_SCRIPTPROMISESETTLE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "promise/scriptpromise.h" #include "promise/scriptpromise.h"
@@ -67,5 +66,3 @@ void scriptPromiseReject(scriptruntime_t *runtime, scriptpromise_t *promise, con
* @param promise The promise. * @param promise The promise.
*/ */
void scriptPromiseStart(scriptruntime_t *runtime, scriptpromise_t *promise); void scriptPromiseStart(scriptruntime_t *runtime, scriptpromise_t *promise);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_PROMISE_SCRIPTTIMER_H #pragma once
#define SCRIPT_PROMISE_SCRIPTTIMER_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -31,5 +30,3 @@ scriptvalue_t scriptTimerPromise(scriptruntime_t *runtime, const uint32_t ticks)
* @param runtime The runtime. * @param runtime The runtime.
*/ */
void scriptTimersAdvance(scriptruntime_t *runtime); void scriptTimersAdvance(scriptruntime_t *runtime);
#endif
+3 -8
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_RUNTIME_SCRIPTRUNTIME_H #pragma once
#define SCRIPT_RUNTIME_SCRIPTRUNTIME_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "core/scriptsource.h" #include "core/scriptsource.h"
@@ -15,7 +14,7 @@
// A runtime is one script context: its own heap, its own globals, its own // A runtime is one script context: its own heap, its own globals, its own
// running scripts. Nothing in it uses malloc, all of its memory comes from the // running scripts. Nothing in it uses malloc, all of its memory comes from the
// block the host gives scriptRuntimeCreate. // block the host gives scriptRuntimeCreate.
typedef struct scriptruntime_t scriptruntime_t; typedef struct scriptruntime_s scriptruntime_t;
/** /**
* Called with the text print() produces, newline included. * Called with the text print() produces, newline included.
@@ -87,12 +86,8 @@ typedef scriptvalue_t (*scriptloadbinary_t)(
*/ */
typedef scriptvalue_t (*scriptrootmaker_t)(scriptruntime_t *runtime, const void *input); typedef scriptvalue_t (*scriptrootmaker_t)(scriptruntime_t *runtime, const void *input);
/** // What scriptRuntimeMakeRoot is given to make the main script's function.
* What scriptRuntimeMakeRoot is given to make the main script's function.
*/
typedef struct { typedef struct {
const scriptsource_t *source; const scriptsource_t *source;
bool rootAsync; bool rootAsync;
} scriptrootinput_t; } scriptrootinput_t;
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_RUNTIME_SCRIPTRUNTIMECONFIG_H #pragma once
#define SCRIPT_RUNTIME_SCRIPTRUNTIMECONFIG_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "runtime/scriptruntime.h" #include "runtime/scriptruntime.h"
@@ -77,5 +76,3 @@ uint32_t scriptRuntimeGcRuns(const scriptruntime_t *runtime);
* @returns Bytes. * @returns Bytes.
*/ */
size_t scriptRuntimeHeapPeak(const scriptruntime_t *runtime); size_t scriptRuntimeHeapPeak(const scriptruntime_t *runtime);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_RUNTIME_SCRIPTRUNTIMECREATE_H #pragma once
#define SCRIPT_RUNTIME_SCRIPTRUNTIMECREATE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -21,5 +20,3 @@
* @returns The runtime, NULL if the block is too small. * @returns The runtime, NULL if the block is too small.
*/ */
scriptruntime_t *scriptRuntimeCreate(void *memory, const size_t size); scriptruntime_t *scriptRuntimeCreate(void *memory, const size_t size);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_RUNTIME_SCRIPTRUNTIMEEXECUTE_H #pragma once
#define SCRIPT_RUNTIME_SCRIPTRUNTIMEEXECUTE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "runtime/scriptruntime.h" #include "runtime/scriptruntime.h"
@@ -23,5 +22,3 @@
* @returns SCRIPT_OK, or the kind of error. * @returns SCRIPT_OK, or the kind of error.
*/ */
scriptresult_t scriptRuntimeExecute(scriptruntime_t *runtime, const scriptrootmaker_t make, const void *input, scripterror_t *error); scriptresult_t scriptRuntimeExecute(scriptruntime_t *runtime, const scriptrootmaker_t make, const void *input, scripterror_t *error);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_RUNTIME_SCRIPTRUNTIMELOAD_H #pragma once
#define SCRIPT_RUNTIME_SCRIPTRUNTIMELOAD_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -63,5 +62,3 @@ scriptvalue_t scriptLoadFunction(scriptruntime_t *runtime, const scriptsource_t
* @returns The script, a missing file is a fatal error. * @returns The script, a missing file is a fatal error.
*/ */
scriptsource_t *scriptReadScript(scriptruntime_t *runtime, const char *path, const char *callerPath); scriptsource_t *scriptReadScript(scriptruntime_t *runtime, const char *path, const char *callerPath);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_RUNTIME_SCRIPTRUNTIMERUN_H #pragma once
#define SCRIPT_RUNTIME_SCRIPTRUNTIMERUN_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "core/scriptsource.h" #include "core/scriptsource.h"
@@ -71,5 +70,3 @@ bool scriptRuntimeResult(scriptruntime_t *runtime, scriptvalue_t *result);
* @returns SCRIPT_OK, or the kind of error. * @returns SCRIPT_OK, or the kind of error.
*/ */
scriptresult_t scriptRuntimeCall(scriptruntime_t *runtime, const scriptvalue_t function, scripterror_t *error); scriptresult_t scriptRuntimeCall(scriptruntime_t *runtime, const scriptvalue_t function, scripterror_t *error);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_RUNTIME_SCRIPTRUNTIMESTATE_H #pragma once
#define SCRIPT_RUNTIME_SCRIPTRUNTIMESTATE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "promise/scripttimer.h" #include "promise/scripttimer.h"
@@ -20,7 +19,9 @@
#include <ucontext.h> #include <ucontext.h>
#endif #endif
struct scriptruntime_t { // One script context: its own heap, its own globals, its own running scripts.
// The embedding API only ever hands out a pointer to this, see scriptruntime.h.
struct scriptruntime_s {
scriptheap_t heap; scriptheap_t heap;
scriptscope_t *builtinScope; scriptscope_t *builtinScope;
scriptscope_t *globalScope; scriptscope_t *globalScope;
@@ -60,7 +61,7 @@ struct scriptruntime_t {
char *mainStackBase; char *mainStackBase;
// The natives that have a signature, which the machine calls by their number // The natives that have a signature, which the machine calls by their number
const struct scriptnativeentry_t *nativeEntries; const struct scriptnativeentry_s *nativeEntries;
uint16_t nativeCount; uint16_t nativeCount;
// Where the maps of compiled scripts are found, see scriptmaphandler_t. It is last, the machine for the // Where the maps of compiled scripts are found, see scriptmaphandler_t. It is last, the machine for the
@@ -72,7 +73,5 @@ struct scriptruntime_t {
// Where the calls of scriptRuntimeCall are run on a platform without coroutines: one that is kept, so a call does not // Where the calls of scriptRuntimeCall are run on a platform without coroutines: one that is kept, so a call does not
// make and unmake one // make and unmake one
struct scriptcoroutine_t *callCoroutine; struct scriptcoroutine_s *callCoroutine;
}; };
#endif
+5 -8
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_SCOPE_SCRIPTSCOPE_H #pragma once
#define SCRIPT_SCOPE_SCRIPTSCOPE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -23,14 +22,12 @@ typedef struct {
// A scope holds the variables of one block, it is thrown away when the block // A scope holds the variables of one block, it is thrown away when the block
// ends. Lookups walk up through the parents. // ends. Lookups walk up through the parents.
typedef struct scriptscope_t { typedef struct scriptscope_s {
struct scriptscope_t *nextAll; struct scriptscope_s *nextAll;
struct scriptscope_t *prevAll; struct scriptscope_s *prevAll;
struct scriptscope_t *parent; struct scriptscope_s *parent;
scriptvariable_t *variables; scriptvariable_t *variables;
uint16_t count; uint16_t count;
uint16_t capacity; uint16_t capacity;
bool fixed; // never grows, so a pointer to a variable of it stays good bool fixed; // never grows, so a pointer to a variable of it stays good
} scriptscope_t; } scriptscope_t;
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_SCOPE_SCRIPTSCOPEFIND_H #pragma once
#define SCRIPT_SCOPE_SCRIPTSCOPEFIND_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "scope/scriptscope.h" #include "scope/scriptscope.h"
@@ -28,5 +27,3 @@ scriptvariable_t *scriptScopeFindLocal(scriptscope_t *scope, const char *name);
* @returns The variable or NULL. * @returns The variable or NULL.
*/ */
scriptvariable_t *scriptScopeFind(scriptscope_t *scope, const char *name); scriptvariable_t *scriptScopeFind(scriptscope_t *scope, const char *name);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_SCOPE_SCRIPTSCOPENEW_H #pragma once
#define SCRIPT_SCOPE_SCRIPTSCOPENEW_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "scope/scriptscope.h" #include "scope/scriptscope.h"
@@ -27,5 +26,3 @@ scriptscope_t *scriptScopeNew(scriptruntime_t *runtime, scriptscope_t *parent);
* @param scope The scope. * @param scope The scope.
*/ */
void scriptScopeFree(scriptruntime_t *runtime, scriptscope_t *scope); void scriptScopeFree(scriptruntime_t *runtime, scriptscope_t *scope);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_SCOPE_SCRIPTSCOPESET_H #pragma once
#define SCRIPT_SCOPE_SCRIPTSCOPESET_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -64,5 +63,3 @@ void scriptScopeDeclare(scriptruntime_t *runtime, scriptscope_t *scope, const ch
* @param value The value. * @param value The value.
*/ */
void scriptScopeDefine(scriptruntime_t *runtime, scriptscope_t *scope, const char *name, const scriptvalue_t value); void scriptScopeDefine(scriptruntime_t *runtime, scriptscope_t *scope, const char *name, const scriptvalue_t value);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_SCRIPTTYPES_H #pragma once
#define SCRIPT_SCRIPTTYPES_H
// Every type and constant of the interpreter, for the files that reach into the // Every type and constant of the interpreter, for the files that reach into the
// structures. The functions are declared next to the files that define them. // structures. The functions are declared next to the files that define them.
@@ -36,5 +35,3 @@
#include "value/scriptstring.h" #include "value/scriptstring.h"
#include "value/scriptstruct.h" #include "value/scriptstruct.h"
#include "promise/scriptpromise.h" #include "promise/scriptpromise.h"
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_STRING_SCRIPTBUF_H #pragma once
#define SCRIPT_STRING_SCRIPTBUF_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -50,5 +49,3 @@ void scriptBufAppendC(scriptruntime_t *runtime, scriptbuf_t *buffer, const char
* @param buffer The buffer. * @param buffer The buffer.
*/ */
void scriptBufFree(scriptruntime_t *runtime, scriptbuf_t *buffer); void scriptBufFree(scriptruntime_t *runtime, scriptbuf_t *buffer);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_STRING_SCRIPTSTRINGCHAR_H #pragma once
#define SCRIPT_STRING_SCRIPTSTRINGCHAR_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -45,5 +44,3 @@ char scriptCharUpper(const char c);
* @returns The trimmed string value. * @returns The trimmed string value.
*/ */
scriptvalue_t scriptStringTrim(scriptruntime_t *runtime, const scriptstring_t *text, const bool left, const bool right); scriptvalue_t scriptStringTrim(scriptruntime_t *runtime, const scriptstring_t *text, const bool left, const bool right);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_STRING_SCRIPTSTRINGCONCAT_H #pragma once
#define SCRIPT_STRING_SCRIPTSTRINGCONCAT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -21,5 +20,3 @@
* @returns The string value. * @returns The string value.
*/ */
scriptvalue_t scriptStringConcat(scriptruntime_t *runtime, const scriptvalue_t a, const scriptvalue_t b); scriptvalue_t scriptStringConcat(scriptruntime_t *runtime, const scriptvalue_t a, const scriptvalue_t b);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_STRING_SCRIPTSTRINGNEW_H #pragma once
#define SCRIPT_STRING_SCRIPTSTRINGNEW_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -29,5 +28,3 @@ scriptvalue_t scriptStringNew(scriptruntime_t *runtime, const char *data, const
* @returns The string value. * @returns The string value.
*/ */
scriptvalue_t scriptStringFromC(scriptruntime_t *runtime, const char *text); scriptvalue_t scriptStringFromC(scriptruntime_t *runtime, const char *text);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_STRING_SCRIPTSTRINGREJECT_H #pragma once
#define SCRIPT_STRING_SCRIPTSTRINGREJECT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -19,5 +18,3 @@
* @param value The first argument of the function. * @param value The first argument of the function.
*/ */
void scriptRejectString(scriptruntime_t *runtime, const scriptvalue_t value); void scriptRejectString(scriptruntime_t *runtime, const scriptvalue_t value);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_STRING_SCRIPTSTRINGSEARCH_H #pragma once
#define SCRIPT_STRING_SCRIPTSTRINGSEARCH_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -19,5 +18,3 @@
* @returns Where the piece starts, or -1 when it is not there. * @returns Where the piece starts, or -1 when it is not there.
*/ */
int scriptStringSearch(const scriptstring_t *text, const scriptstring_t *piece); int scriptStringSearch(const scriptstring_t *text, const scriptstring_t *piece);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_STRUCT_SCRIPTSTRUCT_H #pragma once
#define SCRIPT_STRUCT_SCRIPTSTRUCT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -67,5 +66,3 @@ void scriptStructSet(
* @param value The value to store. * @param value The value to store.
*/ */
void scriptStructSetKey(scriptruntime_t *runtime, scriptstruct_t *structure, scriptstring_t *key, const scriptvalue_t value); void scriptStructSetKey(scriptruntime_t *runtime, scriptstruct_t *structure, scriptstring_t *key, const scriptvalue_t value);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_TEXT_SCRIPTTEXT_H #pragma once
#define SCRIPT_TEXT_SCRIPTTEXT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include <stdarg.h> #include <stdarg.h>
@@ -39,5 +38,3 @@ void scriptFormat(char *out, const size_t capacity, const char *format, ...);
* @param text The text, NULL counts as empty. * @param text The text, NULL counts as empty.
*/ */
void scriptCopyText(char *out, const size_t capacity, const char *text); void scriptCopyText(char *out, const size_t capacity, const char *text);
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_TOKEN_SCRIPTTOKEN_H #pragma once
#define SCRIPT_TOKEN_SCRIPTTOKEN_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
@@ -90,5 +89,3 @@ typedef struct {
uint16_t length; uint16_t length;
float number; float number;
} scripttoken_t; } scripttoken_t;
#endif
+1 -4
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_VALUE_SCRIPTALLOC_H #pragma once
#define SCRIPT_VALUE_SCRIPTALLOC_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "heap/scriptheap.h" #include "heap/scriptheap.h"
@@ -38,5 +37,3 @@ void *scriptAlloc(scriptruntime_t *runtime, const size_t size);
* @param pointer Memory from scriptAlloc, NULL is ignored. * @param pointer Memory from scriptAlloc, NULL is ignored.
*/ */
void scriptFree(scriptruntime_t *runtime, void *pointer); void scriptFree(scriptruntime_t *runtime, void *pointer);
#endif
+2 -5
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_VALUE_SCRIPTARRAY_H #pragma once
#define SCRIPT_VALUE_SCRIPTARRAY_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -23,12 +22,10 @@ typedef enum {
SCRIPT_CATEGORY_PROMISE SCRIPT_CATEGORY_PROMISE
} scriptcategory_t; } scriptcategory_t;
struct scriptarray_t { struct scriptarray_s {
uint16_t length; uint16_t length;
uint16_t capacity; uint16_t capacity;
scriptcategory_t category; scriptcategory_t category;
scriptvalue_t *items; scriptvalue_t *items;
bool frozen; // a constant, which nothing changes bool frozen; // a constant, which nothing changes
}; };
#endif
+5 -9
View File
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_VALUE_SCRIPTFUNCTION_H #pragma once
#define SCRIPT_VALUE_SCRIPTFUNCTION_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -18,16 +17,15 @@ typedef scriptvalue_t (*scriptnative_t)(
scriptfunction_t *self scriptfunction_t *self
); );
struct scriptfunction_t { struct scriptfunction_s {
const char *name; // not copied, it has to stay where it is as long as the function lives const char *name; // not copied, it has to stay where it is as long as the function lives
const struct scriptfuncnode_t *node; const struct scriptfuncnode_s *node;
const void *code; const void *code;
const struct scriptexecutor_t *executor; const struct scriptexecutor_s *executor;
const struct scriptsource_t *source; const struct scriptsource_s *source;
scriptnative_t native; scriptnative_t native;
void *data; void *data;
bool isAsync; bool isAsync;
bool plain; // a compiled function that is not async, which the virtual machine calls without asking anything else
}; };
/** /**
@@ -40,5 +38,3 @@ struct scriptfunction_t {
* @returns The function value. * @returns The function value.
*/ */
scriptvalue_t scriptFunctionNative(scriptruntime_t *runtime, const char *name, scriptnative_t native, void *data); scriptvalue_t scriptFunctionNative(scriptruntime_t *runtime, const char *name, scriptnative_t native, void *data);
#endif
+4 -5
View File
@@ -5,14 +5,13 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_VALUE_SCRIPTSTRING_H #pragma once
#define SCRIPT_VALUE_SCRIPTSTRING_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
struct scriptstring_t { // A string value: immutable, and not null terminated, its bytes follow it in
// the same heap block, which is why nothing holds one by value.
struct scriptstring_s {
uint16_t length; uint16_t length;
char data[]; char data[];
}; };
#endif
+2 -5
View File
@@ -5,17 +5,14 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_VALUE_SCRIPTSTRUCT_H #pragma once
#define SCRIPT_VALUE_SCRIPTSTRUCT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
struct scriptstruct_t { struct scriptstruct_s {
uint8_t count; uint8_t count;
scriptstring_t *keys[SCRIPT_STRUCT_KEYS_MAX]; scriptstring_t *keys[SCRIPT_STRUCT_KEYS_MAX];
scriptvalue_t values[SCRIPT_STRUCT_KEYS_MAX]; scriptvalue_t values[SCRIPT_STRUCT_KEYS_MAX];
bool frozen; // a constant, which nothing changes bool frozen; // a constant, which nothing changes
}; };
#endif
+8 -11
View File
@@ -5,14 +5,13 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_VALUE_SCRIPTVALUE_H #pragma once
#define SCRIPT_VALUE_SCRIPTVALUE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
typedef struct scriptruntime_t scriptruntime_t; typedef struct scriptruntime_s scriptruntime_t;
struct scriptfuncnode_t; struct scriptfuncnode_s;
typedef enum { typedef enum {
SCRIPT_VALUE_UNDEFINED, SCRIPT_VALUE_UNDEFINED,
@@ -26,15 +25,15 @@ typedef enum {
SCRIPT_VALUE_PROMISE SCRIPT_VALUE_PROMISE
} scriptvaluetype_t; } scriptvaluetype_t;
typedef struct scriptstring_t scriptstring_t; typedef struct scriptstring_s scriptstring_t;
typedef struct scriptarray_t scriptarray_t; typedef struct scriptarray_s scriptarray_t;
typedef struct scriptstruct_t scriptstruct_t; typedef struct scriptstruct_s scriptstruct_t;
typedef struct scriptfunction_t scriptfunction_t; typedef struct scriptfunction_s scriptfunction_t;
typedef struct scriptpromise_t scriptpromise_t; typedef struct scriptpromise_s scriptpromise_t;
typedef struct { typedef struct {
scriptvaluetype_t type; scriptvaluetype_t type;
@@ -67,5 +66,3 @@ typedef enum {
SCRIPT_OP_SHL, SCRIPT_OP_SHL,
SCRIPT_OP_SHR SCRIPT_OP_SHR
} scriptoperator_t; } scriptoperator_t;
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_VALUE_SCRIPTVALUECOMPARE_H #pragma once
#define SCRIPT_VALUE_SCRIPTVALUECOMPARE_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -37,5 +36,3 @@ bool scriptValuesEqual(const scriptvalue_t a, const scriptvalue_t b);
* @returns A short lowercase name. * @returns A short lowercase name.
*/ */
const char *scriptTypeName(const scriptvalue_t value); const char *scriptTypeName(const scriptvalue_t value);
#endif
@@ -5,8 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#ifndef SCRIPT_VALUE_SCRIPTVALUEFORMAT_H #pragma once
#define SCRIPT_VALUE_SCRIPTVALUEFORMAT_H
#include "core/scriptcore.h" #include "core/scriptcore.h"
#include "value/scriptvalue.h" #include "value/scriptvalue.h"
@@ -31,5 +30,3 @@ void scriptValueFormat(scriptruntime_t *runtime, scriptbuf_t *buffer, const scri
* @returns A string value. * @returns A string value.
*/ */
scriptvalue_t scriptValueToString(scriptruntime_t *runtime, const scriptvalue_t value); scriptvalue_t scriptValueToString(scriptruntime_t *runtime, const scriptvalue_t value);
#endif
Loaded 100 of 152 files, more files were not shown because too many files have changed in this diff. Show more