ifgen.environment package#

Submodules#

ifgen.environment.field module#

A module implementing interfaces for processing individual struct fields.

ifgen.environment.field.process_field(struct_name: str, padding: PaddingManager, types: TypeSystem, field: dict[str, Any], namespace: list[str]) Iterator[dict[str, Any]][source]#

Process a single struct field.

ifgen.environment.padding module#

A module implementing a struct-padding manager.

class ifgen.environment.padding.PaddingManager[source]#

Bases: object

A class implementing basic padding management.

add_padding(num_bytes: int) Iterator[dict[str, Any]][source]#

Add padding field(s).

base_name = 'reserved_padding'#
reset() None[source]#

Reset the padding-element index.

ifgen.environment.padding.type_string(data: str) str[source]#

Handle some type name conversions.

Module contents#

A module implementing a generation-environment interface.

class ifgen.environment.Directories(config_parts: list[str], source: Path, output: Path, test_dir: Path)[source]#

Bases: NamedTuple

A collection of directories relevant to code generation outputs.

config_parts: list[str]#

Alias for field number 0

output: Path#

Alias for field number 2

prune_empty() None[source]#

Attempt to eliminate any empty output directories.

source: Path#

Alias for field number 1

test_dir: Path#

Alias for field number 3

class ifgen.environment.Generator(*values)[source]#

Bases: StrEnum

An enumeration declaring all valid kinds of generators.

ENUMS = 'enums'#
IFGEN = 'ifgen'#
STRUCTS = 'structs'#
class ifgen.environment.IfgenEnvironment(root: Path, config: Config)[source]#

Bases: LoggerMixin

A class for managing stateful information while generating outputs.

get_dirs(langauge: Language) Directories | None[source]#

Get source, output and test directories.

get_enum(name: str, exact: bool = False) RuntimeEnum[source]#

Get a runtime enum instance for a given enumeration.

get_protocol(name: str, exact: bool = False) Protocol[source]#

Get the protocol instance for a given struct.

is_enum(name: str, exact: bool = False) bool[source]#

Determine if a field is an enumeration or not.

is_struct(name: str) bool[source]#

Determine if a field is a struct or not.

make_path(name: str, generator: Generator, language: Language, from_output: bool = False, track: bool = True) Path[source]#

Make part of a task’s path.

make_test_path(name: str, generator: Generator, language: Language) Path[source]#

Make a path to an interface’s unit-test suite.

prune_empty() None[source]#

Attempt to eliminate any empty output directories.

rel_include(name: str, generator: Generator, language: Language) Path[source]#

Get an include path to a generated output.

size(type_name: str, exact: bool = False, trace: bool = False) int[source]#

Get the size of a given type.

class ifgen.environment.Language(*values)[source]#

Bases: StrEnum

An enumeration declaring output generation variants.

CPP = 'CPP'#
PYTHON = 'Python'#
property cfg_dir_name: str#

Get the configuration key for this language’s output configuration.

property header_suffix: str#

Get a header-file suffix for this language.

property slug: str#

Get a slug string.

property source_suffix: str#

Get a source-file suffix for this language.

ifgen.environment.runtime_enum_data(data: dict[str, Any]) dict[str, int][source]#

Get runtime enumeration data.