types: fix various missing to_type() calls and misc errors
This commit is contained in:
parent
00892cc3ba
commit
8e4a66c6d0
|
@ -185,7 +185,7 @@ class Terminated(G[T], Wrapper[T]):
|
|||
tstream = TerminatedStream(stream, terminator, included, blocksize=self.blocksize)
|
||||
value = super().parse(context, tstream)
|
||||
if required and tstream._end_pos is None:
|
||||
raise IOError(f'terminator {terminator} not found in stream')
|
||||
raise EOFError(f'terminator {terminator} not found in stream')
|
||||
return value
|
||||
|
||||
def dump(self, context: Context, stream: Stream, value: T) -> None:
|
||||
|
@ -249,7 +249,7 @@ class Ref(G[T], Wrapper[T]):
|
|||
def offsetof(self, context: Context, path: Sequence[PathElement], value: O[T]) -> O[Pos]:
|
||||
segment = context.peek(self.segment) or context.params.segments['refs']
|
||||
with context.enter_segment(segment):
|
||||
return super().contextof(context, path, value)
|
||||
return super().offsetof(context, path, value)
|
||||
|
||||
def __str__(self) -> str:
|
||||
indicator = {os.SEEK_SET: '', os.SEEK_CUR: '+', os.SEEK_END: '-'}.get(self.whence, self.whence)
|
||||
|
|
|
@ -59,7 +59,7 @@ class Arr(G[T], Type[List[T]]):
|
|||
for i, elem in enumerate(value):
|
||||
c = to_type(child)
|
||||
with context.enter(i, c):
|
||||
context.dump(child, stream, elem)
|
||||
context.dump(c, stream, elem)
|
||||
|
||||
context.put(self.count, len(value))
|
||||
|
||||
|
|
|
@ -142,8 +142,9 @@ class StructType(G[T], Type[T]):
|
|||
elem = getattr(value, field)
|
||||
else:
|
||||
elem = None
|
||||
with context.enter(field, child):
|
||||
size = context.sizeof(child, elem)
|
||||
c = to_type(child, field)
|
||||
with context.enter(field, c):
|
||||
size = context.sizeof(c, elem)
|
||||
sizes.append(size)
|
||||
return sizes
|
||||
|
||||
|
|
Loading…
Reference in New Issue