File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -1327,12 +1327,35 @@ def children(self) -> List[TypeBuilder]:
13271327class StructureMember :
13281328 type : 'Type'
13291329 name : str
1330- offset : int
1330+ offset : int # Offset (in bytes) from the start of the structure. Use `bit_offset` for bitwise fields.
13311331 access : MemberAccess = MemberAccess .NoAccess
13321332 scope : MemberScope = MemberScope .NoScope
1333- bit_position : int = 0
1333+ bit_position : int = 0 # Relative to the starting byte at `offset`, must be in range 0 to 7.
13341334 bit_width : int = 0
13351335
1336+ @property
1337+ def bit_offset (self ) -> int :
1338+ """
1339+ Total bit offset from the start of the structure.
1340+
1341+ Computed as: offset * 8 + bit_position.
1342+ """
1343+ return (self .offset * 8 ) + self .bit_position
1344+
1345+ @bit_offset .setter
1346+ def bit_offset (self , value : int ) -> None :
1347+ """
1348+ Set the total bit offset from the start of the structure.
1349+
1350+ This will automatically set:
1351+ - offset to value // 8 (byte offset)
1352+ - bit_position to value % 8 (bit within the byte offset)
1353+ """
1354+ if value < 0 :
1355+ raise ValueError ("bit_offset must be non-negative" )
1356+ self .offset = value // 8
1357+ self .bit_position = value % 8
1358+
13361359 def __repr__ (self ):
13371360 if len (self .name ) == 0 :
13381361 base = f"<member: { self .type } , offset { self .offset :#x} >"
You can’t perform that action at this time.
0 commit comments