class RepeatUntilExcluding(Subconstruct):
- """ A version of construct's RepeatUntil that doesn't include the last
+ """ A version of construct's RepeatUntil that doesn't include the last
element (which casued the repeat to exit) in the return value.
-
+
Only parsing is currently implemented.
-
+
P.S. removed some code duplication
"""
__slots__ = ["predicate"]
context_for_subcon = context
if self.subcon.conflags & self.FLAG_COPY_CONTEXT:
context_for_subcon = context.__copy__()
-
+
while True:
subobj = self.subcon._parse(stream, context_for_subcon)
if self.predicate(subobj, context):
raise NotImplementedError('no building')
def _sizeof(self, context):
raise SizeofError("can't calculate size")
-
def __init__(self, structs, stream, offset):
""" Create new abbreviation table. Parses the actual table from the
stream and stores it internally.
-
+
structs:
A DWARFStructs instance for parsing the data
-
+
stream, offset:
The stream and offset into the stream where this abbreviation
table lives.
self.structs = structs
self.stream = stream
self.offset = offset
-
+
self._abbrev_map = self._parse_abbrev_table()
def get_abbrev(self, code):
class AbbrevDecl(object):
- """ Wraps a parsed abbreviation declaration, exposing its fields with
+ """ Wraps a parsed abbreviation declaration, exposing its fields with
dict-like access, and adding some convenience methods.
-
+
The abbreviation declaration represents an "entry" that points to it.
"""
def __init__(self, code, decl):
self.code = code
self.decl = decl
-
+
def has_children(self):
""" Does the entry have children?
"""
"""
for attr_spec in self['attr_spec']:
yield attr_spec.name, attr_spec.form
-
+
def __getitem__(self, entry):
return self.decl[entry]
-