Cython Generation

Generates a Cython wrappers for C++ classes from description dictionaries. This module relies heavily on the type system to convert between C/C++, Cython, and Python types in a seamless way. While this module does not explicitly rely on the auto-describer, it sure helps! The functions in this module are conceptually easy to understand – given class descriptions they generate strings of Cython code – their implementations do a lot of heavy lifting.

author:Anthony Scopatz <scopatz@gmail.com>

Cython Generation API

bright.apigen.cythongen.gencpppxd(desc, exception_type='+')

Generates a cpp_*.pxd Cython header file for exposing C/C++ data from to other Cython wrappers based off of a dictionary description.

Parameters :

desc : dict

Class description dictonary.

exception_type : str, optional

Cython exception annotation. Set to None when exceptions should not be included.

Returns :

cpppxd : str

Cython cpp_*.pxd header file as in-memory string.

bright.apigen.cythongen.genpxd(desc)

Generates a *pxd Cython header file for exposing C/C++ data to other Cython wrappers based off of a dictionary description.

Parameters :

desc : dict

Class description dictonary.

Returns :

pxd : str

Cython *.pxd header file as in-memory string.

bright.apigen.cythongen.genpyx(desc, env=None)

Generates a *.pyx Cython wrapper implementation for exposing a C/C++ class based off of a dictionary description. The environment is a dictionary of all class names known to their descriptions.

Parameters :

desc : dict

Class description dictonary.

env : env, optional

Environment dictionary which maps all class names that are required to their own descriptions. This is required for resolved class heirarchy dependencies.

Returns :

pyx : str

Cython *.pyx implementation file as in-memory string.

Previous topic

Automatic Descriptions

Next topic

API Generation CLI

This Page