Tuning codegen

This commit is contained in:
Pavel Shevaev 2022-12-08 19:45:55 +03:00
parent a0461bf3a3
commit 892158b2e0
1 changed files with 10 additions and 10 deletions

View File

@ -122,25 +122,25 @@ func (self *{{o.name}}) WriteFields(writer meta.Writer) error {
{% macro props_map(tokens) %}
map[string]string{
{% for k,v in tokens %}
{%- for k,v in tokens -%}
"{{k}}" : "{{v|replace({'"' : '\\"'})}}",
{%- endfor ~%}
{%- endfor -%}
}
{% endmacro %}
{% macro struct_fields_names(o) %}
[]string{
{% for f in get_all_fields(o) ~%}
{%- for f in get_all_fields(o) -%}
"{{f.name}}",
{%- endfor ~%}
{%- endfor -%}
}
{% endmacro %}
{% macro struct_fields_props(o) %}
map[string]map[string]string{
{% for f in get_all_fields(o) ~%}
{%- for f in get_all_fields(o) -%}
"{{f.name|ucfirst}}" : {{_self.props_map(f.tokens)}},
{%- endfor ~%}
{%- endfor -%}
}
{% endmacro %}
@ -192,8 +192,8 @@ self.fieldsMask = meta.FieldsMask{}
return err
}
if _cont_size < {{o.fields|length - count_optional(o.fields)}} {
_cont_size = {{o.fields|length - count_optional(o.fields)}}
if _cont_size < {{(o.fields|length) - count_optional(o.fields)}} {
_cont_size = {{(o.fields|length) - count_optional(o.fields)}}
}
{%- if o.parent ~%}
@ -373,13 +373,13 @@ func New{{o.name}}ByName(name string) ({{o.name}}, error) {
{% endmacro %}
{% macro enum_values_list(o) %}
{%- for v in o.values|sort ~%}
{%- for v in o.values|sort -%}
{{v}},
{%- endfor ~%}
{% endmacro %}
{% macro enum_values_map(o) %}
{%- for k,v in o.values ~%}
{%- for k,v in o.values -%}
"{{k}}" : {{v}},
{%- endfor ~%}
{% endmacro %}