Known subclasses: reven2.types._array.RawBuffer

A type constructor for contiguous homogeneous arrays ([T; n]).

Method __init__ Construct an array of type ty and count count.
Method parse Parses the value of an instance of this type from a raw buffer, possibly depending on the context.
Method count Property: The number of elements in the array.
Method inner Property: The type of element of the array.
Method is_context_sensitive Whether the context argument needed by some methods actually has an effect.
Method _construct_type Return the underlying construct instance

Inherited from Type:

Method size_bytes The minimal number of bytes necessary to hold an instance of this type, possibly depending on the context.
def __init__(self, ty, count):

Construct an array of type ty and count count.

Examples

An array of 4 contiguous 64 bits unsigned integers: >>> U64_4 = types.Array(types.U64, 4)

Information

ParameterstyThe type of element in the resulting array type.
countThe number of elements in the resulting array type.
RaisesValueErrorif count < 0.
def _construct_type(self, context=None):

Return the underlying construct instance

def parse(self, buf, context=None):

Parses the value of an instance of this type from a raw buffer, possibly depending on the context.

Information

ParameterscontextThe context object. See package documentation.
@property
def count(self):

Property: The number of elements in the array.

Information

ReturnsAn integer.
@property
def inner(self):

Property: The type of element of the array.

Information

ReturnsA type from reven2.types.
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

API Documentation for reven2, generated by pydoctor at 2021-01-06 13:24:12.