diff --git a/tpl/macro.twig b/tpl/macro.twig index 4b1ff80..078adf5 100644 --- a/tpl/macro.twig +++ b/tpl/macro.twig @@ -92,7 +92,9 @@ func (self *{{o.name}}) WriteFields(writer meta.Writer) error { return nil } -%ext_methods% +{% if has_token(o, 'bitfields') %} +{{_self.bitfields_methods(o)}} +{% endif %} {% if has_token(o, 'statist') %} {{_self.stats_methods(meta, o)}} @@ -212,6 +214,24 @@ self.fieldsMask = meta.FieldsMask{} {% endmacro %} +{% macro bitfields_methods(o) %} +func(self *{{o.name}}) HasValue(index uint64) bool { + return self.fieldsMask.FieldChanged(index) +} + +func(self *{{o.name}}) SetFieldChanged(index uint64) { + self.fieldsMask.SetFieldChanged(index) +} + +func(self *{{o.name}}) IsMaskFilled() bool { + return self.fieldsMask.IsFilled() +} + +func(self *{{o.name}}) GetMask() meta.FieldsMask { + return self.fieldsMask +} +{% endmacro %} + {% macro stats_methods(meta, o) %} func (self *{{o.name}}) Table() string {