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