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