cjdrake / seqlogic

Sequential Logic
1 stars 0 forks source link

Struct cannot nest a Struct #13

Closed cjdrake closed 5 months ago

cjdrake commented 5 months ago

The code for struct field getter only works for Enum/Vec:

def _fget(name, cls, self):
    n = getattr(self, f"_{name}_size")
    nbits = _ITEM_BITS * n
    mask = (1 << nbits) - 1
    i = getattr(self, f"_{name}_base")
    data = (self._data >> (_ITEM_BITS * i)) & mask
    return cls(data)

This missing piece is the ability to cast data directly into a Struct. Using the constructor (as is) won't work.