17
struct swig_type_info;
20
Use -DSWIG_DIRECTOR_NOUEH if you prefer to avoid the use of the
21
Undefined Exception Handler provided by swift
23
#ifndef SWIG_DIRECTOR_NOUEH
24
#ifndef SWIG_DIRECTOR_UEH
25
#define SWIG_DIRECTOR_UEH
31
Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the
32
'Swig' namespace. This could be usefull for multi-modules projects.
20
34
#ifdef SWIG_DIRECTOR_STATIC
21
35
/* Force anonymous (static) namespace */
41
Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the
42
native C++ RTTI and dynamic_cast<>. But be aware that directors
43
could stop working when using this option.
45
#ifdef SWIG_DIRECTOR_NORTTI
47
When we don't use the native C++ RTTI, we implement a minimal one
50
# ifndef SWIG_DIRECTOR_RTDIR
51
# define SWIG_DIRECTOR_RTDIR
55
SWIGINTERN std::map<void*,Director*>& get_rtdir_map() {
56
static std::map<void*,Director*> rtdir_map;
60
SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) {
61
get_rtdir_map()[vptr] = rtdir;
64
SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
65
std::map<void*,Director*>::const_iterator pos = get_rtdir_map().find(vptr);
66
Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0;
70
# endif /* SWIG_DIRECTOR_RTDIR */
72
# define SWIG_DIRECTOR_CAST(Arg) Swig::get_rtdir(static_cast<void*>(Arg))
73
# define SWIG_DIRECTOR_RGTR(Arg1, Arg2) Swig::set_rtdir(static_cast<void*>(Arg1), Arg2)
77
# define SWIG_DIRECTOR_CAST(Arg) dynamic_cast<Swig::Director*>(Arg)
78
# define SWIG_DIRECTOR_RGTR(Arg1, Arg2)
80
#endif /* SWIG_DIRECTOR_NORTTI */
83
struct swig_type_info;
26
88
/* base class for director exceptions */
27
89
class DirectorException {
31
DirectorException(const char* msg="") {
33
const char *getMessage() const {
34
return swig_msg.c_str();
36
virtual ~DirectorException();
93
DirectorException(const char* hdr ="", const char* msg ="")
96
if (!PyErr_Occurred()) {
97
PyErr_SetString(PyExc_TypeError, getMessage());
99
SWIG_Python_AddErrMesg(getMessage(), 1);
103
const char *getMessage() const {
104
return swig_msg.c_str();
107
static void raise(const char* msg = "")
109
throw DirectorException(msg);
113
class UnknownExceptionHandler
115
static void handler();
119
#ifdef SWIG_DIRECTOR_UEH
120
std::unexpected_handler old;
121
UnknownExceptionHandler(std::unexpected_handler nh = handler)
123
old = std::set_unexpected(nh);
126
~UnknownExceptionHandler()
128
std::set_unexpected(old);
40
133
/* type mismatch in the return value from a python method call */
41
134
class DirectorTypeMismatchException : public Swig::DirectorException {
43
DirectorTypeMismatchException(const char* msg="") {
44
swig_msg = "Swig director type mismatch: ";
46
PyErr_SetString(PyExc_TypeError, getMessage());
136
DirectorTypeMismatchException(const char* msg="")
137
: Swig::DirectorException("Swig director type mismatch: ", msg) {
140
static void raise(const char* msg = "")
142
throw DirectorTypeMismatchException(msg);
50
146
/* any python exception that occurs during a director method call */
51
class DirectorMethodException : public Swig::DirectorException {};
147
class DirectorMethodException : public Swig::DirectorException {
149
DirectorMethodException(const char* msg = "")
150
: DirectorException("Swig director python method error: ", msg)
154
static void raise(const char* msg = "")
156
throw DirectorMethodException(msg);
53
160
/* attempt to call a pure virtual method via a director method */
54
class DirectorPureVirtualException : public Swig::DirectorException {};
161
class DirectorPureVirtualException : public Swig::DirectorException
164
DirectorPureVirtualException(const char* msg = "")
165
: DirectorException("Swig director pure virtal method called: ", msg)
169
static void raise(const char* msg = "")
171
throw DirectorPureVirtualException(msg);
57
176
/* simple thread abstraction for pthreads on win32 */
72
191
/* director base class */
75
/* pointer to the wrapped python object */
77
/* flag indicating whether the object is owned by python or c++ */
78
mutable bool swig_disown_flag;
79
/* shared flag for breaking recursive director calls */
194
/* pointer to the wrapped python object */
196
/* flag indicating whether the object is owned by python or c++ */
197
mutable bool swig_disown_flag;
198
/* shared flag for breaking recursive director calls */
82
201
#ifdef __PTHREAD__
83
/* locks for sharing the swig_up flag in a threaded environment */
84
static pthread_mutex_t swig_mutex_up;
85
static bool swig_mutex_active;
86
static pthread_t swig_mutex_thread;
202
/* locks for sharing the swig_up flag in a threaded environment */
203
static pthread_mutex_t swig_mutex_up;
204
static bool swig_mutex_active;
205
static pthread_t swig_mutex_thread;
89
/* decrement the reference count of the wrapped python object */
90
void swig_decref() const {
91
if (swig_disown_flag) {
208
/* decrement the reference count of the wrapped python object */
209
void swig_decref() const {
210
if (swig_disown_flag) {
211
Py_DECREF(swig_self);
96
/* reset the swig_up flag once the routing direction has been determined */
215
/* reset the swig_up flag once the routing direction has been determined */
97
216
#ifdef __PTHREAD__
98
void swig_clear_up() const {
99
Swig::Director::swig_up = false;
100
Swig::Director::swig_mutex_active = false;
101
pthread_mutex_unlock(&swig_mutex_up);
217
void swig_clear_up() const {
218
Swig::Director::swig_up = false;
219
Swig::Director::swig_mutex_active = false;
220
pthread_mutex_unlock(&swig_mutex_up);
104
void swig_clear_up() const {
105
Swig::Director::swig_up = false;
110
/* wrap a python object, optionally taking ownership */
111
Director(PyObject* self) : swig_self(self), swig_disown_flag(false) {
115
/* discard our reference at destruction */
118
/* return a pointer to the wrapped python object */
119
PyObject *swig_get_self() const {
123
/* get the swig_up flag to determine if the method call should be routed
124
* to the c++ base class or through the wrapped python object
127
bool swig_get_up() const {
128
if (Swig::Director::swig_mutex_active) {
129
if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
138
bool swig_get_up() const {
145
/* set the swig_up flag if the next method call should be directed to
146
* the c++ base class rather than the wrapped python object
149
void swig_set_up() const {
150
pthread_mutex_lock(&Swig::Director::swig_mutex_up);
151
Swig::Director::swig_mutex_thread = pthread_self();
152
Swig::Director::swig_mutex_active = true;
153
Swig::Director::swig_up = true;
156
void swig_set_up() const {
157
Swig::Director::swig_up = true;
161
/* acquire ownership of the wrapped python object (the sense of "disown"
163
void swig_disown() const {
164
if (!swig_disown_flag) {
165
swig_disown_flag=true;
170
/* increase the reference count of the wrapped python object */
171
void swig_incref() const {
172
if (swig_disown_flag) {
173
Py_INCREF(swig_self);
177
/* methods to implement pseudo protected director members */
178
virtual bool swig_get_inner(const char* name) const {
182
virtual void swig_set_inner(const char* name, bool val) const {
223
void swig_clear_up() const {
224
Swig::Director::swig_up = false;
229
/* wrap a python object, optionally taking ownership */
230
Director(PyObject* self) : swig_self(self), swig_disown_flag(false) {
234
/* discard our reference at destruction */
237
/* return a pointer to the wrapped python object */
238
PyObject *swig_get_self() const {
242
/* get the swig_up flag to determine if the method call should be routed
243
* to the c++ base class or through the wrapped python object
246
bool swig_get_up() const {
247
if (Swig::Director::swig_mutex_active) {
248
if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
257
bool swig_get_up() const {
264
/* set the swig_up flag if the next method call should be directed to
265
* the c++ base class rather than the wrapped python object
268
void swig_set_up() const {
269
pthread_mutex_lock(&Swig::Director::swig_mutex_up);
270
Swig::Director::swig_mutex_thread = pthread_self();
271
Swig::Director::swig_mutex_active = true;
272
Swig::Director::swig_up = true;
275
void swig_set_up() const {
276
Swig::Director::swig_up = true;
280
/* acquire ownership of the wrapped python object (the sense of "disown"
282
void swig_disown() const {
283
if (!swig_disown_flag) {
284
swig_disown_flag=true;
289
/* increase the reference count of the wrapped python object */
290
void swig_incref() const {
291
if (swig_disown_flag) {
292
Py_INCREF(swig_self);
296
/* methods to implement pseudo protected director members */
297
virtual bool swig_get_inner(const char* /* name */) const {
301
virtual void swig_set_inner(const char* /* name */, bool /* val */) const {