mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Removed unneeded safties from the libs
I missed removing these before, and I haven't needed these in a long time.
This commit is contained in:
@@ -30,11 +30,6 @@ static int nativeCreateRandomGenerator(Toy_Interpreter* interpreter, Toy_Literal
|
|||||||
Toy_freeLiteral(seedLiteralIdn);
|
Toy_freeLiteral(seedLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(seedLiteral)) {
|
|
||||||
Toy_freeLiteral(seedLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TOY_IS_INTEGER(seedLiteral)) {
|
if (!TOY_IS_INTEGER(seedLiteral)) {
|
||||||
interpreter->errorOutput("Incorrect literal type passed to createRandomGenerator");
|
interpreter->errorOutput("Incorrect literal type passed to createRandomGenerator");
|
||||||
Toy_freeLiteral(seedLiteral);
|
Toy_freeLiteral(seedLiteral);
|
||||||
@@ -70,11 +65,6 @@ static int nativeGenerateRandomNumber(Toy_Interpreter* interpreter, Toy_LiteralA
|
|||||||
Toy_freeLiteral(generatorLiteralIdn);
|
Toy_freeLiteral(generatorLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(generatorLiteral)) {
|
|
||||||
Toy_freeLiteral(generatorLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TOY_GET_OPAQUE_TAG(generatorLiteral) != TOY_OPAQUE_TAG_RANDOM) {
|
if (TOY_GET_OPAQUE_TAG(generatorLiteral) != TOY_OPAQUE_TAG_RANDOM) {
|
||||||
interpreter->errorOutput("Unrecognized opaque literal in generateRandomNumber\n");
|
interpreter->errorOutput("Unrecognized opaque literal in generateRandomNumber\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -111,11 +101,6 @@ static int nativeFreeRandomGenerator(Toy_Interpreter* interpreter, Toy_LiteralAr
|
|||||||
Toy_freeLiteral(generatorLiteralIdn);
|
Toy_freeLiteral(generatorLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(generatorLiteral)) {
|
|
||||||
Toy_freeLiteral(generatorLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TOY_GET_OPAQUE_TAG(generatorLiteral) != TOY_OPAQUE_TAG_RANDOM) {
|
if (TOY_GET_OPAQUE_TAG(generatorLiteral) != TOY_OPAQUE_TAG_RANDOM) {
|
||||||
interpreter->errorOutput("Unrecognized opaque literal in freeRandomGenerator\n");
|
interpreter->errorOutput("Unrecognized opaque literal in freeRandomGenerator\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ static int nativeLoadScript(Toy_Interpreter* interpreter, Toy_LiteralArray* argu
|
|||||||
Toy_freeLiteral(drivePathLiteralIdn);
|
Toy_freeLiteral(drivePathLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(drivePathLiteral)) {
|
|
||||||
Toy_freeLiteral(drivePathLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Toy_Literal filePathLiteral = Toy_getDrivePathLiteral(interpreter, &drivePathLiteral);
|
Toy_Literal filePathLiteral = Toy_getDrivePathLiteral(interpreter, &drivePathLiteral);
|
||||||
|
|
||||||
if (TOY_IS_NULL(filePathLiteral)) {
|
if (TOY_IS_NULL(filePathLiteral)) {
|
||||||
@@ -107,11 +102,6 @@ static int nativeLoadScriptBytecode(Toy_Interpreter* interpreter, Toy_LiteralArr
|
|||||||
Toy_freeLiteral(drivePathLiteralIdn);
|
Toy_freeLiteral(drivePathLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(drivePathLiteral)) {
|
|
||||||
Toy_freeLiteral(drivePathLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Toy_Literal filePathLiteral = Toy_getDrivePathLiteral(interpreter, &drivePathLiteral);
|
Toy_Literal filePathLiteral = Toy_getDrivePathLiteral(interpreter, &drivePathLiteral);
|
||||||
|
|
||||||
if (TOY_IS_NULL(filePathLiteral)) {
|
if (TOY_IS_NULL(filePathLiteral)) {
|
||||||
@@ -172,11 +162,6 @@ static int nativeRunScript(Toy_Interpreter* interpreter, Toy_LiteralArray* argum
|
|||||||
Toy_freeLiteral(runnerIdn);
|
Toy_freeLiteral(runnerIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(runnerLiteral)) {
|
|
||||||
Toy_freeLiteral(runnerLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
||||||
interpreter->errorOutput("Unrecognized opaque literal in runScript\n");
|
interpreter->errorOutput("Unrecognized opaque literal in runScript\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -224,12 +209,6 @@ static int nativeGetScriptVar(Toy_Interpreter* interpreter, Toy_LiteralArray* ar
|
|||||||
Toy_freeLiteral(runnerIdn);
|
Toy_freeLiteral(runnerIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(varName) || TOY_IS_IDENTIFIER(runnerLiteral)) {
|
|
||||||
Toy_freeLiteral(varName);
|
|
||||||
Toy_freeLiteral(runnerLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
||||||
interpreter->errorOutput("Unrecognized opaque literal in getScriptVar\n");
|
interpreter->errorOutput("Unrecognized opaque literal in getScriptVar\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -302,12 +281,6 @@ static int nativeCallScriptFn(Toy_Interpreter* interpreter, Toy_LiteralArray* ar
|
|||||||
Toy_freeLiteral(runnerIdn);
|
Toy_freeLiteral(runnerIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(varName) || TOY_IS_IDENTIFIER(runnerLiteral)) {
|
|
||||||
Toy_freeLiteral(varName);
|
|
||||||
Toy_freeLiteral(runnerLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
||||||
interpreter->errorOutput("Unrecognized opaque literal in callScriptFn\n");
|
interpreter->errorOutput("Unrecognized opaque literal in callScriptFn\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -377,11 +350,6 @@ static int nativeResetScript(Toy_Interpreter* interpreter, Toy_LiteralArray* arg
|
|||||||
Toy_freeLiteral(runnerIdn);
|
Toy_freeLiteral(runnerIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(runnerLiteral)) {
|
|
||||||
Toy_freeLiteral(runnerLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
||||||
interpreter->errorOutput("Unrecognized opaque literal in resetScript\n");
|
interpreter->errorOutput("Unrecognized opaque literal in resetScript\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -418,11 +386,6 @@ static int nativeFreeScript(Toy_Interpreter* interpreter, Toy_LiteralArray* argu
|
|||||||
Toy_freeLiteral(runnerIdn);
|
Toy_freeLiteral(runnerIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(runnerLiteral)) {
|
|
||||||
Toy_freeLiteral(runnerLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
||||||
interpreter->errorOutput("Unrecognized opaque literal in freeScript\n");
|
interpreter->errorOutput("Unrecognized opaque literal in freeScript\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -457,11 +420,6 @@ static int nativeCheckScriptDirty(Toy_Interpreter* interpreter, Toy_LiteralArray
|
|||||||
Toy_freeLiteral(runnerIdn);
|
Toy_freeLiteral(runnerIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(runnerLiteral)) {
|
|
||||||
Toy_freeLiteral(runnerLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
|
||||||
interpreter->errorOutput("Unrecognized opaque literal in checkScriptDirty\n");
|
interpreter->errorOutput("Unrecognized opaque literal in checkScriptDirty\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1502,12 +1502,6 @@ static int nativeSort(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments)
|
|||||||
Toy_freeLiteral(fnLiteralIdn);
|
Toy_freeLiteral(fnLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(fnLiteral)) {
|
|
||||||
Toy_freeLiteral(selfLiteral);
|
|
||||||
Toy_freeLiteral(fnLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//check type
|
//check type
|
||||||
if (!TOY_IS_ARRAY(selfLiteral) || !( TOY_IS_FUNCTION(fnLiteral) || TOY_IS_FUNCTION_NATIVE(fnLiteral) )) {
|
if (!TOY_IS_ARRAY(selfLiteral) || !( TOY_IS_FUNCTION(fnLiteral) || TOY_IS_FUNCTION_NATIVE(fnLiteral) )) {
|
||||||
interpreter->errorOutput("Incorrect argument type passed to sort\n");
|
interpreter->errorOutput("Incorrect argument type passed to sort\n");
|
||||||
@@ -1570,11 +1564,6 @@ static int nativeToLower(Toy_Interpreter* interpreter, Toy_LiteralArray* argumen
|
|||||||
Toy_freeLiteral(selfLiteralIdn);
|
Toy_freeLiteral(selfLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(selfLiteral)) {
|
|
||||||
Toy_freeLiteral(selfLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TOY_IS_STRING(selfLiteral)) {
|
if (!TOY_IS_STRING(selfLiteral)) {
|
||||||
interpreter->errorOutput("Incorrect argument type passed to toLower\n");
|
interpreter->errorOutput("Incorrect argument type passed to toLower\n");
|
||||||
Toy_freeLiteral(selfLiteral);
|
Toy_freeLiteral(selfLiteral);
|
||||||
@@ -1636,17 +1625,6 @@ static int nativeToString(Toy_Interpreter* interpreter, Toy_LiteralArray* argume
|
|||||||
Toy_freeLiteral(selfLiteralIdn);
|
Toy_freeLiteral(selfLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(selfLiteral)) {
|
|
||||||
Toy_freeLiteral(selfLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//BUGFIX: probably an undefined variable
|
|
||||||
if (TOY_IS_IDENTIFIER(selfLiteral)) {
|
|
||||||
Toy_freeLiteral(selfLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//print it to a custom function
|
//print it to a custom function
|
||||||
Toy_printLiteralCustom(selfLiteral, toStringUtil);
|
Toy_printLiteralCustom(selfLiteral, toStringUtil);
|
||||||
|
|
||||||
@@ -1680,11 +1658,6 @@ static int nativeToUpper(Toy_Interpreter* interpreter, Toy_LiteralArray* argumen
|
|||||||
Toy_freeLiteral(selfLiteralIdn);
|
Toy_freeLiteral(selfLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(selfLiteral)) {
|
|
||||||
Toy_freeLiteral(selfLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TOY_IS_STRING(selfLiteral)) {
|
if (!TOY_IS_STRING(selfLiteral)) {
|
||||||
interpreter->errorOutput("Incorrect argument type passed to toUpper\n");
|
interpreter->errorOutput("Incorrect argument type passed to toUpper\n");
|
||||||
Toy_freeLiteral(selfLiteral);
|
Toy_freeLiteral(selfLiteral);
|
||||||
@@ -1745,12 +1718,6 @@ static int nativeTrim(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments)
|
|||||||
Toy_freeLiteral(selfLiteralIdn);
|
Toy_freeLiteral(selfLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(trimCharsLiteral)) {
|
|
||||||
Toy_freeLiteral(selfLiteral);
|
|
||||||
Toy_freeLiteral(trimCharsLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TOY_IS_STRING(selfLiteral) || !TOY_IS_STRING(trimCharsLiteral)) {
|
if (!TOY_IS_STRING(selfLiteral) || !TOY_IS_STRING(trimCharsLiteral)) {
|
||||||
interpreter->errorOutput("Incorrect argument type passed to trim\n");
|
interpreter->errorOutput("Incorrect argument type passed to trim\n");
|
||||||
Toy_freeLiteral(trimCharsLiteral);
|
Toy_freeLiteral(trimCharsLiteral);
|
||||||
@@ -1862,12 +1829,6 @@ static int nativeTrimBegin(Toy_Interpreter* interpreter, Toy_LiteralArray* argum
|
|||||||
Toy_freeLiteral(selfLiteralIdn);
|
Toy_freeLiteral(selfLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(trimCharsLiteral)) {
|
|
||||||
Toy_freeLiteral(selfLiteral);
|
|
||||||
Toy_freeLiteral(trimCharsLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TOY_IS_STRING(selfLiteral) || !TOY_IS_STRING(trimCharsLiteral)) {
|
if (!TOY_IS_STRING(selfLiteral) || !TOY_IS_STRING(trimCharsLiteral)) {
|
||||||
interpreter->errorOutput("Incorrect argument type passed to trimBegin\n");
|
interpreter->errorOutput("Incorrect argument type passed to trimBegin\n");
|
||||||
Toy_freeLiteral(trimCharsLiteral);
|
Toy_freeLiteral(trimCharsLiteral);
|
||||||
@@ -1956,12 +1917,6 @@ static int nativeTrimEnd(Toy_Interpreter* interpreter, Toy_LiteralArray* argumen
|
|||||||
Toy_freeLiteral(selfLiteralIdn);
|
Toy_freeLiteral(selfLiteralIdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(trimCharsLiteral)) {
|
|
||||||
Toy_freeLiteral(selfLiteral);
|
|
||||||
Toy_freeLiteral(trimCharsLiteral);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TOY_IS_STRING(selfLiteral) || !TOY_IS_STRING(trimCharsLiteral)) {
|
if (!TOY_IS_STRING(selfLiteral) || !TOY_IS_STRING(trimCharsLiteral)) {
|
||||||
interpreter->errorOutput("Incorrect argument type passed to trimEnd\n");
|
interpreter->errorOutput("Incorrect argument type passed to trimEnd\n");
|
||||||
Toy_freeLiteral(trimCharsLiteral);
|
Toy_freeLiteral(trimCharsLiteral);
|
||||||
|
|||||||
Reference in New Issue
Block a user