ifgen package — docs

Skip to main content
`Ctrl`+`K`

# ifgen package

## Subpackages

- ifgen.commands package
  - Submodules
  - ifgen.commands.all module
    - `commands()`
  - ifgen.commands.gen module
    - `add_gen_cmd()`
    - `gen_cmd()`
  - ifgen.commands.svd module
    - `add_svd_cmd()`
    - `svd_cmd()`
  - Module contents
- ifgen.common package
  - Module contents
    - `common_endianness()`
    - `create_common()`
    - `create_common_test()`
    - `endianness_enum()`
    - `endianness_float()`
    - `endianness_integral()`
    - `endianness_native()`
    - `endianness_single()`
- ifgen.config package
  - Submodules
  - ifgen.config.svd module
    - `SvdConfig`
  - Module contents
    - `Config`
      - `Config.init()`
    - `load()`
- ifgen.enum package
  - Subpackages
    - ifgen.enum.python package
      - Module contents
  - Submodules
  - ifgen.enum.common module
    - `enum_from_string()`
    - `enum_to_string()`
    - `enum_to_string_function()`
    - `string_to_enum_function()`
  - ifgen.enum.header module
    - `cpp_enum_neader()`
    - `enum_header()`
    - `enum_line()`
  - ifgen.enum.map module
    - `enum_from_string_map()`
    - `enum_to_string_map()`
  - ifgen.enum.source module
    - `create_enum_source()`
    - `enum_source()`
  - ifgen.enum.test module
    - `create_enum_test()`
    - `test_single()`
    - `unit_test_body()`
  - Module contents
    - `create_enum()`
    - `create_enum_source()`
    - `create_enum_test()`
- ifgen.environment package
  - Submodules
  - ifgen.environment.field module
    - `process_field()`
  - ifgen.environment.padding module
    - `PaddingManager`
      - `PaddingManager.add_padding()`
      - `PaddingManager.base_name`
      - `PaddingManager.reset()`
    - `type_string()`
  - Module contents
    - `Directories`
      - `Directories.config_parts`
      - `Directories.output`
      - `Directories.prune_empty()`
      - `Directories.source`
      - `Directories.test_dir`
    - `IfgenEnvironment`
      - `IfgenEnvironment.directories`
      - `IfgenEnvironment.generated`
      - `IfgenEnvironment.get_dirs()`
      - `IfgenEnvironment.get_enum()`
      - `IfgenEnvironment.get_protocol()`
      - `IfgenEnvironment.is_enum()`
      - `IfgenEnvironment.is_struct()`
      - `IfgenEnvironment.make_path()`
      - `IfgenEnvironment.make_test_path()`
      - `IfgenEnvironment.preprocessors`
      - `IfgenEnvironment.prune_empty()`
      - `IfgenEnvironment.rel_include()`
      - `IfgenEnvironment.size()`
    - `runtime_enum_data()`
- ifgen.generation package
  - Subpackages
    - ifgen.generation.python package
      - Module contents
  - Submodules
  - ifgen.generation.interface module
    - `GenerateTask`
      - `GenerateTask.boilerplate()`
      - `GenerateTask.check_custom_type()`
      - `GenerateTask.command()`
      - `GenerateTask.config`
      - `GenerateTask.cpp_namespace()`
      - `GenerateTask.custom_include()`
      - `GenerateTask.enum()`
      - `GenerateTask.env`
      - `GenerateTask.generator`
      - `GenerateTask.handle_namespace()`
      - `GenerateTask.has_instances()`
      - `GenerateTask.instance`
      - `GenerateTask.is_cpp`
      - `GenerateTask.is_python`
      - `GenerateTask.javadoc_header()`
      - `GenerateTask.language`
      - `GenerateTask.method_suffix()`
      - `GenerateTask.name`
      - `GenerateTask.namespace()`
      - `GenerateTask.path`
      - `GenerateTask.protocol()`
      - `GenerateTask.resolve_description()`
      - `GenerateTask.source_boilerplate()`
      - `GenerateTask.source_path`
      - `GenerateTask.stream_implementation`
      - `GenerateTask.test_path`
      - `GenerateTask.write_includes()`
    - `TypeLookup`
      - `TypeLookup.final`
      - `TypeLookup.generator`
      - `TypeLookup.name`
    - `apply_cpp_namespace()`
    - `ifndef_guard()`
  - ifgen.generation.json module
    - `to_json_method()`
  - ifgen.generation.test module
    - `unit_test_boilerplate()`
    - `unit_test_main()`
    - `unit_test_method()`
    - `unit_test_method_name()`
  - Module contents
    - `generate()`
    - `resolve_generators()`
- ifgen.plugins package
  - Subpackages
    - ifgen.plugins.struct_receiver package
      - Module contents
  - Module contents
    - `internal_plugin_entry()`
- ifgen.struct package
  - Subpackages
    - ifgen.struct.methods package
      - Subpackages
      - Submodules
      - ifgen.struct.methods.bit module
      - ifgen.struct.methods.common module
      - Module contents
    - ifgen.struct.python package
      - Module contents
  - Submodules
  - ifgen.struct.header module
    - `cpp_struct_header()`
    - `enforce_expected_size()`
    - `struct_fields()`
    - `struct_header()`
    - `struct_instance()`
    - `struct_line()`
  - ifgen.struct.stream module
    - `struct_istream()`
    - `struct_ostream()`
    - `struct_stream_methods()`
  - ifgen.struct.test module
    - `assert_line()`
    - `create_struct_test()`
    - `unit_test_basic_method()`
    - `unit_test_body()`
    - `unit_test_stream_tests()`
  - ifgen.struct.util module
    - `struct_dependencies()`
  - Module contents
    - `create_struct()`
    - `create_struct_test()`
- ifgen.svd package
  - Subpackages
    - ifgen.svd.group package
      - Submodules
      - ifgen.svd.group.base module
      - ifgen.svd.group.enums module
      - ifgen.svd.group.fields module
      - Module contents
    - ifgen.svd.model package
      - Submodules
      - ifgen.svd.model.address_block module
      - ifgen.svd.model.cpu module
      - ifgen.svd.model.derived module
      - ifgen.svd.model.device module
      - ifgen.svd.model.enum module
      - ifgen.svd.model.field module
      - ifgen.svd.model.interrupt module
      - ifgen.svd.model.peripheral module
      - Module contents
  - Submodules
  - ifgen.svd.cpu module
    - `process_cpu()`
  - ifgen.svd.device module
    - `process_device()`
  - ifgen.svd.peripherals module
    - `process_peripheral()`
    - `process_peripherals()`
  - ifgen.svd.process module
    - `cluster()`
    - `handle_registers()`
    - `register()`
  - ifgen.svd.string module
    - `StringKeyVal`
      - `StringKeyVal.key`
      - `StringKeyVal.required`
    - `StringKeyValueMixin`
      - `StringKeyValueMixin.create()`
      - `StringKeyValueMixin.get_values()`
      - `StringKeyValueMixin.handle_description()`
      - `StringKeyValueMixin.log()`
      - `StringKeyValueMixin.raw()`
      - `StringKeyValueMixin.raw_data`
      - `StringKeyValueMixin.string_keys()`
    - `get_string_values()`
  - ifgen.svd.task module
    - `SvdProcessingTask`
      - `SvdProcessingTask.generate_configs()`
      - `SvdProcessingTask.min_enum_width`
      - `SvdProcessingTask.model`
      - `SvdProcessingTask.process()`
      - `SvdProcessingTask.svd()`
    - `filter_includes()`
  - Module contents
    - `register_processors()`

## Submodules

## ifgen.app module

This package’s command-line entry-point application.

ifgen.app.add_app_args(parser: ArgumentParser) → None

  Add application-specific arguments to the command-line parser.

ifgen.app.entry(args: Namespace) → int

  Execute the requested task.

## ifgen.entry module

This package’s command-line entry-point (boilerplate).

ifgen.entry.main(argv: list[str] = None) → int

  Program entry-point.

## ifgen.enums module

A module implementing enumerations used by this package.

class ifgen.enums.Generator(*values)

  Bases: `StrEnum`

  An enumeration declaring all valid kinds of generators.

  CUSTOM = 'custom'
  ENUMS = 'enums'
  IFGEN = 'ifgen'
  STRUCTS = 'structs'

class ifgen.enums.Language(*values)

  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.paths module

A module exposing some pathing utilities.

ifgen.paths.audit_init_file(source: Path, parent_depth: int = 0) → None

  Create initialization files if necessary.

ifgen.paths.combine_if_not_absolute(root: Path, candidate: Path | str | None) → Path

  Combine a root directory with a path if the path isn’t absolute.

ifgen.paths.create_formatter(*args: str, **kwargs) → Callable[[str], str]

  Create a formatting preprocessor that uses stdin/stdout of a subprocess.

## ifgen.schemas module

A module for working with schemas belonging to this package.

class ifgen.schemas.IfgenDictCodec(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)

  Bases: `DictCodec`

  A simple wrapper for package classes that want to implement DictCodec.

  data: dict[str, Any]
  default_schemas: SchemaMap | None = {'has_bit_fields': <vcorelib.schemas.json.JsonSchema object>, 'StructField': <vcorelib.schemas.json.JsonSchema object>, 'StructInstance': <vcorelib.schemas.json.JsonSchema object>, 'has_namespace': <vcorelib.schemas.json.JsonSchema object>, 'has_description': <vcorelib.schemas.json.JsonSchema object>, 'StructFieldAlternate': <vcorelib.schemas.json.JsonSchema object>, 'has_expected_size': <vcorelib.schemas.json.JsonSchema object>, 'SvdConfig': <vcorelib.schemas.json.JsonSchema object>, 'Enum': <vcorelib.schemas.json.JsonSchema object>, 'SvdInstanceConfig': <vcorelib.schemas.json.JsonSchema object>, 'Struct': <vcorelib.schemas.json.JsonSchema object>, 'has_volatile': <vcorelib.schemas.json.JsonSchema object>, 'Config': <vcorelib.schemas.json.JsonSchema object>, 'BitField': <vcorelib.schemas.json.JsonSchema object>, 'has_json_indent': <vcorelib.schemas.json.JsonSchema object>}

## Module contents

Useful defaults and other package metadata.