mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-25 16:10:16 +00:00
m1n1.constructutils: Improve json serialization of Value types
Signed-off-by: Asahi Lina <lina@asahilina.net>
This commit is contained in:
parent
311385e645
commit
6a149e5028
1 changed files with 6 additions and 1 deletions
|
@ -599,7 +599,11 @@ class ConstructClass(ConstructClassBase, Container):
|
|||
for k in list(self):
|
||||
if k.startswith("_"):
|
||||
continue
|
||||
yield k, self[k]
|
||||
v = self[k]
|
||||
if getattr(v, "HAS_VALUE", None):
|
||||
yield k, v.value
|
||||
else:
|
||||
yield k, v
|
||||
|
||||
def addrof(self, name):
|
||||
return self._addr + self._off[name][0]
|
||||
|
@ -724,6 +728,7 @@ class ConstructValueClass(ConstructClassBase):
|
|||
|
||||
the value is stored as .value
|
||||
"""
|
||||
HAS_VALUE = True
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.value == other.value
|
||||
|
|
Loading…
Reference in a new issue