Gradually adding support for all features

This commit is contained in:
Pavel Shevaev 2022-12-08 12:34:39 +03:00
parent d3473d961f
commit af0e8119c1
1 changed files with 77 additions and 2 deletions

View File

@ -11,10 +11,85 @@
{% endmacro %}
{% macro decl_struct(o) %}
//==============================
type {{o.name}} struct {
{% if o.parent %}
{{o.parent.name}}
{% endif %}
%fields%
}
var _{{o.name}}_class_props map[string]string
var _{{o.name}}_class_fields []string = %fields_names%
var _{{o.name}}_fields_props meta.ClassFieldsProps
func init() {
_{{o.name}}_class_props = %class_props%
_{{o.name}}_fields_props = %fields_props%
}
func {{o.name}}_CLASS_ID() uint32 {
return {{o.classid}}
}
type I{{o.name}} interface {
meta.IMetaStruct
Ptr{{o.name}}() *{{o.name}}
}
func (*{{o.name}}) CLASS_ID() uint32 {
return %class_id%
}
func (*{{o.name}}) CLASS_NAME() string {
return "{{o.name}}"
}
func (*{{o.name}}) CLASS_PROPS() *map[string]string {
return &_{{o.name}}_class_props
}
func (*{{o.name}}) CLASS_FIELDS() []string {
return _{{o.name}}_class_fields
}
func (*{{o.name}}) CLASS_FIELDS_PROPS() *meta.ClassFieldsProps {
return &_{{o.name}}_fields_props
}
//convenience getter
func Ptr{{o.name}}(m meta.IMetaStruct) *{{o.name}} {
p, ok := m.(I{{o.name}})
if !ok {
return nil
}
return p.Ptr{{o.name}}()
}
func (self *{{o.name}}) Ptr{{o.name}}() *{{o.name}} {
return self
}
func New{{o.name}}() *{{o.name}} {
item := new ({{o.name}})
item.Reset()
return item
}
func (self *{{o.name}}) Reset() {
%fields_reset%
}
func (self *{{o.name}}) Read(reader meta.Reader) error {
return meta.ReadStruct(reader, self, "")
}
func (self *{{o.name}}) ReadFields(reader meta.Reader) error {
self.Reset()
%read_buffer%
return nil
}
func (self *{{o.name}}) Write(writer meta.Writer) error {
return meta.WriteStruct(writer, self, "")
}
func (self *{{o.name}}) WriteFields(writer meta.Writer) error {
%write_buffer%
return nil
}
%ext_methods%
%analytics_methods%
{% endmacro %}
{% macro decl_enum(o) %}
//==============================
const (
{{_self.enum_consts(o)}}
)
@ -53,13 +128,13 @@ func New{{o.name}}ByName(name string) ({{o.name}}, error) {
{% endmacro %}
{% macro enum_values_list(o) %}
{%- for v in o.values -%}
{%- 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 %}