ifgen.environment package — docs

Skip to main content
`Ctrl`+`K`

# 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]]

  Process a single struct field.

## ifgen.environment.padding module

A module implementing a struct-padding manager.

class ifgen.environment.padding.PaddingManager

  Bases: `object`

  A class implementing basic padding management.

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

    Add padding field(s).

  base_name = 'reserved_padding'
  reset() → None

    Reset the padding-element index.

ifgen.environment.padding.type_string(data: str) → str

  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)

  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

    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.IfgenEnvironment(root: Path, config: Config)

  Bases: `LoggerMixin`

  A class for managing stateful information while generating outputs.

  directories: dict[Language, Directories]
  generated: set[Path]
  get_dirs(langauge: Language) → Directories | None

    Get source, output and test directories.

  get_enum(name: str, exact: bool = False) → RuntimeEnum

    Get a runtime enum instance for a given enumeration.

  get_protocol(name: str, exact: bool = False) → Protocol

    Get the protocol instance for a given struct.

  is_enum(name: str, exact: bool = False) → bool

    Determine if a field is an enumeration or not.

  is_struct(name: str) → bool

    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

    Make part of a task’s path.

  make_test_path(name: str, generator: Generator, language: Language) → Path

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

  preprocessors: dict[Language, Callable[[str], str]]
  prune_empty() → None

    Attempt to eliminate any empty output directories.

  rel_include(name: str, generator: Generator, language: Language) → Path

    Get an include path to a generated output.

  size(type_name: str, exact: bool = False, trace: bool = False) → int

    Get the size of a given type.

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

  Get runtime enumeration data.