devana.preprocessing

Subpackages

devana.preprocessing.preprocessor

class IDestination[source]

Bases: IInputContract, ABC

Interface specifying a class that manages the recording of preprocessor output artifacts. Typical use case is the generation of c++ code to files on disk, but other outputs are also possible, although the artifacts are generally focused on the disk.

class Artifacts(files)[source]

Bases: object

Resulting preprocessor artifacts.

files: List[Path]

List of touching files.

abstract consume(data)[source]

Consume data from generator and save it.

Return type

Optional[Artifacts]

class IGenerator[source]

Bases: IInputContract, IOutputContract, ABC

A preprocessing unit which, based on general input data, generates output data by implementing methods of binding input and output data.

abstract generate(data)[source]

Generate data like generate code.

Return type

Iterable[Any]

class IInputContract[source]

Bases: ABC

Contract that allows you to define what specific type is required.

abstract classmethod get_required_type()[source]

Specifies the required input type. In common cases should be interfaced.

Return type

Type

class IOutputContract[source]

Bases: ABC

Contract that allows you to define what specific type is provided in the output.

abstract classmethod get_produced_type()[source]

Specifies a result type, typically as an interface.

Return type

Type

class ISource[source]

Bases: IOutputContract, ABC

The data source interface for the processor. Typical implementation assumes reading files (json or header files) and returning the parsed output of the generator, for example, C++ type systems from Devana.

abstract feed()[source]

Create data, one by one.

Return type

Iterable[Any]

class Preprocessor(source, generator, destination)[source]

Bases: object

A preprocessor class that, through aggregation, combines the provided data source, generator or class that saves input data into one coherent entity. It also provides validation contracts of the classes used.

property destination: IDestination
Return type

IDestination

property generator: IGenerator
Return type

IGenerator

process()[source]
Return type

Optional[Artifacts]

property source: ISource
Return type

ISource

A feature set that combines code parsing and generation to provide a high-level feature set that allows for context-aware code preprocessing, such as runtime information generation, metaclass, and more.