LCOV - code coverage report
Current view: top level - usr/include/x86_64-linux-gnu/qt5/QtCore - qobjectdefs.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 11 100.0 %
Date: 2016-09-12 13:07:23 Functions: 6 6 100.0 %

          Line data    Source code
       1             : /****************************************************************************
       2             : **
       3             : ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
       4             : ** Contact: http://www.qt-project.org/legal
       5             : **
       6             : ** This file is part of the QtCore module of the Qt Toolkit.
       7             : **
       8             : ** $QT_BEGIN_LICENSE:LGPL$
       9             : ** Commercial License Usage
      10             : ** Licensees holding valid commercial Qt licenses may use this file in
      11             : ** accordance with the commercial license agreement provided with the
      12             : ** Software or, alternatively, in accordance with the terms contained in
      13             : ** a written agreement between you and Digia.  For licensing terms and
      14             : ** conditions see http://qt.digia.com/licensing.  For further information
      15             : ** use the contact form at http://qt.digia.com/contact-us.
      16             : **
      17             : ** GNU Lesser General Public License Usage
      18             : ** Alternatively, this file may be used under the terms of the GNU Lesser
      19             : ** General Public License version 2.1 as published by the Free Software
      20             : ** Foundation and appearing in the file LICENSE.LGPL included in the
      21             : ** packaging of this file.  Please review the following information to
      22             : ** ensure the GNU Lesser General Public License version 2.1 requirements
      23             : ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
      24             : **
      25             : ** In addition, as a special exception, Digia gives you certain additional
      26             : ** rights.  These rights are described in the Digia Qt LGPL Exception
      27             : ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
      28             : **
      29             : ** GNU General Public License Usage
      30             : ** Alternatively, this file may be used under the terms of the GNU
      31             : ** General Public License version 3.0 as published by the Free Software
      32             : ** Foundation and appearing in the file LICENSE.GPL included in the
      33             : ** packaging of this file.  Please review the following information to
      34             : ** ensure the GNU General Public License version 3.0 requirements will be
      35             : ** met: http://www.gnu.org/copyleft/gpl.html.
      36             : **
      37             : **
      38             : ** $QT_END_LICENSE$
      39             : **
      40             : ****************************************************************************/
      41             : 
      42             : #ifndef QOBJECTDEFS_H
      43             : #define QOBJECTDEFS_H
      44             : 
      45             : #if defined(__OBJC__) && !defined(__cplusplus)
      46             : #  warning "File built in Objective-C mode (.m), but using Qt requires Objective-C++ (.mm)"
      47             : #endif
      48             : 
      49             : #include <QtCore/qnamespace.h>
      50             : 
      51             : #include <QtCore/qobjectdefs_impl.h>
      52             : 
      53             : QT_BEGIN_NAMESPACE
      54             : 
      55             : 
      56             : class QByteArray;
      57             : struct QArrayData;
      58             : typedef QArrayData QByteArrayData;
      59             : 
      60             : class QString;
      61             : 
      62             : #ifndef Q_MOC_OUTPUT_REVISION
      63             : #define Q_MOC_OUTPUT_REVISION 67
      64             : #endif
      65             : 
      66             : // The following macros are our "extensions" to C++
      67             : // They are used, strictly speaking, only by the moc.
      68             : 
      69             : #ifndef Q_MOC_RUN
      70             : #ifndef QT_NO_META_MACROS
      71             : # if defined(QT_NO_KEYWORDS)
      72             : #  define QT_NO_EMIT
      73             : # else
      74             : #   ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS
      75             : #     define slots
      76             : #     define signals public
      77             : #   endif
      78             : # endif
      79             : # define Q_SLOTS
      80             : # define Q_SIGNALS public
      81             : # define Q_PRIVATE_SLOT(d, signature)
      82             : # define Q_EMIT
      83             : #ifndef QT_NO_EMIT
      84             : # define emit
      85             : #endif
      86             : #define Q_CLASSINFO(name, value)
      87             : #define Q_PLUGIN_METADATA(x)
      88             : #define Q_INTERFACES(x)
      89             : #define Q_PROPERTY(text)
      90             : #define Q_PRIVATE_PROPERTY(d, text)
      91             : #define Q_REVISION(v)
      92             : #define Q_OVERRIDE(text)
      93             : #define Q_ENUMS(x)
      94             : #define Q_FLAGS(x)
      95             : #define Q_SCRIPTABLE
      96             : #define Q_INVOKABLE
      97             : #define Q_SIGNAL
      98             : #define Q_SLOT
      99             : #endif // QT_NO_META_MACROS
     100             : 
     101             : #ifndef QT_NO_TRANSLATION
     102             : // full set of tr functions
     103             : #  define QT_TR_FUNCTIONS \
     104             :     static inline QString tr(const char *s, const char *c = 0, int n = -1) \
     105             :         { return staticMetaObject.tr(s, c, n); } \
     106             :     QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) \
     107             :         { return staticMetaObject.tr(s, c, n); }
     108             : #else
     109             : // inherit the ones from QObject
     110             : # define QT_TR_FUNCTIONS
     111             : #endif
     112             : 
     113             : #if defined(QT_NO_QOBJECT_CHECK)
     114             : /* qmake ignore Q_OBJECT */
     115             : #define Q_OBJECT_CHECK
     116             : #else
     117             : 
     118             : /* This is a compile time check that ensures that any class cast with qobject_cast
     119             :    actually contains a Q_OBJECT macro. Note: qobject_cast will fail if a QObject
     120             :    subclass doesn't contain Q_OBJECT.
     121             : 
     122             :    In qt_check_for_QOBJECT_macro, we call a dummy templated function with two
     123             :    parameters, the first being "this" and the other the target of the qobject
     124             :    cast. If the types are not identical, we know that a Q_OBJECT macro is missing.
     125             : 
     126             :    If you get a compiler error here, make sure that the class you are casting
     127             :    to contains a Q_OBJECT macro.
     128             : */
     129             : 
     130             : /* qmake ignore Q_OBJECT */
     131             : #define Q_OBJECT_CHECK \
     132             :     template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const \
     133             :     { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }
     134             : 
     135             : template <typename T>
     136             : inline int qYouForgotTheQ_OBJECT_Macro(T, T) { return 0; }
     137             : 
     138             : template <typename T1, typename T2>
     139             : inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {}
     140             : #endif // QT_NO_QOBJECT_CHECK
     141             : 
     142             : #if defined(Q_CC_INTEL)
     143             : // Cannot redefine the visibility of a method in an exported class
     144             : # define Q_DECL_HIDDEN_STATIC_METACALL
     145             : #else
     146             : # define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN
     147             : #endif
     148             : 
     149             : /* qmake ignore Q_OBJECT */
     150             : #define Q_OBJECT \
     151             : public: \
     152             :     Q_OBJECT_CHECK \
     153             :     static const QMetaObject staticMetaObject; \
     154             :     virtual const QMetaObject *metaObject() const; \
     155             :     virtual void *qt_metacast(const char *); \
     156             :     QT_TR_FUNCTIONS \
     157             :     virtual int qt_metacall(QMetaObject::Call, int, void **); \
     158             : private: \
     159             :     Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
     160             :     struct QPrivateSignal {};
     161             : 
     162             : /* qmake ignore Q_OBJECT */
     163             : #define Q_OBJECT_FAKE Q_OBJECT
     164             : 
     165             : #ifndef QT_NO_META_MACROS
     166             : /* qmake ignore Q_GADGET */
     167             : #define Q_GADGET \
     168             : public: \
     169             :     static const QMetaObject staticMetaObject; \
     170             : private:
     171             : #endif // QT_NO_META_MACROS
     172             : 
     173             : #else // Q_MOC_RUN
     174             : #define slots slots
     175             : #define signals signals
     176             : #define Q_SLOTS Q_SLOTS
     177             : #define Q_SIGNALS Q_SIGNALS
     178             : #define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value)
     179             : #define Q_INTERFACES(x) Q_INTERFACES(x)
     180             : #define Q_PROPERTY(text) Q_PROPERTY(text)
     181             : #define Q_PRIVATE_PROPERTY(d, text) Q_PRIVATE_PROPERTY(d, text)
     182             : #define Q_REVISION(v) Q_REVISION(v)
     183             : #define Q_OVERRIDE(text) Q_OVERRIDE(text)
     184             : #define Q_ENUMS(x) Q_ENUMS(x)
     185             : #define Q_FLAGS(x) Q_FLAGS(x)
     186             :  /* qmake ignore Q_OBJECT */
     187             : #define Q_OBJECT Q_OBJECT
     188             :  /* qmake ignore Q_OBJECT */
     189             : #define Q_OBJECT_FAKE Q_OBJECT_FAKE
     190             :  /* qmake ignore Q_GADGET */
     191             : #define Q_GADGET Q_GADGET
     192             : #define Q_SCRIPTABLE Q_SCRIPTABLE
     193             : #define Q_INVOKABLE Q_INVOKABLE
     194             : #define Q_SIGNAL Q_SIGNAL
     195             : #define Q_SLOT Q_SLOT
     196             : #endif //Q_MOC_RUN
     197             : 
     198             : #ifndef QT_NO_META_MACROS
     199             : // macro for onaming members
     200             : #ifdef METHOD
     201             : #undef METHOD
     202             : #endif
     203             : #ifdef SLOT
     204             : #undef SLOT
     205             : #endif
     206             : #ifdef SIGNAL
     207             : #undef SIGNAL
     208             : #endif
     209             : #endif // QT_NO_META_MACROS
     210             : 
     211             : Q_CORE_EXPORT const char *qFlagLocation(const char *method);
     212             : 
     213             : #ifndef QT_NO_META_MACROS
     214             : #ifndef QT_NO_DEBUG
     215             : # define QLOCATION "\0" __FILE__ ":" QT_STRINGIFY(__LINE__)
     216             : # ifndef QT_NO_KEYWORDS
     217             : #  define METHOD(a)   qFlagLocation("0"#a QLOCATION)
     218             : # endif
     219             : # define SLOT(a)     qFlagLocation("1"#a QLOCATION)
     220             : # define SIGNAL(a)   qFlagLocation("2"#a QLOCATION)
     221             : #else
     222             : # ifndef QT_NO_KEYWORDS
     223             : #  define METHOD(a)   "0"#a
     224             : # endif
     225             : # define SLOT(a)     "1"#a
     226             : # define SIGNAL(a)   "2"#a
     227             : #endif
     228             : 
     229             : #define QMETHOD_CODE  0                        // member type codes
     230             : #define QSLOT_CODE    1
     231             : #define QSIGNAL_CODE  2
     232             : #endif // QT_NO_META_MACROS
     233             : 
     234             : #define Q_ARG(type, data) QArgument<type >(#type, data)
     235             : #define Q_RETURN_ARG(type, data) QReturnArgument<type >(#type, data)
     236             : 
     237             : class QObject;
     238             : class QMetaMethod;
     239             : class QMetaEnum;
     240             : class QMetaProperty;
     241             : class QMetaClassInfo;
     242             : 
     243             : 
     244             : class Q_CORE_EXPORT QGenericArgument
     245             : {
     246             : public:
     247         242 :     inline QGenericArgument(const char *aName = 0, const void *aData = 0)
     248         242 :         : _data(aData), _name(aName) {}
     249             :     inline void *data() const { return const_cast<void *>(_data); }
     250             :     inline const char *name() const { return _name; }
     251             : 
     252             : private:
     253             :     const void *_data;
     254             :     const char *_name;
     255             : };
     256             : 
     257             : class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument
     258             : {
     259             : public:
     260          22 :     inline QGenericReturnArgument(const char *aName = 0, void *aData = 0)
     261          22 :         : QGenericArgument(aName, aData)
     262          22 :         {}
     263             : };
     264             : 
     265             : template <class T>
     266             : class QArgument: public QGenericArgument
     267             : {
     268             : public:
     269          66 :     inline QArgument(const char *aName, const T &aData)
     270          66 :         : QGenericArgument(aName, static_cast<const void *>(&aData))
     271          66 :         {}
     272             : };
     273             : template <class T>
     274             : class QArgument<T &>: public QGenericArgument
     275             : {
     276             : public:
     277             :     inline QArgument(const char *aName, T &aData)
     278             :         : QGenericArgument(aName, static_cast<const void *>(&aData))
     279             :         {}
     280             : };
     281             : 
     282             : 
     283             : template <typename T>
     284             : class QReturnArgument: public QGenericReturnArgument
     285             : {
     286             : public:
     287             :     inline QReturnArgument(const char *aName, T &aData)
     288             :         : QGenericReturnArgument(aName, static_cast<void *>(&aData))
     289             :         {}
     290             : };
     291             : 
     292             : struct Q_CORE_EXPORT QMetaObject
     293             : {
     294             :     class Connection;
     295             :     const char *className() const;
     296             :     const QMetaObject *superClass() const;
     297             : 
     298             :     QObject *cast(QObject *obj) const;
     299             :     const QObject *cast(const QObject *obj) const;
     300             : 
     301             : #ifndef QT_NO_TRANSLATION
     302             :     QString tr(const char *s, const char *c, int n = -1) const;
     303             : #endif // QT_NO_TRANSLATION
     304             : 
     305             :     int methodOffset() const;
     306             :     int enumeratorOffset() const;
     307             :     int propertyOffset() const;
     308             :     int classInfoOffset() const;
     309             : 
     310             :     int constructorCount() const;
     311             :     int methodCount() const;
     312             :     int enumeratorCount() const;
     313             :     int propertyCount() const;
     314             :     int classInfoCount() const;
     315             : 
     316             :     int indexOfConstructor(const char *constructor) const;
     317             :     int indexOfMethod(const char *method) const;
     318             :     int indexOfSignal(const char *signal) const;
     319             :     int indexOfSlot(const char *slot) const;
     320             :     int indexOfEnumerator(const char *name) const;
     321             :     int indexOfProperty(const char *name) const;
     322             :     int indexOfClassInfo(const char *name) const;
     323             : 
     324             :     QMetaMethod constructor(int index) const;
     325             :     QMetaMethod method(int index) const;
     326             :     QMetaEnum enumerator(int index) const;
     327             :     QMetaProperty property(int index) const;
     328             :     QMetaClassInfo classInfo(int index) const;
     329             :     QMetaProperty userProperty() const;
     330             : 
     331             :     static bool checkConnectArgs(const char *signal, const char *method);
     332             :     static bool checkConnectArgs(const QMetaMethod &signal,
     333             :                                  const QMetaMethod &method);
     334             :     static QByteArray normalizedSignature(const char *method);
     335             :     static QByteArray normalizedType(const char *type);
     336             : 
     337             :     // internal index-based connect
     338             :     static Connection connect(const QObject *sender, int signal_index,
     339             :                         const QObject *receiver, int method_index,
     340             :                         int type = 0, int *types = 0);
     341             :     // internal index-based disconnect
     342             :     static bool disconnect(const QObject *sender, int signal_index,
     343             :                            const QObject *receiver, int method_index);
     344             :     static bool disconnectOne(const QObject *sender, int signal_index,
     345             :                               const QObject *receiver, int method_index);
     346             :     // internal slot-name based connect
     347             :     static void connectSlotsByName(QObject *o);
     348             : 
     349             :     // internal index-based signal activation
     350             :     static void activate(QObject *sender, int signal_index, void **argv);
     351             :     static void activate(QObject *sender, const QMetaObject *, int local_signal_index, void **argv);
     352             :     static void activate(QObject *sender, int signal_offset, int local_signal_index, void **argv);
     353             : 
     354             :     static bool invokeMethod(QObject *obj, const char *member,
     355             :                              Qt::ConnectionType,
     356             :                              QGenericReturnArgument ret,
     357             :                              QGenericArgument val0 = QGenericArgument(0),
     358             :                              QGenericArgument val1 = QGenericArgument(),
     359             :                              QGenericArgument val2 = QGenericArgument(),
     360             :                              QGenericArgument val3 = QGenericArgument(),
     361             :                              QGenericArgument val4 = QGenericArgument(),
     362             :                              QGenericArgument val5 = QGenericArgument(),
     363             :                              QGenericArgument val6 = QGenericArgument(),
     364             :                              QGenericArgument val7 = QGenericArgument(),
     365             :                              QGenericArgument val8 = QGenericArgument(),
     366             :                              QGenericArgument val9 = QGenericArgument());
     367             : 
     368             :     static inline bool invokeMethod(QObject *obj, const char *member,
     369             :                              QGenericReturnArgument ret,
     370             :                              QGenericArgument val0 = QGenericArgument(0),
     371             :                              QGenericArgument val1 = QGenericArgument(),
     372             :                              QGenericArgument val2 = QGenericArgument(),
     373             :                              QGenericArgument val3 = QGenericArgument(),
     374             :                              QGenericArgument val4 = QGenericArgument(),
     375             :                              QGenericArgument val5 = QGenericArgument(),
     376             :                              QGenericArgument val6 = QGenericArgument(),
     377             :                              QGenericArgument val7 = QGenericArgument(),
     378             :                              QGenericArgument val8 = QGenericArgument(),
     379             :                              QGenericArgument val9 = QGenericArgument())
     380             :     {
     381             :         return invokeMethod(obj, member, Qt::AutoConnection, ret, val0, val1, val2, val3,
     382             :                 val4, val5, val6, val7, val8, val9);
     383             :     }
     384             : 
     385          22 :     static inline bool invokeMethod(QObject *obj, const char *member,
     386             :                              Qt::ConnectionType type,
     387             :                              QGenericArgument val0 = QGenericArgument(0),
     388             :                              QGenericArgument val1 = QGenericArgument(),
     389             :                              QGenericArgument val2 = QGenericArgument(),
     390             :                              QGenericArgument val3 = QGenericArgument(),
     391             :                              QGenericArgument val4 = QGenericArgument(),
     392             :                              QGenericArgument val5 = QGenericArgument(),
     393             :                              QGenericArgument val6 = QGenericArgument(),
     394             :                              QGenericArgument val7 = QGenericArgument(),
     395             :                              QGenericArgument val8 = QGenericArgument(),
     396             :                              QGenericArgument val9 = QGenericArgument())
     397             :     {
     398             :         return invokeMethod(obj, member, type, QGenericReturnArgument(), val0, val1, val2,
     399          22 :                                  val3, val4, val5, val6, val7, val8, val9);
     400             :     }
     401             : 
     402             :     static inline bool invokeMethod(QObject *obj, const char *member,
     403             :                              QGenericArgument val0 = QGenericArgument(0),
     404             :                              QGenericArgument val1 = QGenericArgument(),
     405             :                              QGenericArgument val2 = QGenericArgument(),
     406             :                              QGenericArgument val3 = QGenericArgument(),
     407             :                              QGenericArgument val4 = QGenericArgument(),
     408             :                              QGenericArgument val5 = QGenericArgument(),
     409             :                              QGenericArgument val6 = QGenericArgument(),
     410             :                              QGenericArgument val7 = QGenericArgument(),
     411             :                              QGenericArgument val8 = QGenericArgument(),
     412             :                              QGenericArgument val9 = QGenericArgument())
     413             :     {
     414             :         return invokeMethod(obj, member, Qt::AutoConnection, QGenericReturnArgument(), val0,
     415             :                 val1, val2, val3, val4, val5, val6, val7, val8, val9);
     416             :     }
     417             : 
     418             :     QObject *newInstance(QGenericArgument val0 = QGenericArgument(0),
     419             :                          QGenericArgument val1 = QGenericArgument(),
     420             :                          QGenericArgument val2 = QGenericArgument(),
     421             :                          QGenericArgument val3 = QGenericArgument(),
     422             :                          QGenericArgument val4 = QGenericArgument(),
     423             :                          QGenericArgument val5 = QGenericArgument(),
     424             :                          QGenericArgument val6 = QGenericArgument(),
     425             :                          QGenericArgument val7 = QGenericArgument(),
     426             :                          QGenericArgument val8 = QGenericArgument(),
     427             :                          QGenericArgument val9 = QGenericArgument()) const;
     428             : 
     429             :     enum Call {
     430             :         InvokeMetaMethod,
     431             :         ReadProperty,
     432             :         WriteProperty,
     433             :         ResetProperty,
     434             :         QueryPropertyDesignable,
     435             :         QueryPropertyScriptable,
     436             :         QueryPropertyStored,
     437             :         QueryPropertyEditable,
     438             :         QueryPropertyUser,
     439             :         CreateInstance,
     440             :         IndexOfMethod,
     441             :         RegisterPropertyMetaType,
     442             :         RegisterMethodArgumentMetaType
     443             :     };
     444             : 
     445             :     int static_metacall(Call, int, void **) const;
     446             :     static int metacall(QObject *, Call, int, void **);
     447             : 
     448             :     struct { // private data
     449             :         const QMetaObject *superdata;
     450             :         const QByteArrayData *stringdata;
     451             :         const uint *data;
     452             :         typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **);
     453             :         StaticMetacallFunction static_metacall;
     454             :         const QMetaObject * const *relatedMetaObjects;
     455             :         void *extradata; //reserved for future use
     456             :     } d;
     457             : };
     458             : 
     459             : class Q_CORE_EXPORT QMetaObject::Connection {
     460             :     void *d_ptr; //QObjectPrivate::Connection*
     461             :     explicit Connection(void *data) : d_ptr(data) {  }
     462             :     friend class QObject;
     463             :     friend class QObjectPrivate;
     464             :     friend struct QMetaObject;
     465             : public:
     466             :     ~Connection();
     467             :     Connection();
     468             :     Connection(const Connection &other);
     469             :     Connection &operator=(const Connection &other);
     470             : #ifdef Q_QDOC
     471             :     operator bool() const;
     472             : #else
     473             :     typedef void *Connection::*RestrictedBool;
     474           5 :     operator RestrictedBool() const { return d_ptr ? &Connection::d_ptr : 0; }
     475             : #endif
     476             : 
     477             : #ifdef Q_COMPILER_RVALUE_REFS
     478             :     inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = 0; }
     479             :     inline Connection &operator=(Connection &&other)
     480             :     { qSwap(d_ptr, other.d_ptr); return *this; }
     481             : #endif
     482             : };
     483             : 
     484             : inline const QMetaObject *QMetaObject::superClass() const
     485             : { return d.superdata; }
     486             : 
     487             : namespace QtPrivate {
     488             :     /* Trait that tells is a the Object has a Q_OBJECT macro */
     489             :     template <typename Object> struct HasQ_OBJECT_Macro {
     490             :         template <typename T>
     491             :         static char test(int (T::*)(QMetaObject::Call, int, void **));
     492             :         static int test(int (Object::*)(QMetaObject::Call, int, void **));
     493             :         enum { Value =  sizeof(test(&Object::qt_metacall)) == sizeof(int) };
     494             :     };
     495             : }
     496             : 
     497             : QT_END_NAMESPACE
     498             : 
     499             : #endif // QOBJECTDEFS_H

Generated by: LCOV version 1.11