Package pyffi :: Package object_models :: Module binary_type :: Class IntType
[hide private]
[frames] | no frames]

Class IntType

source code

            object --+                
                     |                
utils.graph.DetailNode --+            
                         |            
          any_type.AnyType --+        
                             |        
        simple_type.SimpleType --+    
                                 |    
            object --+           |    
                     |           |    
utils.graph.DetailNode --+       |    
                         |       |    
          any_type.AnyType --+   |    
                             |   |    
                    BinaryType --+    
                                 |    
                  BinarySimpleType --+
                                     |
                    object --+       |
                             |       |
         editable.EditableBase --+   |
                                 |   |
          editable.EditableSpinBox --+
                                     |
                                    IntType
Known Subclasses:

Basic implementation of a 32-bit signed integer type. Also serves as a base class for all other integer types.

>>> from tempfile import TemporaryFile
>>> tmp = TemporaryFile()
>>> i = IntType()
>>> i.value = -1
>>> i.value
-1
>>> i.value = 0x11223344
>>> i.write(tmp)
>>> j = IntType()
>>> if tmp.seek(0): pass # ignore result for py3k
>>> j.read(tmp)
>>> hex(j.value)
'0x11223344'
>>> i.value = 2**40 # doctest: +ELLIPSIS
Traceback (most recent call last):
    ...
ValueError: ...
>>> i.value = 'hello world'
Traceback (most recent call last):
    ...
ValueError: cannot convert value 'hello world' to integer
>>> if tmp.seek(0): pass # ignore result for py3k
>>> if tmp.write('"3D'.encode("ascii")): pass # b'"3D'
>>> if tmp.seek(0): pass # ignore result for py3k
>>> i.read(tmp)
>>> hex(i.value)
'0x44332211'
Nested Classes [hide private]

Inherited from simple_type.SimpleType: __metaclass__

Instance Methods [hide private]
 
__init__(self)
Initialize the integer.
source code
 
set_value(self, value)
Set value to C{value}.
source code
 
read(self, stream)
Read value from stream.
source code
 
write(self, stream)
Write value to stream.
source code
 
get_size(self)
Return number of bytes this type occupies in a file.
source code
 
get_editor_minimum(self)
Minimum possible value.
source code
 
get_editor_maximum(self)
Maximum possible value.
source code

Inherited from simple_type.SimpleType: __str__, get_detail_display, get_value, is_interchangeable

Inherited from any_type.AnyType: __hash__

Inherited from utils.graph.DetailNode: get_detail_child_edge_types, get_detail_child_names, get_detail_child_nodes, get_detail_iterator, replace_global_node

Inherited from editable.EditableSpinBox: get_editor_value, set_editor_value

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]
  _min = -2147483648
Minimum value.
  _max = 2147483647
Maximum value.
  _struct = 'i'
Character used to represent type in struct.
  _size = 4
Number of bytes.

Inherited from simple_type.SimpleType (private): _value

Properties [hide private]
  value
A property which wraps the actual data.

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 
Initialize the integer.
Overrides: object.__init__

set_value(self, value)

source code 
Set value to C{value}. Calls C{int(value)} to convert to integer.
Parameters:
  • value (int) - The value to assign.
Overrides: simple_type.SimpleType.set_value

read(self, stream)

source code 
Read value from stream.
Parameters:
  • stream (file) - The stream to read from.
Overrides: any_type.AnyType.read

write(self, stream)

source code 
Write value to stream.
Parameters:
  • stream (file) - The stream to write to.
Overrides: any_type.AnyType.write

get_size(self)

source code 
Return number of bytes this type occupies in a file.
Returns:
Number of bytes.
Overrides: BinaryType.get_size

get_editor_minimum(self)

source code 
Minimum possible value.
Returns:
Minimum possible value.
Overrides: editable.EditableSpinBox.get_editor_minimum

get_editor_maximum(self)

source code 
Maximum possible value.
Returns:
Maximum possible value.
Overrides: editable.EditableSpinBox.get_editor_maximum

Property Details [hide private]

value

A property which wraps the actual data. This property always calls set_value to assign the value, and ensures that the value is valid (type, range, ...). Unless you know what you are doing, always use the value property to change the data.
Get Method:
unreachable.get_value(self) - Return the stored value.
Set Method:
unreachable.set_value(self, value) - Set value to C{value}.