]>
Commit | Line | Data |
---|---|---|
b1462dfa | 1 | //////////////////////////////////////////////////////////////////////////// |
7bf85405 RD |
2 | // Name: helpers.h |
3 | // Purpose: Helper functions/classes for the wxPython extenaion module | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7/1/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef __wxp_helpers__ | |
14 | #define __wxp_helpers__ | |
15 | ||
16 | #include <wx/wx.h> | |
17 | ||
cf694132 RD |
18 | //---------------------------------------------------------------------- |
19 | ||
20 | // if we want to handle threads and Python threads are available... | |
21 | #if defined(WXP_USE_THREAD) && defined(WITH_THREAD) | |
22 | ||
23 | #define WXP_WITH_THREAD | |
24 | #define wxPy_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS | |
25 | #define wxPy_END_ALLOW_THREADS Py_END_ALLOW_THREADS | |
26 | ||
27 | #else // no Python threads... | |
28 | #undef WXP_WITH_THREAD | |
29 | #define wxPy_BEGIN_ALLOW_THREADS | |
30 | #define wxPy_END_ALLOW_THREADS | |
31 | #endif | |
32 | ||
33 | ||
efc5f224 RD |
34 | //--------------------------------------------------------------------------- |
35 | ||
2f90df85 RD |
36 | typedef unsigned char byte; |
37 | ||
7bf85405 RD |
38 | |
39 | class wxPyApp: public wxApp | |
40 | { | |
41 | public: | |
cf694132 RD |
42 | wxPyApp(); |
43 | ~wxPyApp(); | |
7bf85405 RD |
44 | int MainLoop(void); |
45 | bool OnInit(void); | |
7bf85405 | 46 | }; |
7bf85405 RD |
47 | extern wxPyApp *wxPythonApp; |
48 | ||
49 | //---------------------------------------------------------------------- | |
50 | ||
0d6f9504 | 51 | void __wxPreStart(); |
7bf85405 | 52 | PyObject* __wxStart(PyObject*, PyObject* args); |
7ff49f0c | 53 | void __wxCleanup(); |
7bf85405 | 54 | |
9416aa89 | 55 | //extern PyObject* wxPython_dict; |
7bf85405 RD |
56 | PyObject* __wxSetDictionary(PyObject*, PyObject* args); |
57 | ||
7bf85405 | 58 | void wxPyEventThunker(wxObject*, wxEvent& event); |
efc5f224 | 59 | |
1e7ecb7b RD |
60 | PyObject* wxPyConstructObject(void* ptr, |
61 | const char* className, | |
62 | int setThisOwn=0); | |
9416aa89 RD |
63 | PyObject* wxPyConstructObject(void* ptr, |
64 | const char* className, | |
65 | PyObject* klass, | |
66 | int setThisOwn=0); | |
67 | PyObject* wxPyClassExists(const char* className); | |
68 | PyObject* wxPyMake_wxObject(wxObject* source); | |
69 | void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName); | |
70 | ||
1e7ecb7b RD |
71 | PyObject* wxPy_ConvertList(wxListBase* list, const char* className); |
72 | long wxPyGetWinHandle(wxWindow* win); | |
9b3d3bc4 | 73 | |
19a97bd6 RD |
74 | //---------------------------------------------------------------------- |
75 | ||
76 | struct wxPyTState { | |
77 | PyThreadState* newState; | |
78 | PyThreadState* prevState; | |
79 | ||
80 | wxPyTState() : newState(NULL), prevState(NULL) {} | |
81 | }; | |
82 | ||
83 | ||
84 | wxPyTState* wxPyBeginBlockThreads(); | |
85 | void wxPyEndBlockThreads(wxPyTState* state); | |
9b3d3bc4 | 86 | |
9b3d3bc4 | 87 | |
c368d904 RD |
88 | //---------------------------------------------------------------------- |
89 | // Handle wxInputStreams by Joerg Baumann | |
90 | // See stream.i for implementations | |
91 | ||
92 | // list class for return list of strings, e.g. readlines() | |
93 | WX_DECLARE_LIST(wxString, wxStringPtrList); | |
94 | ||
95 | ||
96 | // C++ class wxPyInputStream to act as base for python class wxInputStream | |
97 | // Use it in python like a python file object | |
1e7ecb7b | 98 | class wxPyInputStream { |
c368d904 RD |
99 | public: |
100 | // underlying wxInputStream | |
101 | wxInputStream* wxi; | |
102 | ||
103 | public: | |
104 | wxPyInputStream(wxInputStream* wxi_) : wxi(wxi_) {} | |
105 | ~wxPyInputStream(); | |
106 | ||
107 | // python file object interface for input files (most of it) | |
108 | void close(); | |
109 | void flush(); | |
110 | bool eof(); | |
111 | wxString* read(int size=-1); | |
112 | wxString* readline(int size=-1); | |
113 | wxStringPtrList* readlines(int sizehint=-1); | |
114 | void seek(int offset, int whence=0); | |
115 | int tell(); | |
116 | /* | |
117 | bool isatty(); | |
118 | int fileno(); | |
119 | void truncate(int size=-1); | |
120 | void write(wxString data); | |
121 | void writelines(wxStringPtrList); | |
122 | */ | |
123 | }; | |
124 | ||
125 | ||
7bf85405 | 126 | //---------------------------------------------------------------------- |
2f90df85 RD |
127 | // These are helpers used by the typemaps |
128 | ||
1e7ecb7b RD |
129 | byte* byte_LIST_helper(PyObject* source); |
130 | int* int_LIST_helper(PyObject* source); | |
131 | long* long_LIST_helper(PyObject* source); | |
132 | char** string_LIST_helper(PyObject* source); | |
e0672e2f | 133 | wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints); |
1e7ecb7b RD |
134 | wxBitmap** wxBitmap_LIST_helper(PyObject* source); |
135 | wxString* wxString_LIST_helper(PyObject* source); | |
136 | wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source); | |
9d37f964 | 137 | wxPen** wxPen_LIST_helper(PyObject* source); |
1e7ecb7b RD |
138 | |
139 | bool wxSize_helper(PyObject* source, wxSize** obj); | |
140 | bool wxPoint_helper(PyObject* source, wxPoint** obj); | |
141 | bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj); | |
142 | bool wxRect_helper(PyObject* source, wxRect** obj); | |
143 | bool wxColour_helper(PyObject* source, wxColour** obj); | |
7bf85405 | 144 | |
9d37f964 RD |
145 | #if PYTHON_API_VERSION < 1009 |
146 | #define PySequence_Fast_GET_ITEM(o, i) \ | |
147 | (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) | |
148 | #endif | |
149 | ||
150 | bool _2int_seq_helper(PyObject* source, int* i1, int* i2); | |
151 | bool _4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4); | |
152 | ||
153 | ||
b37c7e1d RD |
154 | PyObject* wxArrayString2PyList_helper(const wxArrayString& app); |
155 | ||
156 | ||
157 | #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; } | |
158 | ||
2f90df85 | 159 | //---------------------------------------------------------------------- |
7bf85405 RD |
160 | |
161 | #ifndef SWIGCODE | |
162 | extern "C" void SWIG_MakePtr(char *, void *, char *); | |
163 | extern "C" char *SWIG_GetPtr(char *, void **, char *); | |
d559219f | 164 | extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type); |
7bf85405 RD |
165 | #endif |
166 | ||
167 | ||
168 | #ifdef _MSC_VER | |
169 | # pragma warning(disable:4800) | |
f6bcfd97 | 170 | # pragma warning(disable:4190) |
7bf85405 RD |
171 | #endif |
172 | ||
7bf85405 RD |
173 | //---------------------------------------------------------------------- |
174 | ||
175 | class wxPyCallback : public wxObject { | |
2f90df85 | 176 | DECLARE_ABSTRACT_CLASS(wxPyCallback); |
7bf85405 | 177 | public: |
cf694132 | 178 | wxPyCallback(PyObject* func); |
2f90df85 | 179 | wxPyCallback(const wxPyCallback& other); |
cf694132 | 180 | ~wxPyCallback(); |
7bf85405 RD |
181 | |
182 | void EventThunker(wxEvent& event); | |
183 | ||
184 | PyObject* m_func; | |
185 | }; | |
186 | ||
7bf85405 RD |
187 | //--------------------------------------------------------------------------- |
188 | ||
189 | class wxPyTimer : public wxTimer { | |
190 | public: | |
191 | wxPyTimer(PyObject* callback); | |
192 | ~wxPyTimer(); | |
193 | ||
194 | void Notify(); | |
195 | ||
196 | private: | |
197 | PyObject* func; | |
198 | }; | |
199 | ||
cf694132 | 200 | //--------------------------------------------------------------------------- |
65dd82cb | 201 | //--------------------------------------------------------------------------- |
9b3d3bc4 RD |
202 | // These Event classes can be derived from in Python and passed through the |
203 | // event system without loosing anything. They do this by keeping a reference | |
204 | // to themselves and some special case handling in wxPyCallback::EventThunker. | |
65dd82cb RD |
205 | |
206 | ||
e19b7164 | 207 | class wxPyEvtSelfRef { |
65dd82cb | 208 | public: |
e19b7164 RD |
209 | wxPyEvtSelfRef(); |
210 | ~wxPyEvtSelfRef(); | |
65dd82cb RD |
211 | |
212 | void SetSelf(PyObject* self, bool clone=FALSE); | |
213 | PyObject* GetSelf() const; | |
214 | ||
215 | protected: | |
216 | PyObject* m_self; | |
217 | bool m_cloned; | |
218 | }; | |
219 | ||
220 | ||
e19b7164 | 221 | class wxPyEvent : public wxEvent, public wxPyEvtSelfRef { |
65dd82cb RD |
222 | DECLARE_DYNAMIC_CLASS(wxPyEvent) |
223 | public: | |
224 | wxPyEvent(int id=0); | |
225 | ~wxPyEvent(); | |
226 | ||
227 | void CopyObject(wxObject& dest) const; | |
228 | }; | |
229 | ||
230 | ||
e19b7164 | 231 | class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef { |
65dd82cb RD |
232 | DECLARE_DYNAMIC_CLASS(wxPyCommandEvent) |
233 | public: | |
234 | wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0); | |
235 | ~wxPyCommandEvent(); | |
236 | ||
237 | void CopyObject(wxObject& dest) const; | |
238 | }; | |
239 | ||
bb0054cd | 240 | |
1e7ecb7b RD |
241 | //--------------------------------------------------------------------------- |
242 | // Export a C API in a struct. Other modules will be able to load this from | |
243 | // the wxc module and will then have safe access to these functions, even if | |
244 | // in another shared library. | |
245 | ||
246 | class wxPyCallbackHelper; | |
247 | ||
248 | struct wxPyCoreAPI { | |
249 | ||
250 | void (*p_SWIG_MakePtr)(char*, void*, char*); | |
251 | char* (*p_SWIG_GetPtr)(char*, void**, char*); | |
252 | char* (*p_SWIG_GetPtrObj)(PyObject*, void**, char*); | |
253 | void (*p_SWIG_RegisterMapping)(char*, char*, void *(*cast)(void *)); | |
254 | void (*p_SWIG_addvarlink)(PyObject*, char*, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)); | |
255 | PyObject* (*p_SWIG_newvarlink)(void); | |
256 | ||
19a97bd6 RD |
257 | wxPyTState* (*p_wxPyBeginBlockThreads)(); |
258 | void (*p_wxPyEndBlockThreads)(wxPyTState* state); | |
259 | ||
1e7ecb7b RD |
260 | PyObject* (*p_wxPyConstructObject)(void *, const char *, int); |
261 | PyObject* (*p_wxPy_ConvertList)(wxListBase* list, const char* className); | |
262 | ||
263 | byte* (*p_byte_LIST_helper)(PyObject* source); | |
264 | int* (*p_int_LIST_helper)(PyObject* source); | |
265 | long* (*p_long_LIST_helper)(PyObject* source); | |
266 | char** (*p_string_LIST_helper)(PyObject* source); | |
e0672e2f | 267 | wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints); |
1e7ecb7b RD |
268 | wxBitmap** (*p_wxBitmap_LIST_helper)(PyObject* source); |
269 | wxString* (*p_wxString_LIST_helper)(PyObject* source); | |
270 | wxAcceleratorEntry* (*p_wxAcceleratorEntry_LIST_helper)(PyObject* source); | |
271 | ||
272 | bool (*p_wxSize_helper)(PyObject* source, wxSize** obj); | |
273 | bool (*p_wxPoint_helper)(PyObject* source, wxPoint** obj); | |
274 | bool (*p_wxRealPoint_helper)(PyObject* source, wxRealPoint** obj); | |
275 | bool (*p_wxRect_helper)(PyObject* source, wxRect** obj); | |
276 | bool (*p_wxColour_helper)(PyObject* source, wxColour** obj); | |
277 | ||
0122b7e3 | 278 | void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref); |
1e7ecb7b RD |
279 | bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name); |
280 | int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
281 | PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
282 | void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh); | |
283 | ||
9416aa89 RD |
284 | PyObject* (*p_wxPyClassExists)(const char* className); |
285 | PyObject* (*p_wxPyMake_wxObject)(wxObject* source); | |
286 | void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName); | |
287 | ||
1e7ecb7b RD |
288 | }; |
289 | ||
290 | #ifdef wxPyUSE_EXPORT | |
291 | static wxPyCoreAPI* wxPyCoreAPIPtr = NULL; // Each module needs one, but may not use it. | |
292 | #endif | |
293 | ||
294 | //--------------------------------------------------------------------------- | |
295 | // This class holds an instance of a Python Shadow Class object and assists | |
296 | // with looking up and invoking Python callback methods from C++ virtual | |
297 | // method redirections. For all classes which have virtuals which should be | |
298 | // overridable in wxPython, a new subclass is created that contains a | |
299 | // wxPyCallbackHelper. | |
300 | // | |
301 | ||
302 | class wxPyCallbackHelper { | |
303 | public: | |
304 | wxPyCallbackHelper(const wxPyCallbackHelper& other); | |
305 | ||
306 | wxPyCallbackHelper() { | |
307 | m_class = NULL; | |
308 | m_self = NULL; | |
309 | m_lastFound = NULL; | |
310 | m_incRef = FALSE; | |
311 | } | |
312 | ||
313 | ~wxPyCallbackHelper() { | |
314 | #ifdef wxPyUSE_EXPORT | |
315 | wxPyCoreAPIPtr->p_wxPyCBH_delete(this); | |
316 | #else | |
317 | wxPyCBH_delete(this); | |
318 | #endif | |
319 | } | |
320 | ||
321 | void setSelf(PyObject* self, PyObject* klass, int incref=TRUE); | |
322 | bool findCallback(const char* name) const; | |
323 | int callCallback(PyObject* argTuple) const; | |
324 | PyObject* callCallbackObj(PyObject* argTuple) const; | |
325 | ||
326 | private: | |
327 | PyObject* m_self; | |
328 | PyObject* m_class; | |
329 | PyObject* m_lastFound; | |
330 | int m_incRef; | |
331 | ||
332 | friend void wxPyCBH_delete(wxPyCallbackHelper* cbh); | |
333 | }; | |
334 | ||
335 | ||
0122b7e3 | 336 | void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref); |
1e7ecb7b RD |
337 | bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name); |
338 | int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
339 | PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
340 | void wxPyCBH_delete(wxPyCallbackHelper* cbh); | |
341 | ||
342 | ||
343 | ||
344 | //---------------------------------------------------------------------- | |
345 | ||
346 | class wxPyUserData : public wxObject { | |
347 | public: | |
348 | wxPyUserData(PyObject* obj) { | |
349 | m_obj = obj; | |
350 | Py_INCREF(m_obj); | |
351 | } | |
352 | ||
353 | ~wxPyUserData() { | |
1e7ecb7b | 354 | #ifdef wxPyUSE_EXPORT |
19a97bd6 | 355 | wxPyTState* state = wxPyCoreAPIPtr->p_wxPyBeginBlockThreads(); |
1e7ecb7b | 356 | Py_DECREF(m_obj); |
19a97bd6 | 357 | wxPyCoreAPIPtr->p_wxPyEndBlockThreads(state); |
1e7ecb7b | 358 | #else |
19a97bd6 | 359 | wxPyTState* state = wxPyBeginBlockThreads(); |
bdb9373a | 360 | Py_DECREF(m_obj); |
19a97bd6 | 361 | wxPyEndBlockThreads(state); |
1e7ecb7b RD |
362 | #endif |
363 | } | |
364 | PyObject* m_obj; | |
365 | }; | |
366 | ||
367 | ||
368 | ||
900d9886 RD |
369 | class wxPyClientData : public wxClientData { |
370 | public: | |
371 | wxPyClientData(PyObject* obj) { | |
372 | m_obj = obj; | |
373 | Py_INCREF(m_obj); | |
374 | } | |
375 | ||
376 | ~wxPyClientData() { | |
377 | #ifdef wxPyUSE_EXPORT | |
378 | wxPyTState* state = wxPyCoreAPIPtr->p_wxPyBeginBlockThreads(); | |
379 | Py_DECREF(m_obj); | |
380 | wxPyCoreAPIPtr->p_wxPyEndBlockThreads(state); | |
381 | #else | |
382 | wxPyTState* state = wxPyBeginBlockThreads(); | |
383 | Py_DECREF(m_obj); | |
384 | wxPyEndBlockThreads(state); | |
385 | #endif | |
386 | } | |
387 | PyObject* m_obj; | |
388 | }; | |
389 | ||
390 | ||
391 | ||
bb0054cd RD |
392 | //--------------------------------------------------------------------------- |
393 | // These macros are used to implement the virtual methods that should | |
394 | // redirect to a Python method if one exists. The names designate the | |
b1462dfa | 395 | // return type, if any, as well as any parameter types. |
bb0054cd RD |
396 | //--------------------------------------------------------------------------- |
397 | ||
f6bcfd97 | 398 | #define PYPRIVATE \ |
0122b7e3 RD |
399 | void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \ |
400 | wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \ | |
f6bcfd97 | 401 | } \ |
c368d904 | 402 | private: wxPyCallbackHelper m_myInst |
efc5f224 RD |
403 | |
404 | //--------------------------------------------------------------------------- | |
405 | ||
d559219f RD |
406 | #define DEC_PYCALLBACK__(CBNAME) \ |
407 | void CBNAME(); \ | |
408 | void base_##CBNAME(); | |
409 | ||
410 | ||
19a97bd6 RD |
411 | #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \ |
412 | void CLASS::CBNAME() { \ | |
413 | bool found; \ | |
414 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
415 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
416 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
417 | wxPyEndBlockThreads(state); \ | |
418 | if (! found) \ | |
419 | PCLASS::CBNAME(); \ | |
420 | } \ | |
421 | void CLASS::base_##CBNAME() { \ | |
422 | PCLASS::CBNAME(); \ | |
d559219f RD |
423 | } |
424 | ||
425 | //--------------------------------------------------------------------------- | |
426 | ||
427 | #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \ | |
428 | bool CBNAME(int a, int b); \ | |
429 | bool base_##CBNAME(int a, int b); | |
430 | ||
431 | ||
432 | #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \ | |
433 | bool CLASS::CBNAME(int a, int b) { \ | |
059a841c | 434 | bool rval=FALSE, found; \ |
19a97bd6 RD |
435 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
436 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
1e7ecb7b | 437 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ |
19a97bd6 RD |
438 | wxPyEndBlockThreads(state); \ |
439 | if (! found) \ | |
d559219f | 440 | rval = PCLASS::CBNAME(a,b); \ |
d559219f | 441 | return rval; \ |
bb0054cd | 442 | } \ |
d559219f | 443 | bool CLASS::base_##CBNAME(int a, int b) { \ |
bb0054cd RD |
444 | return PCLASS::CBNAME(a,b); \ |
445 | } | |
446 | ||
447 | //--------------------------------------------------------------------------- | |
448 | ||
c368d904 RD |
449 | #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \ |
450 | void CBNAME(int a, int b); \ | |
451 | void base_##CBNAME(int a, int b); | |
452 | ||
453 | ||
454 | #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \ | |
455 | void CLASS::CBNAME(int a, int b) { \ | |
19a97bd6 RD |
456 | bool found; \ |
457 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
458 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
459 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
460 | wxPyEndBlockThreads(state); \ | |
461 | if (! found) \ | |
c368d904 | 462 | PCLASS::CBNAME(a,b); \ |
c368d904 RD |
463 | } \ |
464 | void CLASS::base_##CBNAME(int a, int b) { \ | |
465 | PCLASS::CBNAME(a,b); \ | |
466 | } | |
467 | ||
468 | //--------------------------------------------------------------------------- | |
469 | ||
d559219f RD |
470 | #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \ |
471 | bool CBNAME(int a); \ | |
472 | bool base_##CBNAME(int a); | |
473 | ||
474 | ||
475 | #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \ | |
476 | bool CLASS::CBNAME(int a) { \ | |
059a841c | 477 | bool rval=FALSE, found; \ |
19a97bd6 RD |
478 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
479 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
059a841c | 480 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\ |
19a97bd6 RD |
481 | wxPyEndBlockThreads(state); \ |
482 | if (! found) \ | |
d559219f | 483 | rval = PCLASS::CBNAME(a); \ |
d559219f | 484 | return rval; \ |
bb0054cd | 485 | } \ |
d559219f | 486 | bool CLASS::base_##CBNAME(int a) { \ |
bb0054cd RD |
487 | return PCLASS::CBNAME(a); \ |
488 | } | |
489 | ||
efc5f224 RD |
490 | //--------------------------------------------------------------------------- |
491 | ||
d559219f RD |
492 | #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \ |
493 | bool CBNAME(int a); | |
494 | ||
495 | ||
496 | #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \ | |
497 | bool CLASS::CBNAME(int a) { \ | |
059a841c | 498 | bool rval=FALSE; \ |
19a97bd6 RD |
499 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
500 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
1e7ecb7b | 501 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \ |
194fa2ac | 502 | else rval = FALSE; \ |
19a97bd6 | 503 | wxPyEndBlockThreads(state); \ |
d559219f | 504 | return rval; \ |
bb0054cd RD |
505 | } |
506 | ||
507 | ||
508 | //--------------------------------------------------------------------------- | |
509 | ||
d559219f RD |
510 | #define DEC_PYCALLBACK__DC(CBNAME) \ |
511 | void CBNAME(wxDC& a); \ | |
512 | void base_##CBNAME(wxDC& a); | |
513 | ||
514 | ||
19a97bd6 RD |
515 | #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \ |
516 | void CLASS::CBNAME(wxDC& a) { \ | |
517 | bool found; \ | |
518 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
519 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
520 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
521 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
522 | Py_DECREF(obj); \ | |
523 | } \ | |
524 | wxPyEndBlockThreads(state); \ | |
525 | if (! found) \ | |
526 | PCLASS::CBNAME(a); \ | |
527 | } \ | |
528 | void CLASS::base_##CBNAME(wxDC& a) { \ | |
529 | PCLASS::CBNAME(a); \ | |
bb0054cd RD |
530 | } |
531 | ||
efc5f224 RD |
532 | |
533 | ||
bb0054cd RD |
534 | //--------------------------------------------------------------------------- |
535 | ||
d559219f RD |
536 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
537 | void CBNAME(wxDC& a, bool b); \ | |
538 | void base_##CBNAME(wxDC& a, bool b); | |
539 | ||
540 | ||
541 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
542 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
19a97bd6 RD |
543 | bool found; \ |
544 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
545 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
546 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 547 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ |
de20db99 RD |
548 | Py_DECREF(obj); \ |
549 | } \ | |
19a97bd6 RD |
550 | wxPyEndBlockThreads(state); \ |
551 | if (! found) \ | |
efc5f224 RD |
552 | PCLASS::CBNAME(a, b); \ |
553 | } \ | |
d559219f | 554 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ |
efc5f224 RD |
555 | PCLASS::CBNAME(a, b); \ |
556 | } | |
557 | ||
558 | //--------------------------------------------------------------------------- | |
559 | ||
d559219f RD |
560 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
561 | void CBNAME(wxDC& a, bool b); \ | |
562 | void base_##CBNAME(wxDC& a, bool b); | |
563 | ||
564 | ||
565 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
566 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
19a97bd6 RD |
567 | bool found; \ |
568 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
569 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
570 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 571 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ |
de20db99 RD |
572 | Py_DECREF(obj); \ |
573 | } \ | |
19a97bd6 RD |
574 | wxPyEndBlockThreads(state); \ |
575 | if (! found) \ | |
efc5f224 RD |
576 | PCLASS::CBNAME(a, b); \ |
577 | } \ | |
d559219f | 578 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ |
efc5f224 RD |
579 | PCLASS::CBNAME(a, b); \ |
580 | } | |
581 | ||
582 | //--------------------------------------------------------------------------- | |
583 | ||
d559219f RD |
584 | #define DEC_PYCALLBACK__2DBL(CBNAME) \ |
585 | void CBNAME(double a, double b); \ | |
586 | void base_##CBNAME(double a, double b); | |
587 | ||
588 | ||
19a97bd6 RD |
589 | #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \ |
590 | void CLASS::CBNAME(double a, double b) { \ | |
591 | bool found; \ | |
592 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
593 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
594 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \ | |
595 | wxPyEndBlockThreads(state); \ | |
596 | if (! found) \ | |
597 | PCLASS::CBNAME(a, b); \ | |
598 | } \ | |
599 | void CLASS::base_##CBNAME(double a, double b) { \ | |
600 | PCLASS::CBNAME(a, b); \ | |
efc5f224 RD |
601 | } |
602 | ||
603 | //--------------------------------------------------------------------------- | |
604 | ||
d559219f RD |
605 | #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \ |
606 | void CBNAME(double a, double b, int c, int d); \ | |
607 | void base_##CBNAME(double a, double b, int c, int d); | |
608 | ||
609 | ||
610 | #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
611 | void CLASS::CBNAME(double a, double b, int c, int d) { \ | |
19a97bd6 RD |
612 | bool found; \ |
613 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
614 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
615 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \ | |
efc5f224 | 616 | a,b,c,d)); \ |
19a97bd6 RD |
617 | wxPyEndBlockThreads(state); \ |
618 | if (! found) \ | |
efc5f224 RD |
619 | PCLASS::CBNAME(a, b, c, d); \ |
620 | } \ | |
d559219f | 621 | void CLASS::base_##CBNAME(double a, double b, int c, int d) { \ |
efc5f224 RD |
622 | PCLASS::CBNAME(a, b, c, d); \ |
623 | } | |
624 | ||
625 | //--------------------------------------------------------------------------- | |
626 | ||
19a97bd6 | 627 | #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \ |
d559219f RD |
628 | void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \ |
629 | void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f); | |
630 | ||
631 | ||
632 | #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \ | |
633 | void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \ | |
19a97bd6 RD |
634 | bool found; \ |
635 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
636 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
637 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 638 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \ |
de20db99 RD |
639 | Py_DECREF(obj); \ |
640 | } \ | |
19a97bd6 RD |
641 | wxPyEndBlockThreads(state); \ |
642 | if (! found) \ | |
d559219f | 643 | PCLASS::CBNAME(a, b, c, d, e, f); \ |
d559219f RD |
644 | } \ |
645 | void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ | |
646 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
efc5f224 RD |
647 | } |
648 | ||
649 | //--------------------------------------------------------------------------- | |
650 | ||
d559219f RD |
651 | #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \ |
652 | bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \ | |
653 | bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f); | |
654 | ||
655 | ||
656 | #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \ | |
657 | bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \ | |
19a97bd6 RD |
658 | bool found; \ |
659 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
059a841c | 660 | bool rval=FALSE; \ |
19a97bd6 RD |
661 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
662 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 663 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\ |
de20db99 RD |
664 | Py_DECREF(obj); \ |
665 | } \ | |
19a97bd6 RD |
666 | wxPyEndBlockThreads(state); \ |
667 | if (! found) \ | |
99a49d3e | 668 | rval = PCLASS::CBNAME(a, b, c, d, e, f); \ |
99a49d3e | 669 | return rval; \ |
d559219f RD |
670 | } \ |
671 | bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ | |
672 | return PCLASS::CBNAME(a, b, c, d, e, f); \ | |
efc5f224 RD |
673 | } |
674 | ||
675 | //--------------------------------------------------------------------------- | |
676 | ||
d559219f RD |
677 | #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \ |
678 | void CBNAME(bool a, double b, double c, int d, int e); \ | |
679 | void base_##CBNAME(bool a, double b, double c, int d, int e); | |
680 | ||
681 | ||
682 | #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
683 | void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \ | |
19a97bd6 RD |
684 | bool found; \ |
685 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
686 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
f2e1c18a | 687 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \ |
d559219f | 688 | (int)a,b,c,d,e)); \ |
19a97bd6 RD |
689 | wxPyEndBlockThreads(state); \ |
690 | if (! found) \ | |
d559219f | 691 | PCLASS::CBNAME(a, b, c, d, e); \ |
d559219f RD |
692 | } \ |
693 | void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \ | |
694 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
695 | } |
696 | ||
697 | //--------------------------------------------------------------------------- | |
698 | ||
19a97bd6 | 699 | #define DEC_PYCALLBACK__DC4DBL(CBNAME) \ |
d559219f RD |
700 | void CBNAME(wxDC& a, double b, double c, double d, double e); \ |
701 | void base_##CBNAME(wxDC& a, double b, double c, double d, double e); | |
702 | ||
703 | ||
704 | #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \ | |
705 | void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \ | |
19a97bd6 RD |
706 | bool found; \ |
707 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
708 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
709 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 710 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \ |
de20db99 RD |
711 | Py_DECREF(obj); \ |
712 | } \ | |
19a97bd6 RD |
713 | wxPyEndBlockThreads(state); \ |
714 | if (! found) \ | |
d559219f | 715 | PCLASS::CBNAME(a, b, c, d, e); \ |
d559219f RD |
716 | } \ |
717 | void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\ | |
718 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
719 | } |
720 | ||
721 | //--------------------------------------------------------------------------- | |
722 | ||
d559219f RD |
723 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
724 | void CBNAME(wxDC& a, bool b); \ | |
725 | void base_##CBNAME(wxDC& a, bool b); | |
726 | ||
727 | ||
19a97bd6 RD |
728 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ |
729 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
730 | bool found; \ | |
731 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
732 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
733 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
734 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ | |
735 | Py_DECREF(obj); \ | |
736 | } \ | |
737 | wxPyEndBlockThreads(state); \ | |
738 | if (! found) \ | |
739 | PCLASS::CBNAME(a, b); \ | |
740 | } \ | |
741 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ | |
742 | PCLASS::CBNAME(a, b); \ | |
efc5f224 | 743 | } |
bb0054cd | 744 | |
7bf85405 | 745 | //--------------------------------------------------------------------------- |
7bf85405 | 746 | |
d559219f RD |
747 | #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \ |
748 | void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \ | |
749 | void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); | |
750 | ||
751 | ||
752 | #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
753 | void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \ | |
754 | int e, int f) { \ | |
19a97bd6 RD |
755 | bool found; \ |
756 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
757 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
758 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1e7ecb7b | 759 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\ |
de20db99 RD |
760 | Py_DECREF(obj); \ |
761 | } \ | |
19a97bd6 RD |
762 | wxPyEndBlockThreads(state); \ |
763 | if (! found) \ | |
d559219f | 764 | PCLASS::CBNAME(a, b, c, d, e, f); \ |
d559219f RD |
765 | } \ |
766 | void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \ | |
767 | int e, int f) { \ | |
768 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
efc5f224 RD |
769 | } |
770 | ||
771 | //--------------------------------------------------------------------------- | |
772 | ||
d559219f RD |
773 | #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \ |
774 | void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \ | |
775 | void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e); | |
776 | ||
777 | ||
778 | #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
779 | void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \ | |
19a97bd6 RD |
780 | bool found; \ |
781 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
782 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
783 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1e7ecb7b | 784 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \ |
de20db99 RD |
785 | Py_DECREF(obj); \ |
786 | } \ | |
19a97bd6 RD |
787 | wxPyEndBlockThreads(state); \ |
788 | if (! found) \ | |
d559219f | 789 | PCLASS::CBNAME(a, b, c, d, e); \ |
d559219f RD |
790 | } \ |
791 | void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \ | |
792 | int d, int e) { \ | |
793 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
794 | } |
795 | ||
796 | //--------------------------------------------------------------------------- | |
797 | ||
d559219f RD |
798 | #define DEC_PYCALLBACK__2DBLINT(CBNAME) \ |
799 | void CBNAME(double a, double b, int c); \ | |
800 | void base_##CBNAME(double a, double b, int c); | |
801 | ||
802 | ||
19a97bd6 RD |
803 | #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \ |
804 | void CLASS::CBNAME(double a, double b, int c) { \ | |
805 | bool found; \ | |
806 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
807 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
808 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \ | |
809 | wxPyEndBlockThreads(state); \ | |
810 | if (! found) \ | |
811 | PCLASS::CBNAME(a, b, c); \ | |
812 | } \ | |
813 | void CLASS::base_##CBNAME(double a, double b, int c) { \ | |
814 | PCLASS::CBNAME(a, b, c); \ | |
efc5f224 RD |
815 | } |
816 | ||
817 | //--------------------------------------------------------------------------- | |
818 | ||
d559219f RD |
819 | #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \ |
820 | void CBNAME(bool a, double b, double c, int d); \ | |
821 | void base_##CBNAME(bool a, double b, double c, int d); | |
822 | ||
823 | ||
824 | #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \ | |
825 | void CLASS::CBNAME(bool a, double b, double c, int d) { \ | |
19a97bd6 RD |
826 | bool found; \ |
827 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
828 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
829 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\ | |
830 | wxPyEndBlockThreads(state); \ | |
831 | if (! found) \ | |
d559219f | 832 | PCLASS::CBNAME(a, b, c, d); \ |
d559219f RD |
833 | } \ |
834 | void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \ | |
835 | PCLASS::CBNAME(a, b, c, d); \ | |
efc5f224 RD |
836 | } |
837 | ||
838 | //--------------------------------------------------------------------------- | |
839 | //--------------------------------------------------------------------------- | |
389c5527 RD |
840 | |
841 | #define DEC_PYCALLBACK__STRING(CBNAME) \ | |
842 | void CBNAME(const wxString& a); \ | |
843 | void base_##CBNAME(const wxString& a); | |
844 | ||
845 | ||
19a97bd6 RD |
846 | #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \ |
847 | void CLASS::CBNAME(const wxString& a) { \ | |
848 | bool found; \ | |
849 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
850 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
851 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ | |
852 | wxPyEndBlockThreads(state); \ | |
853 | if (! found) \ | |
854 | PCLASS::CBNAME(a); \ | |
855 | } \ | |
856 | void CLASS::base_##CBNAME(const wxString& a) { \ | |
857 | PCLASS::CBNAME(a); \ | |
389c5527 RD |
858 | } |
859 | ||
860 | //--------------------------------------------------------------------------- | |
861 | ||
862 | #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \ | |
863 | bool CBNAME(const wxString& a); \ | |
864 | bool base_##CBNAME(const wxString& a); | |
865 | ||
866 | ||
867 | #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \ | |
868 | bool CLASS::CBNAME(const wxString& a) { \ | |
059a841c | 869 | bool rval=FALSE; \ |
19a97bd6 RD |
870 | bool found; \ |
871 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
872 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
873 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\ | |
874 | wxPyEndBlockThreads(state); \ | |
875 | if (! found) \ | |
389c5527 | 876 | rval = PCLASS::CBNAME(a); \ |
389c5527 RD |
877 | return rval; \ |
878 | } \ | |
879 | bool CLASS::base_##CBNAME(const wxString& a) { \ | |
880 | return PCLASS::CBNAME(a); \ | |
881 | } | |
882 | ||
883 | //--------------------------------------------------------------------------- | |
884 | ||
c368d904 RD |
885 | #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \ |
886 | bool CBNAME(const wxString& a); | |
887 | \ | |
19a97bd6 RD |
888 | #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \ |
889 | bool CLASS::CBNAME(const wxString& a) { \ | |
059a841c | 890 | bool rval=FALSE; \ |
19a97bd6 RD |
891 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
892 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
893 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ | |
894 | wxPyEndBlockThreads(state); \ | |
895 | return rval; \ | |
896 | } \ | |
c368d904 RD |
897 | |
898 | //--------------------------------------------------------------------------- | |
899 | ||
900 | #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \ | |
901 | wxString CBNAME(const wxString& a); \ | |
902 | ||
903 | #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \ | |
904 | wxString CLASS::CBNAME(const wxString& a) { \ | |
905 | wxString rval; \ | |
19a97bd6 RD |
906 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
907 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
c368d904 | 908 | PyObject* ro; \ |
19a97bd6 | 909 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\ |
c368d904 | 910 | if (ro) { \ |
de20db99 RD |
911 | PyObject* str = PyObject_Str(ro); \ |
912 | rval = PyString_AsString(str); \ | |
913 | Py_DECREF(ro); Py_DECREF(str); \ | |
c368d904 RD |
914 | } \ |
915 | } \ | |
19a97bd6 | 916 | wxPyEndBlockThreads(state); \ |
c368d904 RD |
917 | return rval; \ |
918 | } \ | |
919 | ||
920 | //--------------------------------------------------------------------------- | |
921 | ||
922 | #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \ | |
923 | wxString CBNAME(const wxString& a,int b); \ | |
924 | ||
925 | #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \ | |
926 | wxString CLASS::CBNAME(const wxString& a,int b) { \ | |
927 | wxString rval; \ | |
19a97bd6 RD |
928 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
929 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
c368d904 | 930 | PyObject* ro; \ |
1e7ecb7b | 931 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \ |
c368d904 | 932 | if (ro) { \ |
de20db99 RD |
933 | PyObject* str = PyObject_Str(ro); \ |
934 | rval = PyString_AsString(str); \ | |
935 | Py_DECREF(ro); Py_DECREF(str); \ | |
c368d904 RD |
936 | } \ |
937 | } \ | |
19a97bd6 | 938 | wxPyEndBlockThreads(state); \ |
c368d904 RD |
939 | return rval; \ |
940 | } \ | |
941 | ||
942 | //--------------------------------------------------------------------------- | |
943 | ||
f0261a72 RD |
944 | #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \ |
945 | bool CBNAME(const wxString& a, const wxString& b); \ | |
946 | bool base_##CBNAME(const wxString& a, const wxString& b); | |
947 | ||
948 | ||
949 | #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \ | |
950 | bool CLASS::CBNAME(const wxString& a, const wxString& b) { \ | |
059a841c | 951 | bool rval=FALSE; \ |
19a97bd6 RD |
952 | bool found; \ |
953 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
954 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
955 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \ | |
f0261a72 | 956 | a.c_str(), b.c_str())); \ |
19a97bd6 RD |
957 | wxPyEndBlockThreads(state); \ |
958 | if (! found) \ | |
f0261a72 | 959 | rval = PCLASS::CBNAME(a, b); \ |
f0261a72 RD |
960 | return rval; \ |
961 | } \ | |
962 | bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \ | |
963 | return PCLASS::CBNAME(a, b); \ | |
964 | } | |
965 | ||
966 | //--------------------------------------------------------------------------- | |
967 | ||
389c5527 RD |
968 | #define DEC_PYCALLBACK_STRING_(CBNAME) \ |
969 | wxString CBNAME(); \ | |
970 | wxString base_##CBNAME(); | |
971 | ||
972 | ||
973 | #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \ | |
974 | wxString CLASS::CBNAME() { \ | |
975 | wxString rval; \ | |
19a97bd6 RD |
976 | bool found; \ |
977 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
978 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
389c5527 | 979 | PyObject* ro; \ |
19a97bd6 | 980 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ |
f6bcfd97 | 981 | if (ro) { \ |
de20db99 RD |
982 | PyObject* str = PyObject_Str(ro); \ |
983 | rval = PyString_AsString(str); \ | |
984 | Py_DECREF(ro); Py_DECREF(str); \ | |
f6bcfd97 | 985 | } \ |
389c5527 | 986 | } \ |
19a97bd6 RD |
987 | wxPyEndBlockThreads(state); \ |
988 | if (! found) \ | |
b1462dfa | 989 | rval = PCLASS::CBNAME(); \ |
389c5527 RD |
990 | return rval; \ |
991 | } \ | |
b1462dfa RD |
992 | wxString CLASS::base_##CBNAME() { \ |
993 | return PCLASS::CBNAME(); \ | |
389c5527 RD |
994 | } |
995 | ||
996 | //--------------------------------------------------------------------------- | |
997 | ||
998 | #define DEC_PYCALLBACK_STRING__pure(CBNAME) \ | |
999 | wxString CBNAME(); | |
1000 | ||
1001 | ||
1002 | #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \ | |
1003 | wxString CLASS::CBNAME() { \ | |
1004 | wxString rval; \ | |
19a97bd6 RD |
1005 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
1006 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
389c5527 | 1007 | PyObject* ro; \ |
19a97bd6 | 1008 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ |
f6bcfd97 | 1009 | if (ro) { \ |
de20db99 RD |
1010 | PyObject* str = PyObject_Str(ro); \ |
1011 | rval = PyString_AsString(str); \ | |
1012 | Py_DECREF(ro); Py_DECREF(str); \ | |
f6bcfd97 | 1013 | } \ |
389c5527 | 1014 | } \ |
19a97bd6 | 1015 | wxPyEndBlockThreads(state); \ |
389c5527 RD |
1016 | return rval; \ |
1017 | } | |
1018 | ||
1019 | //--------------------------------------------------------------------------- | |
1020 | ||
1021 | #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \ | |
1022 | bool CBNAME(const wxHtmlTag& a); \ | |
1023 | ||
1024 | ||
1025 | #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \ | |
1026 | bool CLASS::CBNAME(const wxHtmlTag& a) { \ | |
059a841c | 1027 | bool rval=FALSE; \ |
19a97bd6 RD |
1028 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
1029 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
1030 | PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \ | |
1031 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
de20db99 RD |
1032 | Py_DECREF(obj); \ |
1033 | } \ | |
19a97bd6 | 1034 | wxPyEndBlockThreads(state); \ |
389c5527 RD |
1035 | return rval; \ |
1036 | } | |
1037 | ||
0122b7e3 RD |
1038 | //--------------------------------------------------------------------------- |
1039 | ||
1040 | #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \ | |
1041 | void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \ | |
1042 | void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); | |
1043 | ||
1044 | #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \ | |
1045 | void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \ | |
1046 | wxString rval; \ | |
1047 | bool found; \ | |
1048 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1049 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1050 | PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \ | |
1051 | wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \ | |
1052 | Py_DECREF(obj); \ | |
1053 | } \ | |
1054 | wxPyEndBlockThreads(state); \ | |
1055 | if (! found) \ | |
1056 | PCLASS::CBNAME(cell, x, y); \ | |
1057 | } \ | |
1058 | void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \ | |
1059 | PCLASS::CBNAME(cell, x, y); \ | |
1060 | } | |
1061 | ||
1062 | ||
1063 | //--------------------------------------------------------------------------- | |
1064 | ||
1065 | #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \ | |
1066 | void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \ | |
1067 | void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); | |
1068 | ||
1069 | #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \ | |
1070 | void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \ | |
1071 | bool found; \ | |
1072 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1073 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1074 | PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \ | |
1075 | PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \ | |
1076 | wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \ | |
1077 | Py_DECREF(obj); \ | |
1078 | Py_DECREF(o2); \ | |
1079 | } \ | |
1080 | wxPyEndBlockThreads(state); \ | |
1081 | if (! found) \ | |
1082 | PCLASS::CBNAME(cell, x, y, e); \ | |
1083 | } \ | |
1084 | void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \ | |
1085 | PCLASS::CBNAME(cell, x, y, e); \ | |
1086 | } | |
1087 | ||
1088 | ||
1089 | ||
389c5527 | 1090 | //--------------------------------------------------------------------------- |
2f90df85 RD |
1091 | |
1092 | #define DEC_PYCALLBACK___pure(CBNAME) \ | |
1093 | void CBNAME(); \ | |
1094 | ||
1095 | ||
1096 | #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \ | |
1097 | void CLASS::CBNAME() { \ | |
19a97bd6 RD |
1098 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
1099 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
1100 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
1101 | wxPyEndBlockThreads(state); \ | |
2f90df85 RD |
1102 | } |
1103 | ||
1104 | //--------------------------------------------------------------------------- | |
1105 | ||
1106 | #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \ | |
1107 | wxSize CBNAME(); \ | |
1108 | ||
1109 | ||
1110 | #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \ | |
1111 | wxSize CLASS::CBNAME() { \ | |
1112 | wxSize rval(0,0); \ | |
19a97bd6 RD |
1113 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
1114 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
2f90df85 RD |
1115 | PyObject* ro; \ |
1116 | wxSize* ptr; \ | |
19a97bd6 | 1117 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ |
f6bcfd97 BP |
1118 | if (ro) { \ |
1119 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \ | |
1120 | rval = *ptr; \ | |
1121 | Py_DECREF(ro); \ | |
1122 | } \ | |
2f90df85 | 1123 | } \ |
19a97bd6 | 1124 | wxPyEndBlockThreads(state); \ |
2f90df85 RD |
1125 | return rval; \ |
1126 | } | |
1127 | ||
1128 | //--------------------------------------------------------------------------- | |
1129 | ||
1130 | #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \ | |
1131 | bool CBNAME(wxWindow* a); \ | |
1132 | bool base_##CBNAME(wxWindow* a); | |
1133 | ||
1134 | ||
19a97bd6 RD |
1135 | #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \ |
1136 | bool CLASS::CBNAME(wxWindow* a) { \ | |
059a841c | 1137 | bool rval=FALSE; \ |
19a97bd6 RD |
1138 | bool found; \ |
1139 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1140 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1141 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1142 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1143 | Py_DECREF(obj); \ | |
1144 | } \ | |
1145 | wxPyEndBlockThreads(state); \ | |
1146 | if (! found) \ | |
1147 | rval = PCLASS::CBNAME(a); \ | |
1148 | return rval; \ | |
1149 | } \ | |
1150 | bool CLASS::base_##CBNAME(wxWindow* a) { \ | |
1151 | return PCLASS::CBNAME(a); \ | |
2f90df85 RD |
1152 | } |
1153 | ||
389c5527 | 1154 | //--------------------------------------------------------------------------- |
2f90df85 RD |
1155 | |
1156 | #define DEC_PYCALLBACK_BOOL_(CBNAME) \ | |
1157 | bool CBNAME(); \ | |
1158 | bool base_##CBNAME(); | |
1159 | ||
1160 | ||
19a97bd6 RD |
1161 | #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \ |
1162 | bool CLASS::CBNAME() { \ | |
059a841c | 1163 | bool rval=FALSE; \ |
19a97bd6 RD |
1164 | bool found; \ |
1165 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1166 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
1167 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
1168 | wxPyEndBlockThreads(state); \ | |
1169 | if (! found) \ | |
1170 | rval = PCLASS::CBNAME(); \ | |
1171 | return rval; \ | |
1172 | } \ | |
1173 | bool CLASS::base_##CBNAME() { \ | |
1174 | return PCLASS::CBNAME(); \ | |
2f90df85 RD |
1175 | } |
1176 | ||
b1462dfa RD |
1177 | //--------------------------------------------------------------------------- |
1178 | ||
19a97bd6 RD |
1179 | #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \ |
1180 | wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \ | |
b1462dfa RD |
1181 | wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def); |
1182 | ||
1183 | ||
19a97bd6 RD |
1184 | #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \ |
1185 | wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
059a841c | 1186 | int rval=0; \ |
19a97bd6 RD |
1187 | bool found; \ |
1188 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
19a97bd6 | 1189 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1e7ecb7b | 1190 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ |
19a97bd6 RD |
1191 | wxPyEndBlockThreads(state); \ |
1192 | if (! found) \ | |
1193 | rval = PCLASS::CBNAME(a, b, c); \ | |
1194 | return (wxDragResult)rval; \ | |
1195 | } \ | |
1196 | wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
1197 | return PCLASS::CBNAME(a, b, c); \ | |
b1462dfa RD |
1198 | } |
1199 | ||
1200 | //--------------------------------------------------------------------------- | |
1201 | ||
c368d904 RD |
1202 | #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \ |
1203 | wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \ | |
1204 | ||
1205 | #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \ | |
1206 | wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \ | |
19a97bd6 | 1207 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
c368d904 | 1208 | wxFSFile* rval=0; \ |
19a97bd6 | 1209 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
c368d904 | 1210 | PyObject* ro; \ |
19a97bd6 RD |
1211 | PyObject* obj = wxPyMake_wxObject(&a); \ |
1212 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\ | |
de20db99 | 1213 | obj, b.c_str())); \ |
c368d904 RD |
1214 | if (ro) { \ |
1215 | SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \ | |
1216 | Py_DECREF(ro); \ | |
1217 | } \ | |
de20db99 RD |
1218 | Py_DECREF(obj); \ |
1219 | } \ | |
19a97bd6 | 1220 | wxPyEndBlockThreads(state); \ |
c368d904 RD |
1221 | return rval; \ |
1222 | }; | |
1223 | ||
1224 | //--------------------------------------------------------------------------- | |
1225 | ||
b1462dfa RD |
1226 | #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \ |
1227 | bool CBNAME(wxDragResult a); \ | |
1228 | bool base_##CBNAME(wxDragResult a); | |
1229 | ||
1230 | ||
1231 | #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \ | |
1232 | bool CLASS::CBNAME(wxDragResult a) { \ | |
059a841c | 1233 | bool rval=FALSE; \ |
19a97bd6 RD |
1234 | bool found; \ |
1235 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
19a97bd6 RD |
1236 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1237 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\ | |
1238 | wxPyEndBlockThreads(state); \ | |
1239 | if (! found) \ | |
b1462dfa | 1240 | rval = PCLASS::CBNAME(a); \ |
b1462dfa RD |
1241 | return rval; \ |
1242 | } \ | |
1243 | bool CLASS::base_##CBNAME(wxDragResult a) { \ | |
1244 | return PCLASS::CBNAME(a); \ | |
1245 | } | |
1246 | ||
1247 | //--------------------------------------------------------------------------- | |
1248 | ||
1249 | #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \ | |
1250 | wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); | |
1251 | ||
1252 | ||
1253 | #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \ | |
1254 | wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
19a97bd6 | 1255 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
059a841c | 1256 | int rval=0; \ |
19a97bd6 | 1257 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ |
1e7ecb7b | 1258 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ |
19a97bd6 | 1259 | wxPyEndBlockThreads(state); \ |
b1462dfa RD |
1260 | return (wxDragResult)rval; \ |
1261 | } \ | |
1262 | ||
1263 | //--------------------------------------------------------------------------- | |
1264 | ||
1265 | #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \ | |
1266 | bool CBNAME(int a, int b, const wxString& c); | |
1267 | ||
1268 | ||
1269 | #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \ | |
1270 | bool CLASS::CBNAME(int a, int b, const wxString& c) { \ | |
059a841c | 1271 | bool rval=FALSE; \ |
19a97bd6 RD |
1272 | wxPyTState* state = wxPyBeginBlockThreads(); \ |
1273 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
1e7ecb7b | 1274 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\ |
19a97bd6 | 1275 | wxPyEndBlockThreads(state); \ |
b1462dfa RD |
1276 | return rval; \ |
1277 | } \ | |
1278 | ||
1279 | //--------------------------------------------------------------------------- | |
1280 | ||
1281 | #define DEC_PYCALLBACK_SIZET_(CBNAME) \ | |
1282 | size_t CBNAME(); \ | |
1283 | size_t base_##CBNAME(); | |
1284 | ||
1285 | ||
1286 | #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \ | |
1287 | size_t CLASS::CBNAME() { \ | |
059a841c | 1288 | size_t rval=0; \ |
19a97bd6 RD |
1289 | bool found; \ |
1290 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1291 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
1292 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
1293 | wxPyEndBlockThreads(state); \ | |
1294 | if (! found) \ | |
b1462dfa | 1295 | rval = PCLASS::CBNAME(); \ |
b1462dfa RD |
1296 | return rval; \ |
1297 | } \ | |
1298 | size_t CLASS::base_##CBNAME() { \ | |
1299 | return PCLASS::CBNAME(); \ | |
1300 | } | |
1301 | ||
1302 | //--------------------------------------------------------------------------- | |
1303 | ||
c7e7022c RD |
1304 | #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \ |
1305 | wxDataFormat CBNAME(size_t a); \ | |
1306 | wxDataFormat base_##CBNAME(size_t a); | |
b1462dfa RD |
1307 | |
1308 | ||
1309 | #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \ | |
1310 | wxDataFormat CLASS::CBNAME(size_t a) { \ | |
059a841c | 1311 | wxDataFormat rval=0; \ |
19a97bd6 RD |
1312 | bool found; \ |
1313 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1314 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
b1462dfa RD |
1315 | PyObject* ro; \ |
1316 | wxDataFormat* ptr; \ | |
c7e7022c | 1317 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \ |
f6bcfd97 BP |
1318 | if (ro) { \ |
1319 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \ | |
1320 | rval = *ptr; \ | |
1321 | Py_DECREF(ro); \ | |
1322 | } \ | |
b1462dfa | 1323 | } \ |
19a97bd6 RD |
1324 | wxPyEndBlockThreads(state); \ |
1325 | if (! found) \ | |
b1462dfa | 1326 | rval = PCLASS::CBNAME(a); \ |
b1462dfa RD |
1327 | return rval; \ |
1328 | } \ | |
1329 | wxDataFormat CLASS::base_##CBNAME(size_t a) { \ | |
1330 | return PCLASS::CBNAME(a); \ | |
1331 | } | |
1332 | ||
389c5527 | 1333 | //--------------------------------------------------------------------------- |
f6bcfd97 BP |
1334 | |
1335 | #define DEC_PYCALLBACK__constany(CBNAME, Type) \ | |
1336 | void CBNAME(const Type& a); \ | |
1337 | void base_##CBNAME(const Type& a); | |
1338 | ||
1339 | ||
19a97bd6 RD |
1340 | #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \ |
1341 | void CLASS::CBNAME(const Type& a) { \ | |
1342 | bool found; \ | |
1343 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1344 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1345 | PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ | |
1346 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1347 | Py_DECREF(obj); \ | |
1348 | } \ | |
1349 | wxPyEndBlockThreads(state); \ | |
1350 | if (! found) \ | |
1351 | PCLASS::CBNAME(a); \ | |
1352 | } \ | |
1353 | void CLASS::base_##CBNAME(const Type& a) { \ | |
1354 | PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
1355 | } |
1356 | ||
1357 | ||
1358 | //--------------------------------------------------------------------------- | |
1359 | ||
1360 | #define DEC_PYCALLBACK__any(CBNAME, Type) \ | |
1361 | void CBNAME(Type& a); \ | |
1362 | void base_##CBNAME(Type& a); | |
1363 | ||
1364 | ||
19a97bd6 RD |
1365 | #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \ |
1366 | void CLASS::CBNAME(Type& a) { \ | |
1367 | bool found; \ | |
1368 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1369 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1370 | PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ | |
1371 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1372 | Py_DECREF(obj); \ | |
1373 | } \ | |
1374 | wxPyEndBlockThreads(state); \ | |
1375 | if (! found) \ | |
1376 | PCLASS::CBNAME(a); \ | |
1377 | } \ | |
1378 | void CLASS::base_##CBNAME(Type& a) { \ | |
1379 | PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
1380 | } |
1381 | ||
efc5f224 | 1382 | //--------------------------------------------------------------------------- |
f6bcfd97 BP |
1383 | |
1384 | #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \ | |
1385 | bool CBNAME(Type& a); \ | |
1386 | bool base_##CBNAME(Type& a); | |
1387 | ||
1388 | ||
19a97bd6 RD |
1389 | #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \ |
1390 | bool CLASS::CBNAME(Type& a) { \ | |
1391 | bool rv; \ | |
1392 | bool found; \ | |
1393 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1394 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1395 | PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ | |
1396 | rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1397 | Py_DECREF(obj); \ | |
1398 | } \ | |
1399 | wxPyEndBlockThreads(state); \ | |
1400 | if (! found) \ | |
1401 | rv = PCLASS::CBNAME(a); \ | |
1402 | return rv; \ | |
1403 | } \ | |
1404 | bool CLASS::base_##CBNAME(Type& a) { \ | |
1405 | return PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
1406 | } |
1407 | ||
efc5f224 RD |
1408 | //--------------------------------------------------------------------------- |
1409 | ||
c7e7022c RD |
1410 | #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \ |
1411 | wxString CBNAME(long a, long b) const; \ | |
1412 | wxString base_##CBNAME(long a, long b)const ; | |
1413 | ||
1414 | ||
1415 | #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \ | |
1416 | wxString CLASS::CBNAME(long a, long b) const { \ | |
1417 | wxString rval; \ | |
19a97bd6 RD |
1418 | bool found; \ |
1419 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1420 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
c7e7022c RD |
1421 | PyObject* ro; \ |
1422 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \ | |
1423 | if (ro) { \ | |
1424 | PyObject* str = PyObject_Str(ro); \ | |
1425 | rval = PyString_AsString(str); \ | |
1426 | Py_DECREF(ro); Py_DECREF(str); \ | |
1427 | } \ | |
1428 | } \ | |
19a97bd6 RD |
1429 | wxPyEndBlockThreads(state); \ |
1430 | if (! found) \ | |
c7e7022c | 1431 | rval = PCLASS::CBNAME(a,b); \ |
c7e7022c RD |
1432 | return rval; \ |
1433 | } \ | |
1434 | wxString CLASS::base_##CBNAME(long a, long b) const { \ | |
1435 | return PCLASS::CBNAME(a,b); \ | |
1436 | } | |
1437 | ||
1438 | //--------------------------------------------------------------------------- | |
1439 | ||
1440 | #define DEC_PYCALLBACK_INT_LONG(CBNAME) \ | |
1441 | int CBNAME(long a) const; \ | |
1442 | int base_##CBNAME(long a)const ; | |
1443 | ||
1444 | ||
1445 | #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \ | |
1446 | int CLASS::CBNAME(long a) const { \ | |
1447 | int rval=-1; \ | |
19a97bd6 RD |
1448 | bool found; \ |
1449 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1450 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
c7e7022c RD |
1451 | PyObject* ro; \ |
1452 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \ | |
1453 | if (ro) { \ | |
1454 | rval = PyInt_AsLong(ro); \ | |
1455 | Py_DECREF(ro); \ | |
1456 | } \ | |
1457 | } \ | |
19a97bd6 RD |
1458 | wxPyEndBlockThreads(state); \ |
1459 | if (! found) \ | |
c7e7022c | 1460 | rval = PCLASS::CBNAME(a); \ |
c7e7022c RD |
1461 | return rval; \ |
1462 | } \ | |
1463 | int CLASS::base_##CBNAME(long a) const { \ | |
1464 | return PCLASS::CBNAME(a); \ | |
1465 | } | |
1466 | ||
1467 | ||
1468 | //--------------------------------------------------------------------------- | |
1469 | ||
1470 | #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \ | |
00b6c4e3 | 1471 | wxListItemAttr* CBNAME(long a) const; \ |
c7e7022c RD |
1472 | wxListItemAttr* base_##CBNAME(long a); |
1473 | ||
1474 | ||
1475 | #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \ | |
00b6c4e3 | 1476 | wxListItemAttr *CLASS::CBNAME(long a) const { \ |
c7e7022c | 1477 | wxListItemAttr *rval = NULL; \ |
19a97bd6 RD |
1478 | bool found; \ |
1479 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1480 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
c7e7022c RD |
1481 | PyObject* ro; \ |
1482 | wxListItemAttr* ptr; \ | |
1483 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \ | |
1484 | if (ro) { \ | |
1485 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \ | |
1486 | rval = ptr; \ | |
1487 | Py_DECREF(ro); \ | |
1488 | } \ | |
1489 | } \ | |
19a97bd6 RD |
1490 | wxPyEndBlockThreads(state); \ |
1491 | if (! found) \ | |
c7e7022c | 1492 | rval = PCLASS::CBNAME(a); \ |
c7e7022c RD |
1493 | return rval; \ |
1494 | } \ | |
1495 | wxListItemAttr *CLASS::base_##CBNAME(long a) { \ | |
1496 | return PCLASS::CBNAME(a); \ | |
1497 | } | |
1498 | ||
1499 | //--------------------------------------------------------------------------- | |
1500 | ||
0122b7e3 RD |
1501 | #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \ |
1502 | bool CBNAME(wxMouseEvent& e); \ | |
1503 | bool base_##CBNAME(wxMouseEvent& e); | |
1504 | ||
1505 | #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \ | |
1506 | bool CLASS::CBNAME(wxMouseEvent& e) { \ | |
1507 | bool rval; \ | |
1508 | bool found; \ | |
1509 | wxPyTState* state = wxPyBeginBlockThreads(); \ | |
1510 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1511 | PyObject* ro; \ | |
1512 | PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \ | |
1513 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \ | |
1514 | if (ro) { \ | |
1515 | rval = PyInt_AsLong(ro); \ | |
1516 | Py_DECREF(ro); \ | |
1517 | } \ | |
1518 | Py_DECREF(obj); \ | |
1519 | } \ | |
1520 | wxPyEndBlockThreads(state); \ | |
1521 | if (! found) \ | |
1522 | return PCLASS::CBNAME(e); \ | |
9d37f964 | 1523 | return rval; \ |
0122b7e3 RD |
1524 | } \ |
1525 | bool CLASS::base_##CBNAME(wxMouseEvent& e) { \ | |
1526 | return PCLASS::CBNAME(e); \ | |
1527 | } | |
1528 | ||
1529 | ||
1530 | //--------------------------------------------------------------------------- | |
1531 | ||
7bf85405 | 1532 | #endif |