File: settings.py

package info (click to toggle)
spring 103.0%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 43,720 kB
  • ctags: 63,685
  • sloc: cpp: 368,283; ansic: 33,988; python: 12,417; java: 12,203; awk: 5,879; sh: 1,846; xml: 655; perl: 405; php: 211; objc: 194; makefile: 77; sed: 2
file content (99 lines) | stat: -rw-r--r-- 3,073 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# pylint: disable-msg=W0105

from wrapper_registry import NullWrapperRegistry, StdMapWrapperRegistry

"""

Global settings to the code generator.

"""

name_prefix = ''
"""
Prefix applied to global declarations, such as instance and type
structures.
"""

automatic_type_narrowing = False
"""
Default value for the automatic_type_narrowing parameter of C++ classes.
"""

allow_subclassing = False
"""
Allow generated classes to be subclassed by default.
"""

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.
"""


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
:class:`pybindgen.settings.ErrorHandler` subclass instance that handles the error.
"""

min_python_version=(2, 3)
"""
Minimum python version the generated code must support.
"""

wrapper_registry = NullWrapperRegistry
"""
A :class:`WrapperRegistry` subclass to use for creating
wrapper registries.  A wrapper registry ensures that at most one
python wrapper exists for each C/C++ object.
"""

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.
"""


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).
"""

def _get_deprecated_virtuals():
    if deprecated_virtuals is None:
        import warnings
        warnings.warn("The option pybindgen.settings.deprecated_virtuals has not been set."
                      "  I am going to assume the value of True, to preserve backward"
                      " compatibility, but the default value will change in the future,"
                      " and the option will eventually disappear.",
                      DeprecationWarning)
        return True
    return deprecated_virtuals


class ErrorHandler(object):
    def handle_error(self, 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.
        """
        raise NotImplementedError