diff options
Diffstat (limited to 'ddl/templates/data.cs.ede')
-rw-r--r-- | ddl/templates/data.cs.ede | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/ddl/templates/data.cs.ede b/ddl/templates/data.cs.ede index 74e0dac..08dc42c 100644 --- a/ddl/templates/data.cs.ede +++ b/ddl/templates/data.cs.ede | |||
@@ -95,22 +95,27 @@ namespace {{ moduleName }} { | |||
95 | {% for t in definitions %} | 95 | {% for t in definitions %} |
96 | case Type.{{ t.value.dataName }}: { | 96 | case Type.{{ t.value.dataName }}: { |
97 | string tag = (string)obj["tag"]; | 97 | string tag = (string)obj["tag"]; |
98 | {% if t.value | hasEnumConstructor %} | ||
98 | {{ t.value.dataName }}.Tag tagType; | 99 | {{ t.value.dataName }}.Tag tagType; |
100 | {% endif %} | ||
101 | switch (tag) { | ||
99 | {% for c in t.value.constructors %} | 102 | {% for c in t.value.constructors %} |
100 | {% if !c.first %}else {% endif %}if (tag == "{{ c.value.name }}") { | 103 | case "{{ c.value.name }}":{% if (c.value.fields | empty) %} tagType = {{ t.value.dataName }}.Tag.{{ c.value.name }}; break; |
101 | tagType = {{ t.value.dataName }}.Tag.{{ c.value.name }}; | 104 | {% else %} { |
102 | {% if !(c.value.fields | empty) %} | 105 | data.{{ c.value.name }} tv = new data.{{ c.value.name }}();{% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %} |
103 | data.{{ c.value.name }} tv = new data.{{ c.value.name }}();{% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %} | 106 | tv.{{ f.value.fieldName }} = ({{ f.value.fieldType | csType }})fromJSON(Type.{{ f.value.fieldType | typeEnum }},obj["{{ f.value.fieldName }}"]);{% else %} |
104 | tv.{{ f.value.fieldName }} = ({{ f.value.fieldType | csType }})fromJSON(Type.{{ f.value.fieldType | typeEnum }},obj["{{ f.value.fieldName }}"]);{% else %} | 107 | tv._{{ f.index0 }} = ({{ f.value.fieldType | csType }})fromJSON(Type.{{ f.value.fieldType | typeEnum }},obj["arg{{ f.index0 }}"]);{% endif %}{% endfor %} |
105 | tv._{{ f.index0 }} = ({{ f.value.fieldType | csType }})fromJSON(Type.{{ f.value.fieldType | typeEnum }},obj["arg{{ f.index0 }}"]);{% endif %}{% endfor %} | 108 | return tv; |
106 | return tv; | 109 | } |
107 | {% endif %} | 110 | {% endif %} |
108 | } | ||
109 | {% endfor %} | 111 | {% endfor %} |
110 | else throw new Exception("unknown constructor: " + tag); | 112 | default: throw new Exception("unknown constructor: " + tag); |
113 | } | ||
114 | {% if t.value | hasEnumConstructor %} | ||
111 | {{ t.value.dataName }} o = new {{ t.value.dataName }}(); | 115 | {{ t.value.dataName }} o = new {{ t.value.dataName }}(); |
112 | o.tag = tagType; | 116 | o.tag = tagType; |
113 | return o; | 117 | return o; |
118 | {% endif %} | ||
114 | } | 119 | } |
115 | {% endfor %} | 120 | {% endfor %} |
116 | } | 121 | } |