3#include <unordered_map>
20using std::unordered_map;
34void gatherMethodCode(
const vector<string>& miniScriptExtensionsCode,
const string& className,
int registerLine, unordered_map<
string, vector<string>>& methodCodeMap) {
36 auto classDefinitionLine = -1;
38 for (
auto i = registerLine; i >= 0; i--) {
39 auto& line = miniScriptExtensionsCode[i];
40 auto trimmedLine = StringTools::trim(line);
41 if (StringTools::regexMatch(trimmedLine,
"class[\\ \\t]+" + className +
"[\\ \\t]*:.*") ==
true) {
42 classDefinitionLine = i;
47 if (classDefinitionLine == -1) {
48 Console::println(
"gatherMethodCode(): did not found '" + className +
"' definition");
52 auto curlyBracketCount = 0;
53 auto finished =
false;
54 auto haveExecuteMethodDeclaration =
false;
55 auto executeMethodCurlyBracketStart = -1;
56 auto haveGetMethodNameDeclaration =
false;
57 auto getMethodNameCurlyBracketStart = -1;
58 vector<string> executeMethodCode;
59 string getMethodNameCode;
60 for (
auto i = classDefinitionLine; finished ==
false && i < miniScriptExtensionsCode.size(); i++) {
61 auto& line = miniScriptExtensionsCode[i];
62 auto trimmedLine = StringTools::trim(line);
64 if (StringTools::regexMatch(trimmedLine,
"const[\\ \\t]+string[\\ \\t]+getMethodName()[\\ \\t]*\\(.*") ==
true) {
65 haveGetMethodNameDeclaration =
true;
68 if (StringTools::regexMatch(trimmedLine,
"void[\\ \\t]+executeMethod[\\ \\t]*\\(.*") ==
true) {
69 haveExecuteMethodDeclaration =
true;
72 for (
auto j = 0; j < trimmedLine.size(); j++) {
73 auto c = trimmedLine[j];
78 if (haveExecuteMethodDeclaration ==
true) {
79 executeMethodCurlyBracketStart = curlyBracketCount;
82 if (haveGetMethodNameDeclaration ==
true) {
83 getMethodNameCurlyBracketStart = curlyBracketCount;
88 if (getMethodNameCurlyBracketStart != -1 && curlyBracketCount == getMethodNameCurlyBracketStart) {
90 getMethodNameCurlyBracketStart = -1;
93 if (executeMethodCurlyBracketStart != -1 && curlyBracketCount == executeMethodCurlyBracketStart) {
95 executeMethodCurlyBracketStart = -1;
100 if (curlyBracketCount <= 0) {
107 if (haveGetMethodNameDeclaration ==
false && getMethodNameCurlyBracketStart != -1 && curlyBracketCount >= getMethodNameCurlyBracketStart) {
108 getMethodNameCode+= trimmedLine;
111 if (haveExecuteMethodDeclaration ==
false && executeMethodCurlyBracketStart != -1 && curlyBracketCount >= executeMethodCurlyBracketStart) {
112 executeMethodCode.push_back(line);
115 if (haveGetMethodNameDeclaration ==
true) {
117 haveGetMethodNameDeclaration =
false;
120 if (haveExecuteMethodDeclaration ==
true) {
122 haveExecuteMethodDeclaration =
false;
129 auto haveMethodName =
false;
130 for (
auto i = 0; i < getMethodNameCode.size(); i++) {
131 auto c = getMethodNameCode[i];
133 if (haveMethodName ==
false) haveMethodName =
true;
else
136 if (haveMethodName ==
true) {
143 int minIndent = Integer::MAX_VALUE;
144 for (
auto& codeLine: executeMethodCode) {
146 for (
auto i = 0; i < codeLine.size(); i++) {
147 auto c = codeLine[i];
154 minIndent = Math::min(minIndent, indent);
158 for (
auto& codeLine: executeMethodCode) {
159 codeLine = StringTools::substring(codeLine, minIndent);
163 auto methodCodeMapIt = methodCodeMap.find(methodName);
164 if (methodCodeMapIt != methodCodeMap.end()) {
165 Console::println(
"gatherMethodCode(): Not registering method with methodName: '" + methodName +
"': method already registered");
170 Console::println(
"gatherMethodCode(): registering method with methodName: '" + methodName +
"'");
173 methodCodeMap[methodName] = executeMethodCode;
176void processFile(
const string& scriptFileName,
const string& miniscriptTranspilationFileName,
const vector<string>& miniScriptExtensionFileNames) {
177 Console::println(
"Processing script: " + scriptFileName);
180 unordered_map<string, vector<string>> methodCodeMap;
183 vector<string> _miniScriptExtensionFileNames;
184 _miniScriptExtensionFileNames.push_back(
"src/tdme/utilities/MiniScript.cpp");
185 for (
auto& miniScriptExtensionFileName: miniScriptExtensionFileNames) _miniScriptExtensionFileNames.push_back(miniScriptExtensionFileName);
186 for (
auto& miniScriptExtensionFileName: _miniScriptExtensionFileNames) {
187 vector<string> miniScriptExtensionsCode;
188 FileSystem::getInstance()->getContentAsStringArray(Tools::getPathName(miniScriptExtensionFileName), Tools::getFileName(miniScriptExtensionFileName), miniScriptExtensionsCode);
189 for (
auto i = 0; i < miniScriptExtensionsCode.size(); i++) {
190 auto& line = miniScriptExtensionsCode[i];
191 auto trimmedLine = StringTools::trim(line);
192 if (StringTools::startsWith(trimmedLine,
"registerMethod") ==
true) {
193 auto bracketCount = 0;
195 auto classNameStartIdx = StringTools::firstIndexOf(StringTools::substring(trimmedLine, 14),
"new");
196 if (classNameStartIdx == string::npos) {
197 Console::println(
"src/tdme/utilities/MiniScript.cpp: registerMethod @ " + to_string(i) +
": '" + trimmedLine +
"': unable to determine class name");
199 classNameStartIdx+= 14 + 3;
200 for (
auto j = classNameStartIdx; j < trimmedLine.size(); j++) {
201 auto c = trimmedLine[j];
203 if (c ==
' ')
continue;
214 scriptInstance->
loadScript(Tools::getPathName(scriptFileName), Tools::getFileName(scriptFileName));
218 string headerIndent =
"\t";
219 string methodCodeIndent =
"\t";
221 string generatedExecuteCode;
224 for (
auto& script: scripts) {
227 (script.conditionType == MiniScript::Script::CONDITIONTYPE_ON?
"on_":
"on_enabled_") +
228 (script.name.empty() ==
false?script.name:(
229 StringTools::regexMatch(script.condition,
"[a-zA-Z0-9]+") ==
true?
235 generatedExecuteCode+= headerIndent +
"\t\t" +
"if (scriptState.scriptIdx == " + to_string(scriptIdx) +
") " + methodName +
"(scriptState.statementIdx);" + (scriptIdx < scripts.size() - 1?
" else":
"") +
"\n";
241 auto initializeScriptIdx = -1;
242 auto nothingScriptIdx = -1;
245 for (
auto& script: scripts) {
247 if (StringTools::regexMatch(script.condition,
"[a-zA-Z0-9]+") ==
true) {
248 if (script.condition ==
"nothing") nothingScriptIdx = scriptIdx;
249 if (script.condition ==
"initialize") initializeScriptIdx = scriptIdx;
257 string miniScriptClassName = Tools::removeFileEnding(Tools::getFileName(miniscriptTranspilationFileName));
258 string generatedDeclarations =
"\n";
259 generatedDeclarations+= string() +
"public:" +
"\n";
260 generatedDeclarations+= headerIndent +
"// overridden methods" +
"\n";
261 generatedDeclarations+= headerIndent +
"void emit(const string& condition) override;" +
"\n";
262 generatedDeclarations+= headerIndent +
"inline void startScript() override {" +
"\n";
263 generatedDeclarations+= headerIndent +
"\t" +
"if (native == false) {" +
"\n";
264 generatedDeclarations+= headerIndent +
"\t" +
"\t" +
"MiniScript::startScript();" +
"\n";
265 generatedDeclarations+= headerIndent +
"\t" +
"\t" +
"return;" +
"\n";
266 generatedDeclarations+= headerIndent +
"\t" +
"}" +
"\n";
267 generatedDeclarations+= headerIndent +
"\t" +
"for (auto& scriptVariableIt: scriptState.variables) delete scriptVariableIt.second;" +
"\n";
268 generatedDeclarations+= headerIndent +
"\t" +
"scriptState.variables.clear();" +
"\n";
269 generatedDeclarations+= headerIndent +
"\t" +
"scriptState.running = true;" +
"\n";
270 generatedDeclarations+= headerIndent +
"\t" +
"registerVariables();" +
"\n";
271 generatedDeclarations+= headerIndent +
"\t" +
"resetScriptExecutationState(" + to_string(initializeScriptIdx) +
", STATE_NEXT_STATEMENT);" +
"\n";
272 generatedDeclarations+= headerIndent +
"}" +
"\n";
273 generatedDeclarations+= headerIndent +
"inline void execute() override {" +
"\n";
274 generatedDeclarations+= headerIndent +
"\t" +
"if (native == false) {" +
"\n";
275 generatedDeclarations+= headerIndent +
"\t" +
"\t" +
"MiniScript::execute();" +
"\n";
276 generatedDeclarations+= headerIndent +
"\t" +
"\t" +
"return;" +
"\n";
277 generatedDeclarations+= headerIndent +
"\t" +
"}" +
"\n";
278 generatedDeclarations+= headerIndent +
"\t" +
"if (scriptState.running == false) return;" +
"\n";
279 generatedDeclarations+= headerIndent +
"\t" +
"// execute while having statements to be processed" +
"\n";
280 generatedDeclarations+= headerIndent +
"\t" +
"if (scriptState.state.state == STATE_NEXT_STATEMENT) {" +
"\n";
281 generatedDeclarations+= generatedExecuteCode;
282 generatedDeclarations+= headerIndent +
"\t" +
"}" +
"\n";
283 generatedDeclarations+= headerIndent +
"\t" +
"if (scriptState.running == false) return;" +
"\n";
284 generatedDeclarations+= headerIndent +
"\t" +
"executeStateMachine();" +
"\n";
285 generatedDeclarations+= headerIndent +
"};" +
"\n";
286 generatedDeclarations+=
"\n";
287 generatedDeclarations+= string() +
"protected:" +
"\n";
288 generatedDeclarations+= headerIndent +
"// overridden methods" +
"\n";
289 generatedDeclarations+= headerIndent +
"void initializeNative() override;" +
"\n";
290 generatedDeclarations+= headerIndent +
"int determineScriptIdxToStart() override;" +
"\n";
291 generatedDeclarations+= headerIndent +
"int determineNamedScriptIdxToStart() override;" +
"\n";
292 generatedDeclarations+=
"\n";
295 string emitDefinition;
296 emitDefinition+=
"void " + miniScriptClassName +
"::emit(const string& condition) {" +
"\n";
297 emitDefinition+= methodCodeIndent +
"if (native == false) {" +
"\n";
298 emitDefinition+= methodCodeIndent +
"\t" +
"MiniScript::emit(condition);" +
"\n";
299 emitDefinition+= methodCodeIndent +
"\t" +
"return;" +
"\n";
300 emitDefinition+= methodCodeIndent +
"}" +
"\n";
301 string generatedDefinitions =
"\n";
302 string initializeNativeDefinition;
303 initializeNativeDefinition+=
"void " + miniScriptClassName +
"::initializeNative() {" +
"\n";
304 initializeNativeDefinition+= methodCodeIndent +
"setNative(true);" +
"\n";
305 initializeNativeDefinition+= methodCodeIndent +
"setHash(\"" + scriptInstance->
getHash() +
"\");" +
"\n";
306 initializeNativeDefinition+= methodCodeIndent +
"setNativeScripts(" +
"\n";
307 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"{" +
"\n";
310 for (
auto& script: scripts) {
311 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"{" +
"\n";
312 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
".conditionType = " + (script.conditionType == MiniScript::Script::CONDITIONTYPE_ON?
"Script::CONDITIONTYPE_ON":
"Script::CONDITIONTYPE_ONENABLED") +
"," +
"\n";
313 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
".line = " + to_string(script.line) +
"," +
"\n";
314 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
".condition = \"" + StringTools::replace(script.condition,
"\"",
"\\\"") +
"\"," +
"\n";
315 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
".name = \"" + script.name +
"\"," +
"\n";
316 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
".emitCondition = " + (script.emitCondition ==
true?
"true":
"false") +
"," +
"\n";
317 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
".statements = {" +
"\n";
318 auto statementIdx = 0;
319 for (
auto& statement: script.statements) {
320 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
"\t" +
"{" +
"\n";
321 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
"\t" +
"\t" +
".line = " + to_string(statement.line) +
"," +
"\n";
322 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
"\t" +
"\t" +
".statementIdx = " + to_string(statement.statementIdx) +
"," +
"\n";
323 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
"\t" +
"\t" +
".statement = \"" + StringTools::replace(statement.statement,
"\"",
"\\\"") +
"\"," +
"\n";
324 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
"\t" +
"\t" +
".gotoStatementIdx = " + to_string(statement.gotoStatementIdx) +
"\n";
325 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
"\t" +
"}" + (statementIdx < script.statements.size() - 1?
",":
"") +
"\n";
328 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"\t" +
"}" +
"\n";
329 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"\t" +
"}" + (scriptIdx < scripts.size() - 1?
",":
"") +
"\n";
333 initializeNativeDefinition+= methodCodeIndent +
"\t" +
"}" +
"\n";
334 initializeNativeDefinition+= methodCodeIndent +
");" +
"\n";
335 initializeNativeDefinition+= string() +
"}" +
"\n";
338 string generatedDetermineScriptIdxToStartDefinition =
"\n";
339 generatedDetermineScriptIdxToStartDefinition+=
"int " + miniScriptClassName +
"::determineScriptIdxToStart() {" +
"\n";
340 generatedDetermineScriptIdxToStartDefinition+= string() +
"\t" +
"if (native == false) return MiniScript::determineScriptIdxToStart();" +
"\n";
341 generatedDetermineScriptIdxToStartDefinition+= string() +
"\t" +
"auto miniScript = this;" +
"\n";
342 string generatedDetermineNamedScriptIdxToStartDefinition =
"\n";
343 generatedDetermineNamedScriptIdxToStartDefinition+=
"int " + miniScriptClassName +
"::determineNamedScriptIdxToStart() {" +
"\n";
344 generatedDetermineNamedScriptIdxToStartDefinition+= string() +
"\t" +
"if (native == false) return MiniScript::determineNamedScriptIdxToStart();" +
"\n";
345 generatedDetermineNamedScriptIdxToStartDefinition+= string() +
"\t" +
"auto miniScript = this;" +
"\n";
346 generatedDetermineNamedScriptIdxToStartDefinition+= string() +
"\t" +
"for (auto& enabledNamedCondition: scriptState.enabledNamedConditions) {" +
"\n";
349 for (
auto& script: scripts) {
352 (script.conditionType == MiniScript::Script::CONDITIONTYPE_ON?
"on_":
"on_enabled_") +
353 (script.name.empty() ==
false?script.name:(
354 StringTools::regexMatch(script.condition,
"[a-zA-Z0-9]+") ==
true?
361 (script.name.empty() ==
false?script.name:(
362 StringTools::regexMatch(script.condition,
"[a-zA-Z0-9]+") ==
true?
369 if (script.conditionType == MiniScript::Script::CONDITIONTYPE_ON && StringTools::regexMatch(script.condition,
"[a-zA-Z0-9]+") ==
true) {
370 string emitDefinitionIndent =
"\t";
371 emitDefinition+= emitDefinitionIndent +
"if (condition == \"" + emitName +
"\") {" +
"\n";
372 emitDefinition+= emitDefinitionIndent +
"\t" + methodName +
"(-1);" +
"\n";
373 emitDefinition+= emitDefinitionIndent +
"\t" +
"return;" +
"\n";
374 emitDefinition+= emitDefinitionIndent +
"}" +
"\n";
378 generatedDeclarations+= headerIndent +
"/**" +
"\n";
379 generatedDeclarations+= headerIndent +
" * Miniscript transpilation of: " + (script.conditionType == MiniScript::Script::CONDITIONTYPE_ON?
"ON":
"ON-ENABLED") +
": " + script.condition + (script.name.empty() ==
false?
" (" + script.name +
")":
"") +
"\n";
380 generatedDeclarations+= headerIndent +
" * @param miniScriptGotoStatementIdx MiniScript goto statement index" +
"\n";
381 generatedDeclarations+= headerIndent +
" */" +
"\n";
382 generatedDeclarations+= headerIndent +
"void " + methodName +
"(int miniScriptGotoStatementIdx);" +
"\n";
383 generatedDeclarations+=
"\n";
386 generatedDefinitions+=
"void " + miniScriptClassName +
"::" + methodName +
"(int miniScriptGotoStatementIdx) {" +
"\n";
387 string generatedSubCode;
388 scriptInstance->
transpile(generatedSubCode, scriptIdx, methodCodeMap);
389 generatedDefinitions+= generatedSubCode;
390 generatedDefinitions+= string() +
"}" +
"\n\n";
393 if (StringTools::regexMatch(script.condition,
"[a-zA-Z0-9]+") ==
false) {
394 if (script.conditionType == MiniScript::Script::CONDITIONTYPE_ONENABLED) {
395 generatedDetermineNamedScriptIdxToStartDefinition+= string() +
"\n";
396 generatedDetermineNamedScriptIdxToStartDefinition+= string() +
"\t" +
"\t" +
"// next statements belong to tested enabled named condition with name \"" + script.name +
"\"" +
"\n";
397 generatedDetermineNamedScriptIdxToStartDefinition+= string() +
"\t" +
"\t" +
"if (enabledNamedCondition == \"" + script.name +
"\")" +
"\n";
400 script.conditionType == MiniScript::Script::CONDITIONTYPE_ON?generatedDetermineScriptIdxToStartDefinition:generatedDetermineNamedScriptIdxToStartDefinition,
404 "bool returnValueBool; returnValue.getBooleanValue(returnValueBool); if (returnValueBool == true) return " + to_string(scriptIdx) +
";",
405 script.conditionType == MiniScript::Script::CONDITIONTYPE_ONENABLED?1:0
415 generatedDetermineScriptIdxToStartDefinition+=
"\n";
416 generatedDetermineScriptIdxToStartDefinition+= methodCodeIndent +
"//" +
"\n";
417 generatedDetermineScriptIdxToStartDefinition+= methodCodeIndent +
"return " + to_string(nothingScriptIdx) +
";" +
"\n";
418 generatedDetermineScriptIdxToStartDefinition+= string() +
"}" +
"\n";
420 generatedDetermineNamedScriptIdxToStartDefinition+= methodCodeIndent +
"}" +
"\n";
421 generatedDetermineNamedScriptIdxToStartDefinition+=
"\n";
422 generatedDetermineNamedScriptIdxToStartDefinition+= methodCodeIndent +
"//" +
"\n";
423 generatedDetermineNamedScriptIdxToStartDefinition+= methodCodeIndent +
"return -1;" +
"\n";
424 generatedDetermineNamedScriptIdxToStartDefinition+= string() +
"}" +
"\n";
427 emitDefinition+= string() +
"}" +
"\n";
430 generatedDefinitions = initializeNativeDefinition + generatedDetermineScriptIdxToStartDefinition + generatedDetermineNamedScriptIdxToStartDefinition +
"\n" + emitDefinition + generatedDefinitions;
434 vector<string> miniScriptClass;
435 vector<string> miniScriptClassNew;
436 FileSystem::getInstance()->getContentAsStringArray(Tools::getPathName(miniscriptTranspilationFileName), Tools::getFileName(miniscriptTranspilationFileName), miniScriptClass);
438 auto injectedGeneratedCode =
false;
439 for (
auto i = 0; i < miniScriptClass.size(); i++) {
440 auto& line = miniScriptClass[i];
441 auto trimmedLine = StringTools::trim(line);
442 if (StringTools::startsWith(trimmedLine,
"//") ==
true) {
443 if (reject ==
false) miniScriptClassNew.push_back(line);
446 if (trimmedLine ==
"/*__MINISCRIPT_TRANSPILEDMINISCRIPTCODE_DEFINITIONS_START__*/") {
448 miniScriptClassNew.push_back(line);
450 if (trimmedLine ==
"/*__MINISCRIPT_TRANSPILEDMINISCRIPTCODE_DEFINITIONS_END__*/") {
452 injectedGeneratedCode =
true;
453 miniScriptClassNew.push_back(generatedDefinitions);
454 miniScriptClassNew.push_back(line);
456 if (reject ==
false) miniScriptClassNew.push_back(line);
461 if (injectedGeneratedCode ==
false) {
462 Console::println(scriptFileName +
": Could not inject generated C++ code, are you missing the /*__MINISCRIPT_TRANSPILEDMINISCRIPTCODE_DEFINITIONS_START__*/ and /*__MINISCRIPT_TRANSPILEDMINISCRIPTCODE_DEFINITIONS_END__*/ markers in file " + miniscriptTranspilationFileName +
"?");
465 FileSystem::getInstance()->setContentFromStringArray(
466 Tools::getPathName(miniscriptTranspilationFileName),
467 Tools::getFileName(miniscriptTranspilationFileName),
471 Console::println(scriptFileName +
": Injected generated C++ code in file " + miniscriptTranspilationFileName +
". Dont forget to rebuild your sources.");
478 vector<string> miniScriptClassHeader;
479 vector<string> miniScriptClassHeaderNew;
480 auto miniscriptTranspilationHeaderFileName = Tools::getPathName(miniscriptTranspilationFileName) +
"/" + Tools::removeFileEnding(Tools::getFileName(miniscriptTranspilationFileName)) +
".h";
481 FileSystem::getInstance()->getContentAsStringArray(Tools::getPathName(miniscriptTranspilationHeaderFileName), Tools::getFileName(miniscriptTranspilationHeaderFileName), miniScriptClassHeader);
483 auto injectedGeneratedCode =
false;
484 for (
auto i = 0; i < miniScriptClassHeader.size(); i++) {
485 auto& line = miniScriptClassHeader[i];
486 auto trimmedLine = StringTools::trim(line);
487 if (StringTools::startsWith(trimmedLine,
"//") ==
true) {
488 if (reject ==
false) miniScriptClassHeaderNew.push_back(line);
491 if (trimmedLine ==
"/*__MINISCRIPT_TRANSPILEDMINISCRIPTCODE_DECLARATIONS_START__*/") {
493 miniScriptClassHeaderNew.push_back(line);
495 if (trimmedLine ==
"/*__MINISCRIPT_TRANSPILEDMINISCRIPTCODE_DECLARATIONS_END__*/") {
497 injectedGeneratedCode =
true;
498 miniScriptClassHeaderNew.push_back(generatedDeclarations);
499 miniScriptClassHeaderNew.push_back(line);
501 if (reject ==
false) miniScriptClassHeaderNew.push_back(line);
506 if (injectedGeneratedCode ==
false) {
507 Console::println(scriptFileName +
": Could not inject generated C++ code, are you missing the /*__MINISCRIPT_TRANSPILEDMINISCRIPTCODE_DECLARATIONS_START__*/ and /*__MINISCRIPT_TRANSPILEDMINISCRIPTCODE_DECLARATIONS_END__*/ markers in file " + miniscriptTranspilationFileName +
"?");
510 FileSystem::getInstance()->setContentFromStringArray(
511 Tools::getPathName(miniscriptTranspilationHeaderFileName),
512 Tools::getFileName(miniscriptTranspilationHeaderFileName),
513 miniScriptClassHeaderNew
516 Console::println(scriptFileName +
": Injected generated C++ code in header file " + miniscriptTranspilationHeaderFileName +
". Dont forget to rebuild your sources.");
523 Console::println(
string(
"miniscripttranspiler ") + Version::getVersion());
524 Console::println(Version::getCopyright());
529 Console::println(
"Usage: miniscripttranspiler path_to_script_file path_to_cpp_miniscript_transpilation_file [path_to_cpp_miniscript_extension_file1] [path_to_cpp_miniscript_extension_fileN]");
530 Application::exit(1);
533 vector<string> miniScriptExtensionFileNames;
534 for (
auto i = 3; i < argc; i++) miniScriptExtensionFileNames.push_back(argv[i]);
537 processFile(argv[1], argv[2], miniScriptExtensionFileNames);
Application base class, please make sure to allocate application on heap to have correct application ...
File system singleton class.
bool transpile(string &generatedCode, int scriptIdx, const unordered_map< string, vector< string > > &methodCodeMap)
Transpile a script statement.
void loadScript(const string &pathName, const string &fileName)
Load script.
bool transpileScriptCondition(string &generatedCode, int scriptIdx, const unordered_map< string, vector< string > > &methodCodeMap, const string &returnValue, const string &injectCode, int depth=0)
Transpile a script condition.
const string getInformation()
Get miniscript instance information.
const vector< Script > & getScripts()
int main(int argc, char **argv)
void gatherMethodCode(const vector< string > &miniScriptExtensionsCode, const string &className, int registerLine, unordered_map< string, vector< string > > &methodCodeMap)
void processFile(const string &scriptFileName, const string &miniscriptTranspilationFileName, const vector< string > &miniScriptExtensionFileNames)
std::exception Exception
Exception base class.