]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/helpers.h
Fixed Tim's patch so it will compile when using a Python version < 2.0
[wxWidgets.git] / wxPython / src / helpers.h
1 ////////////////////////////////////////////////////////////////////////////
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
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
34 //---------------------------------------------------------------------------
35
36 typedef unsigned char byte;
37
38
39 class wxPyApp: public wxApp
40 {
41 public:
42 wxPyApp();
43 ~wxPyApp();
44 int MainLoop(void);
45 bool OnInit(void);
46 };
47 extern wxPyApp *wxPythonApp;
48
49 //----------------------------------------------------------------------
50
51 void __wxPreStart();
52 PyObject* __wxStart(PyObject*, PyObject* args);
53 void __wxCleanup();
54
55 extern PyObject* wxPython_dict;
56 PyObject* __wxSetDictionary(PyObject*, PyObject* args);
57
58 void wxPyEventThunker(wxObject*, wxEvent& event);
59
60 PyObject* wxPyConstructObject(void* ptr,
61 const char* className,
62 int setThisOwn=0);
63 bool wxPyRestoreThread();
64 void wxPySaveThread(bool doSave);
65 PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
66 long wxPyGetWinHandle(wxWindow* win);
67
68
69
70 //----------------------------------------------------------------------
71 // Handle wxInputStreams by Joerg Baumann
72 // See stream.i for implementations
73
74 // list class for return list of strings, e.g. readlines()
75 WX_DECLARE_LIST(wxString, wxStringPtrList);
76
77
78 // C++ class wxPyInputStream to act as base for python class wxInputStream
79 // Use it in python like a python file object
80 class wxPyInputStream {
81 public:
82 // underlying wxInputStream
83 wxInputStream* wxi;
84
85 public:
86 wxPyInputStream(wxInputStream* wxi_) : wxi(wxi_) {}
87 ~wxPyInputStream();
88
89 // python file object interface for input files (most of it)
90 void close();
91 void flush();
92 bool eof();
93 wxString* read(int size=-1);
94 wxString* readline(int size=-1);
95 wxStringPtrList* readlines(int sizehint=-1);
96 void seek(int offset, int whence=0);
97 int tell();
98 /*
99 bool isatty();
100 int fileno();
101 void truncate(int size=-1);
102 void write(wxString data);
103 void writelines(wxStringPtrList);
104 */
105 };
106
107
108 //----------------------------------------------------------------------
109 // These are helpers used by the typemaps
110
111 byte* byte_LIST_helper(PyObject* source);
112 int* int_LIST_helper(PyObject* source);
113 long* long_LIST_helper(PyObject* source);
114 char** string_LIST_helper(PyObject* source);
115 wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints);
116 wxBitmap** wxBitmap_LIST_helper(PyObject* source);
117 wxString* wxString_LIST_helper(PyObject* source);
118 wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
119
120 bool wxSize_helper(PyObject* source, wxSize** obj);
121 bool wxPoint_helper(PyObject* source, wxPoint** obj);
122 bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
123 bool wxRect_helper(PyObject* source, wxRect** obj);
124 bool wxColour_helper(PyObject* source, wxColour** obj);
125
126 //----------------------------------------------------------------------
127
128 #ifndef SWIGCODE
129 extern "C" void SWIG_MakePtr(char *, void *, char *);
130 extern "C" char *SWIG_GetPtr(char *, void **, char *);
131 extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type);
132 #endif
133
134
135 #ifdef _MSC_VER
136 # pragma warning(disable:4800)
137 # pragma warning(disable:4190)
138 #endif
139
140 //----------------------------------------------------------------------
141
142 class wxPyCallback : public wxObject {
143 DECLARE_ABSTRACT_CLASS(wxPyCallback);
144 public:
145 wxPyCallback(PyObject* func);
146 wxPyCallback(const wxPyCallback& other);
147 ~wxPyCallback();
148
149 void EventThunker(wxEvent& event);
150
151 PyObject* m_func;
152 };
153
154 //---------------------------------------------------------------------------
155
156 class wxPyTimer : public wxTimer {
157 public:
158 wxPyTimer(PyObject* callback);
159 ~wxPyTimer();
160
161 void Notify();
162
163 private:
164 PyObject* func;
165 };
166
167 //---------------------------------------------------------------------------
168 //---------------------------------------------------------------------------
169 // These Event classes can be derived from in Python and passed through the
170 // event system without loosing anything. They do this by keeping a reference
171 // to themselves and some special case handling in wxPyCallback::EventThunker.
172
173
174 class wxPyEvtSelfRef {
175 public:
176 wxPyEvtSelfRef();
177 ~wxPyEvtSelfRef();
178
179 void SetSelf(PyObject* self, bool clone=FALSE);
180 PyObject* GetSelf() const;
181
182 protected:
183 PyObject* m_self;
184 bool m_cloned;
185 };
186
187
188 class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
189 DECLARE_DYNAMIC_CLASS(wxPyEvent)
190 public:
191 wxPyEvent(int id=0);
192 ~wxPyEvent();
193
194 void CopyObject(wxObject& dest) const;
195 };
196
197
198 class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
199 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
200 public:
201 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
202 ~wxPyCommandEvent();
203
204 void CopyObject(wxObject& dest) const;
205 };
206
207
208 //---------------------------------------------------------------------------
209 // Export a C API in a struct. Other modules will be able to load this from
210 // the wxc module and will then have safe access to these functions, even if
211 // in another shared library.
212
213 class wxPyCallbackHelper;
214
215 struct wxPyCoreAPI {
216
217 void (*p_SWIG_MakePtr)(char*, void*, char*);
218 char* (*p_SWIG_GetPtr)(char*, void**, char*);
219 char* (*p_SWIG_GetPtrObj)(PyObject*, void**, char*);
220 void (*p_SWIG_RegisterMapping)(char*, char*, void *(*cast)(void *));
221 void (*p_SWIG_addvarlink)(PyObject*, char*, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p));
222 PyObject* (*p_SWIG_newvarlink)(void);
223
224 void (*p_wxPySaveThread)(bool);
225 bool (*p_wxPyRestoreThread)();
226 PyObject* (*p_wxPyConstructObject)(void *, const char *, int);
227 PyObject* (*p_wxPy_ConvertList)(wxListBase* list, const char* className);
228
229 byte* (*p_byte_LIST_helper)(PyObject* source);
230 int* (*p_int_LIST_helper)(PyObject* source);
231 long* (*p_long_LIST_helper)(PyObject* source);
232 char** (*p_string_LIST_helper)(PyObject* source);
233 wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints);
234 wxBitmap** (*p_wxBitmap_LIST_helper)(PyObject* source);
235 wxString* (*p_wxString_LIST_helper)(PyObject* source);
236 wxAcceleratorEntry* (*p_wxAcceleratorEntry_LIST_helper)(PyObject* source);
237
238 bool (*p_wxSize_helper)(PyObject* source, wxSize** obj);
239 bool (*p_wxPoint_helper)(PyObject* source, wxPoint** obj);
240 bool (*p_wxRealPoint_helper)(PyObject* source, wxRealPoint** obj);
241 bool (*p_wxRect_helper)(PyObject* source, wxRect** obj);
242 bool (*p_wxColour_helper)(PyObject* source, wxColour** obj);
243
244 void (*p_wxPyCBH_setSelf)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
245 bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name);
246 int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
247 PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
248 void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh);
249
250 };
251
252 #ifdef wxPyUSE_EXPORT
253 static wxPyCoreAPI* wxPyCoreAPIPtr = NULL; // Each module needs one, but may not use it.
254 #endif
255
256 //---------------------------------------------------------------------------
257 // This class holds an instance of a Python Shadow Class object and assists
258 // with looking up and invoking Python callback methods from C++ virtual
259 // method redirections. For all classes which have virtuals which should be
260 // overridable in wxPython, a new subclass is created that contains a
261 // wxPyCallbackHelper.
262 //
263
264 class wxPyCallbackHelper {
265 public:
266 wxPyCallbackHelper(const wxPyCallbackHelper& other);
267
268 wxPyCallbackHelper() {
269 m_class = NULL;
270 m_self = NULL;
271 m_lastFound = NULL;
272 m_incRef = FALSE;
273 }
274
275 ~wxPyCallbackHelper() {
276 #ifdef wxPyUSE_EXPORT
277 wxPyCoreAPIPtr->p_wxPyCBH_delete(this);
278 #else
279 wxPyCBH_delete(this);
280 #endif
281 }
282
283 void setSelf(PyObject* self, PyObject* klass, int incref=TRUE);
284 bool findCallback(const char* name) const;
285 int callCallback(PyObject* argTuple) const;
286 PyObject* callCallbackObj(PyObject* argTuple) const;
287
288 private:
289 PyObject* m_self;
290 PyObject* m_class;
291 PyObject* m_lastFound;
292 int m_incRef;
293
294 friend void wxPyCBH_delete(wxPyCallbackHelper* cbh);
295 };
296
297
298 void wxPyCBH_setSelf(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
299 bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name);
300 int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple);
301 PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple);
302 void wxPyCBH_delete(wxPyCallbackHelper* cbh);
303
304
305
306 //----------------------------------------------------------------------
307
308 class wxPyUserData : public wxObject {
309 public:
310 wxPyUserData(PyObject* obj) {
311 m_obj = obj;
312 Py_INCREF(m_obj);
313 }
314
315 ~wxPyUserData() {
316 bool doSave;
317 #ifdef wxPyUSE_EXPORT
318 doSave = wxPyCoreAPIPtr->p_wxPyRestoreThread();
319 Py_DECREF(m_obj);
320 wxPyCoreAPIPtr->p_wxPySaveThread(doSave);
321 #else
322 doSave = wxPyRestoreThread();
323 Py_DECREF(m_obj);
324 wxPySaveThread(doSave);
325 #endif
326 }
327 PyObject* m_obj;
328 };
329
330
331
332 //---------------------------------------------------------------------------
333 // These macros are used to implement the virtual methods that should
334 // redirect to a Python method if one exists. The names designate the
335 // return type, if any, as well as any parameter types.
336 //---------------------------------------------------------------------------
337
338 #define PYPRIVATE \
339 void _setSelf(PyObject* self, PyObject* _class, int incref=1) { \
340 wxPyCBH_setSelf(m_myInst, self, _class, incref); \
341 } \
342 private: wxPyCallbackHelper m_myInst
343
344 //---------------------------------------------------------------------------
345
346 #define DEC_PYCALLBACK__(CBNAME) \
347 void CBNAME(); \
348 void base_##CBNAME();
349
350
351 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
352 void CLASS::CBNAME() { \
353 bool doSave = wxPyRestoreThread(); \
354 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
355 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
356 else \
357 PCLASS::CBNAME(); \
358 wxPySaveThread(doSave); \
359 } \
360 void CLASS::base_##CBNAME() { \
361 PCLASS::CBNAME(); \
362 }
363
364 //---------------------------------------------------------------------------
365
366 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
367 bool CBNAME(int a, int b); \
368 bool base_##CBNAME(int a, int b);
369
370
371 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
372 bool CLASS::CBNAME(int a, int b) { \
373 bool rval; \
374 bool doSave = wxPyRestoreThread(); \
375 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
376 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
377 else \
378 rval = PCLASS::CBNAME(a,b); \
379 wxPySaveThread(doSave); \
380 return rval; \
381 } \
382 bool CLASS::base_##CBNAME(int a, int b) { \
383 return PCLASS::CBNAME(a,b); \
384 }
385
386 //---------------------------------------------------------------------------
387
388 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
389 void CBNAME(int a, int b); \
390 void base_##CBNAME(int a, int b);
391
392
393 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
394 void CLASS::CBNAME(int a, int b) { \
395 bool doSave = wxPyRestoreThread(); \
396 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
397 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
398 else \
399 PCLASS::CBNAME(a,b); \
400 wxPySaveThread(doSave); \
401 } \
402 void CLASS::base_##CBNAME(int a, int b) { \
403 PCLASS::CBNAME(a,b); \
404 }
405
406 //---------------------------------------------------------------------------
407
408 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
409 bool CBNAME(int a); \
410 bool base_##CBNAME(int a);
411
412
413 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
414 bool CLASS::CBNAME(int a) { \
415 bool rval; \
416 bool doSave = wxPyRestoreThread(); \
417 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
418 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
419 else \
420 rval = PCLASS::CBNAME(a); \
421 wxPySaveThread(doSave); \
422 return rval; \
423 } \
424 bool CLASS::base_##CBNAME(int a) { \
425 return PCLASS::CBNAME(a); \
426 }
427
428 //---------------------------------------------------------------------------
429
430 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
431 bool CBNAME(int a);
432
433
434 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
435 bool CLASS::CBNAME(int a) { \
436 bool rval; \
437 bool doSave = wxPyRestoreThread(); \
438 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
439 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
440 else rval = FALSE; \
441 wxPySaveThread(doSave); \
442 return rval; \
443 }
444
445
446 //---------------------------------------------------------------------------
447
448 #define DEC_PYCALLBACK__DC(CBNAME) \
449 void CBNAME(wxDC& a); \
450 void base_##CBNAME(wxDC& a);
451
452
453 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
454 void CLASS::CBNAME(wxDC& a) { \
455 bool doSave = wxPyRestoreThread(); \
456 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
457 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
458 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
459 Py_DECREF(obj); \
460 } \
461 else \
462 PCLASS::CBNAME(a); \
463 wxPySaveThread(doSave); \
464 } \
465 void CLASS::base_##CBNAME(wxDC& a) { \
466 PCLASS::CBNAME(a); \
467 }
468
469
470
471 //---------------------------------------------------------------------------
472
473 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
474 void CBNAME(wxDC& a, bool b); \
475 void base_##CBNAME(wxDC& a, bool b);
476
477
478 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
479 void CLASS::CBNAME(wxDC& a, bool b) { \
480 bool doSave = wxPyRestoreThread(); \
481 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
482 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
483 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
484 Py_DECREF(obj); \
485 } \
486 else \
487 PCLASS::CBNAME(a, b); \
488 wxPySaveThread(doSave); \
489 } \
490 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
491 PCLASS::CBNAME(a, b); \
492 }
493
494 //---------------------------------------------------------------------------
495
496 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
497 void CBNAME(wxDC& a, bool b); \
498 void base_##CBNAME(wxDC& a, bool b);
499
500
501 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
502 void CLASS::CBNAME(wxDC& a, bool b) { \
503 bool doSave = wxPyRestoreThread(); \
504 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
505 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
506 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
507 Py_DECREF(obj); \
508 } \
509 else \
510 PCLASS::CBNAME(a, b); \
511 wxPySaveThread(doSave); \
512 } \
513 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
514 PCLASS::CBNAME(a, b); \
515 }
516
517 //---------------------------------------------------------------------------
518
519 #define DEC_PYCALLBACK__2DBL(CBNAME) \
520 void CBNAME(double a, double b); \
521 void base_##CBNAME(double a, double b);
522
523
524 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
525 void CLASS::CBNAME(double a, double b) { \
526 bool doSave = wxPyRestoreThread(); \
527 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
528 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
529 else \
530 PCLASS::CBNAME(a, b); \
531 wxPySaveThread(doSave); \
532 } \
533 void CLASS::base_##CBNAME(double a, double b) { \
534 PCLASS::CBNAME(a, b); \
535 }
536
537 //---------------------------------------------------------------------------
538
539 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
540 void CBNAME(double a, double b, int c, int d); \
541 void base_##CBNAME(double a, double b, int c, int d);
542
543
544 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
545 void CLASS::CBNAME(double a, double b, int c, int d) { \
546 bool doSave = wxPyRestoreThread(); \
547 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
548 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
549 a,b,c,d)); \
550 else \
551 PCLASS::CBNAME(a, b, c, d); \
552 wxPySaveThread(doSave); \
553 } \
554 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
555 PCLASS::CBNAME(a, b, c, d); \
556 }
557
558 //---------------------------------------------------------------------------
559
560 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
561 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
562 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
563
564
565 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
566 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
567 bool doSave = wxPyRestoreThread(); \
568 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
569 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
570 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
571 Py_DECREF(obj); \
572 } \
573 else \
574 PCLASS::CBNAME(a, b, c, d, e, f); \
575 wxPySaveThread(doSave); \
576 } \
577 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
578 PCLASS::CBNAME(a, b, c, d, e, f); \
579 }
580
581 //---------------------------------------------------------------------------
582
583 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
584 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
585 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
586
587
588 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
589 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
590 bool doSave = wxPyRestoreThread(); \
591 bool rval; \
592 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
593 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
594 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
595 Py_DECREF(obj); \
596 } \
597 else \
598 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
599 wxPySaveThread(doSave); \
600 return rval; \
601 } \
602 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
603 return PCLASS::CBNAME(a, b, c, d, e, f); \
604 }
605
606 //---------------------------------------------------------------------------
607
608 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
609 void CBNAME(bool a, double b, double c, int d, int e); \
610 void base_##CBNAME(bool a, double b, double c, int d, int e);
611
612
613 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
614 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
615 bool doSave = wxPyRestoreThread(); \
616 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
617 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
618 (int)a,b,c,d,e)); \
619 else \
620 PCLASS::CBNAME(a, b, c, d, e); \
621 wxPySaveThread(doSave); \
622 } \
623 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
624 PCLASS::CBNAME(a, b, c, d, e); \
625 }
626
627 //---------------------------------------------------------------------------
628
629 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
630 void CBNAME(wxDC& a, double b, double c, double d, double e); \
631 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
632
633
634 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
635 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
636 bool doSave = wxPyRestoreThread(); \
637 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
638 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
639 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
640 Py_DECREF(obj); \
641 } \
642 else \
643 PCLASS::CBNAME(a, b, c, d, e); \
644 wxPySaveThread(doSave); \
645 } \
646 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
647 PCLASS::CBNAME(a, b, c, d, e); \
648 }
649
650 //---------------------------------------------------------------------------
651
652 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
653 void CBNAME(wxDC& a, bool b); \
654 void base_##CBNAME(wxDC& a, bool b);
655
656
657 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
658 void CLASS::CBNAME(wxDC& a, bool b) { \
659 bool doSave = wxPyRestoreThread(); \
660 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
661 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
662 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
663 Py_DECREF(obj); \
664 } \
665 else \
666 PCLASS::CBNAME(a, b); \
667 wxPySaveThread(doSave); \
668 } \
669 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
670 PCLASS::CBNAME(a, b); \
671 }
672
673 //---------------------------------------------------------------------------
674
675 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
676 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
677 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
678
679
680 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
681 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
682 int e, int f) { \
683 bool doSave = wxPyRestoreThread(); \
684 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
685 PyObject* obj = wxPyConstructObject(a, "wxPyControlPoint", 0); \
686 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
687 Py_DECREF(obj); \
688 } \
689 else \
690 PCLASS::CBNAME(a, b, c, d, e, f); \
691 wxPySaveThread(doSave); \
692 } \
693 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
694 int e, int f) { \
695 PCLASS::CBNAME(a, b, c, d, e, f); \
696 }
697
698 //---------------------------------------------------------------------------
699
700 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
701 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
702 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
703
704
705 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
706 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
707 bool doSave = wxPyRestoreThread(); \
708 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
709 PyObject* obj = wxPyConstructObject(a, "wxPyControlPoint", 0); \
710 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
711 Py_DECREF(obj); \
712 } \
713 else \
714 PCLASS::CBNAME(a, b, c, d, e); \
715 wxPySaveThread(doSave); \
716 } \
717 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
718 int d, int e) { \
719 PCLASS::CBNAME(a, b, c, d, e); \
720 }
721
722 //---------------------------------------------------------------------------
723
724 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
725 void CBNAME(double a, double b, int c); \
726 void base_##CBNAME(double a, double b, int c);
727
728
729 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
730 void CLASS::CBNAME(double a, double b, int c) { \
731 bool doSave = wxPyRestoreThread(); \
732 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
733 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
734 else \
735 PCLASS::CBNAME(a, b, c); \
736 wxPySaveThread(doSave); \
737 } \
738 void CLASS::base_##CBNAME(double a, double b, int c) { \
739 PCLASS::CBNAME(a, b, c); \
740 }
741
742 //---------------------------------------------------------------------------
743
744 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
745 void CBNAME(bool a, double b, double c, int d); \
746 void base_##CBNAME(bool a, double b, double c, int d);
747
748
749 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
750 void CLASS::CBNAME(bool a, double b, double c, int d) { \
751 bool doSave = wxPyRestoreThread(); \
752 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
753 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d)); \
754 else \
755 PCLASS::CBNAME(a, b, c, d); \
756 wxPySaveThread(doSave); \
757 } \
758 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
759 PCLASS::CBNAME(a, b, c, d); \
760 }
761
762 //---------------------------------------------------------------------------
763 //---------------------------------------------------------------------------
764
765 #define DEC_PYCALLBACK__STRING(CBNAME) \
766 void CBNAME(const wxString& a); \
767 void base_##CBNAME(const wxString& a);
768
769
770 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
771 void CLASS::CBNAME(const wxString& a) { \
772 bool doSave = wxPyRestoreThread(); \
773 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
774 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
775 else \
776 PCLASS::CBNAME(a); \
777 wxPySaveThread(doSave); \
778 } \
779 void CLASS::base_##CBNAME(const wxString& a) { \
780 PCLASS::CBNAME(a); \
781 }
782
783 //---------------------------------------------------------------------------
784
785 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
786 bool CBNAME(const wxString& a); \
787 bool base_##CBNAME(const wxString& a);
788
789
790 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
791 bool CLASS::CBNAME(const wxString& a) { \
792 bool rval; \
793 bool doSave = wxPyRestoreThread(); \
794 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
795 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
796 else \
797 rval = PCLASS::CBNAME(a); \
798 wxPySaveThread(doSave); \
799 return rval; \
800 } \
801 bool CLASS::base_##CBNAME(const wxString& a) { \
802 return PCLASS::CBNAME(a); \
803 }
804
805 //---------------------------------------------------------------------------
806
807 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
808 bool CBNAME(const wxString& a);
809 \
810 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
811 bool CLASS::CBNAME(const wxString& a) { \
812 bool rval; \
813 bool doSave = wxPyRestoreThread(); \
814 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
815 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
816 wxPySaveThread(doSave); \
817 return rval; \
818 } \
819
820 //---------------------------------------------------------------------------
821
822 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
823 wxString CBNAME(const wxString& a); \
824
825 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
826 wxString CLASS::CBNAME(const wxString& a) { \
827 wxString rval; \
828 bool doSave = wxPyRestoreThread(); \
829 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
830 PyObject* ro; \
831 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str())); \
832 if (ro) { \
833 PyObject* str = PyObject_Str(ro); \
834 rval = PyString_AsString(str); \
835 Py_DECREF(ro); Py_DECREF(str); \
836 } \
837 } \
838 wxPySaveThread(doSave); \
839 return rval; \
840 } \
841
842 //---------------------------------------------------------------------------
843
844 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
845 wxString CBNAME(const wxString& a,int b); \
846
847 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
848 wxString CLASS::CBNAME(const wxString& a,int b) { \
849 wxString rval; \
850 bool doSave = wxPyRestoreThread(); \
851 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
852 PyObject* ro; \
853 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \
854 if (ro) { \
855 PyObject* str = PyObject_Str(ro); \
856 rval = PyString_AsString(str); \
857 Py_DECREF(ro); Py_DECREF(str); \
858 } \
859 } \
860 wxPySaveThread(doSave); \
861 return rval; \
862 } \
863
864 //---------------------------------------------------------------------------
865
866 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
867 bool CBNAME(const wxString& a, const wxString& b); \
868 bool base_##CBNAME(const wxString& a, const wxString& b);
869
870
871 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
872 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
873 bool rval; \
874 bool doSave = wxPyRestoreThread(); \
875 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
876 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \
877 a.c_str(), b.c_str())); \
878 else \
879 rval = PCLASS::CBNAME(a, b); \
880 wxPySaveThread(doSave); \
881 return rval; \
882 } \
883 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
884 return PCLASS::CBNAME(a, b); \
885 }
886
887 //---------------------------------------------------------------------------
888
889 #define DEC_PYCALLBACK_STRING_(CBNAME) \
890 wxString CBNAME(); \
891 wxString base_##CBNAME();
892
893
894 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
895 wxString CLASS::CBNAME() { \
896 wxString rval; \
897 bool doSave = wxPyRestoreThread(); \
898 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
899 PyObject* ro; \
900 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
901 if (ro) { \
902 PyObject* str = PyObject_Str(ro); \
903 rval = PyString_AsString(str); \
904 Py_DECREF(ro); Py_DECREF(str); \
905 } \
906 } \
907 else \
908 rval = PCLASS::CBNAME(); \
909 wxPySaveThread(doSave); \
910 return rval; \
911 } \
912 wxString CLASS::base_##CBNAME() { \
913 return PCLASS::CBNAME(); \
914 }
915
916 //---------------------------------------------------------------------------
917
918 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
919 wxString CBNAME();
920
921
922 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
923 wxString CLASS::CBNAME() { \
924 wxString rval; \
925 bool doSave = wxPyRestoreThread(); \
926 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
927 PyObject* ro; \
928 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
929 if (ro) { \
930 PyObject* str = PyObject_Str(ro); \
931 rval = PyString_AsString(str); \
932 Py_DECREF(ro); Py_DECREF(str); \
933 } \
934 } \
935 wxPySaveThread(doSave); \
936 return rval; \
937 }
938
939 //---------------------------------------------------------------------------
940
941 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
942 bool CBNAME(const wxHtmlTag& a); \
943
944
945 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
946 bool CLASS::CBNAME(const wxHtmlTag& a) { \
947 bool rval = FALSE; \
948 bool doSave = wxPyRestoreThread(); \
949 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
950 PyObject* obj = wxPyConstructObject((void*)&a,"wxHtmlTag", 0); \
951 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
952 Py_DECREF(obj); \
953 } \
954 wxPySaveThread(doSave); \
955 return rval; \
956 }
957
958 //---------------------------------------------------------------------------
959
960 #define DEC_PYCALLBACK___pure(CBNAME) \
961 void CBNAME(); \
962
963
964 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
965 void CLASS::CBNAME() { \
966 bool doSave = wxPyRestoreThread(); \
967 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
968 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
969 wxPySaveThread(doSave); \
970 }
971
972 //---------------------------------------------------------------------------
973
974 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
975 wxSize CBNAME(); \
976
977
978 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
979 wxSize CLASS::CBNAME() { \
980 wxSize rval(0,0); \
981 bool doSave = wxPyRestoreThread(); \
982 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
983 PyObject* ro; \
984 wxSize* ptr; \
985 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
986 if (ro) { \
987 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
988 rval = *ptr; \
989 Py_DECREF(ro); \
990 } \
991 } \
992 wxPySaveThread(doSave); \
993 return rval; \
994 }
995
996 //---------------------------------------------------------------------------
997
998 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
999 bool CBNAME(wxWindow* a); \
1000 bool base_##CBNAME(wxWindow* a);
1001
1002
1003 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1004 bool CLASS::CBNAME(wxWindow* a) { \
1005 bool rval; \
1006 bool doSave = wxPyRestoreThread(); \
1007 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1008 PyObject* obj = wxPyConstructObject((void*)a,"wxWindow", 0);\
1009 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1010 Py_DECREF(obj); \
1011 } \
1012 else \
1013 rval = PCLASS::CBNAME(a); \
1014 wxPySaveThread(doSave); \
1015 return rval; \
1016 } \
1017 bool CLASS::base_##CBNAME(wxWindow* a) { \
1018 return PCLASS::CBNAME(a); \
1019 }
1020
1021 //---------------------------------------------------------------------------
1022
1023 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1024 bool CBNAME(); \
1025 bool base_##CBNAME();
1026
1027
1028 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1029 bool CLASS::CBNAME() { \
1030 bool rval; \
1031 bool doSave = wxPyRestoreThread(); \
1032 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1033 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1034 else \
1035 rval = PCLASS::CBNAME(); \
1036 wxPySaveThread(doSave); \
1037 return rval; \
1038 } \
1039 bool CLASS::base_##CBNAME() { \
1040 return PCLASS::CBNAME(); \
1041 }
1042
1043 //---------------------------------------------------------------------------
1044
1045 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1046 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1047 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1048
1049
1050 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1051 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1052 bool doSave = wxPyRestoreThread(); \
1053 int rval; \
1054 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1055 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1056 else \
1057 rval = PCLASS::CBNAME(a, b, c); \
1058 wxPySaveThread(doSave); \
1059 return (wxDragResult)rval; \
1060 } \
1061 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1062 return PCLASS::CBNAME(a, b, c); \
1063 }
1064
1065 //---------------------------------------------------------------------------
1066
1067 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1068 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1069
1070 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1071 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1072 bool doSave = wxPyRestoreThread(); \
1073 wxFSFile* rval=0; \
1074 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1075 PyObject* ro; \
1076 PyObject* obj = wxPyConstructObject(&a, "wxFileSystem", 0); \
1077 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)", \
1078 obj, b.c_str())); \
1079 if (ro) { \
1080 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1081 Py_DECREF(ro); \
1082 } \
1083 Py_DECREF(obj); \
1084 } \
1085 wxPySaveThread(doSave); \
1086 return rval; \
1087 };
1088
1089 //---------------------------------------------------------------------------
1090
1091 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1092 bool CBNAME(wxDragResult a); \
1093 bool base_##CBNAME(wxDragResult a);
1094
1095
1096 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1097 bool CLASS::CBNAME(wxDragResult a) { \
1098 bool doSave = wxPyRestoreThread(); \
1099 bool rval; \
1100 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1101 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1102 else \
1103 rval = PCLASS::CBNAME(a); \
1104 wxPySaveThread(doSave); \
1105 return rval; \
1106 } \
1107 bool CLASS::base_##CBNAME(wxDragResult a) { \
1108 return PCLASS::CBNAME(a); \
1109 }
1110
1111 //---------------------------------------------------------------------------
1112
1113 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1114 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1115
1116
1117 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1118 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1119 bool doSave = wxPyRestoreThread(); \
1120 int rval; \
1121 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1122 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1123 wxPySaveThread(doSave); \
1124 return (wxDragResult)rval; \
1125 } \
1126
1127 //---------------------------------------------------------------------------
1128
1129 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1130 bool CBNAME(int a, int b, const wxString& c);
1131
1132
1133 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1134 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1135 bool rval; \
1136 bool doSave = wxPyRestoreThread(); \
1137 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1138 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
1139 wxPySaveThread(doSave); \
1140 return rval; \
1141 } \
1142
1143 //---------------------------------------------------------------------------
1144
1145 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1146 size_t CBNAME(); \
1147 size_t base_##CBNAME();
1148
1149
1150 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1151 size_t CLASS::CBNAME() { \
1152 size_t rval; \
1153 bool doSave = wxPyRestoreThread(); \
1154 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1155 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1156 else \
1157 rval = PCLASS::CBNAME(); \
1158 wxPySaveThread(doSave); \
1159 return rval; \
1160 } \
1161 size_t CLASS::base_##CBNAME() { \
1162 return PCLASS::CBNAME(); \
1163 }
1164
1165 //---------------------------------------------------------------------------
1166
1167 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1168 wxDataFormat CBNAME(); \
1169 wxDataFormat base_##CBNAME();
1170
1171
1172 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1173 wxDataFormat CLASS::CBNAME(size_t a) { \
1174 wxDataFormat rval; \
1175 bool doSave = wxPyRestoreThread(); \
1176 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1177 PyObject* ro; \
1178 wxDataFormat* ptr; \
1179 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1180 if (ro) { \
1181 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1182 rval = *ptr; \
1183 Py_DECREF(ro); \
1184 } \
1185 } \
1186 else \
1187 rval = PCLASS::CBNAME(a); \
1188 wxPySaveThread(doSave); \
1189 return rval; \
1190 } \
1191 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1192 return PCLASS::CBNAME(a); \
1193 }
1194
1195 //---------------------------------------------------------------------------
1196
1197 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1198 void CBNAME(const Type& a); \
1199 void base_##CBNAME(const Type& a);
1200
1201
1202 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1203 void CLASS::CBNAME(const Type& a) { \
1204 bool doSave = wxPyRestoreThread(); \
1205 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1206 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1207 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1208 Py_DECREF(obj); \
1209 } \
1210 else \
1211 PCLASS::CBNAME(a); \
1212 wxPySaveThread(doSave); \
1213 } \
1214 void CLASS::base_##CBNAME(const Type& a) { \
1215 PCLASS::CBNAME(a); \
1216 }
1217
1218
1219 //---------------------------------------------------------------------------
1220
1221 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1222 void CBNAME(Type& a); \
1223 void base_##CBNAME(Type& a);
1224
1225
1226 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1227 void CLASS::CBNAME(Type& a) { \
1228 bool doSave = wxPyRestoreThread(); \
1229 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1230 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1231 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1232 Py_DECREF(obj); \
1233 } \
1234 else \
1235 PCLASS::CBNAME(a); \
1236 wxPySaveThread(doSave); \
1237 } \
1238 void CLASS::base_##CBNAME(Type& a) { \
1239 PCLASS::CBNAME(a); \
1240 }
1241
1242 //---------------------------------------------------------------------------
1243
1244 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1245 bool CBNAME(Type& a); \
1246 bool base_##CBNAME(Type& a);
1247
1248
1249 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1250 bool CLASS::CBNAME(Type& a) { \
1251 bool rv; \
1252 bool doSave = wxPyRestoreThread(); \
1253 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1254 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1255 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1256 Py_DECREF(obj); \
1257 } \
1258 else \
1259 rv = PCLASS::CBNAME(a); \
1260 wxPySaveThread(doSave); \
1261 return rv; \
1262 } \
1263 bool CLASS::base_##CBNAME(Type& a) { \
1264 return PCLASS::CBNAME(a); \
1265 }
1266
1267 //---------------------------------------------------------------------------
1268
1269 #endif
1270
1271
1272
1273