From ce28ad22e2e8d7dadea55f89e9ef93f2528d1098 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 16 Jun 2009 12:26:39 +1000 Subject: Revert "Compilation fix on MSVC" This reverts commit 6d28410756ab29277807d2026b4cbd8e1c707714. --- src/declarative/qml/qmlprivate.h | 46 +++++++++++++++++++++++----- tests/auto/declarative/qmlparser/testtypes.h | 20 +++++++++--- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index 25e60e0..21a1164 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -123,13 +123,43 @@ namespace QmlPrivate } }; - template - struct has_qmlAttachedProperties + template + class has_attachedPropertiesMember + { + typedef int yes_type; + typedef char no_type; + template + struct Selector {}; + + template + static yes_type test(Selector*); + + template + static no_type test(...); + + public: + static bool const value = sizeof(test(0)) == sizeof(yes_type); + }; + + template + class has_attachedPropertiesMethod { - template struct type_check; - template static char check(type_check *); - template static int check(...); - static bool const value = sizeof(check(0)) == sizeof(char); + typedef int yes_type; + typedef char no_type; + + template + static yes_type check(ReturnType *(*)(QObject *)); + static no_type check(...); + + public: + static bool const value = sizeof(check(&T::qmlAttachedProperties)) == sizeof(yes_type); + }; + + template + class has_attachedPropertiesMethod + { + public: + static bool const value = false; }; template @@ -161,13 +191,13 @@ namespace QmlPrivate template inline QmlAttachedPropertiesFunc attachedPropertiesFunc() { - return AttachedPropertySelector::value >::func(); + return AttachedPropertySelector::value>::value>::func(); } template inline const QMetaObject *attachedPropertiesMetaObject() { - return AttachedPropertySelector::value >::metaObject(); + return AttachedPropertySelector::value>::value>::metaObject(); } struct MetaTypeIds { diff --git a/tests/auto/declarative/qmlparser/testtypes.h b/tests/auto/declarative/qmlparser/testtypes.h index e124631..ab67a4a 100644 --- a/tests/auto/declarative/qmlparser/testtypes.h +++ b/tests/auto/declarative/qmlparser/testtypes.h @@ -34,6 +34,20 @@ static QVariant myCustomVariantTypeConverter(const QString &data) return QVariant::fromValue(rv); } +class MyAttachedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue) +public: + MyAttachedObject(QObject *parent) : QObject(parent), m_value(0) {} + + int value() const { return m_value; } + void setValue(int v) { m_value = v; } + +private: + int m_value; +}; + class MyQmlObject : public QObject, public MyInterface, public QmlParserStatus { Q_OBJECT @@ -66,10 +80,8 @@ public: MyInterface *interface() const { return m_interface; } void setInterface(MyInterface *iface) { m_interface = iface; } - static MyQmlObject *qmlAttachedProperties(QObject *other) { - MyQmlObject *rv = new MyQmlObject; - rv->setParent(other); - return rv; + static MyAttachedObject *qmlAttachedProperties(QObject *other) { + return new MyAttachedObject(other); } Q_CLASSINFO("DefaultMethod", "basicSlot()"); -- cgit v0.12