runtimepy.primitives.field package#

Subpackages#

Submodules#

runtimepy.primitives.field.fields module#

A module implementing a data structure for managing multiple bit fields.

class runtimepy.primitives.field.fields.BitFields(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]] = None, schemas: SchemaMap = None, dest_attr: str = 'data', verify: bool = True)[source]#

Bases: RuntimepyDictCodec

A class for managing bit fields and flags from dictionary data.

asdict() dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]][source]#

Get these bit fields as a dictionary.

claim_field(field: BitField) BitField[source]#

Claim a bit field.

curr_index: int#
field(name: str, width: int, index: int = None, enum: str | int = None, description: str = None, **kwargs) BitField[source]#

Create a new bit field.

finalize() None[source]#

Finalize the fields so that new fields can’t be added.

flag(name: str, index: int = None, enum: str | int = None, description: str = None, **kwargs) BitFlag[source]#

Create a new bit flag.

get_field(key: str | int) BitField | None[source]#

Attempt to get a bit-field from this entity.

init(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]]) None[source]#

Perform implementation-specific initialization.

property names: Iterator[str]#

Iterate over names mapping to individual fields.

classmethod new(value: type[Int8Primitive | Int16Primitive | Int32Primitive | Int64Primitive | Uint8Primitive | Uint16Primitive | Uint32Primitive | Uint64Primitive | HalfPrimitive | FloatPrimitive | DoublePrimitive | BooleanPrimitive] | str | Int8Primitive | Int16Primitive | Int32Primitive | Int64Primitive | Uint8Primitive | Uint16Primitive | Uint32Primitive | Uint64Primitive | HalfPrimitive | FloatPrimitive | DoublePrimitive | BooleanPrimitive = 'uint8') T[source]#

Create a new bit-field storage entity.

pad(width: int = 1, index: int = None, val: int = 0) int[source]#

Pad bits in this primitive so they can’t be allocated.

Module contents#

A module implementing bit flags and fields.

class runtimepy.primitives.field.BitField(name: str, raw: Uint8Primitive | Uint16Primitive | Uint32Primitive | Uint64Primitive, index: int, width: int, enum: str | int = None, commandable: bool = False, description: str = None)[source]#

Bases: BitFieldBase, RegexMixin, EnumMixin

A class managing a portion of an unsigned-integer primitive.

asdict() dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]][source]#

Get this field as a dictionary.

name_regex: _Pattern | None = re.compile('^[a-zA-Z0-9_.-]+$')#
class runtimepy.primitives.field.BitFieldBase(raw: Uint8Primitive | Uint16Primitive | Uint32Primitive | Uint64Primitive, index: int, width: int, commandable: bool = False, description: str = None)[source]#

Bases: object

A simple bit-field implementation.

invert() int[source]#

Invert the value of this field and return the result.

where_str() str[source]#

Get a simple string representing the bit locations this field occupies.

class runtimepy.primitives.field.BitFlag(name: str, raw: Uint8Primitive | Uint16Primitive | Uint32Primitive | Uint64Primitive, index: int, enum: str | int = None, commandable: bool = False, description: str = None)[source]#

Bases: BitField

A bit field that is always a single bit.

clear() None[source]#

Clear this field.

get() bool[source]#

Get the value of this flag.

set(val: bool = True) None[source]#

Set this flag.