ifgen.generation package#

Subpackages#

Submodules#

ifgen.generation.interface module#

A module defining generator interfaces.

class ifgen.generation.interface.GenerateTask(name: str, generator: Generator, language: Language, path: Path, test_path: Path, instance: dict[str, Any], env: IfgenEnvironment)[source]#

Bases: NamedTuple

A container for instance-generation tasks.

boilerplate(includes: Iterable[str] = None, is_test: bool = False, use_namespace: bool = True, description: str | None = None, json: bool = False, parent_depth: int = 0) → Iterator[IndentedFileWriter][source]#

Create standard generation boilerplate and yield the file writer to use for writing the remaining content.

check_custom_type(name: str) → TypeLookup | None[source]#

Check if a name refers to a custom type.

command(command: str, data: str = '', space: str = ' ') → str[source]#

Get a doxygen command string.

property config: dict[str, Any]#

Get the environment’s configuration data.

cpp_namespace(data: str, header: bool = True, prefix: str = None) → str[source]#

Namespace a string with this task’s name.

custom_include(name: str) → Path | None[source]#

Attempt to build a path to a custom include.

enum() → RuntimeEnum[source]#

Look up a runtime enumeration for this task.

env: IfgenEnvironment#

Alias for field number 6

generator: Generator#

Alias for field number 1

handle_namespace(stack: ExitStack, writer: IndentedFileWriter) → None[source]#

Write namespace boilerplate to a file.

has_instances() → bool[source]#

Determine whether or not this instance has concrete instances.

instance: dict[str, Any]#

Alias for field number 5

property is_cpp: bool#

Determine if this task’s language is set to C++.

property is_python: bool#

Determine if this task’s language is set to Python.

javadoc_header(writer: IndentedFileWriter, json: bool = False) → None[source]#

Write a standard file header.

language: Language#

Alias for field number 2

method_suffix() → str[source]#

Get a possible suffix for a method.

name: str#

Alias for field number 0

namespace(*names: str) → str[source]#

Get this task’s namespace.

path: Path#

Alias for field number 3

protocol() → Protocol[source]#

Loop up a protocol for this task.

resolve_description(description: str | None = None) → str | None[source]#

Attempt to resolve a config-driven description.

source_boilerplate(includes: Iterable[str]) → Iterator[IndentedFileWriter][source]#

Create standard generation boilerplate for a source file.

property source_path: Path#

Get a source file for this task.

property stream_implementation: bool#

Determine if this instances should include a stream implementations.

test_path: Path#

Alias for field number 4

write_includes(writer: IndentedFileWriter, includes: Iterable[str] = None) → None[source]#

Write sorted includes to a file.

class ifgen.generation.interface.TypeLookup(name: str, final: str, generator: Generator)[source]#

Bases: NamedTuple

A container for type-lookup results.

final: str#

Alias for field number 1

generator: Generator#

Alias for field number 2

name: str#

Alias for field number 0

ifgen.generation.interface.apply_cpp_namespace(name: str, data: str, header: bool = True, prefix: str = None) → str[source]#

Namespace a string with this task’s name.

ifgen.generation.interface.ifndef_guard(writer: IndentedFileWriter, text: str) → Iterator[None][source]#

Guard contents with header macro convention.

ifgen.generation.json module#

A module for generating methods that store JSON strings.

ifgen.generation.json.to_json_method(task: GenerateTask, writer: IndentedFileWriter, data: dict[str, Any], task_name: bool = True, static: bool = False, dumps_indent: int = None, definition: bool = False, inline: bool = False) → None[source]#

Create a _json() method for a given task.

ifgen.generation.test module#

A module implementing unit-testing related generation utilities.

ifgen.generation.test.unit_test_boilerplate(task: GenerateTask, includes: list[str] = None, main: bool = True, declare_namespace: bool = False) → Iterator[IndentedFileWriter][source]#

Handle standard unit-test boilerplate.

ifgen.generation.test.unit_test_main(task: GenerateTask, writer: IndentedFileWriter, description: bool = True) → Iterator[None][source]#

A method for generating main-function boilerplate for unit tests.

ifgen.generation.test.unit_test_method(name: str, task: GenerateTask, writer: IndentedFileWriter) → Iterator[None][source]#

Generate unit-test method boilerplate.

ifgen.generation.test.unit_test_method_name(name: str, task: GenerateTask) → str[source]#

Get the name of a unit test.

Module contents#

A module implementing interfaces to facilitate code generation.

ifgen.generation.generate(root: Path, config: Config) → None[source]#

Generate struct files.

ifgen.generation.resolve_generators(env: IfgenEnvironment) → dict[Generator, list[Callable[[GenerateTask], None]]][source]#

Populate any custom generator interfaces defined in the configuration.