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