From 91642d37e527710221183996e05eecc7e3a2004e Mon Sep 17 00:00:00 2001 From: Schamper <1254028+Schamper@users.noreply.github.com> Date: Mon, 4 Sep 2023 22:35:04 +0200 Subject: [PATCH] Address comments --- dissect/cstruct/compiler.py | 17 ----------------- dissect/cstruct/cstruct.py | 2 -- 2 files changed, 19 deletions(-) diff --git a/dissect/cstruct/compiler.py b/dissect/cstruct/compiler.py index a56dac8..9ad3491 100644 --- a/dissect/cstruct/compiler.py +++ b/dissect/cstruct/compiler.py @@ -163,7 +163,6 @@ def align_to_field(field: Field) -> Iterator[str]: raise TypeError(f"Unsupported type for compiler: {field_type}") if prev_was_bits and not field.bits: - # Reset the bit reader yield "bit_reader.reset()" prev_was_bits = False bits_remaining = 0 @@ -177,26 +176,16 @@ def align_to_field(field: Field) -> Iterator[str]: # Sub structure if issubclass(field_type, Structure): - # Flush the current block yield from flush() - - # Align if needed yield from align_to_field(field) - - # Yield a structure block yield from self._generate_structure(field) # Array of structures and multi-dimensional arrays elif issubclass(field_type, (Array, CharArray, WcharArray)) and ( issubclass(field_type.type, Structure) or isinstance(field_type.type, ArrayMetaType) or is_dynamic ): - # Flush the current block yield from flush() - - # Align if needed yield from align_to_field(field) - - # Yield a complex array block yield from self._generate_array(field) # Bit fields @@ -209,13 +198,8 @@ def align_to_field(field: Field) -> Iterator[str]: bits_remaining = (size * 8) - field.bits bits_rollover = True - # Flush the current block yield from flush() - - # Align if needed yield from align_to_field(field) - - # Yield a bit read block yield from self._generate_bits(field) # Everything else - basic and composite types (and arrays of them) @@ -231,7 +215,6 @@ def align_to_field(field: Field) -> Iterator[str]: yield from flush() if self.align: - # Align the stream yield f"stream.seek(-stream.tell() & (cls.alignment - 1), {io.SEEK_CUR})" def _generate_structure(self, field: Field) -> Iterator[str]: diff --git a/dissect/cstruct/cstruct.py b/dissect/cstruct/cstruct.py index 87a614c..2ad5549 100644 --- a/dissect/cstruct/cstruct.py +++ b/dissect/cstruct/cstruct.py @@ -209,8 +209,6 @@ def add_type(self, name: str, type_: MetaType, replace: bool = False) -> None: self.typedefs[name] = type_ - addtype = add_type - def load(self, definition: str, deftype: int = None, **kwargs) -> None: """Parse structures from the given definitions using the given definition type.