Exemplo n.º 1
0
 def __init__(self, name):
     '''
     Initialize the :mod:`Container` with the given *name*. By
     default, it does not contain any fields.
     '''
     Field.__init__(self, name)
     self.__fields = []
     self.__fields_name = {}
Exemplo n.º 2
0
 def __init__(self, name):
     '''
     Initialize the :mod:`Container` with the given *name*. By
     default, it does not contain any fields.
     '''
     Field.__init__(self, name)
     self.__fields = []
     self.__fields_name = {}
Exemplo n.º 3
0
 def __init__(self, name, size, value=0):
     '''
     Initialize the field with the given *name* and *size* (in
     bits). By default the field's value will be initialized to 0 or
     to *value* if specified.
     '''
     Field.__init__(self, name)
     self.__bits = []
     self.__size = size
     self.set_value(value)
Exemplo n.º 4
0
 def __init__(self, name, size, value = 0):
     '''
     Initialize the field with the given *name* and *size* (in
     bits). By default the field's value will be initialized to 0 or
     to *value* if specified.
     '''
     Field.__init__(self, name)
     self.__bits = []
     self.__size = size
     self.set_value(value)
Exemplo n.º 5
0
    def __init__(self, name, length):
        '''
        Initialize the string field with a *name* and a
        *length*. *length* can be a fixed number or a single arument
        function that returns the length of the string. The single
        argument is a reference to the top-level root :mod:`Container`
        field where the string belongs to. A possible function could
        be::

            lambda root: root["Length"]

        where we get the length of the string from a *Length* field.
        '''
        Field.__init__(self, name)
        self.__data = ""
        self.__length = length
Exemplo n.º 6
0
    def __init__(self, name, format, value):
        '''
        Initialize the field with the given *name* and *value*. The
        *format* is a string conforming the Python's struct module
        format strings.
        '''
        Field.__init__(self, name)

        # This will store the string of bytes
        self.__bytes = ""

        # Calculate byte size from struct type
        self.__format = format
        self.__size = struct.calcsize(self.__format)

        # Finally set default value
        self.set_value(value)
Exemplo n.º 7
0
    def __init__(self, name, format, value):
        '''
        Initialize the field with the given *name* and *value*. The
        *format* is a string conforming the Python's struct module
        format strings.
        '''
        Field.__init__(self, name)

        # This will store the string of bytes
        self.__bytes = ""

        # Calculate byte size from struct type
        self.__format = format
        self.__size = struct.calcsize(self.__format)

        # Finally set default value
        self.set_value(value)
Exemplo n.º 8
0
 def __init__(self, name,  fieldfunc):
     Field.__init__(self, name)
     self._fieldfunc = fieldfunc
     self._field = None
Exemplo n.º 9
0
 def __init__(self, name, fieldfunc):
     Field.__init__(self, name)
     self._fieldfunc = fieldfunc
     self._field = None