Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Schamper committed Sep 4, 2023
1 parent 4860562 commit 91642d3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
17 changes: 0 additions & 17 deletions dissect/cstruct/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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]:
Expand Down
2 changes: 0 additions & 2 deletions dissect/cstruct/cstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 91642d3

Please sign in to comment.