def visit_array_struct(self, struct, attr, meta): for s in getattr(struct, attr).flatten(): pos0 = self.pos accept(s, self) if meta["__has_fixedSizeInBytes"]: assert self.pos - pos0 <= meta["fixedSizeInBytes"]() self.pos = pos0 + meta["fixedSizeInBytes"]()
def visit_scalar_struct(self, struct, attr, meta): pos0 = self.pos accept(getattr(struct, attr), self) if meta["__has_fixedSizeInBytes"]: assert self.pos - pos0 <= meta["fixedSizeInBytes"]() # TODO fill with 0 self.pos = pos0 + meta["fixedSizeInBytes"]()
def visit_array_struct(self, struct, attr, meta): for s in getattr(struct, attr).flatten(): count0 = self.count accept(s, self) if meta["__has_fixedSizeInBytes"]: assert self.count - count0 <= meta["fixedSizeInBytes"]() self.count = count0 + meta["fixedSizeInBytes"]()
def printto(s, f, indent=0): v = print_visitor(f, indent + 2) f.write(" " * indent + f"{s.__class__.__name__}\n") accept(s, v)
def visit_array_struct(self, struct, attr, meta): for s in getattr(struct, attr).flatten(): accept(s, self)
def visit_scalar_struct(self, struct, attr, meta): accept(getattr(struct, attr), self)
def init_max_values(s): init_default_values(s) v = set_max_values_visitor() accept(s, v) set_length_field(s)
def count_bytes(s): v = count_bytes_visitor() accept(s, v) return v.count
def visit_scalar_struct(self, struct, attr, meta): count0 = self.count accept(getattr(struct, attr), self) if meta["__has_fixedSizeInBytes"]: assert self.count - count0 <= meta["fixedSizeInBytes"]() self.count = count0 + meta["fixedSizeInBytes"]()
def copy_from_mem(mem, s): v = copy_from_mem_visitor(mem) accept(s, v) return v.pos
def copy_to_mem(s, mem): v = copy_to_mem_visitor(mem) accept(s, v) return v.pos