Skip to content

Commit

Permalink
ext/MiniScript: updated MiniScript to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasdr committed Dec 13, 2023
1 parent 892b09f commit 673cfde
Show file tree
Hide file tree
Showing 67 changed files with 6,086 additions and 5,234 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,9 @@ EXT_MINISCRIPT_SRCS = \
ext/miniscript/src/miniscript/utilities/Properties.cpp \
ext/miniscript/src/miniscript/utilities/SHA256.cpp \
ext/miniscript/src/miniscript/utilities/StringTools.cpp \
ext/miniscript/src/miniscript/utilities/StringTokenizer.cpp
ext/miniscript/src/miniscript/utilities/StringTokenizer.cpp \
ext/miniscript/src/miniscript/utilities/UTF8StringTools.cpp \
ext/miniscript/src/miniscript/utilities/UTF8StringTokenizer.cpp

OPENGL2_RENDERER_LIB_SRCS = \
src/tdme/engine/subsystems/renderer/EngineGL2Renderer.cpp \
Expand Down
4 changes: 3 additions & 1 deletion Makefile.nmake
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,9 @@ EXT_MINISCRIPT_SRCS = \
ext/miniscript/src/miniscript/utilities/Properties.cpp \
ext/miniscript/src/miniscript/utilities/SHA256.cpp \
ext/miniscript/src/miniscript/utilities/StringTools.cpp \
ext/miniscript/src/miniscript/utilities/StringTokenizer.cpp
ext/miniscript/src/miniscript/utilities/StringTokenizer.cpp \
ext/miniscript/src/miniscript/utilities/UTF8StringTools.cpp \
ext/miniscript/src/miniscript/utilities/UTF8StringTokenizer.cpp

EXT_SRCS = \
$(EXT_TINYXML_SRCS) \
Expand Down
12 changes: 6 additions & 6 deletions ext/miniscript/src/miniscript/miniscript/ApplicationMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ void ApplicationMethods::registerMethods(MiniScript* miniScript) {
// application
{
//
class ScriptMethodApplicationExecute: public MiniScript::ScriptMethod {
class MethodApplicationExecute: public MiniScript::Method {
private:
MiniScript* miniScript { nullptr };
public:
ScriptMethodApplicationExecute(MiniScript* miniScript):
MiniScript::ScriptMethod(
MethodApplicationExecute(MiniScript* miniScript):
MiniScript::Method(
{
{ .type = MiniScript::TYPE_STRING, .name = "command", .optional = false, .reference = false, .nullable = false },
},
Expand All @@ -55,16 +55,16 @@ void ApplicationMethods::registerMethods(MiniScript* miniScript) {
const string getMethodName() override {
return "application.execute";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
void executeMethod(span<MiniScript::Variable>& arguments, MiniScript::Variable& returnValue, const MiniScript::Statement& statement) override {
string command;
if (MiniScript::getStringValue(argumentValues, 0, command, false) == true) {
if (MiniScript::getStringValue(arguments, 0, command, false) == true) {
returnValue.setValue(ApplicationMethods::execute(command));
} else {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
}
}
};
miniScript->registerMethod(new ScriptMethodApplicationExecute(miniScript));
miniScript->registerMethod(new MethodApplicationExecute(miniScript));
}
}
322 changes: 213 additions & 109 deletions ext/miniscript/src/miniscript/miniscript/ArrayMethods.cpp

Large diffs are not rendered by default.

540 changes: 317 additions & 223 deletions ext/miniscript/src/miniscript/miniscript/BaseMethods.cpp

Large diffs are not rendered by default.

198 changes: 136 additions & 62 deletions ext/miniscript/src/miniscript/miniscript/ByteArrayMethods.cpp

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions ext/miniscript/src/miniscript/miniscript/ConsoleMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,34 @@ void ConsoleMethods::registerMethods(MiniScript* miniScript) {
// console
{
//
class ScriptMethodConsoleLog: public MiniScript::ScriptMethod {
class MethodConsoleLog: public MiniScript::Method {
private:
MiniScript* miniScript { nullptr };
public:
ScriptMethodConsoleLog(MiniScript* miniScript): MiniScript::ScriptMethod(), miniScript(miniScript) {}
MethodConsoleLog(MiniScript* miniScript): MiniScript::Method(), miniScript(miniScript) {}
const string getMethodName() override {
return "console.log";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
for (const auto& argumentValue: argumentValues) {
Console::print(argumentValue.getValueAsString());
void executeMethod(span<MiniScript::Variable>& arguments, MiniScript::Variable& returnValue, const MiniScript::Statement& statement) override {
for (const auto& argument: arguments) {
Console::print(argument.getValueAsString());
}
Console::println();
}
bool isVariadic() const override {
return true;
}
};
miniScript->registerMethod(new ScriptMethodConsoleLog(miniScript));
miniScript->registerMethod(new MethodConsoleLog(miniScript));
}
{
//
class ScriptMethodConsoleDump: public MiniScript::ScriptMethod {
class MethodConsoleDump: public MiniScript::Method {
private:
MiniScript* miniScript { nullptr };
public:
ScriptMethodConsoleDump(MiniScript* miniScript):
MiniScript::ScriptMethod(
MethodConsoleDump(MiniScript* miniScript):
MiniScript::Method(
{
{ .type = MiniScript::TYPE_PSEUDO_MIXED, .name = "value", .optional = false, .reference = false, .nullable = false }
}
Expand All @@ -52,15 +52,15 @@ void ConsoleMethods::registerMethods(MiniScript* miniScript) {
const string getMethodName() override {
return "console.dump";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
if (argumentValues.size() != 1) {
void executeMethod(span<MiniScript::Variable>& arguments, MiniScript::Variable& returnValue, const MiniScript::Statement& statement) override {
if (arguments.size() != 1) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
} else {
Console::println(argumentValues[0].getValueAsString(true));
Console::println(arguments[0].getValueAsString(true));
}
}
};
miniScript->registerMethod(new ScriptMethodConsoleDump(miniScript));
miniScript->registerMethod(new MethodConsoleDump(miniScript));
}
}
90 changes: 45 additions & 45 deletions ext/miniscript/src/miniscript/miniscript/ContextMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
if (miniScript->getContext() == nullptr) return;
{
//
class ScriptMethodContextScriptHasCallable: public MiniScript::ScriptMethod {
class MethodContextScriptHasCallable: public MiniScript::Method {
private:
MiniScript* miniScript { nullptr };
public:
ScriptMethodContextScriptHasCallable(MiniScript* miniScript):
MiniScript::ScriptMethod(
MethodContextScriptHasCallable(MiniScript* miniScript):
MiniScript::Method(
{
{ .type = MiniScript::TYPE_STRING, .name = "scriptId", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_STRING, .name = "callable", .optional = false, .reference = false, .nullable = false }
Expand All @@ -32,11 +32,11 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
const string getMethodName() override {
return "context.script.hasCallable";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
void executeMethod(span<MiniScript::Variable>& arguments, MiniScript::Variable& returnValue, const MiniScript::Statement& statement) override {
string scriptId;
string callable;
if (MiniScript::getStringValue(argumentValues, 0, scriptId) == false ||
MiniScript::getStringValue(argumentValues, 1, callable) == false) {
if (MiniScript::getStringValue(arguments, 0, scriptId) == false ||
MiniScript::getStringValue(arguments, 1, callable) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
} else {
Expand All @@ -45,7 +45,7 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
returnValue.setValue(false);
} else {
auto scriptIdx = script->getFunctionScriptIdx(callable);
if (scriptIdx == MiniScript::SCRIPTIDX_NONE || script->getScripts()[scriptIdx].callable == false) {
if (scriptIdx == MiniScript::SCRIPTIDX_NONE || script->getScripts()[scriptIdx].callableFunction == false) {
returnValue.setValue(false);
} else {
returnValue.setValue(true);
Expand All @@ -54,16 +54,16 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
}
}
};
miniScript->registerMethod(new ScriptMethodContextScriptHasCallable(miniScript));
miniScript->registerMethod(new MethodContextScriptHasCallable(miniScript));
}
{
//
class ScriptMethodContextScriptCall: public MiniScript::ScriptMethod {
class MethodContextScriptCall: public MiniScript::Method {
private:
MiniScript* miniScript { nullptr };
public:
ScriptMethodContextScriptCall(MiniScript* miniScript):
ScriptMethod(
MethodContextScriptCall(MiniScript* miniScript):
Method(
{
{ .type = MiniScript::TYPE_STRING, .name = "scriptId", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_STRING, .name = "callable", .optional = false, .reference = false, .nullable = false }
Expand All @@ -74,11 +74,11 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
const string getMethodName() override {
return "context.script.call";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
void executeMethod(span<MiniScript::Variable>& arguments, MiniScript::Variable& returnValue, const MiniScript::Statement& statement) override {
string scriptId;
string callable;
if (MiniScript::getStringValue(argumentValues, 0, scriptId) == false ||
MiniScript::getStringValue(argumentValues, 1, callable) == false) {
if (MiniScript::getStringValue(arguments, 0, scriptId) == false ||
MiniScript::getStringValue(arguments, 1, callable) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
} else {
Expand All @@ -88,22 +88,22 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
miniScript->startErrorScript();
} else {
auto scriptIdx = script->getFunctionScriptIdx(callable);
if (scriptIdx == MiniScript::SCRIPTIDX_NONE || script->getScripts()[scriptIdx].callable == false) {
if (scriptIdx == MiniScript::SCRIPTIDX_NONE || script->getScripts()[scriptIdx].callableFunction == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": callable not found: " + callable);
miniScript->startErrorScript();
} else {
#if defined (__APPLE__)
// MACOSX currently does not support initializing span using begin and end iterators,
vector<MiniScript::ScriptVariable> callArgumentValues(argumentValues.size() - 2);
for (auto i = 2; i < argumentValues.size(); i++) callArgumentValues[i - 2] = move(argumentValues[i]);
#if defined (__clang__)
// Clang currently does not support initializing span using begin and end iterators,
vector<MiniScript::Variable> callArguments(arguments.size() - 2);
for (auto i = 2; i < arguments.size(); i++) callArguments[i - 2] = move(arguments[i]);
// call
span callArgumentValuesSpan(callArgumentValues);
script->call(scriptIdx, callArgumentValuesSpan, returnValue);
span callArgumentsSpan(callArguments);
script->call(scriptIdx, callArgumentsSpan, returnValue);
// move back arguments
for (auto i = 2; i < argumentValues.size(); i++) argumentValues[i] = move(callArgumentValues[i - 2]);
for (auto i = 2; i < arguments.size(); i++) arguments[i] = move(callArguments[i - 2]);
#else
span callArgumentValuesSpan(argumentValues.begin() + 2, argumentValues.end());
script->call(scriptIdx, callArgumentValuesSpan, returnValue);
span callArgumentsSpan(arguments.begin() + 2, arguments.end());
script->call(scriptIdx, callArgumentsSpan, returnValue);
#endif
}
}
Expand All @@ -113,16 +113,16 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
return true;
}
};
miniScript->registerMethod(new ScriptMethodContextScriptCall(miniScript));
miniScript->registerMethod(new MethodContextScriptCall(miniScript));
}
{
//
class ScriptMethodContextScriptLoadScript: public MiniScript::ScriptMethod {
class MethodContextScriptLoadScript: public MiniScript::Method {
private:
MiniScript* miniScript { nullptr };
public:
ScriptMethodContextScriptLoadScript(MiniScript* miniScript):
MiniScript::ScriptMethod(
MethodContextScriptLoadScript(MiniScript* miniScript):
MiniScript::Method(
{
{ .type = MiniScript::TYPE_STRING, .name = "scriptId", .optional = false, .reference = false, .nullable = false },
{ .type = MiniScript::TYPE_STRING, .name = "pathName", .optional = false, .reference = false, .nullable = false },
Expand All @@ -135,15 +135,15 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
const string getMethodName() override {
return "context.script.loadScript";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
void executeMethod(span<MiniScript::Variable>& arguments, MiniScript::Variable& returnValue, const MiniScript::Statement& statement) override {
string scriptId;
string pathName;
string fileName;
bool verbose = false;
if (MiniScript::getStringValue(argumentValues, 0, scriptId) == false ||
MiniScript::getStringValue(argumentValues, 1, pathName) == false ||
MiniScript::getStringValue(argumentValues, 2, fileName) == false ||
MiniScript::getBooleanValue(argumentValues, 3, verbose, true) == false) {
if (MiniScript::getStringValue(arguments, 0, scriptId) == false ||
MiniScript::getStringValue(arguments, 1, pathName) == false ||
MiniScript::getStringValue(arguments, 2, fileName) == false ||
MiniScript::getBooleanValue(arguments, 3, verbose, true) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
} else {
Expand All @@ -166,16 +166,16 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
}
}
};
miniScript->registerMethod(new ScriptMethodContextScriptLoadScript(miniScript));
miniScript->registerMethod(new MethodContextScriptLoadScript(miniScript));
}
{
//
class ScriptMethodContextScriptRemoveScript: public MiniScript::ScriptMethod {
class MethodContextScriptRemoveScript: public MiniScript::Method {
private:
MiniScript* miniScript { nullptr };
public:
ScriptMethodContextScriptRemoveScript(MiniScript* miniScript):
MiniScript::ScriptMethod(
MethodContextScriptRemoveScript(MiniScript* miniScript):
MiniScript::Method(
{
{ .type = MiniScript::TYPE_STRING, .name = "scriptId", .optional = false, .reference = false, .nullable = false }
},
Expand All @@ -185,36 +185,36 @@ void ContextMethods::registerMethods(MiniScript* miniScript) {
const string getMethodName() override {
return "context.script.removeScript";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
void executeMethod(span<MiniScript::Variable>& arguments, MiniScript::Variable& returnValue, const MiniScript::Statement& statement) override {
string scriptId;
if (MiniScript::getStringValue(argumentValues, 0, scriptId) == false) {
if (MiniScript::getStringValue(arguments, 0, scriptId) == false) {
Console::println(getMethodName() + "(): " + miniScript->getStatementInformation(statement) + ": argument mismatch: expected arguments: " + miniScript->getArgumentInformation(getMethodName()));
miniScript->startErrorScript();
} else {
miniScript->getContext()->removeScript(scriptId);
}
}
};
miniScript->registerMethod(new ScriptMethodContextScriptRemoveScript(miniScript));
miniScript->registerMethod(new MethodContextScriptRemoveScript(miniScript));
}
{
//
class ScriptMethodContextScriptGetScriptIds: public MiniScript::ScriptMethod {
class MethodContextScriptGetScriptIds: public MiniScript::Method {
private:
MiniScript* miniScript { nullptr };
public:
ScriptMethodContextScriptGetScriptIds(MiniScript* miniScript):
MiniScript::ScriptMethod({}, MiniScript::TYPE_ARRAY),
MethodContextScriptGetScriptIds(MiniScript* miniScript):
MiniScript::Method({}, MiniScript::TYPE_ARRAY),
miniScript(miniScript) {}
const string getMethodName() override {
return "context.script.getScriptIds";
}
void executeMethod(span<MiniScript::ScriptVariable>& argumentValues, MiniScript::ScriptVariable& returnValue, const MiniScript::ScriptStatement& statement) override {
void executeMethod(span<MiniScript::Variable>& arguments, MiniScript::Variable& returnValue, const MiniScript::Statement& statement) override {
auto scriptIds = miniScript->getContext()->getScriptIds();
returnValue.setType(MiniScript::TYPE_ARRAY);
for (const auto& scriptId: scriptIds) returnValue.pushArrayEntry(scriptId);
}
};
miniScript->registerMethod(new ScriptMethodContextScriptGetScriptIds(miniScript));
miniScript->registerMethod(new MethodContextScriptGetScriptIds(miniScript));
}
}
Loading

0 comments on commit 673cfde

Please sign in to comment.