pyffi :: object_models :: common :: Int :: Class Int
[hide private]
[frames] | no frames]

Class Int

source code

            object --+        
                     |        
utils.graph.DetailNode --+    
                         |    
       xml.basic.BasicBase --+
                             |
            object --+       |
                     |       |
 editable.EditableBase --+   |
                         |   |
  editable.EditableSpinBox --+
                             |
                            Int
Known Subclasses:

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

>>> from tempfile import TemporaryFile
>>> tmp = TemporaryFile()
>>> from pyffi.object_models import FileFormat
>>> data = FileFormat.Data()
>>> i = Int()
>>> i.set_value(-1)
>>> i.get_value()
-1
>>> i.set_value(0x11223344)
>>> i.write(tmp, data)
>>> j = Int()
>>> if tmp.seek(0): pass # ignore result for py3k
>>> j.read(tmp, data)
>>> hex(j.get_value())
'0x11223344'
>>> i.set_value(2**40) # doctest: +ELLIPSIS
Traceback (most recent call last):
    ...
ValueError: ...
>>> i.set_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, data)
>>> hex(i.get_value())
'0x44332211'
Instance Methods [hide private]
 
__init__(self, **kwargs)
Initialize the integer.
source code
 
get_value(self)
Return stored value.
source code
 
set_value(self, value)
Set value to C{value}.
source code
 
read(self, stream, data)
Read value from stream.
source code
 
write(self, stream, data)
Write value to stream.
source code
 
__str__(self)
Return string representation.
source code
 
get_hash(self, data=None)
Return a hash value for this value.
source code
 
get_editor_minimum(self)
Minimum possible value.
source code
 
get_editor_maximum(self)
Maximum possible value.
source code

Inherited from xml.basic.BasicBase: fix_links, get_detail_display, get_editor_value, get_links, get_refs, get_strings, replace_global_node, set_editor_value

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

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

Class Methods [hide private]
 
get_size(cls, data=None)
Return number of bytes this type occupies in a file.
source code
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 xml.basic.BasicBase: arg

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

source code 
Initialize the integer.
Parameters:
  • template - type used as template
  • argument - argument used to initialize the instance (see the Struct class).
  • parent - The parent of this instance, that is, the instance this instance is an attribute of.
Overrides: object.__init__

get_value(self)

source code 
Return stored value.
Returns:
The stored value.
Overrides: xml.basic.BasicBase.get_value

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: xml.basic.BasicBase.set_value

read(self, stream, data)

source code 
Read value from stream.
Parameters:
  • stream (file) - The stream to read from.
Overrides: xml.basic.BasicBase.read

write(self, stream, data)

source code 
Write value to stream.
Parameters:
  • stream (file) - The stream to write to.
Overrides: xml.basic.BasicBase.write

__str__(self)
(Informal representation operator)

source code 
Return string representation.
Overrides: object.__str__
(inherited documentation)

get_size(cls, data=None)
Class Method

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

get_hash(self, data=None)

source code 
Return a hash value for this value.
Returns:
An immutable object that can be used as a hash.
Overrides: xml.basic.BasicBase.get_hash

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