1# pylint: disable-msg=W0105 2 3from wrapper_registry import NullWrapperRegistry, StdMapWrapperRegistry 4 5""" 6 7Global settings to the code generator. 8 9""" 10 11name_prefix = '' 12""" 13Prefix applied to global declarations, such as instance and type 14structures. 15""" 16 17automatic_type_narrowing = False 18""" 19Default value for the automatic_type_narrowing parameter of C++ classes. 20""" 21 22allow_subclassing = False 23""" 24Allow generated classes to be subclassed by default. 25""" 26 27unblock_threads = False 28""" 29Generate code to support threads. 30When True, by default methods/functions/constructors will unblock 31threads around the funcion call, i.e. allows other Python threads to 32run during the call. 33""" 34 35 36error_handler = None 37""" 38Custom error handling. 39Error handler, or None. When it is None, code generation exceptions 40propagate to the caller. Else it can be a 41:class:`pybindgen.settings.ErrorHandler` subclass instance that handles the error. 42""" 43 44min_python_version=(2, 3) 45""" 46Minimum python version the generated code must support. 47""" 48 49wrapper_registry = NullWrapperRegistry 50""" 51A :class:`WrapperRegistry` subclass to use for creating 52wrapper registries. A wrapper registry ensures that at most one 53python wrapper exists for each C/C++ object. 54""" 55 56deprecated_virtuals = None 57""" 58Prior to PyBindGen version 0.14, the code generated to handle C++ 59virtual methods required Python user code to define a _foo method in 60order to implement the virtual method foo. Since 0.14, PyBindGen 61changed so that virtual method foo is implemented in Python by 62defining a method foo, i.e. no underscore prefix is needed anymore. 63Setting deprecated_virtuals to True will force the old virtual method 64behaviour. But this is really deprecated; newer code should set 65deprecated_virtuals to False. 66""" 67 68 69gcc_rtti_abi_complete = True 70""" 71If True, and GCC >= 3 is detected at compile time, pybindgen will try 72to use abi::__si_class_type_info to determine the closest registered 73type for pointers to objects of unknown type. Notably, Mac OS X Lion 74has GCC > 3 but which breaks this internal API, in which case it 75should be disabled (set this option to False). 76""" 77 78def _get_deprecated_virtuals(): 79 if deprecated_virtuals is None: 80 import warnings 81 warnings.warn("The option pybindgen.settings.deprecated_virtuals has not been set." 82 " I am going to assume the value of True, to preserve backward" 83 " compatibility, but the default value will change in the future," 84 " and the option will eventually disappear.", 85 DeprecationWarning) 86 return True 87 return deprecated_virtuals 88 89 90class ErrorHandler(object): 91 def handle_error(self, wrapper, exception, traceback_): 92 """ 93 Handles a code generation error. Should return True to tell 94 pybindgen to ignore the error and move on to the next wrapper. 95 Returning False will cause pybindgen to allow the exception to 96 propagate, thus aborting the code generation procedure. 97 """ 98 raise NotImplementedError 99 100