# Path: steel/common/meta.py
# class NameAwareOrderedDict(collections.OrderedDict):
# class DeclarativeMetaclass(type):
# class DeclarativeFieldMetaclass(type):
# class AttributeInstance:
#     def __setitem__(self, name, obj):
#     def __prepare__(cls, name, bases, **options):
#     def __new__(cls, name, bases, attrs, **options):
#     def __init__(cls, name, bases, attrs, **options):
#     def __prepare__(cls, name, bases, **options):
#     def __init__(cls, name, bases, attrs, **options):
#     def __call__(cls, *args, **kwargs):
#     def __init__(self, field, instance):
#     def __enter__(self):
#     def __exit__(self, exception_type, exception, traceback):
# 
# Path: steel/common/fields.py
# class Trigger:
# class BoundTrigger:
# class Field(metaclass=meta.DeclarativeFieldMetaclass):
# class FullyDecoded(Exception):
# class Condition:
#     def __init__(self):
#     def __call__(self, func):
#     def __get__(self, instance, owner):
#     def __init__(self, field, functions):
#     def __iter__(self):
#     def __call__(self, func):
#     def apply(self, *args, **kwargs):
#     def getter(self, func):
#     def setter(self, func):
#     def update_size(self, obj, value):
#     def __init__(self, label='', **kwargs):
#     def resolve(self, instance):
#     def read(self, obj):
#     def write(self, obj, value):
#     def set_name(self, name):
#     def attach_to_class(self, cls):
#     def validate(self, obj, value):
#     def _extract(self, instance):
#     def read_value(self, file):
#     def for_instance(self, instance):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __init__(self, bytes, value):
#     def __init__(self, a, b, compare):
#     def __enter__(self):
#     def __exit__(self, 	exception_type, exception, traceback):
#     def get_available_name(self, locals):
#     def set_name(self, name):
#     def attach_to_class(self, cls):
#     def for_instance(self, instance):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):


import collections
import io
from steel.common import meta, fields

    A customized BytesIO that raises an EOFError if more data was requested
    than is available in the data stream.
    """
    def read(self, size=None):
        data = super(EOFBytesIO, self).read(size)
        if size is not None and len(data) < size:
            raise EOFError
        return data


class StructureStreamer:
    def __init__(self, structure):
        self.structure = structure

    def parse(self, file):
        while 1:
            position = file.tell()
            try:
                value = self.structure(file)
                for name, field in self.structure._fields.items():
                    getattr(value, name)
            except Exception as e:
                if file.tell() == position:
                    # The file didn't move, so it must be at the end
                    break
                # Otherwise, something else went wrong
                raise e
            yield value



# Path: steel/common/meta.py
# class NameAwareOrderedDict(collections.OrderedDict):
# class DeclarativeMetaclass(type):
# class DeclarativeFieldMetaclass(type):
# class AttributeInstance:
#     def __setitem__(self, name, obj):
#     def __prepare__(cls, name, bases, **options):
#     def __new__(cls, name, bases, attrs, **options):
#     def __init__(cls, name, bases, attrs, **options):
#     def __prepare__(cls, name, bases, **options):
#     def __init__(cls, name, bases, attrs, **options):
#     def __call__(cls, *args, **kwargs):
#     def __init__(self, field, instance):
#     def __enter__(self):
#     def __exit__(self, exception_type, exception, traceback):
# 
# Path: steel/common/fields.py
# class Trigger:
# class BoundTrigger:
# class Field(metaclass=meta.DeclarativeFieldMetaclass):
# class FullyDecoded(Exception):
# class Condition:
#     def __init__(self):
#     def __call__(self, func):
#     def __get__(self, instance, owner):
#     def __init__(self, field, functions):
#     def __iter__(self):
#     def __call__(self, func):
#     def apply(self, *args, **kwargs):
#     def getter(self, func):
#     def setter(self, func):
#     def update_size(self, obj, value):
#     def __init__(self, label='', **kwargs):
#     def resolve(self, instance):
#     def read(self, obj):
#     def write(self, obj, value):
#     def set_name(self, name):
#     def attach_to_class(self, cls):
#     def validate(self, obj, value):
#     def _extract(self, instance):
#     def read_value(self, file):
#     def for_instance(self, instance):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __init__(self, bytes, value):
#     def __init__(self, a, b, compare):
#     def __enter__(self):
#     def __exit__(self, 	exception_type, exception, traceback):
#     def get_available_name(self, locals):
#     def set_name(self, name):
#     def attach_to_class(self, cls):
#     def for_instance(self, instance):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):


# Path: steel/base.py
import collections
import io
from steel.common import meta, fields

    A customized BytesIO that raises an EOFError if more data was requested
    than is available in the data stream.
    """
    def read(self, size=None):
        data = super(EOFBytesIO, self).read(size)
        if size is not None and len(data) < size:
            raise EOFError
        return data


class StructureStreamer:
    def __init__(self, structure):
        self.structure = structure

    def parse(self, file):
        while 1:
            position = file.tell()
            try:
                value = self.structure(file)
                for name, field in self.structure._fields.items():
                    getattr(value, name)
            except Exception as e:
                if file.tell() == position:
                    # The file didn't move, so it must be at the end
                    break
                # Otherwise, something else went wrong
                raise e
            yield value



class StructureTupleMetaclass(meta.DeclarativeMetaclass):
