changeset 679:979963fd3725

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 16 May 2019 11:20:59 +0200
parents 6f10f9a6676a (current diff) a285a0c0a720 (diff)
children 0eb26f514ac5
files
diffstat 3 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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 <iostream>
+#include <cstdio>
+#include "emscripten/html5.h"
 
 namespace OrthancStone
 {
-      void StartupParametersBuilder::Clear()
+  void StartupParametersBuilder::Clear()
   {
     startupParameters_.clear();
   }
@@ -27,21 +29,27 @@
     std::vector<const char*> 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++;
     }
 
 
--- 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):
--- 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 %}    }