Coverage Report

Created: 2024-03-18 06:28

/src/wxwidgets/include/wx/rtti.h
Line
Count
Source (jump to first uncovered line)
1
/////////////////////////////////////////////////////////////////////////////
2
// Name:        wx/rtti.h
3
// Purpose:     old RTTI macros (use XTI when possible instead)
4
// Author:      Julian Smart
5
// Modified by: Ron Lee
6
// Created:     01/02/97
7
// Copyright:   (c) 1997 Julian Smart
8
//              (c) 2001 Ron Lee <ron@debian.org>
9
// Licence:     wxWindows licence
10
/////////////////////////////////////////////////////////////////////////////
11
12
#ifndef _WX_RTTIH__
13
#define _WX_RTTIH__
14
15
#if !wxUSE_EXTENDED_RTTI     // XTI system is meant to replace these macros
16
17
// ----------------------------------------------------------------------------
18
// forward declarations
19
// ----------------------------------------------------------------------------
20
21
class WXDLLIMPEXP_FWD_BASE wxObject;
22
class WXDLLIMPEXP_FWD_BASE wxString;
23
class WXDLLIMPEXP_FWD_BASE wxClassInfo;
24
class WXDLLIMPEXP_FWD_BASE wxHashTable;
25
class WXDLLIMPEXP_FWD_BASE wxObject;
26
class WXDLLIMPEXP_FWD_BASE wxPluginLibrary;
27
class WXDLLIMPEXP_FWD_BASE wxHashTable_Node;
28
29
// ----------------------------------------------------------------------------
30
// wxClassInfo
31
// ----------------------------------------------------------------------------
32
33
typedef wxObject *(*wxObjectConstructorFn)(void);
34
35
class WXDLLIMPEXP_BASE wxClassInfo
36
{
37
    friend class WXDLLIMPEXP_FWD_BASE wxObject;
38
    friend WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
39
public:
40
    wxClassInfo( const wxChar *className,
41
                 const wxClassInfo *baseInfo1,
42
                 const wxClassInfo *baseInfo2,
43
                 int size,
44
                 wxObjectConstructorFn ctor )
45
        : m_className(className)
46
        , m_objectSize(size)
47
        , m_objectConstructor(ctor)
48
        , m_baseInfo1(baseInfo1)
49
        , m_baseInfo2(baseInfo2)
50
        , m_next(sm_first)
51
76
        {
52
76
            sm_first = this;
53
76
            Register();
54
76
        }
55
56
    ~wxClassInfo();
57
58
    wxObject *CreateObject() const
59
0
        { return m_objectConstructor ? (*m_objectConstructor)() : nullptr; }
60
0
    bool IsDynamic() const { return (nullptr != m_objectConstructor); }
61
62
0
    const wxChar       *GetClassName() const { return m_className; }
63
    const wxChar       *GetBaseClassName1() const
64
0
        { return m_baseInfo1 ? m_baseInfo1->GetClassName() : nullptr; }
65
    const wxChar       *GetBaseClassName2() const
66
0
        { return m_baseInfo2 ? m_baseInfo2->GetClassName() : nullptr; }
67
0
    const wxClassInfo  *GetBaseClass1() const { return m_baseInfo1; }
68
0
    const wxClassInfo  *GetBaseClass2() const { return m_baseInfo2; }
69
0
    int                 GetSize() const { return m_objectSize; }
70
71
    wxObjectConstructorFn      GetConstructor() const
72
0
        { return m_objectConstructor; }
73
0
    static const wxClassInfo  *GetFirst() { return sm_first; }
74
0
    const wxClassInfo         *GetNext() const { return m_next; }
75
    static wxClassInfo        *FindClass(const wxString& className);
76
77
        // Climb upwards through inheritance hierarchy.
78
        // Dual inheritance is catered for.
79
80
    bool IsKindOf(const wxClassInfo *info) const
81
0
    {
82
0
        if ( info == this )
83
0
            return true;
84
85
0
        if ( m_baseInfo1 )
86
0
        {
87
0
            if ( m_baseInfo1->IsKindOf(info) )
88
0
                return true;
89
0
        }
90
91
0
        if ( m_baseInfo2 )
92
0
        {
93
0
            if ( m_baseInfo2->IsKindOf(info) )
94
0
                return true;
95
0
        }
96
97
0
        return false;
98
0
    }
99
100
    wxDECLARE_CLASS_INFO_ITERATORS();
101
102
private:
103
    const wxChar            *m_className;
104
    int                      m_objectSize;
105
    wxObjectConstructorFn    m_objectConstructor;
106
107
        // Pointers to base wxClassInfos
108
109
    const wxClassInfo       *m_baseInfo1;
110
    const wxClassInfo       *m_baseInfo2;
111
112
        // class info object live in a linked list:
113
        // pointers to its head and the next element in it
114
115
    static wxClassInfo      *sm_first;
116
    wxClassInfo             *m_next;
117
118
    static wxHashTable      *sm_classTable;
119
120
protected:
121
    // registers the class
122
    void Register();
123
    void Unregister();
124
125
    wxDECLARE_NO_COPY_CLASS(wxClassInfo);
126
};
127
128
WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
129
130
// ----------------------------------------------------------------------------
131
// Dynamic class macros
132
// ----------------------------------------------------------------------------
133
134
#define wxDECLARE_ABSTRACT_CLASS(name)                                        \
135
    public:                                                                   \
136
        wxWARNING_SUPPRESS_MISSING_OVERRIDE()                                 \
137
        virtual wxClassInfo *GetClassInfo() const wxDUMMY_OVERRIDE;           \
138
        wxWARNING_RESTORE_MISSING_OVERRIDE()                                  \
139
        static wxClassInfo ms_classInfo
140
141
#define wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(name)                               \
142
    wxDECLARE_NO_ASSIGN_CLASS(name);                                          \
143
    wxDECLARE_DYNAMIC_CLASS(name)
144
145
#define wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(name)                      \
146
    wxDECLARE_NO_ASSIGN_DEF_COPY(name);                                       \
147
    wxDECLARE_DYNAMIC_CLASS(name)
148
149
#define wxDECLARE_DYNAMIC_CLASS_NO_COPY(name)                                 \
150
    wxDECLARE_NO_COPY_CLASS(name);                                            \
151
    wxDECLARE_DYNAMIC_CLASS(name)
152
153
#define wxDECLARE_DYNAMIC_CLASS(name)                                         \
154
    wxDECLARE_ABSTRACT_CLASS(name);                                           \
155
    static wxObject* wxCreateObject()
156
157
#define wxDECLARE_CLASS(name)                                                 \
158
    wxDECLARE_ABSTRACT_CLASS(name)
159
160
161
// common part of the macros below
162
#define wxIMPLEMENT_CLASS_COMMON(name, basename, baseclsinfo2, func)          \
163
    wxClassInfo name::ms_classInfo(wxT(#name),                                \
164
            &basename::ms_classInfo,                                          \
165
            baseclsinfo2,                                                     \
166
            (int) sizeof(name),                                               \
167
            func);                                                            \
168
                                                                              \
169
    wxClassInfo *name::GetClassInfo() const                                   \
170
0
        { return &name::ms_classInfo; }
Unexecuted instantiation: wxConfigBase::GetClassInfo() const
Unexecuted instantiation: wxFileConfig::GetClassInfo() const
Unexecuted instantiation: wxFontMapperModule::GetClassInfo() const
Unexecuted instantiation: wxModule::GetClassInfo() const
Unexecuted instantiation: wxMemoryInputStream::GetClassInfo() const
Unexecuted instantiation: wxMemoryOutputStream::GetClassInfo() const
Unexecuted instantiation: wxStreamBase::GetClassInfo() const
Unexecuted instantiation: wxInputStream::GetClassInfo() const
Unexecuted instantiation: wxOutputStream::GetClassInfo() const
Unexecuted instantiation: wxCountingOutputStream::GetClassInfo() const
Unexecuted instantiation: wxFilterInputStream::GetClassInfo() const
Unexecuted instantiation: wxFilterOutputStream::GetClassInfo() const
Unexecuted instantiation: wxFilterClassFactoryBase::GetClassInfo() const
Unexecuted instantiation: wxFilterClassFactory::GetClassInfo() const
Unexecuted instantiation: wxTranslationsModule::GetClassInfo() const
Unexecuted instantiation: wxURI::GetClassInfo() const
Unexecuted instantiation: wxXLocaleModule::GetClassInfo() const
Unexecuted instantiation: wxZipEntry::GetClassInfo() const
Unexecuted instantiation: wxZipClassFactory::GetClassInfo() const
Unexecuted instantiation: wxZlibClassFactory::GetClassInfo() const
Unexecuted instantiation: wxGzipClassFactory::GetClassInfo() const
Unexecuted instantiation: wxTimerUnixModule::GetClassInfo() const
Unexecuted instantiation: wxThreadModule::GetClassInfo() const
Unexecuted instantiation: wxEvtHandler::GetClassInfo() const
Unexecuted instantiation: wxEvent::GetClassInfo() const
Unexecuted instantiation: wxIdleEvent::GetClassInfo() const
Unexecuted instantiation: wxThreadEvent::GetClassInfo() const
Unexecuted instantiation: wxAnyValueTypeGlobalsManager::GetClassInfo() const
Unexecuted instantiation: wxArchiveEntry::GetClassInfo() const
Unexecuted instantiation: wxArchiveClassFactory::GetClassInfo() const
Unexecuted instantiation: wxDateTimeHolidaysModule::GetClassInfo() const
Unexecuted instantiation: wxLocaleModule::GetClassInfo() const
Unexecuted instantiation: wxProcess::GetClassInfo() const
Unexecuted instantiation: wxProcessEvent::GetClassInfo() const
Unexecuted instantiation: wxVariant::GetClassInfo() const
Unexecuted instantiation: wxFDIODispatcherModule::GetClassInfo() const
Unexecuted instantiation: wxTimerEvent::GetClassInfo() const
171
172
#define wxIMPLEMENT_CLASS_COMMON1(name, basename, func)                       \
173
    wxIMPLEMENT_CLASS_COMMON(name, basename, nullptr, func)
174
175
#define wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, func)           \
176
    wxIMPLEMENT_CLASS_COMMON(name, basename1, &basename2::ms_classInfo, func)
177
178
// -----------------------------------
179
// for concrete classes
180
// -----------------------------------
181
182
    // Single inheritance with one base class
183
#define wxIMPLEMENT_DYNAMIC_CLASS(name, basename)                             \
184
    wxIMPLEMENT_CLASS_COMMON1(name, basename, name::wxCreateObject)           \
185
    wxObject* name::wxCreateObject()                                          \
186
0
        { return new name; }
Unexecuted instantiation: wxFontMapperModule::wxCreateObject()
Unexecuted instantiation: wxMemoryOutputStream::wxCreateObject()
Unexecuted instantiation: wxCountingOutputStream::wxCreateObject()
Unexecuted instantiation: wxTranslationsModule::wxCreateObject()
Unexecuted instantiation: wxXLocaleModule::wxCreateObject()
Unexecuted instantiation: wxZipEntry::wxCreateObject()
Unexecuted instantiation: wxZipClassFactory::wxCreateObject()
Unexecuted instantiation: wxZlibClassFactory::wxCreateObject()
Unexecuted instantiation: wxGzipClassFactory::wxCreateObject()
Unexecuted instantiation: wxTimerUnixModule::wxCreateObject()
Unexecuted instantiation: wxThreadModule::wxCreateObject()
Unexecuted instantiation: wxEvtHandler::wxCreateObject()
Unexecuted instantiation: wxIdleEvent::wxCreateObject()
Unexecuted instantiation: wxThreadEvent::wxCreateObject()
Unexecuted instantiation: wxAnyValueTypeGlobalsManager::wxCreateObject()
Unexecuted instantiation: wxDateTimeHolidaysModule::wxCreateObject()
Unexecuted instantiation: wxLocaleModule::wxCreateObject()
Unexecuted instantiation: wxProcess::wxCreateObject()
Unexecuted instantiation: wxProcessEvent::wxCreateObject()
Unexecuted instantiation: wxVariant::wxCreateObject()
Unexecuted instantiation: wxFDIODispatcherModule::wxCreateObject()
187
188
    // Multiple inheritance with two base classes
189
#define wxIMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2)                \
190
    wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2,                     \
191
                              name::wxCreateObject)                           \
192
    wxObject* name::wxCreateObject()                                          \
193
        { return new name; }
194
195
// -----------------------------------
196
// for abstract classes
197
// -----------------------------------
198
199
    // Single inheritance with one base class
200
#define wxIMPLEMENT_ABSTRACT_CLASS(name, basename)                            \
201
    wxIMPLEMENT_CLASS_COMMON1(name, basename, nullptr)
202
203
    // Multiple inheritance with two base classes
204
#define wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2)               \
205
    wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, nullptr)
206
207
// -----------------------------------
208
// XTI-compatible macros
209
// -----------------------------------
210
211
#include "wx/flags.h"
212
213
// these macros only do something when wxUSE_EXTENDED_RTTI=1
214
// (and in that case they are defined by xti.h); however to avoid
215
// to be forced to wrap these macros (in user's source files) with
216
//
217
//  #if wxUSE_EXTENDED_RTTI
218
//  ...
219
//  #endif
220
//
221
// blocks, we define them here as empty.
222
223
#define wxEMPTY_PARAMETER_VALUE /**/
224
225
#define wxBEGIN_ENUM( e ) wxEMPTY_PARAMETER_VALUE
226
#define wxENUM_MEMBER( v ) wxEMPTY_PARAMETER_VALUE
227
#define wxEND_ENUM( e ) wxEMPTY_PARAMETER_VALUE
228
229
#define wxIMPLEMENT_SET_STREAMING(SetName,e) wxEMPTY_PARAMETER_VALUE
230
231
#define wxBEGIN_FLAGS( e ) wxEMPTY_PARAMETER_VALUE
232
#define wxFLAGS_MEMBER( v ) wxEMPTY_PARAMETER_VALUE
233
#define wxEND_FLAGS( e ) wxEMPTY_PARAMETER_VALUE
234
235
#define wxCOLLECTION_TYPE_INFO( element, collection ) wxEMPTY_PARAMETER_VALUE
236
237
#define wxHANDLER(name,eventClassType) wxEMPTY_PARAMETER_VALUE
238
#define wxBEGIN_HANDLERS_TABLE(theClass) wxEMPTY_PARAMETER_VALUE
239
#define wxEND_HANDLERS_TABLE() wxEMPTY_PARAMETER_VALUE
240
241
#define wxIMPLEMENT_DYNAMIC_CLASS_XTI( name, basename, unit ) \
242
    wxIMPLEMENT_DYNAMIC_CLASS( name, basename )
243
#define wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name, basename, unit, callback ) \
244
    wxIMPLEMENT_DYNAMIC_CLASS( name, basename )
245
246
#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name, basename, unit ) \
247
    wxIMPLEMENT_DYNAMIC_CLASS( name, basename)
248
249
#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( name, basename,  \
250
                                                             unit, toString,    \
251
                                                             fromString ) wxEMPTY_PARAMETER_VALUE
252
#define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name, unit ) wxEMPTY_PARAMETER_VALUE
253
#define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name, basename, unit ) wxEMPTY_PARAMETER_VALUE
254
255
#define wxIMPLEMENT_DYNAMIC_CLASS2_XTI( name, basename, basename2, unit) wxIMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2 )
256
257
#define wxCONSTRUCTOR_0(klass) \
258
    wxEMPTY_PARAMETER_VALUE
259
#define wxCONSTRUCTOR_DUMMY(klass) \
260
    wxEMPTY_PARAMETER_VALUE
261
#define wxDIRECT_CONSTRUCTOR_0(klass) \
262
    wxEMPTY_PARAMETER_VALUE
263
#define wxCONSTRUCTOR_1(klass,t0,v0) \
264
    wxEMPTY_PARAMETER_VALUE
265
#define wxDIRECT_CONSTRUCTOR_1(klass,t0,v0) \
266
    wxEMPTY_PARAMETER_VALUE
267
#define wxCONSTRUCTOR_2(klass,t0,v0,t1,v1) \
268
    wxEMPTY_PARAMETER_VALUE
269
#define wxDIRECT_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
270
    wxEMPTY_PARAMETER_VALUE
271
#define wxCONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
272
    wxEMPTY_PARAMETER_VALUE
273
#define wxDIRECT_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
274
    wxEMPTY_PARAMETER_VALUE
275
#define wxCONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
276
    wxEMPTY_PARAMETER_VALUE
277
#define wxDIRECT_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
278
    wxEMPTY_PARAMETER_VALUE
279
#define wxCONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
280
    wxEMPTY_PARAMETER_VALUE
281
#define wxDIRECT_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
282
    wxEMPTY_PARAMETER_VALUE
283
#define wxCONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
284
    wxEMPTY_PARAMETER_VALUE
285
#define wxDIRECT_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
286
    wxEMPTY_PARAMETER_VALUE
287
#define wxCONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
288
    wxEMPTY_PARAMETER_VALUE
289
#define wxDIRECT_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
290
    wxEMPTY_PARAMETER_VALUE
291
#define wxCONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
292
    wxEMPTY_PARAMETER_VALUE
293
#define wxDIRECT_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
294
    wxEMPTY_PARAMETER_VALUE
295
296
#define wxSETTER( property, Klass, valueType, setterMethod ) wxEMPTY_PARAMETER_VALUE
297
#define wxGETTER( property, Klass, valueType, gettermethod ) wxEMPTY_PARAMETER_VALUE
298
#define wxADDER( property, Klass, valueType, addermethod ) wxEMPTY_PARAMETER_VALUE
299
#define wxCOLLECTION_GETTER( property, Klass, valueType, gettermethod ) wxEMPTY_PARAMETER_VALUE
300
301
#define wxBEGIN_PROPERTIES_TABLE(theClass) wxEMPTY_PARAMETER_VALUE
302
#define wxEND_PROPERTIES_TABLE() wxEMPTY_PARAMETER_VALUE
303
#define wxHIDE_PROPERTY( pname ) wxEMPTY_PARAMETER_VALUE
304
305
#define wxPROPERTY( pname, type, setter, getter, defaultValue, flags, help, group) \
306
    wxEMPTY_PARAMETER_VALUE
307
308
#define wxPROPERTY_FLAGS( pname, flags, type, setter, getter,defaultValue,    \
309
                          pflags, help, group) wxEMPTY_PARAMETER_VALUE
310
311
#define wxREADONLY_PROPERTY( pname, type, getter,defaultValue, flags, help, group) \
312
    wxGETTER( pname, class_t, type, getter ) wxEMPTY_PARAMETER_VALUE
313
314
#define wxREADONLY_PROPERTY_FLAGS( pname, flags, type, getter,defaultValue,    \
315
                                   pflags, help, group)  wxEMPTY_PARAMETER_VALUE
316
317
#define wxPROPERTY_COLLECTION( pname, colltype, addelemtype, adder, getter,    \
318
                               flags, help, group )  wxEMPTY_PARAMETER_VALUE
319
320
#define wxREADONLY_PROPERTY_COLLECTION( pname, colltype, addelemtype, getter,   \
321
                                        flags, help, group) wxEMPTY_PARAMETER_VALUE
322
#define wxEVENT_PROPERTY( name, eventType, eventClass ) wxEMPTY_PARAMETER_VALUE
323
324
#define wxEVENT_RANGE_PROPERTY( name, eventType, lastEventType, eventClass ) wxEMPTY_PARAMETER_VALUE
325
326
#define wxIMPLEMENT_PROPERTY(name, type) wxEMPTY_PARAMETER_VALUE
327
328
#define wxEMPTY_HANDLERS_TABLE(name) wxEMPTY_PARAMETER_VALUE
329
330
#endif // !wxUSE_EXTENDED_RTTI
331
#endif // _WX_RTTIH__