Mercurial > hg > orthanc-stone
diff Resources/CodeGeneration/template.in.ts.j2 @ 628:84af39146e76 am-dev
CodeGeneration: support default values
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Wed, 08 May 2019 16:32:57 +0200 |
parents | 17106b29ed6d |
children |
line wrap: on
line diff
--- a/Resources/CodeGeneration/template.in.ts.j2 Wed May 08 10:51:41 2019 +0200 +++ b/Resources/CodeGeneration/template.in.ts.j2 Wed May 08 16:32:57 2019 +0200 @@ -72,10 +72,12 @@ {% for struct in structs%}export class {{struct['name']}} { -{% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} {{key}}:{{CanonToTs(struct['fields'][key])}}; +{% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%} {{key}}:{{CanonToTs(struct['fields'][key]['type'])}}; {% endfor %}{% endif %}{% endif %} constructor() { -{% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%}{% if NeedsTsConstruction(enums,CanonToTs(struct['fields'][key])) %} this.{{key}} = new {{CanonToTs(struct['fields'][key])}}(); +{% if struct %}{% if struct['fields'] %}{% for key in struct['fields']%}{% if NeedsTsConstruction(enums,CanonToTs(struct['fields'][key]['type'])) %} this.{{key}} = new {{CanonToTs(struct['fields'][key]['type'])}}(); +{% endif %} +{% if struct['fields'][key]['defaultValue'] %} this.{{key}} = {{DefaultValueToTs(enums,struct['fields'][key])}}; {% endif %}{% endfor %}{% endif %}{% endif %} } public StoneSerialize(): string {