diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2011-03-29 09:01:48 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-03-31 14:32:45 (GMT) |
commit | a1a141e4af6226dca9ae67c51dd5e14cb3393772 (patch) | |
tree | 6b4ba52827c25f6bd06ea5b2b7b067968c634cc9 | |
parent | bc3491c1b85ca36486c9472ecf7ba82f46699e8a (diff) | |
download | Qt-a1a141e4af6226dca9ae67c51dd5e14cb3393772.zip Qt-a1a141e4af6226dca9ae67c51dd5e14cb3393772.tar.gz Qt-a1a141e4af6226dca9ae67c51dd5e14cb3393772.tar.bz2 |
moc: be able to compile if there are private classes
Reviewed-by: brad
Reviewed-by: thiago
-rw-r--r-- | src/corelib/global/qglobal.h | 9 | ||||
-rw-r--r-- | src/corelib/kernel/qobjectdefs.h | 12 | ||||
-rw-r--r-- | src/tools/moc/generator.cpp | 8 | ||||
-rw-r--r-- | tests/auto/moc/tst_moc.cpp | 22 |
4 files changed, 41 insertions, 10 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 8dd8850..cf63943 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -759,6 +759,7 @@ namespace QT_NAMESPACE {} # endif # if __HP_aCC-0 >= 062000 # define Q_DECL_EXPORT __attribute__((visibility("default"))) +# define Q_DECL_HIDDEN __attribute__((visibility("hidden"))) # define Q_DECL_IMPORT Q_DECL_EXPORT # endif # else @@ -773,11 +774,11 @@ namespace QT_NAMESPACE {} #elif defined(__WINSCW__) && !defined(Q_CC_NOKIAX86) # define Q_CC_NOKIAX86 - #else # error "Qt has not been tested with this compiler - talk to qt-bugs@trolltech.com" #endif + #ifdef Q_CC_INTEL # if __INTEL_COMPILER < 1200 # define Q_NO_TEMPLATE_FRIENDS @@ -1238,6 +1239,7 @@ class QDataStream; #if defined(Q_OS_LINUX) && defined(Q_CC_RVCT) # define Q_DECL_EXPORT __attribute__((visibility("default"))) # define Q_DECL_IMPORT __attribute__((visibility("default"))) +# define Q_DECL_HIDDEN __attribute__((visibility("hidden"))) #endif #ifndef Q_DECL_EXPORT @@ -1245,6 +1247,7 @@ class QDataStream; # define Q_DECL_EXPORT __declspec(dllexport) # elif defined(QT_VISIBILITY_AVAILABLE) # define Q_DECL_EXPORT __attribute__((visibility("default"))) +# define Q_DECL_HIDDEN __attribute__((visibility("hidden"))) # endif # ifndef Q_DECL_EXPORT # define Q_DECL_EXPORT @@ -1257,6 +1260,10 @@ class QDataStream; # define Q_DECL_IMPORT # endif #endif +#ifndef Q_DECL_HIDDEN +# define Q_DECL_HIDDEN +#endif + /* Create Qt DLL if QT_DLL is defined (Windows and Symbian only) diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 6bf40f7..4384837 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -163,8 +163,10 @@ public: \ virtual void *qt_metacast(const char *); \ QT_TR_FUNCTIONS \ virtual int qt_metacall(QMetaObject::Call, int, void **); \ - static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ -private: +private: \ + Q_DECL_HIDDEN static const QMetaObjectExtraData staticMetaObjectExtraData; \ + Q_DECL_HIDDEN static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); + /* tmake ignore Q_OBJECT */ #define Q_OBJECT_FAKE Q_OBJECT /* tmake ignore Q_GADGET */ @@ -480,8 +482,10 @@ struct QMetaObjectExtraData #else const QMetaObject **objects; #endif - void (*static_metacall)(QObject *, QMetaObject::Call, int, void **); //from revision 6 - //int (*static_metacall)(QMetaObject::Call, int, void **); //used from revison 2 until revison 5 + + typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **); //from revision 6 + //typedef int (*StaticMetaCall)(QMetaObject::Call, int, void **); //used from revison 2 until revison 5 + StaticMetacallFunction static_metacall; }; inline const char *QMetaObject::className() const diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index ac769d7..67aba8f 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -330,15 +330,15 @@ void Generator::generateCode() bool hasExtraData = (cdef->hasQObject && !isQt) || !extraList.isEmpty(); if (hasExtraData) { - fprintf(out, "static const QMetaObjectExtraData qt_meta_extradata2_%s = {\n ", - qualifiedClassNameIdentifier.constData()); + fprintf(out, "const QMetaObjectExtraData %s::staticMetaObjectExtraData = {\n ", + cdef->qualified.constData()); if (extraList.isEmpty()) fprintf(out, "0, "); else fprintf(out, "qt_meta_extradata_%s, ", qualifiedClassNameIdentifier.constData()); if (cdef->hasQObject && !isQt) - fprintf(out, " %s::qt_static_metacall", cdef->qualified.constData()); + fprintf(out, " qt_static_metacall"); else fprintf(out, " 0"); fprintf(out, " \n};\n\n"); @@ -363,7 +363,7 @@ void Generator::generateCode() if (!hasExtraData) fprintf(out, "0 }\n"); else - fprintf(out, "&qt_meta_extradata2_%s }\n", qualifiedClassNameIdentifier.constData()); + fprintf(out, "&staticMetaObjectExtraData }\n"); fprintf(out, "};\n"); if(isQt) diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index 203f0ae..7a8f958 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -497,7 +497,7 @@ private slots: void revisions(); void warnings_data(); void warnings(); - + void privateClass(); signals: void sigWithUnsignedArg(unsigned foo); @@ -517,6 +517,7 @@ private: private: QString qtIncludePath; + class PrivateClass; }; void tst_Moc::initTestCase() @@ -1648,6 +1649,25 @@ void tst_Moc::warnings() } +class tst_Moc::PrivateClass : public QObject { + Q_PROPERTY(int someProperty READ someSlot WRITE someSlot2) +Q_OBJECT +Q_SIGNALS: + void someSignal(); +public Q_SLOTS: + int someSlot() { return 1; } + void someSlot2(int) {} +public: + Q_INVOKABLE PrivateClass() {} +}; + +void tst_Moc::privateClass() +{ + QVERIFY(PrivateClass::staticMetaObject.indexOfConstructor("PrivateClass()") == 0); + QVERIFY(PrivateClass::staticMetaObject.indexOfSignal("someSignal()") > 0); +} + + QTEST_APPLESS_MAIN(tst_Moc) #include "tst_moc.moc" |