From ec77833c37f5d9040cba640da8643716f4f206e2 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Thu, 8 Dec 2022 16:56:42 +0300 Subject: [PATCH] Gradually adding support for all features --- tpl/macro.twig | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 {