settings: pybindgen global settings

class pybindgen.settings.ErrorHandler

Bases: object

x.__init__(...) initializes x; see help(type(x)) for signature

handle_error(wrapper, exception, traceback_)

Handles a code generation error. Should return True to tell pybindgen to ignore the error and move on to the next wrapper. Returning False will cause pybindgen to allow the exception to propagate, thus aborting the code generation procedure.

pybindgen.settings.allow_subclassing = False

Allow generated classes to be subclassed by default.

pybindgen.settings.automatic_type_narrowing = False

Default value for the automatic_type_narrowing parameter of C++ classes.

pybindgen.settings.deprecated_virtuals = None

Prior to PyBindGen version 0.14, the code generated to handle C++ virtual methods required Python user code to define a _foo method in order to implement the virtual method foo. Since 0.14, PyBindGen changed so that virtual method foo is implemented in Python by defining a method foo, i.e. no underscore prefix is needed anymore. Setting deprecated_virtuals to True will force the old virtual method behaviour. But this is really deprecated; newer code should set deprecated_virtuals to False.

pybindgen.settings.error_handler = None

Custom error handling. Error handler, or None. When it is None, code generation exceptions propagate to the caller. Else it can be a pybindgen.settings.ErrorHandler subclass instance that handles the error.

pybindgen.settings.gcc_rtti_abi_complete = True

If True, and GCC >= 3 is detected at compile time, pybindgen will try to use abi::__si_class_type_info to determine the closest registered type for pointers to objects of unknown type. Notably, Mac OS X Lion has GCC > 3 but which breaks this internal API, in which case it should be disabled (set this option to False).

pybindgen.settings.name_prefix = ''

Prefix applied to global declarations, such as instance and type structures.

pybindgen.settings.unblock_threads = False

Generate code to support threads. When True, by default methods/functions/constructors will unblock threads around the funcion call, i.e. allows other Python threads to run during the call.

pybindgen.settings.wrapper_registry

A WrapperRegistry subclass to use for creating wrapper registries. A wrapper registry ensures that at most one python wrapper exists for each C/C++ object.

alias of NullWrapperRegistry

pybindgen.settings.wrapper_registry

A pybindgen.wrapper_registry.WrapperRegistry subclass to use for creating wrapper registries. A wrapper registry ensures that at most one python wrapper exists for each C/C++ object.

class pybindgen.wrapper_registry.WrapperRegistry(base_name)

Bases: object

Abstract base class for wrapepr registries.

generate(code_sink, module, import_from_module)
generate_forward_declarations(code_sink, module)
write_lookup_wrapper(code_block, wrapper_type, wrapper_lvalue, object_rvalue)
write_register_new_wrapper(code_block, wrapper_lvalue, object_rvalue)
write_unregister_wrapper(code_block, wrapper_lvalue, object_rvalue)
class pybindgen.settings.NullWrapperRegistry(base_name)

Bases: pybindgen.wrapper_registry.WrapperRegistry

A ‘null’ wrapper registry class. It produces no code, and does not guarantee that more than one wrapper cannot be created for each object. Use this class to disable wrapper registries entirely.

class pybindgen.settings.StdMapWrapperRegistry(base_name)

Bases: pybindgen.wrapper_registry.WrapperRegistry

A wrapper registry that uses std::map as implementation. Do not use this if generating pure C wrapping code, else the code will not compile.