class documentation

class Enumeration(_Type):

View In Hierarchy

A user-defined, named type that represents a list of named values, like enums in C.

Method __eq__ Compares the instance for equality with an object.
Method __hash__ Returns the hash for this value.
Method __init__ Initializes a new instance of this class from its integer type used to represent it, its name, its mangled name if available, and all its items.
Method __ne__ Compares the instance for equality with an object.
Method __str__ Returns the nicely printable string representation of this instance.
Method description The short description of this type.
Method is_context_sensitive Whether the context argument needed by some methods actually has an effect.
Method item Get an item of the enumeration by its name.
Method items An iterator over the items in the enumeration, in the order of declaration.
Property mangled_name The mangled name of this enumeration, if available.
Property name The name of this enumeration.
Property underlying_type The integer type that serves as representation for this enumeration.
Method _construct_type Return the underlying construct instance
Method _decode Undocumented
Method _encode Undocumented
Instance Variable _items Undocumented
Instance Variable _mangled_name Undocumented
Instance Variable _name Undocumented
Instance Variable _underlying_type Undocumented

Inherited from Type:

Method parse Parses the value of an instance of this type from a raw buffer, possibly depending on the context.
Method size_bytes The minimal number of bytes necessary to hold an instance of this type, possibly depending on the context.
Method to_bytes 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.
def __eq__(self, o):

Compares the instance for equality with an object.

  • if the object is not an Enumeration, it will never be equal to this instance.
Parameters
o:objectUndocumented
Returns
boolUndocumented
def __hash__(self):

Returns the hash for this value.

Returns
intUndocumented
def __init__(self, underlying_type, name, mangled_name, items):

Initializes a new instance of this class from its integer type used to represent it, its name, its mangled name if available, and all its items.

Parameters
underlying_type:_IntegerUndocumented
name:strUndocumented
mangled_name:_Optional[str]Undocumented
items:_Iterable[Item]Undocumented
def __ne__(self, o):

Compares the instance for equality with an object.

  • if the object is not an Enumeration, it will never be equal to this instance.
Parameters
o:objectUndocumented
Returns
boolUndocumented
def __str__(self):

Returns the nicely printable string representation of this instance.

Returns
strUndocumented
def description(self):

The short description of this type.

For named types, it is the name of the type. For other types, it is generally __str__.

Returns
strUndocumented
def is_context_sensitive(self):

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

Returns
boolUndocumented
def item(self, key):

Get an item of the enumeration by its name.

Information

Parameters
key:strUndocumented
Returns
ItemUndocumented
Raises
KeyErrorif there is no item of this name in the enumeration.
def items(self):

An iterator over the items in the enumeration, in the order of declaration.

Returns
_Iterator[Item]Undocumented
@property
mangled_name: _Optional[str] =

The mangled name of this enumeration, if available.

@property
name: str =

The name of this enumeration.

@property
underlying_type: _Integer =

The integer type that serves as representation for this enumeration.

def _construct_type(self, context=None):

Return the underlying construct instance

Returns
_construct.core.ConstructUndocumented
def _decode(self, value, _):

Undocumented

Parameters
value:intUndocumented
_Undocumented
Returns
EnumerationInstanceUndocumented
def _encode(self, value, _):

Undocumented

Parameters
value:EnumerationInstanceUndocumented
_Undocumented
Returns
intUndocumented
_items =

Undocumented

_mangled_name =

Undocumented

_name =

Undocumented

_underlying_type =

Undocumented