# HG changeset patch
# User Benjamin Golinvaux <bgo@osimis.io>
# Date 1557937782 -7200
# Node ID 5dd496343fad9be493698f9d9974db2f853adc12
# Parent  daf43666bbc2bd34d7a9f33d9cc97252b6d1ab94
Restored missing code + fixed key ordering when generating code

diff -r daf43666bbc2 -r 5dd496343fad Applications/Wasm/StartupParametersBuilder.cpp
--- a/Applications/Wasm/StartupParametersBuilder.cpp	Wed May 15 15:42:49 2019 +0200
+++ b/Applications/Wasm/StartupParametersBuilder.cpp	Wed May 15 18:29:42 2019 +0200
@@ -42,6 +42,11 @@
         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];
+        argv[argCounter] = argvStrings[argCounter].c_str();
+        argCounter++;
     }
 
 
diff -r daf43666bbc2 -r 5dd496343fad Resources/CodeGeneration/stonegentool.py
--- a/Resources/CodeGeneration/stonegentool.py	Wed May 15 15:42:49 2019 +0200
+++ b/Resources/CodeGeneration/stonegentool.py	Wed May 15 18:29:42 2019 +0200
@@ -186,6 +186,7 @@
   RegisterTemplateFunction(template,NeedsCppConstruction)
   RegisterTemplateFunction(template, DefaultValueToTs)
   RegisterTemplateFunction(template, DefaultValueToCpp)
+  RegisterTemplateFunction(template, sorted)
   return template
 
 def MakeTemplateFromFile(templateFileName):
@@ -533,6 +534,11 @@
           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)
+    print("*******************************************")
+    print("*******************************************")
+    print(schema["struct EventBase"])
+    print("*******************************************")
+    print("*******************************************")
     return schema
 
 def GetTemplatingDictFromSchemaFilename(fn):
diff -r daf43666bbc2 -r 5dd496343fad Resources/CodeGeneration/template.in.h.j2
--- a/Resources/CodeGeneration/template.in.h.j2	Wed May 15 15:42:49 2019 +0200
+++ b/Resources/CodeGeneration/template.in.h.j2	Wed May 15 18:29:42 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 %}    }