~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/corelib/kernel/qobjectdefs.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the core module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QOBJECTDEFS_H
 
30
#define QOBJECTDEFS_H
 
31
 
 
32
#include "QtCore/qnamespace.h"
 
33
 
 
34
class QString;
 
35
 
 
36
class QByteArray;
 
37
 
 
38
#ifndef Q_MOC_OUTPUT_REVISION
 
39
#define Q_MOC_OUTPUT_REVISION 58
 
40
#endif
 
41
 
 
42
// The following macros are our "extensions" to C++
 
43
// They are used, strictly speaking, only by the moc.
 
44
 
 
45
#ifndef QT_MOC_CPP
 
46
# define slots
 
47
# define signals protected
 
48
# define Q_PRIVATE_SLOT(d, signature)
 
49
#ifndef QT_NO_EMIT
 
50
# define emit
 
51
#endif
 
52
#define Q_CLASSINFO(name, value)
 
53
#define Q_INTERFACES(x)
 
54
#define Q_PROPERTY(text)
 
55
#define Q_OVERRIDE(text)
 
56
#define Q_ENUMS(x)
 
57
#define Q_FLAGS(x)
 
58
#ifdef QT3_SUPPORT
 
59
# define Q_SETS(x)
 
60
#endif
 
61
#define Q_SCRIPTABLE
 
62
#define Q_INVOKABLE
 
63
 
 
64
#ifndef QT_NO_TRANSLATION
 
65
# ifndef QT_NO_TEXTCODEC
 
66
// full set of tr functions
 
67
#  define QT_TR_FUNCTIONS \
 
68
    static inline QString tr(const char *s, const char *c = 0) \
 
69
        { return staticMetaObject.tr(s, c); } \
 
70
    static inline QString trUtf8(const char *s, const char *c = 0) \
 
71
        { return staticMetaObject.trUtf8(s, c); }
 
72
# else
 
73
// no QTextCodec, no utf8
 
74
#  define QT_TR_FUNCTIONS \
 
75
    static inline QString tr(const char *s, const char *c = 0) \
 
76
        { return staticMetaObject.tr(s, c); }
 
77
# endif
 
78
#else
 
79
// inherit the ones from QObject
 
80
# define QT_TR_FUNCTIONS
 
81
#endif
 
82
 
 
83
/* tmake ignore Q_OBJECT */
 
84
#define Q_OBJECT \
 
85
public: \
 
86
    static const QMetaObject staticMetaObject; \
 
87
    virtual const QMetaObject *metaObject() const; \
 
88
    virtual void *qt_metacast(const char *); \
 
89
    QT_TR_FUNCTIONS \
 
90
    virtual int qt_metacall(QMetaObject::Call, int, void **); \
 
91
private:
 
92
/* tmake ignore Q_OBJECT */
 
93
#define Q_OBJECT_FAKE Q_OBJECT
 
94
/* tmake ignore Q_GADGET */
 
95
#define Q_GADGET \
 
96
public: \
 
97
    static const QMetaObject staticMetaObject; \
 
98
private:
 
99
#else // QT_MOC_CPP
 
100
#define slots slots
 
101
#define signals signals
 
102
#define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value)
 
103
#define Q_PROPERTY(text) Q_PROPERTY(text)
 
104
#define Q_OVERRIDE(text) Q_OVERRIDE(text)
 
105
#define Q_ENUMS(x) Q_ENUMS(x)
 
106
#define Q_FLAGS(x) Q_FLAGS(x)
 
107
#ifdef QT3_SUPPORT
 
108
# define Q_SETS(x) Q_SETS(x)
 
109
#endif
 
110
 /* tmake ignore Q_OBJECT */
 
111
#define Q_OBJECT Q_OBJECT
 
112
 /* tmake ignore Q_OBJECT */
 
113
#define Q_OBJECT_FAKE Q_OBJECT_FAKE
 
114
 /* tmake ignore Q_GADGET */
 
115
#define Q_GADGET Q_GADGET
 
116
#define Q_SCRIPTABLE Q_SCRIPTABLE
 
117
#define Q_INVOKABLE Q_INVOKABLE
 
118
#endif //QT_MOC_CPP
 
119
 
 
120
// macro for onaming members
 
121
#ifdef METHOD
 
122
#undef METHOD
 
123
#endif
 
124
#ifdef SLOT
 
125
#undef SLOT
 
126
#endif
 
127
#ifdef SIGNAL
 
128
#undef SIGNAL
 
129
#endif
 
130
 
 
131
#define METHOD(a)        "0"#a
 
132
#define SLOT(a)                "1"#a
 
133
#define SIGNAL(a)        "2"#a
 
134
 
 
135
#ifdef QT3_SUPPORT
 
136
#define METHOD_CODE        0                        // member type codes
 
137
#define SLOT_CODE        1
 
138
#define SIGNAL_CODE        2
 
139
#endif
 
140
 
 
141
#define QMETHOD_CODE        0                        // member type codes
 
142
#define QSLOT_CODE        1
 
143
#define QSIGNAL_CODE        2
 
144
 
 
145
#define Q_ARG(type, data) QArgument<type>(#type, data)
 
146
#define Q_RETURN_ARG(type, data) QReturnArgument<type>(#type, data)
 
147
 
 
148
class QObject;
 
149
class QMetaMethod;
 
150
class QMetaEnum;
 
151
class QMetaProperty;
 
152
class QMetaClassInfo;
 
153
 
 
154
 
 
155
class Q_CORE_EXPORT QGenericArgument
 
156
{
 
157
public:
 
158
    inline QGenericArgument(const char *aName = 0, const void *aData = 0)
 
159
        : _data(aData), _name(aName) {}
 
160
    inline void *data() const { return const_cast<void *>(_data); }
 
161
    inline const char *name() const { return _name; }
 
162
 
 
163
private:
 
164
    const void *_data;
 
165
    const char *_name;
 
166
};
 
167
 
 
168
class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument
 
169
{
 
170
public:
 
171
    inline QGenericReturnArgument(const char *aName = 0, void *aData = 0)
 
172
        : QGenericArgument(aName, aData)
 
173
        {}
 
174
};
 
175
 
 
176
template <class T>
 
177
class QArgument: public QGenericArgument
 
178
{
 
179
public:
 
180
    inline QArgument(const char *aName, const T &aData)
 
181
        : QGenericArgument(aName, static_cast<const void *>(&aData))
 
182
        {}
 
183
};
 
184
 
 
185
 
 
186
template<class T>
 
187
class QReturnArgument: public QGenericReturnArgument
 
188
{
 
189
public:
 
190
    inline QReturnArgument(const char *aName, T &aData)
 
191
        : QGenericReturnArgument(aName, static_cast<void *>(&aData))
 
192
        {}
 
193
};
 
194
 
 
195
struct Q_CORE_EXPORT QMetaObject
 
196
{
 
197
    const char *className() const;
 
198
    const QMetaObject *superClass() const;
 
199
 
 
200
    QObject *cast(QObject *obj) const;
 
201
 
 
202
#ifndef QT_NO_TRANSLATION
 
203
    QString tr(const char *s, const char *c) const;
 
204
    QString trUtf8(const char *s, const char *c) const;
 
205
#endif // QT_NO_TRANSLATION
 
206
 
 
207
    int methodOffset() const;
 
208
    int enumeratorOffset() const;
 
209
    int propertyOffset() const;
 
210
    int classInfoOffset() const;
 
211
 
 
212
    int methodCount() const;
 
213
    int enumeratorCount() const;
 
214
    int propertyCount() const;
 
215
    int classInfoCount() const;
 
216
 
 
217
    int indexOfMethod(const char *method) const;
 
218
    int indexOfSignal(const char *signal) const;
 
219
    int indexOfSlot(const char *slot) const;
 
220
    int indexOfEnumerator(const char *name) const;
 
221
    int indexOfProperty(const char *name) const;
 
222
    int indexOfClassInfo(const char *name) const;
 
223
 
 
224
    QMetaMethod method(int index) const;
 
225
    QMetaEnum enumerator(int index) const;
 
226
    QMetaProperty property(int index) const;
 
227
    QMetaClassInfo classInfo(int index) const;
 
228
 
 
229
    static bool checkConnectArgs(const char *signal, const char *method);
 
230
    static QByteArray normalizedSignature(const char *method);
 
231
 
 
232
    // internal index-based connect
 
233
    static bool connect(const QObject *sender, int signal_index,
 
234
                        const QObject *receiver, int method_index,
 
235
                        int type = 0, int *types = 0);
 
236
    // internal index-based disconnect
 
237
    static bool disconnect(const QObject *sender, int signal_index,
 
238
                           const QObject *receiver, int method_index);
 
239
    // internal slot-name based connect
 
240
    static void connectSlotsByName(QObject *o);
 
241
 
 
242
    // internal index-based signal activation
 
243
    static void activate(QObject *obj, int signal_index, void **argv);
 
244
    static void activate(QObject *obj, const QMetaObject *, int local_signal_index, void **argv);
 
245
    // internal guarded pointers
 
246
    static void addGuard(QObject **ptr);
 
247
    static void removeGuard(QObject **ptr);
 
248
    static void changeGuard(QObject **ptr, QObject *o);
 
249
 
 
250
    static bool invokeMethod(QObject *obj, const char *member,
 
251
                             Qt::ConnectionType,
 
252
                             QGenericReturnArgument ret,
 
253
                             QGenericArgument val0 = QGenericArgument(0),
 
254
                             QGenericArgument val1 = QGenericArgument(),
 
255
                             QGenericArgument val2 = QGenericArgument(),
 
256
                             QGenericArgument val3 = QGenericArgument(),
 
257
                             QGenericArgument val4 = QGenericArgument(),
 
258
                             QGenericArgument val5 = QGenericArgument(),
 
259
                             QGenericArgument val6 = QGenericArgument(),
 
260
                             QGenericArgument val7 = QGenericArgument(),
 
261
                             QGenericArgument val8 = QGenericArgument(),
 
262
                             QGenericArgument val9 = QGenericArgument());
 
263
 
 
264
    static inline bool invokeMethod(QObject *obj, const char *member,
 
265
                             QGenericReturnArgument ret,
 
266
                             QGenericArgument val0 = QGenericArgument(0),
 
267
                             QGenericArgument val1 = QGenericArgument(),
 
268
                             QGenericArgument val2 = QGenericArgument(),
 
269
                             QGenericArgument val3 = QGenericArgument(),
 
270
                             QGenericArgument val4 = QGenericArgument(),
 
271
                             QGenericArgument val5 = QGenericArgument(),
 
272
                             QGenericArgument val6 = QGenericArgument(),
 
273
                             QGenericArgument val7 = QGenericArgument(),
 
274
                             QGenericArgument val8 = QGenericArgument(),
 
275
                             QGenericArgument val9 = QGenericArgument())
 
276
    {
 
277
        return invokeMethod(obj, member, Qt::AutoConnection, ret, val0, val1, val2, val3,
 
278
                val4, val5, val6, val7, val8, val9);
 
279
    }
 
280
 
 
281
    static inline bool invokeMethod(QObject *obj, const char *member,
 
282
                             Qt::ConnectionType type,
 
283
                             QGenericArgument val0 = QGenericArgument(0),
 
284
                             QGenericArgument val1 = QGenericArgument(),
 
285
                             QGenericArgument val2 = QGenericArgument(),
 
286
                             QGenericArgument val3 = QGenericArgument(),
 
287
                             QGenericArgument val4 = QGenericArgument(),
 
288
                             QGenericArgument val5 = QGenericArgument(),
 
289
                             QGenericArgument val6 = QGenericArgument(),
 
290
                             QGenericArgument val7 = QGenericArgument(),
 
291
                             QGenericArgument val8 = QGenericArgument(),
 
292
                             QGenericArgument val9 = QGenericArgument())
 
293
    {
 
294
        return invokeMethod(obj, member, type, QGenericReturnArgument(), val0, val1, val2,
 
295
                                 val3, val4, val5, val6, val7, val8, val9);
 
296
    }
 
297
 
 
298
 
 
299
    static inline bool invokeMethod(QObject *obj, const char *member,
 
300
                             QGenericArgument val0 = QGenericArgument(0),
 
301
                             QGenericArgument val1 = QGenericArgument(),
 
302
                             QGenericArgument val2 = QGenericArgument(),
 
303
                             QGenericArgument val3 = QGenericArgument(),
 
304
                             QGenericArgument val4 = QGenericArgument(),
 
305
                             QGenericArgument val5 = QGenericArgument(),
 
306
                             QGenericArgument val6 = QGenericArgument(),
 
307
                             QGenericArgument val7 = QGenericArgument(),
 
308
                             QGenericArgument val8 = QGenericArgument(),
 
309
                             QGenericArgument val9 = QGenericArgument())
 
310
    {
 
311
        return invokeMethod(obj, member, Qt::AutoConnection, QGenericReturnArgument(), val0,
 
312
                val1, val2, val3, val4, val5, val6, val7, val8, val9);
 
313
    }
 
314
 
 
315
    enum Call {
 
316
        InvokeMetaMethod,
 
317
        ReadProperty,
 
318
        WriteProperty,
 
319
        ResetProperty,
 
320
        QueryPropertyDesignable,
 
321
        QueryPropertyScriptable,
 
322
        QueryPropertyStored,
 
323
        QueryPropertyEditable
 
324
    };
 
325
 
 
326
#ifdef QT3_SUPPORT
 
327
    QT3_SUPPORT const char *superClassName() const;
 
328
#endif
 
329
 
 
330
    struct { // private data
 
331
        const QMetaObject *superdata;
 
332
        const char *stringdata;
 
333
        const uint *data;
 
334
        const QMetaObject **extradata;
 
335
    } d;
 
336
};
 
337
 
 
338
inline const char *QMetaObject::className() const
 
339
{ return d.stringdata; }
 
340
 
 
341
inline const QMetaObject *QMetaObject::superClass() const
 
342
{ return d.superdata; }
 
343
 
 
344
#ifdef QT3_SUPPORT
 
345
inline const char *QMetaObject::superClassName() const
 
346
{ return d.superdata ? d.superdata->className() : 0; }
 
347
#endif
 
348
 
 
349
#endif // QOBJECTDEFS_H