summaryrefslogtreecommitdiffstats
path: root/experimental/tqtinterface/qt4/src/kernel/tqobjectdefs.h
blob: 794d1f0b247bab2af8ee90be206b2fbcc0589c64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/****************************************************************************
**
** Macros and definitions related to TQObject
**
** Created : 930419
**
** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
**
** This file is part of the kernel module of the TQt GUI Toolkit.
**
** This file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the files LICENSE.GPL2
** and LICENSE.GPL3 included in the packaging of this file.
** Alternatively you may (at your option) use any later version
** of the GNU General Public License if such license has been
** publicly approved by Trolltech ASA (or its successors, if any)
** and the KDE Free TQt Foundation.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/.
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** This file may be used under the terms of the Q Public License as
** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
** included in the packaging of this file.  Licensees holding valid TQt
** Commercial licenses may use this file in accordance with the TQt
** Commercial License Agreement provided with the Software.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
** herein.
**
**********************************************************************/

#ifndef TQOBJECTDEFS_H
#define TQOBJECTDEFS_H

#include "tqtglobaldefines.h"

#ifndef TQT_H
#include "tqglobal.h"
#endif // TQT_H

#ifdef USE_QT4

#include <Qt/qobject.h>
#include <Qt/qmetaobject.h>
#undef TQT_H
#include "tqvariant.h"

#endif


#ifndef TQT_NO_TRANSLATION
# ifndef TQT_NO_TEXTCODEC
// full set of tr functions
#  define TQT_TR_FUNCTIONS \
    static TQString tr( const char *, const char * = 0 ); \
    static TQString trUtf8( const char *, const char * = 0 );
# else
// no TQTextCodec, no utf8
#  define TQT_TR_FUNCTIONS \
    static TQString tr( const char *, const char * = 0 );
# endif
#else
// inherit the ones from TQObject
# define TQT_TR_FUNCTIONS
#endif

#ifdef USE_QT4

#ifndef TQT_NO_PROPERTIES
# define TQT_PROP_FUNCTIONS \
    inline virtual bool qt_property( int id, int f, TQVariant* v) {		\
        /* f==0 is write and f==1 is read */					\
        QMetaProperty p = metaObject()->property(id);				\
        switch (f) {								\
            case 0:								\
                p.write(this, *v);						\
                break;								\
            case 1:								\
                *static_cast<QVariant*>(v) = p.read(this);			\
                break;								\
        }									\
        return true;	/* Always assume success */				\
    }										\
    //static bool qt_static_property( TQObject* , int, int, TQVariant* );
#else
# define TQT_PROP_FUNCTIONS
#endif

#else // USE_QT4

#ifndef TQT_NO_PROPERTIES
# define TQT_PROP_FUNCTIONS \
    virtual bool qt_property( int id, int f, TQVariant* v); \
    static bool qt_static_property( TQObject* , int, int, TQVariant* );
#else
# define TQT_PROP_FUNCTIONS
#endif

#endif // USE_QT4

// The following macros are our "extensions" to C++
// They are used, strictly speaking, only by the tqmoc.
struct TQUObject;

#ifdef TQT_TQMOC_CPP
#define Q_SLOTS			    Q_SLOTS
#define Q_SIGNALS		    Q_SIGNALS
#define TQ_CLASSINFO( name, value ) TQ_CLASSINFO( name, value )
#define TQ_PROPERTY( text )	    TQ_PROPERTY( text )
#define TQ_OVERRIDE( text )	    TQ_OVERRIDE( text )
#define TQ_ENUMS( x )		    TQ_ENUMS( x )
#define TQ_SETS( x )		    TQ_SETS( x )

#ifdef USE_QT4
//  /* tmake ignore TQ_OBJECT */
#define TQ_OBJECT //
//  /* tmake ignore TQ_OBJECT */
#define TQ_OBJECT_FAKE //
#else // USE_QT4
 /* tmake ignore TQ_OBJECT */
#define TQ_OBJECT		    TQ_OBJECT
 /* tmake ignore TQ_OBJECT */
#define TQ_OBJECT_FAKE		    TQ_OBJECT_FAKE
#endif // USE_QT4

#else
#define Q_SLOTS					// Q_SLOTS: in class
#define Q_SIGNALS protected			// Q_SIGNALS: in class
#ifndef TQT_NO_EMIT
#define emit					// emit signal
#endif
#define TQ_CLASSINFO( name, value )		// class info
#define TQ_PROPERTY( text )			// property
#define TQ_OVERRIDE( text )			// override property
#define TQ_ENUMS( x )
#define TQ_SETS( x )

#ifdef USE_QT4

# ifndef TQT_NO_TEXTCODEC
// full set of tr functions
#  define TQT_TR_FUNCTIONS_QT4 \
    inline static TQString tqtr( const char *ch1, const char *ch2 = 0 ) { return TQT_TQSTRING(tr(ch1, ch2)); } \
    inline static TQString tqtrUtf8( const char *ch1, const char *ch2 = 0 ) { return TQT_TQSTRING(tr(ch1, ch2)); }
# else
// no TQTextCodec, no utf8
#  define TQT_TR_FUNCTIONS_QT4 \
    inline static TQString tqtr( const char *ch1, const char *ch2 = 0 ) { return TQT_TQSTRING(tr(ch1, ch2)); }
# endif

#define TQ_OBJECT								\
public:										\
    inline static TQMetaObject* tqstaticMetaObject()				\
        { return tqstaticMetaObject_helper(&staticMetaObject); }		\
    inline virtual const char *className() const				\
        { return metaObject()->className(); }					\
    inline virtual void* tqqt_cast( const char* ctname )			\
        { if (inherits(ctname)) 						\
        return const_cast<TQT_BASE_OBJECT_NAME *>(reinterpret_cast<TQT_BASE_OBJECT_NAME *>(0)->staticMetaObject.cast(const_cast<QObject *>(static_cast<const QObject*>(TQT_TQOBJECT_CONST(this)))));	\
            return 0; }	/* [FIXME] VERIFY THIS!!! */				\
    inline void* qt_cast( const char* ctname )			\
        { if (inherits(ctname)) 						\
        return const_cast<TQT_BASE_OBJECT_NAME *>(reinterpret_cast<TQT_BASE_OBJECT_NAME *>(0)->staticMetaObject.cast(const_cast<QObject *>(static_cast<const QObject*>(TQT_TQOBJECT_CONST(this)))));	\
            return 0; }	/* [FIXME] VERIFY THIS!!! */				\
    inline virtual bool qt_invoke( int, TQUObject* ) 				\
        { printf("[WARNING] qt_invoke unimplemented\n\r"); return false; }	\
    inline virtual bool qt_emit( int, TQUObject* ) 				\
        { printf("[WARNING] qt_emit unimplemented\n\r"); return false; }	\
    TQT_PROP_FUNCTIONS								\
    TQT_TR_FUNCTIONS_QT4

#else // USE_QT4
/* tmake ignore TQ_OBJECT */
#define TQ_OBJECT							\
public:									\
    virtual TQMetaObject *tqmetaObject() const { 			\
         return staticMetaObject();					\
    }									\
    virtual const char *className() const;				\
    virtual void* tqqt_cast( const char* ); 				\
    virtual bool qt_invoke( int, TQUObject* ); 				\
    virtual bool qt_emit( int, TQUObject* ); 				\
    TQT_PROP_FUNCTIONS							\
    static TQMetaObject* staticMetaObject();				\
    TQObject* qObject() { return (TQObject*)this; } 			\
    TQT_TR_FUNCTIONS							\
private:								\
    static TQMetaObject *metaObj;

#endif // USE_QT4

/* tmake ignore TQ_OBJECT */
#define TQ_OBJECT_FAKE TQ_OBJECT

#endif

// macro for naming members
#ifdef TQT_METHOD
#undef TQT_METHOD
#endif
#ifdef TQT_SLOT
#undef TQT_SLOT
#endif
#ifdef TQT_SIGNAL
#undef TQT_SIGNAL
#endif

#if defined(_OLD_CPP_)
#define TQT_METHOD(a)	"0""a"
#define TQT_SLOT(a)		"1""a"
#define TQT_SIGNAL(a)	"2""a"
#else
#define TQT_METHOD(a)	"0"#a
#define TQT_SLOT(a)		"1"#a
#define TQT_SIGNAL(a)	"2"#a
#endif

#ifndef TQT_CLEAN_NAMESPACE
#define METHOD_CODE	0			// member type codes
#define SLOT_CODE	1
#define SIGNAL_CODE	2
#endif

#define TQMETHOD_CODE	0			// member type codes
#define TQSLOT_CODE	1
#define TQSIGNAL_CODE	2

class TQObject;
class TQMetaObject;
class TQSignal;
class TQConnection;
class TQEvent;
struct TQMetaData;
class TQConnectionList;
class TQConnectionListIt;
class TQSignalVec;
class TQObjectList;
class TQObjectListIt;
class TQMemberDict;

TQ_EXPORT void *qt_tqfind_obj_child( TQObject *, const char *, const char * );
#define TQ_CHILD(tqparent,type,name) \
	((type*)qt_tqfind_obj_child(tqparent,#type,name))

TQ_EXPORT void *qt_inheritedBy( TQMetaObject *super, const TQObject *cls );

// template <typename T>
// TQ_INLINE_TEMPLATES T tqqt_cast(const TQObject *object)
// { return (T)qt_inheritedBy( ((T)0)->staticMetaObject(), object ); }

// template <typename T>
// TQ_INLINE_TEMPLATES T tqqt_cast(const TQT_BASE_OBJECT_NAME *object)
// { return (T)qt_inheritedBy( ((T)0)->staticMetaObject(), TQT_TQOBJECT_CONST(object) ); }

template <typename T>
TQ_INLINE_TEMPLATES T tqqt_cast(const TQT_BASE_OBJECT_NAME *object)
//{ return (const T)qobject_cast<const T>(object); }
{
//     // this will cause a compilation error if T is not const
//     register T ptr = static_cast<T>(object);
//     Q_UNUSED(ptr);

#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK)
    reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<TQT_BASE_OBJECT_NAME *>(object)));
#endif
    return static_cast<T>(const_cast<TQT_BASE_OBJECT_NAME *>(reinterpret_cast<T>(0)->staticMetaObject.cast(const_cast<TQT_BASE_OBJECT_NAME *>(object))));
}
#endif // TQOBJECTDEFS_H