diff options
Diffstat (limited to 'tools/net')
-rw-r--r-- | tools/net/ynl/lib/nlspec.py | 8 | ||||
-rwxr-xr-x | tools/net/ynl/ynl-gen-c.py | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py index d04450c2a44a..dba70100124a 100644 --- a/tools/net/ynl/lib/nlspec.py +++ b/tools/net/ynl/lib/nlspec.py @@ -90,8 +90,8 @@ class SpecEnumEntry(SpecElement): def raw_value(self): return self.value - def user_value(self): - if self.enum_set['type'] == 'flags': + def user_value(self, as_flags=None): + if self.enum_set['type'] == 'flags' or as_flags: return 1 << self.value else: return self.value @@ -136,10 +136,10 @@ class SpecEnumSet(SpecElement): return True return False - def get_mask(self): + def get_mask(self, as_flags=None): mask = 0 for e in self.entries.values(): - mask += e.user_value() + mask += e.user_value(as_flags) return mask diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 972b87c7aaaf..cc2f8c945340 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -254,7 +254,8 @@ class TypeScalar(Type): def _attr_policy(self, policy): if 'flags-mask' in self.checks or self.is_bitfield: if self.is_bitfield: - mask = self.family.consts[self.attr['enum']].get_mask() + enum = self.family.consts[self.attr['enum']] + mask = enum.get_mask(as_flags=True) else: flags = self.family.consts[self.checks['flags-mask']] flag_cnt = len(flags['entries']) |