Recursively add offsets of Struct.field_from_path()

This commit is contained in:
Sybren A. Stüvel
2018-02-23 12:24:50 +01:00
parent 480b82337e
commit 8d32ab513f
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -160,9 +160,6 @@ class Struct:
raise KeyError('%r has no field %r, only %r' %
(self, name, sorted(self._fields_by_name.keys())))
if name_tail:
return field.dna_type.field_from_path(pointer_size, name_tail)
offset = field.offset
if index:
if field.name.is_pointer:
@@ -174,6 +171,10 @@ class Struct:
(path, field.dna_type))
offset += index_offset
if name_tail:
subval, suboff = field.dna_type.field_from_path(pointer_size, name_tail)
return subval, suboff + offset
return field, offset
def field_get(self,