TypeVariant

class dsviper.TypeVariant(types)

Bases: Type

The variant<T0, …> type.

types() gives the alternatives, each a Type; ValueVariant builds values of it.

static cast(type: Type) → TypeVariant

Return a type variant<T0, …> or raise.

description(*, namespace: NameSpace | None = None) → str

Return the variant spelled out as variant<T0, T1, …>.

representation() gives the bare T0|T1|… instead. namespace qualifies the names.

representation(*, namespace: NameSpace | None = None) → str

Return the type written out as T0|T1|…, with the names qualified against namespace - the global namespace when it is None.

runtime_id() → ValueUUId

Return the uuid identifying this type.

It is computed from what the type is, so the same declaration yields the same id in any Definitions. Definitions says what each kind is computed from.

type_code() → str

Return the code naming this kind of type, such as “int32”, “struct” or “vector”.

types() → list[Type]

Return the list of types.