class ArchDependentInteger(Integer):
An integer type whose size depends on whether the current context is 32 or 64 bits.
Information
Parameters | |
signedness | an element of the Signedness enum indicating whether instances of this type are signed |
endianness | an element of the Endianness enum indicating the endianness of instances of this type |
size32 | the size in a 32 bits context |
size64 | the size in a 64 bits context |
Raises | |
ValueError | if one of the passed sizes is negative or null |
Method | __init__ |
Undocumented |
Method | __str__ |
Returns the nicely printable string representation of this instance. |
Method | is |
Whether the context argument needed by some methods actually has an effect. |
Method | size |
The minimal number of bytes necessary to hold an instance of this integer type, depending on the current context. |
Instance Variable | size32 |
Undocumented |
Instance Variable | size64 |
Undocumented |
Property | endianness |
Property: The endianness of this integer type. |
Property | signedness |
Property: The signedness of this integer type. |
Method | _possible |
Undocumented |
Instance Variable | _endianness |
Undocumented |
Instance Variable | _signedness |
Undocumented |
Inherited from Integer
:
Method | __eq__ |
Compares the instance for equality with an object. |
Method | __hash__ |
Returns the hash for this value. |
Method | __ne__ |
Compares the instance for equality with an object. |
Method | _construct |
Return the underlying construct instance |
Inherited from Type
(via Integer
):
Method | description |
The short description of this type. |
Method | parse |
Parses the value of an instance of this type from a raw buffer, possibly depending on the context. |
Method | to |
Build a byte buffer from a value of this type. |
Method | _resolve |
Uses the resolver to return a resolved version of the type, if possible. |
Returns the nicely printable string representation of this instance.
Returns | |
str | Undocumented |
Whether the context argument needed by some methods actually has an effect.
Types that return False to this method are context-insensitive types. You can safely pass any object as context parameter (including None) to the methods of such type.
Note that the context-sensitivity of a type may change in the future.
Examples
Getting the size of a type without needing a context for context-insensitive types: >>> types.U32.is_context_sensitive() False >>> types.U32.size_bytes(context=None) 4 >>> array32_12 = types.Array(types.U32, 12) >>> array32_12.is_context_sensitive() False >>> array32_12.size_bytes() # context=None by default 48
Context-sensitive types may raise errors when attempting to get the size without a context: >>> types.USize.is_context_sensitive() True >>> types.USize.size_bytes(context=None) ValueError: Please provide a context when using a context-sensitive type
reven2.types._integer.Integer.size_bytes
The minimal number of bytes necessary to hold an instance of this integer type, depending on the current context.
Information
Parameters | |
context | The context object. See package documentation. |
Returns | |
An integer. | |
Raises | |
ValueError | If called without a context. |