# Path: steel/common/args.py
# class Argument:
# class Override(Argument):
# class Removed(Argument):
#     def __init__(self, positional=False, resolve_field=False, **kwargs):
#     def default(self):
#     def default(self, value):
#     def default(self):
#     def set_name(self, name):
#     def attach_to_class(self, cls):
#     def init(self, func):
#     def initialize(self, instance, value):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):
#     def __init__(self, **kwargs):
#     def attach_to_class(self, cls):
#     def __init__(self):
#     def attach_to_class(self, cls):
# 
# 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 sys
from steel.common import args, fields

__all__ = ['Field', 'Reserved']


class Field(fields.Field):
    offset = args.Argument(default=None, resolve_field=True)

    @fields.Field.after_encode
    def update_size(self, obj, value):
        if isinstance(self.size, Field):
            setattr(obj, self.size.name, len(value))

    def read(self, obj):
        # If the size can be determined easily, read
        # that number of bytes and return it directly.
        if self.size is not None:
            return obj.read(self.size)

        # Otherwise, the field needs to supply its own
        # technique for determining how much data to read.
        raise NotImplementedError()

    def write(self, obj, value):
        # By default, this doesn't do much, but individual
        # fields can/should override it if necessary
        obj.write(value)


class Reserved(Field):
    default = args.Override(default=None)


# Path: steel/common/args.py
# class Argument:
# class Override(Argument):
# class Removed(Argument):
#     def __init__(self, positional=False, resolve_field=False, **kwargs):
#     def default(self):
#     def default(self, value):
#     def default(self):
#     def set_name(self, name):
#     def attach_to_class(self, cls):
#     def init(self, func):
#     def initialize(self, instance, value):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):
#     def __init__(self, **kwargs):
#     def attach_to_class(self, cls):
#     def __init__(self):
#     def attach_to_class(self, cls):
# 
# 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/fields/base.py
import sys
from steel.common import args, fields

__all__ = ['Field', 'Reserved']


class Field(fields.Field):
    offset = args.Argument(default=None, resolve_field=True)

    @fields.Field.after_encode
    def update_size(self, obj, value):
        if isinstance(self.size, Field):
            setattr(obj, self.size.name, len(value))

    def read(self, obj):
        # If the size can be determined easily, read
        # that number of bytes and return it directly.
        if self.size is not None:
            return obj.read(self.size)

        # Otherwise, the field needs to supply its own
        # technique for determining how much data to read.
        raise NotImplementedError()

    def write(self, obj, value):
        # By default, this doesn't do much, but individual
        # fields can/should override it if necessary
        obj.write(value)


class Reserved(Field):
    default = args.Override(default=None)


    def __init__(self, *args, **kwargs):
