runtimepy.primitives.types package#
Submodules#
runtimepy.primitives.types.base module#
A module for implementing a base class for primitive types.
- class runtimepy.primitives.types.base.PrimitiveType(struct_format: str, signed: bool = True)[source]#
Bases:
Generic[T]A simple wrapper around ctype primitives.
- c_type: type[T]#
- decode(data: bytes, byte_order: ByteOrder = ByteOrder.NETWORK) bool | int | float[source]#
Decode primitive based on this type.
- encode(value: bool | int | float, byte_order: ByteOrder = ByteOrder.NETWORK) bytes[source]#
Encode a primitive value.
- name: str#
runtimepy.primitives.types.bool module#
A module implementing a type interface for booleans.
- class runtimepy.primitives.types.bool.BooleanType[source]#
Bases:
PrimitiveType[c_bool]A simple type interface for booleans.
- c_type#
alias of
c_bool
- name: str = 'bool'#
runtimepy.primitives.types.bounds module#
A module implementing an interface for keeping track of primitive-integer bounds (based on bit width).
- class runtimepy.primitives.types.bounds.IntegerBounds(min: int, max: int)[source]#
Bases:
NamedTupleA container for integer bounds.
- clamp(val: int) int[source]#
Ensure that ‘val’ is between min and max, use the min or max value instead of the provided value if it exceeds these bounds.
- static create(byte_count: int, signed: bool) IntegerBounds[source]#
Compute maximum and minimum values given size and signedness.
- max: int#
Alias for field number 1
- min: int#
Alias for field number 0
runtimepy.primitives.types.float module#
A module implementing a type interface for floating-point numbers.
- class runtimepy.primitives.types.float.DoubleType[source]#
Bases:
PrimitiveType[c_double]A simple type interface for double-precision floating-point.
- c_type#
alias of
c_double
- name: str = 'double'#
- class runtimepy.primitives.types.float.FloatType[source]#
Bases:
PrimitiveType[c_float]A simple type interface for single-precision floating-point.
- c_type#
alias of
c_float
- name: str = 'float'#
- class runtimepy.primitives.types.float.HalfType[source]#
Bases:
PrimitiveType[c_float]A simple type interface for single-precision floating-point.
- c_type#
alias of
c_float
- name: str = 'half'#
runtimepy.primitives.types.int module#
A module implementing a type interface for integers.
- class runtimepy.primitives.types.int.Int16Type[source]#
Bases:
PrimitiveType[c_short]A simple type interface for int16’s.
- c_type#
alias of
c_short
- name: str = 'int16'#
- class runtimepy.primitives.types.int.Int32Type[source]#
Bases:
PrimitiveType[c_int]A simple type interface for int32’s.
- c_type#
alias of
c_int
- name: str = 'int32'#
- class runtimepy.primitives.types.int.Int64Type[source]#
Bases:
PrimitiveType[c_long]A simple type interface for int64’s.
- c_type#
alias of
c_long
- name: str = 'int64'#
- class runtimepy.primitives.types.int.Int8Type[source]#
Bases:
PrimitiveType[c_byte]A simple type interface for int8’s.
- c_type#
alias of
c_byte
- name: str = 'int8'#
- class runtimepy.primitives.types.int.Uint16Type[source]#
Bases:
PrimitiveType[c_ushort]A simple type interface for uint16’s.
- c_type#
alias of
c_ushort
- name: str = 'uint16'#
- class runtimepy.primitives.types.int.Uint32Type[source]#
Bases:
PrimitiveType[c_uint]A simple type interface for uint32’s.
- c_type#
alias of
c_uint
- name: str = 'uint32'#
- class runtimepy.primitives.types.int.Uint64Type[source]#
Bases:
PrimitiveType[c_ulong]A simple type interface for uint64’s.
- c_type#
alias of
c_ulong
- name: str = 'uint64'#
- class runtimepy.primitives.types.int.Uint8Type[source]#
Bases:
PrimitiveType[c_ubyte]A simple type interface for uint8’s.
- c_type#
alias of
c_ubyte
- name: str = 'uint8'#
Module contents#
A module exposing primitive types.
- runtimepy.primitives.types.normalize(value: str | Int8Type | Int16Type | Int32Type | Int64Type | Uint8Type | Uint16Type | Uint32Type | Uint64Type | HalfType | FloatType | DoubleType | BooleanType) Int8Type | Int16Type | Int32Type | Int64Type | Uint8Type | Uint16Type | Uint32Type | Uint64Type | HalfType | FloatType | DoubleType | BooleanType[source]#
Normalize a primitive type or string into a primitive type.