Skip to content

Commit

Permalink
MiniScript: some more WIP (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasdr committed Nov 12, 2023
1 parent 4863511 commit daf02b7
Show file tree
Hide file tree
Showing 22 changed files with 314 additions and 314 deletions.
74 changes: 37 additions & 37 deletions src/tdme/utilities/MiniScriptArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArray(MiniScript* miniScript):
MiniScript::ScriptMethod(
{},
MiniScript::ScriptVariableType::TYPE_ARRAY
MiniScript::TYPE_ARRAY
),
miniScript(miniScript) {}
const string getMethodName() override {
Expand All @@ -48,16 +48,16 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArrayLength(MiniScript* miniScript):
MiniScript::ScriptMethod(
{
{ .type = MiniScript::ScriptVariableType::TYPE_ARRAY, .name = "array", .optional = false, .reference = false, .nullable = false }
{ .type = MiniScript::TYPE_ARRAY, .name = "array", .optional = false, .reference = false, .nullable = false }
},
MiniScript::ScriptVariableType::TYPE_INTEGER
MiniScript::TYPE_INTEGER
),
miniScript(miniScript) {}
const string getMethodName() override {
return "array.length";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
if (argumentValues.size() != 1 || argumentValues[0].getType() != MiniScript::ScriptVariableType::TYPE_ARRAY) {
if (argumentValues.size() != 1 || argumentValues[0].getType() != MiniScript::TYPE_ARRAY) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
} else {
Expand All @@ -76,9 +76,9 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArrayPush(MiniScript* miniScript):
MiniScript::ScriptMethod(
{
{ .type = MiniScript::ScriptVariableType::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false }
{ .type = MiniScript::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false }
},
MiniScript::ScriptVariableType::TYPE_NULL
MiniScript::TYPE_NULL
),
miniScript(miniScript) {}
const string getMethodName() override {
Expand All @@ -89,7 +89,7 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
//
if (argumentValues.size() < 1 || argumentValues[0].getType() != MiniScript::ScriptVariableType::TYPE_ARRAY) {
if (argumentValues.size() < 1 || argumentValues[0].getType() != MiniScript::TYPE_ARRAY) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
} else {
Expand All @@ -110,18 +110,18 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArrayGet(MiniScript* miniScript):
MiniScript::ScriptMethod(
{
{ .type = MiniScript::ScriptVariableType::TYPE_ARRAY, .name = "array", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::ScriptVariableType::TYPE_INTEGER, .name = "index", .optional = false, .reference = false, .nullable = false }
{ .type = MiniScript::TYPE_ARRAY, .name = "array", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_INTEGER, .name = "index", .optional = false, .reference = false, .nullable = false }
},
MiniScript::ScriptVariableType::TYPE_PSEUDO_MIXED
MiniScript::TYPE_PSEUDO_MIXED
),
miniScript(miniScript) {}
const string getMethodName() override {
return "array.get";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
int64_t index;
if ((argumentValues.size() <= 1 || argumentValues[0].getType() != MiniScript::ScriptVariableType::TYPE_ARRAY) ||
if ((argumentValues.size() <= 1 || argumentValues[0].getType() != MiniScript::TYPE_ARRAY) ||
MiniScript::getIntegerValue(argumentValues, 1, index, false) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
Expand All @@ -141,19 +141,19 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArraySet(MiniScript* miniScript):
MiniScript::ScriptMethod(
{
{ .type = MiniScript::ScriptVariableType::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false },
{ .type = MiniScript::ScriptVariableType::TYPE_INTEGER, .name = "index", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::ScriptVariableType::TYPE_PSEUDO_MIXED, .name = "value", .optional = false, .reference = false, .nullable = false }
{ .type = MiniScript::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false },
{ .type = MiniScript::TYPE_INTEGER, .name = "index", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_PSEUDO_MIXED, .name = "value", .optional = false, .reference = false, .nullable = false }
},
MiniScript::ScriptVariableType::TYPE_NULL
MiniScript::TYPE_NULL
),
miniScript(miniScript) {}
const string getMethodName() override {
return "array.set";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
int64_t index;
if ((argumentValues.size() <= 2 || argumentValues[0].getType() != MiniScript::ScriptVariableType::TYPE_ARRAY) ||
if ((argumentValues.size() <= 2 || argumentValues[0].getType() != MiniScript::TYPE_ARRAY) ||
MiniScript::getIntegerValue(argumentValues, 1, index, false) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
Expand All @@ -173,18 +173,18 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArrayRemove(MiniScript* miniScript):
MiniScript::ScriptMethod(
{
{ .type = MiniScript::ScriptVariableType::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false },
{ .type = MiniScript::ScriptVariableType::TYPE_INTEGER, .name = "index", .optional = false, .reference = false, .nullable = false }
{ .type = MiniScript::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false },
{ .type = MiniScript::TYPE_INTEGER, .name = "index", .optional = false, .reference = false, .nullable = false }
},
MiniScript::ScriptVariableType::TYPE_NULL
MiniScript::TYPE_NULL
),
miniScript(miniScript) {}
const string getMethodName() override {
return "array.remove";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
int64_t index;
if ((argumentValues.size() < 2 || argumentValues[0].getType() != MiniScript::ScriptVariableType::TYPE_ARRAY) ||
if ((argumentValues.size() < 2 || argumentValues[0].getType() != MiniScript::TYPE_ARRAY) ||
MiniScript::getIntegerValue(argumentValues, 1, index, false) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
Expand All @@ -204,11 +204,11 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArrayRemoveOf(MiniScript* miniScript):
MiniScript::ScriptMethod(
{
{ .type = MiniScript::ScriptVariableType::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false },
{ .type = MiniScript::ScriptVariableType::TYPE_STRING, .name = "value", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::ScriptVariableType::TYPE_INTEGER, .name = "beginIndex", .optional = true, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false },
{ .type = MiniScript::TYPE_STRING, .name = "value", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_INTEGER, .name = "beginIndex", .optional = true, .reference = false, .nullable = false },
},
MiniScript::ScriptVariableType::TYPE_NULL
MiniScript::TYPE_NULL
),
miniScript(miniScript) {}
const string getMethodName() override {
Expand All @@ -218,7 +218,7 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
string stringValue;
int64_t beginIndex = 0;
if (argumentValues.size() < 2 ||
argumentValues[0].getType() != MiniScript::ScriptVariableType::TYPE_ARRAY ||
argumentValues[0].getType() != MiniScript::TYPE_ARRAY ||
MiniScript::getStringValue(argumentValues, 1, stringValue, false) == false ||
MiniScript::getIntegerValue(argumentValues, 2, beginIndex, true) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
Expand Down Expand Up @@ -246,11 +246,11 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArrayIndexOf(MiniScript* miniScript):
MiniScript::ScriptMethod(
{
{ .type = MiniScript::ScriptVariableType::TYPE_ARRAY, .name = "array", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::ScriptVariableType::TYPE_STRING, .name = "value", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::ScriptVariableType::TYPE_INTEGER, .name = "beginIndex", .optional = true, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_ARRAY, .name = "array", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_STRING, .name = "value", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_INTEGER, .name = "beginIndex", .optional = true, .reference = false, .nullable = false },
},
MiniScript::ScriptVariableType::TYPE_INTEGER
MiniScript::TYPE_INTEGER
),
miniScript(miniScript) {}
const string getMethodName() override {
Expand All @@ -260,7 +260,7 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
string stringValue;
int64_t beginIndex = 0;
if (argumentValues.size() < 2 ||
argumentValues[0].getType() != MiniScript::ScriptVariableType::TYPE_ARRAY ||
argumentValues[0].getType() != MiniScript::TYPE_ARRAY ||
MiniScript::getStringValue(argumentValues, 1, stringValue, false) == false ||
MiniScript::getIntegerValue(argumentValues, 2, beginIndex, true) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
Expand Down Expand Up @@ -289,10 +289,10 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArraySort(MiniScript* miniScript):
MiniScript::ScriptMethod(
{
{ .type = MiniScript::ScriptVariableType::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false },
{ .type = MiniScript::ScriptVariableType::TYPE_STRING, .name = "function", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false },
{ .type = MiniScript::TYPE_STRING, .name = "function", .optional = false, .reference = false, .nullable = false },
},
MiniScript::ScriptVariableType::TYPE_NULL
MiniScript::TYPE_NULL
),
miniScript(miniScript) {}
const string getMethodName() override {
Expand All @@ -301,7 +301,7 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
string function;
if (argumentValues.size() != 2 ||
argumentValues[0].getType() != MiniScript::ScriptVariableType::TYPE_ARRAY ||
argumentValues[0].getType() != MiniScript::TYPE_ARRAY ||
MiniScript::getStringValue(argumentValues, 1, function, false) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
Expand Down Expand Up @@ -342,17 +342,17 @@ void MiniScriptArray::registerMethods(MiniScript* miniScript) {
ScriptMethodArrayReverse(MiniScript* miniScript):
MiniScript::ScriptMethod(
{
{ .type = MiniScript::ScriptVariableType::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false }
{ .type = MiniScript::TYPE_ARRAY, .name = "array", .optional = false, .reference = true, .nullable = false }
},
MiniScript::ScriptVariableType::TYPE_NULL
MiniScript::TYPE_NULL
),
miniScript(miniScript) {}
const string getMethodName() override {
return "array.reverse";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
if (argumentValues.size() != 1 ||
argumentValues[0].getType() != MiniScript::ScriptVariableType::TYPE_ARRAY) {
argumentValues[0].getType() != MiniScript::TYPE_ARRAY) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/tdme/utilities/MiniScriptArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using tdme::utilities::MiniScript;

/**
* MiniScript Array
* MiniScript script array class
* @author Andreas Drewke
*/
class tdme::utilities::MiniScriptArray {
Expand Down
Loading

0 comments on commit daf02b7

Please sign in to comment.