]> git.saurik.com Git - wxWidgets.git/blame - include/wx/xtictor.h
Disable double-to-float conversion tests in wxAny code.
[wxWidgets.git] / include / wx / xtictor.h
CommitLineData
e1d3601a
PC
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/xtictor.h
3// Purpose: XTI constructors
4// Author: Stefan Csomor
5// Modified by: Francesco Montorsi
6// Created: 27/07/03
7// RCS-ID: $Id$
8// Copyright: (c) 1997 Julian Smart
9// (c) 2003 Stefan Csomor
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef _XTICTOR_H_
14#define _XTICTOR_H_
15
16#include "wx/defs.h"
17
18#if wxUSE_EXTENDED_RTTI
19
6c887dde 20#include "wx/xti.h"
e1d3601a
PC
21
22// ----------------------------------------------------------------------------
23// Constructor Bridges
24// ----------------------------------------------------------------------------
25
26// A constructor bridge allows to call a ctor with an arbitrary number
27// or parameters during runtime
28class WXDLLIMPEXP_BASE wxObjectAllocatorAndCreator
29{
30public:
31 virtual ~wxObjectAllocatorAndCreator() { }
6c887dde 32 virtual bool Create(wxObject * &o, wxAny *args) = 0;
e1d3601a
PC
33};
34
35// a direct constructor bridge calls the operator new for this class and
36// passes all params to the constructor. Needed for classes that cannot be
37// instantiated using alloc-create semantics
38class WXDLLIMPEXP_BASE wxObjectAllocator : public wxObjectAllocatorAndCreator
39{
40public:
6c887dde 41 virtual bool Create(wxObject * &o, wxAny *args) = 0;
e1d3601a
PC
42};
43
44
45// ----------------------------------------------------------------------------
46// Constructor Bridges for all Numbers of Params
47// ----------------------------------------------------------------------------
48
49// no params
50
51template<typename Class>
52struct wxObjectAllocatorAndCreator_0 : public wxObjectAllocatorAndCreator
53{
6c887dde 54 bool Create(wxObject * &o, wxAny *)
e1d3601a
PC
55 {
56 Class *obj = wx_dynamic_cast(Class*, o);
57 return obj->Create();
58 }
59};
60
61struct wxObjectAllocatorAndCreator_Dummy : public wxObjectAllocatorAndCreator
62{
6c887dde 63 bool Create(wxObject *&, wxAny *)
e1d3601a
PC
64 {
65 return true;
66 }
67};
68
69#define wxCONSTRUCTOR_0(klass) \
70 wxObjectAllocatorAndCreator_0<klass> constructor##klass; \
71 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
72 const wxChar *klass::ms_constructorProperties[] = { NULL }; \
73 const int klass::ms_constructorPropertiesCount = 0;
74
75#define wxCONSTRUCTOR_DUMMY(klass) \
76 wxObjectAllocatorAndCreator_Dummy constructor##klass; \
77 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
78 const wxChar *klass::ms_constructorProperties[] = { NULL }; \
79 const int klass::ms_constructorPropertiesCount = 0;
80
81// direct constructor version
82
83template<typename Class>
84struct wxDirectConstructorBridge_0 : public wxObjectAllocator
85{
6c887dde 86 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
87 {
88 o = new Class( );
89 return o != NULL;
90 }
91};
92
93#define wxDIRECT_CONSTRUCTOR_0(klass) \
94 wxDirectConstructorBridge_0<klass> constructor##klass; \
95 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
96 const wxChar *klass::ms_constructorProperties[] = { NULL }; \
97 const int klass::ms_constructorPropertiesCount = 0;
98
99
100// 1 param
101
102template<typename Class, typename T0>
103struct wxObjectAllocatorAndCreator_1 : public wxObjectAllocatorAndCreator
104{
6c887dde 105 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
106 {
107 Class *obj = wx_dynamic_cast(Class*, o);
108 return obj->Create(
6c887dde 109 (args[0]).As(static_cast<T0*>(NULL))
e1d3601a
PC
110 );
111 }
112};
113
114#define wxCONSTRUCTOR_1(klass,t0,v0) \
115 wxObjectAllocatorAndCreator_1<klass,t0> constructor##klass; \
116 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
117 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) }; \
118 const int klass::ms_constructorPropertiesCount = 1;
119
120// direct constructor version
121
122template<typename Class, typename T0>
123struct wxDirectConstructorBridge_1 : public wxObjectAllocator
124{
6c887dde 125 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
126 {
127 o = new Class(
6c887dde 128 (args[0]).As(static_cast<T0*>(NULL))
e1d3601a
PC
129 );
130 return o != NULL;
131 }
132};
133
134#define wxDIRECT_CONSTRUCTOR_1(klass,t0,v0) \
135 wxDirectConstructorBridge_1<klass,t0,t1> constructor##klass; \
136 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
137 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) }; \
138 const int klass::ms_constructorPropertiesCount = 1;
139
140
141// 2 params
142
143template<typename Class,
144typename T0, typename T1>
145struct wxObjectAllocatorAndCreator_2 : public wxObjectAllocatorAndCreator
146{
6c887dde 147 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
148 {
149 Class *obj = wx_dynamic_cast(Class*, o);
150 return obj->Create(
6c887dde
SC
151 (args[0]).As(static_cast<T0*>(NULL)),
152 (args[1]).As(static_cast<T1*>(NULL))
e1d3601a
PC
153 );
154 }
155};
156
157#define wxCONSTRUCTOR_2(klass,t0,v0,t1,v1) \
158 wxObjectAllocatorAndCreator_2<klass,t0,t1> constructor##klass; \
159 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
160 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1) }; \
161 const int klass::ms_constructorPropertiesCount = 2;
162
163// direct constructor version
164
165template<typename Class,
166typename T0, typename T1>
167struct wxDirectConstructorBridge_2 : public wxObjectAllocator
168{
6c887dde 169 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
170 {
171 o = new Class(
6c887dde
SC
172 (args[0]).As(static_cast<T0*>(NULL)),
173 (args[1]).As(static_cast<T1*>(NULL))
e1d3601a
PC
174 );
175 return o != NULL;
176 }
177};
178
179#define wxDIRECT_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
180 wxDirectConstructorBridge_2<klass,t0,t1> constructor##klass; \
181 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
182 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1) }; \
183 const int klass::ms_constructorPropertiesCount = 2;
184
185
186// 3 params
187
188template<typename Class,
189typename T0, typename T1, typename T2>
190struct wxObjectAllocatorAndCreator_3 : public wxObjectAllocatorAndCreator
191{
6c887dde 192 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
193 {
194 Class *obj = wx_dynamic_cast(Class*, o);
195 return obj->Create(
6c887dde
SC
196 (args[0]).As(static_cast<T0*>(NULL)),
197 (args[1]).As(static_cast<T1*>(NULL)),
198 (args[2]).As(static_cast<T2*>(NULL))
e1d3601a
PC
199 );
200 }
201};
202
203#define wxCONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
204 wxObjectAllocatorAndCreator_3<klass,t0,t1,t2> constructor##klass; \
205 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
206 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1), wxT(#v2) }; \
207 const int klass::ms_constructorPropertiesCount = 3;
208
209// direct constructor version
210
211template<typename Class,
212typename T0, typename T1, typename T2>
213struct wxDirectConstructorBridge_3 : public wxObjectAllocator
214{
6c887dde 215 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
216 {
217 o = new Class(
6c887dde
SC
218 (args[0]).As(static_cast<T0*>(NULL)),
219 (args[1]).As(static_cast<T1*>(NULL)),
220 (args[2]).As(static_cast<T2*>(NULL))
e1d3601a
PC
221 );
222 return o != NULL;
223 }
224};
225
226#define wxDIRECT_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
227 wxDirectConstructorBridge_3<klass,t0,t1,t2> constructor##klass; \
228 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
229 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1), wxT(#v2) }; \
230 const int klass::ms_constructorPropertiesCount = 3;
231
232
233// 4 params
234
235template<typename Class,
236typename T0, typename T1, typename T2, typename T3>
237struct wxObjectAllocatorAndCreator_4 : public wxObjectAllocatorAndCreator
238{
6c887dde 239 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
240 {
241 Class *obj = wx_dynamic_cast(Class*, o);
242 return obj->Create(
6c887dde
SC
243 (args[0]).As(static_cast<T0*>(NULL)),
244 (args[1]).As(static_cast<T1*>(NULL)),
245 (args[2]).As(static_cast<T2*>(NULL)),
246 (args[3]).As(static_cast<T3*>(NULL))
e1d3601a
PC
247 );
248 }
249};
250
251#define wxCONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
252 wxObjectAllocatorAndCreator_4<klass,t0,t1,t2,t3> constructor##klass; \
253 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
254 const wxChar *klass::ms_constructorProperties[] = \
255 { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3) }; \
256 const int klass::ms_constructorPropertiesCount = 4;
257
258// direct constructor version
259
260template<typename Class,
261typename T0, typename T1, typename T2, typename T3>
262struct wxDirectConstructorBridge_4 : public wxObjectAllocator
263{
6c887dde 264 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
265 {
266 o = new Class(
6c887dde
SC
267 (args[0]).As(static_cast<T0*>(NULL)),
268 (args[1]).As(static_cast<T1*>(NULL)),
269 (args[2]).As(static_cast<T2*>(NULL)),
270 (args[3]).As(static_cast<T3*>(NULL))
e1d3601a
PC
271 );
272 return o != NULL;
273 }
274};
275
276#define wxDIRECT_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
277 wxDirectConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass; \
278 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
279 const wxChar *klass::ms_constructorProperties[] = \
280 { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3) }; \
281 const int klass::ms_constructorPropertiesCount = 4;
282
283
284// 5 params
285
286template<typename Class,
287typename T0, typename T1, typename T2, typename T3, typename T4>
288struct wxObjectAllocatorAndCreator_5 : public wxObjectAllocatorAndCreator
289{
6c887dde 290 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
291 {
292 Class *obj = wx_dynamic_cast(Class*, o);
293 return obj->Create(
6c887dde
SC
294 (args[0]).As(static_cast<T0*>(NULL)),
295 (args[1]).As(static_cast<T1*>(NULL)),
296 (args[2]).As(static_cast<T2*>(NULL)),
297 (args[3]).As(static_cast<T3*>(NULL)),
298 (args[4]).As(static_cast<T4*>(NULL))
e1d3601a
PC
299 );
300 }
301};
302
303#define wxCONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
304 wxObjectAllocatorAndCreator_5<klass,t0,t1,t2,t3,t4> constructor##klass; \
305 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
306 const wxChar *klass::ms_constructorProperties[] = \
307 { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4) }; \
308 const int klass::ms_constructorPropertiesCount = 5;
309
310// direct constructor version
311
312template<typename Class,
313typename T0, typename T1, typename T2, typename T3, typename T4>
314struct wxDirectConstructorBridge_5 : public wxObjectAllocator
315{
6c887dde 316 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
317 {
318 o = new Class(
6c887dde
SC
319 (args[0]).As(static_cast<T0*>(NULL)),
320 (args[1]).As(static_cast<T1*>(NULL)),
321 (args[2]).As(static_cast<T2*>(NULL)),
322 (args[3]).As(static_cast<T3*>(NULL)),
323 (args[4]).As(static_cast<T4*>(NULL))
e1d3601a
PC
324 );
325 return o != NULL;
326 }
327};
328
329#define wxDIRECT_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
330 wxDirectConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass; \
331 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
332 const wxChar *klass::ms_constructorProperties[] = \
333 { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4) }; \
334 const int klass::ms_constructorPropertiesCount = 5;
335
336
337// 6 params
338
339template<typename Class,
340typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
341struct wxObjectAllocatorAndCreator_6 : public wxObjectAllocatorAndCreator
342{
6c887dde 343 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
344 {
345 Class *obj = wx_dynamic_cast(Class*, o);
346 return obj->Create(
6c887dde
SC
347 (args[0]).As(static_cast<T0*>(NULL)),
348 (args[1]).As(static_cast<T1*>(NULL)),
349 (args[2]).As(static_cast<T2*>(NULL)),
350 (args[3]).As(static_cast<T3*>(NULL)),
351 (args[4]).As(static_cast<T4*>(NULL)),
352 (args[5]).As(static_cast<T5*>(NULL))
e1d3601a
PC
353 );
354 }
355};
356
357#define wxCONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
358 wxObjectAllocatorAndCreator_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass; \
359 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
360 const wxChar *klass::ms_constructorProperties[] = \
361 { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5) }; \
362 const int klass::ms_constructorPropertiesCount = 6;
363
364// direct constructor version
365
366template<typename Class,
367typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
368struct wxDirectConstructorBridge_6 : public wxObjectAllocator
369{
6c887dde 370 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
371 {
372 o = new Class(
6c887dde
SC
373 (args[0]).As(static_cast<T0*>(NULL)),
374 (args[1]).As(static_cast<T1*>(NULL)),
375 (args[2]).As(static_cast<T2*>(NULL)),
376 (args[3]).As(static_cast<T3*>(NULL)),
377 (args[4]).As(static_cast<T4*>(NULL)),
378 (args[5]).As(static_cast<T5*>(NULL))
e1d3601a
PC
379 );
380 return o != NULL;
381 }
382};
383
384#define wxDIRECT_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
385 wxDirectConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass; \
386 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
387 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1), \
388 wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5) }; \
389 const int klass::ms_constructorPropertiesCount = 6;
390
391
392// 7 params
393
394template<typename Class,
395typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
396struct wxObjectAllocatorAndCreator_7 : public wxObjectAllocatorAndCreator
397{
6c887dde 398 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
399 {
400 Class *obj = wx_dynamic_cast(Class*, o);
401 return obj->Create(
6c887dde
SC
402 (args[0]).As(static_cast<T0*>(NULL)),
403 (args[1]).As(static_cast<T1*>(NULL)),
404 (args[2]).As(static_cast<T2*>(NULL)),
405 (args[3]).As(static_cast<T3*>(NULL)),
406 (args[4]).As(static_cast<T4*>(NULL)),
407 (args[5]).As(static_cast<T5*>(NULL)),
408 (args[6]).As(static_cast<T6*>(NULL))
e1d3601a
PC
409 );
410 }
411};
412
413#define wxCONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
414 wxObjectAllocatorAndCreator_7<klass,t0,t1,t2,t3,t4,t5,t6> constructor##klass; \
415 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
416 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0), wxT(#v1), \
417 wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5), wxT(#v6) }; \
418 const int klass::ms_constructorPropertiesCount = 7;
419
420// direct constructor version
421
422template<typename Class,
423typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
424struct wxDirectConstructorBridge_7 : public wxObjectAllocator
425{
6c887dde 426 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
427 {
428 o = new Class(
6c887dde
SC
429 (args[0]).As(static_cast<T0*>(NULL)),
430 (args[1]).As(static_cast<T1*>(NULL)),
431 (args[2]).As(static_cast<T2*>(NULL)),
432 (args[3]).As(static_cast<T3*>(NULL)),
433 (args[4]).As(static_cast<T4*>(NULL)),
434 (args[5]).As(static_cast<T5*>(NULL)),
435 (args[6]).As(static_cast<T6*>(NULL))
e1d3601a
PC
436 );
437 return o != NULL;
438 }
439};
440
441#define wxDIRECT_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
442 wxDirectConstructorBridge_7<klass,t0,t1,t2,t3,t4,t5,t6> constructor##klass; \
443 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
444 const wxChar *klass::ms_constructorProperties[] = \
445 { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5), wxT(#v6) }; \
446 const int klass::ms_constructorPropertiesCount = 7;
447
448
449// 8 params
450
451template<typename Class,
452typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, \
453typename T6, typename T7>
454struct wxObjectAllocatorAndCreator_8 : public wxObjectAllocatorAndCreator
455{
6c887dde 456 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
457 {
458 Class *obj = wx_dynamic_cast(Class*, o);
459 return obj->Create(
6c887dde
SC
460 (args[0]).As(static_cast<T0*>(NULL)),
461 (args[1]).As(static_cast<T1*>(NULL)),
462 (args[2]).As(static_cast<T2*>(NULL)),
463 (args[3]).As(static_cast<T3*>(NULL)),
464 (args[4]).As(static_cast<T4*>(NULL)),
465 (args[5]).As(static_cast<T5*>(NULL)),
466 (args[6]).As(static_cast<T6*>(NULL)),
467 (args[7]).As(static_cast<T7*>(NULL))
e1d3601a
PC
468 );
469 }
470};
471
472#define wxCONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
473 wxObjectAllocatorAndCreator_8<klass,t0,t1,t2,t3,t4,t5,t6,t7> constructor##klass; \
474 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
475 const wxChar *klass::ms_constructorProperties[] = \
476 { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5), wxT(#v6), wxT(#v7) }; \
477 const int klass::ms_constructorPropertiesCount = 8;
478
479// direct constructor version
480
481template<typename Class,
482typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, \
483typename T6, typename T7>
484struct wxDirectConstructorBridge_8 : public wxObjectAllocator
485{
6c887dde 486 bool Create(wxObject * &o, wxAny *args)
e1d3601a
PC
487 {
488 o = new Class(
6c887dde
SC
489 (args[0]).As(static_cast<T0*>(NULL)),
490 (args[1]).As(static_cast<T1*>(NULL)),
491 (args[2]).As(static_cast<T2*>(NULL)),
492 (args[3]).As(static_cast<T3*>(NULL)),
493 (args[4]).As(static_cast<T4*>(NULL)),
494 (args[5]).As(static_cast<T5*>(NULL)),
495 (args[6]).As(static_cast<T6*>(NULL)),
496 (args[7]).As(static_cast<T7*>(NULL))
e1d3601a
PC
497 );
498 return o != NULL;
499 }
500};
501
502#define wxDIRECT_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
503 wxDirectConstructorBridge_8<klass,t0,t1,t2,t3,t4,t5,t6,t7> constructor##klass; \
504 wxObjectAllocatorAndCreator* klass::ms_constructor = &constructor##klass; \
505 const wxChar *klass::ms_constructorProperties[] = \
506 { wxT(#v0), wxT(#v1), wxT(#v2), wxT(#v3), wxT(#v4), wxT(#v5), wxT(#v6), wxT(#v7) }; \
507 const int klass::ms_constructorPropertiesCount = 8;
508
509#endif // wxUSE_EXTENDED_RTTI
510#endif // _XTICTOR_H_