# HG changeset patch # User Sebastien Jodogne # Date 1557998459 -7200 # Node ID 979963fd3725ddb157cd909d568c027988053bd3 # Parent 6f10f9a6676a2a8232018d0f82697b9159e5ce0d# Parent a285a0c0a7205cadd79812072bd55fe5117607b1 merge diff -r 6f10f9a6676a -r 979963fd3725 Applications/Wasm/StartupParametersBuilder.cpp --- a/Applications/Wasm/StartupParametersBuilder.cpp Thu May 16 11:20:43 2019 +0200 +++ b/Applications/Wasm/StartupParametersBuilder.cpp Thu May 16 11:20:59 2019 +0200 @@ -1,9 +1,11 @@ #include "StartupParametersBuilder.h" #include +#include +#include "emscripten/html5.h" namespace OrthancStone { - void StartupParametersBuilder::Clear() + void StartupParametersBuilder::Clear() { startupParameters_.clear(); } @@ -27,21 +29,27 @@ std::vector argv(startupParameters_.size() + 1); int argCounter = 0; - argvStrings[argCounter] = "Toto.exe"; + argvStrings[argCounter] = "dummy.exe"; argv[argCounter] = argvStrings[argCounter].c_str(); argCounter++; - + std::string cmdLine = ""; for ( StartupParameters::const_iterator it = startupParameters_.begin(); it != startupParameters_.end(); it++) { - std::stringstream argSs; + std::stringstream argSs; - argSs << "--" << std::get<0>(*it); - if(std::get<1>(*it).length() > 0) - argSs << "=" << std::get<1>(*it); + argSs << "--" << std::get<0>(*it); + if(std::get<1>(*it).length() > 0) + argSs << "=" << std::get<1>(*it); + + argvStrings[argCounter] = argSs.str(); + cmdLine = cmdLine + " " + argvStrings[argCounter]; + std::cout << cmdLine << std::endl; + argv[argCounter] = argvStrings[argCounter].c_str(); + argCounter++; } diff -r 6f10f9a6676a -r 979963fd3725 Resources/CodeGeneration/stonegentool.py --- a/Resources/CodeGeneration/stonegentool.py Thu May 16 11:20:43 2019 +0200 +++ b/Resources/CodeGeneration/stonegentool.py Thu May 16 11:20:59 2019 +0200 @@ -186,6 +186,7 @@ RegisterTemplateFunction(template,NeedsCppConstruction) RegisterTemplateFunction(template, DefaultValueToTs) RegisterTemplateFunction(template, DefaultValueToCpp) + RegisterTemplateFunction(template, sorted) return template def MakeTemplateFromFile(templateFileName): @@ -532,7 +533,7 @@ if not (nextCh == ' ' or nextCh == '\n'): lineNumber = schemaText.count("\n",0,i) + 1 raise RuntimeError("Error at line " + str(lineNumber) + " in the schema: colons must be followed by a space or a newline!") - schema = yaml.load(schemaText) + schema = yaml.load(schemaText, Loader = yaml.SafeLoader) return schema def GetTemplatingDictFromSchemaFilename(fn): diff -r 6f10f9a6676a -r 979963fd3725 Resources/CodeGeneration/template.in.h.j2 --- a/Resources/CodeGeneration/template.in.h.j2 Thu May 16 11:20:43 2019 +0200 +++ b/Resources/CodeGeneration/template.in.h.j2 Thu May 16 11:20:59 2019 +0200 @@ -394,9 +394,9 @@ struct {{struct['name']}} { -{% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} {{CanonToCpp(struct['fields'][key]['type'])}} {{key}}; +{% if struct %}{% if struct['fields'] %}{% for key in sorted(struct['fields']) %} {{CanonToCpp(struct['fields'][key]['type'])}} {{key}}; {% endfor %}{% endif %}{% endif %} - {{struct['name']}}({% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%}{{CanonToCpp(struct['fields'][key]['type'])}} {{key}} = {% if struct['fields'][key]['defaultValue'] %}{{DefaultValueToCpp(rootName,enums,struct['fields'][key])}} {%else%} {{CanonToCpp(struct['fields'][key]['type'])}}() {%endif%} {{ ", " if not loop.last }}{% endfor %}{% endif %}{% endif %}) + {{struct['name']}}({% if struct %}{% if struct['fields'] %}{% for key in sorted(struct['fields']) %}{{CanonToCpp(struct['fields'][key]['type'])}} {{key}} = {% if struct['fields'][key]['defaultValue'] %}{{DefaultValueToCpp(rootName,enums,struct['fields'][key])}} {%else%} {{CanonToCpp(struct['fields'][key]['type'])}}() {%endif%} {{ ", " if not loop.last }}{% endfor %}{% endif %}{% endif %}) { {% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} this->{{key}} = {{key}}; {% endfor %}{% endif %}{% endif %} }