Fix crash caused by dereferencing collected v8 data
[profile/ivi/qtdeclarative.git] / tests / auto / qml / qqmlecmascript / testtypes.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #ifndef TESTTYPES_H
42 #define TESTTYPES_H
43
44 #include <QtCore/qobject.h>
45 #include <QtQml/qqml.h>
46 #include <QtQml/qqmlexpression.h>
47 #include <QtCore/qpoint.h>
48 #include <QtCore/qsize.h>
49 #include <QtQml/qqmllist.h>
50 #include <QtCore/qrect.h>
51 #include <QtGui/qmatrix.h>
52 #include <QtGui/qcolor.h>
53 #include <QtGui/qvector3d.h>
54 #include <QtGui/QPixmap>
55 #include <QtCore/qdatetime.h>
56 #include <QtQml/qjsvalue.h>
57 #include <QtQml/qqmlscriptstring.h>
58 #include <QtQml/qqmlcomponent.h>
59
60 #include <private/qqmlengine_p.h>
61 #include <private/qv8engine_p.h>
62
63 class MyQmlAttachedObject : public QObject
64 {
65     Q_OBJECT
66     Q_PROPERTY(int value READ value CONSTANT)
67     Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed)
68 public:
69     MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
70
71     int value() const { return 19; }
72     int value2() const { return m_value2; }
73     void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); }
74
75     void emitMySignal() { emit mySignal(); }
76
77 signals:
78     void value2Changed();
79     void mySignal();
80
81 private:
82     int m_value2;
83 };
84
85 class MyQmlObject : public QObject
86 {
87     Q_OBJECT
88     Q_ENUMS(MyEnum)
89     Q_ENUMS(MyEnum2)
90     Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
91     Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
92     Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
93     Q_PROPERTY(int value READ value WRITE setValue)
94     Q_PROPERTY(int console READ console CONSTANT)
95     Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
96     Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlChanged)
97     Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
98     Q_PROPERTY(QQmlListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
99     Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
100     Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
101     Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false)
102     Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intChanged)
103
104 public:
105     MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0) {}
106
107     enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
108     enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
109
110     bool trueProperty() const { return true; }
111     bool falseProperty() const { return false; }
112
113     QString stringProperty() const { return m_string; }
114     void setStringProperty(const QString &s)
115     {
116         if (s == m_string)
117             return;
118         m_string = s;
119         emit stringChanged();
120     }
121
122     QUrl urlProperty() const { return m_url; }
123     void setUrlProperty(const QUrl &url)
124     {
125         if (url == m_url)
126             return;
127         m_url = url;
128         emit urlChanged();
129     }
130
131     QObject *objectProperty() const { return m_object; }
132     void setObjectProperty(QObject *obj) { 
133         if (obj == m_object)
134             return;
135         m_object = obj;
136         emit objectChanged();
137     }
138
139     QQmlListProperty<QObject> objectListProperty() { return QQmlListProperty<QObject>(this, m_objectQList); }
140
141     bool methodCalled() const { return m_methodCalled; }
142     bool methodIntCalled() const { return m_methodIntCalled; }
143
144     QString string() const { return m_string; }
145
146     static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
147         return new MyQmlAttachedObject(o);
148     }
149
150     int deleteOnSet() const { return 1; }
151     void setDeleteOnSet(int v) { if(v) delete this; }
152
153     int value() const { return m_value; }
154     void setValue(int v) { m_value = v; }
155
156     int resettableProperty() const { return m_resetProperty; }
157     void setResettableProperty(int v) { m_resetProperty = v; }
158     void resetProperty() { m_resetProperty = 13; }
159
160     QRegExp regExp() { return m_regExp; }
161     void setRegExp(const QRegExp &regExp) { m_regExp = regExp; }
162
163     int console() const { return 11; }
164
165     int nonscriptable() const { return 0; }
166     void setNonscriptable(int) {}
167
168     MyQmlObject *myinvokableObject;
169     Q_INVOKABLE MyQmlObject *returnme() { return this; }
170
171     struct MyType {
172         int value;
173     };
174     QVariant variant() const { return m_variant; }
175     QJSValue qjsvalue() const { return m_qjsvalue; }
176
177     int intProperty() const { return m_intProperty; }
178     void setIntProperty(int i) { m_intProperty = i; emit intChanged(); }
179     
180 signals:
181     void basicSignal();
182     void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
183     void unnamedArgumentSignal(int a, qreal, QString c);
184     void stringChanged();
185     void urlChanged();
186     void objectChanged();
187     void anotherBasicSignal();
188     void thirdBasicSignal();
189     void signalWithUnknownType(const MyQmlObject::MyType &arg);
190     void signalWithVariant(const QVariant &arg);
191     void signalWithQJSValue(const QJSValue &arg);
192     void signalWithGlobalName(int parseInt);
193     void intChanged();
194
195 public slots:
196     void deleteMe() { delete this; }
197     void methodNoArgs() { m_methodCalled = true; }
198     void method(int a) { if(a == 163) m_methodIntCalled = true; }
199     void setString(const QString &s) { m_string = s; }
200     void myinvokable(MyQmlObject *o) { myinvokableObject = o; }
201     void variantMethod(const QVariant &v) { m_variant = v; }
202     void qjsvalueMethod(const QJSValue &v) { m_qjsvalue = v; }
203     void v8function(QQmlV8Function*);
204
205 private:
206     friend class tst_qqmlecmascript;
207     bool m_methodCalled;
208     bool m_methodIntCalled;
209
210     QObject *m_object;
211     QString m_string;
212     QUrl m_url;
213     QList<QObject *> m_objectQList;
214     int m_value;
215     int m_resetProperty;
216     QRegExp m_regExp;
217     QVariant m_variant;
218     QJSValue m_qjsvalue;
219     int m_intProperty;
220 };
221
222 QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
223
224 class MyQmlContainer : public QObject
225 {
226     Q_OBJECT
227     Q_PROPERTY(QQmlListProperty<MyQmlObject> children READ children CONSTANT)
228 public:
229     MyQmlContainer() {}
230
231     QQmlListProperty<MyQmlObject> children() { return QQmlListProperty<MyQmlObject>(this, m_children); }
232
233 private:
234     QList<MyQmlObject*> m_children;
235 };
236
237
238 class MyExpression : public QQmlExpression
239 {
240     Q_OBJECT
241 public:
242     MyExpression(QQmlContext *ctxt, const QString &expr)
243         : QQmlExpression(ctxt, 0, expr), changed(false)
244     {
245         QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged()));
246         setNotifyOnValueChanged(true);
247     }
248
249     bool changed;
250
251 public slots:
252     void expressionValueChanged() {
253         changed = true;
254     }
255 };
256
257
258 class MyDefaultObject1 : public QObject
259 {
260     Q_OBJECT
261     Q_PROPERTY(int horseLegs READ horseLegs CONSTANT)
262     Q_PROPERTY(int antLegs READ antLegs CONSTANT)
263     Q_PROPERTY(int emuLegs READ emuLegs CONSTANT)
264 public:
265     int horseLegs() const { return 4; }
266     int antLegs() const { return 6; }
267     int emuLegs() const { return 2; }
268 };
269
270 class MyDefaultObject3 : public QObject
271 {
272     Q_OBJECT
273     Q_PROPERTY(int antLegs READ antLegs CONSTANT)
274     Q_PROPERTY(int humanLegs READ humanLegs CONSTANT)
275 public:
276     int antLegs() const { return 7; } // Mutant
277     int humanLegs() const { return 2; }
278     int millipedeLegs() const { return 1000; }
279 };
280
281 class MyDeferredObject : public QObject
282 {
283     Q_OBJECT
284     Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
285     Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
286     Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2)
287     Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2")
288
289 public:
290     MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {}
291
292     int value() const { return m_value; }
293     void setValue(int v) { m_value = v; emit valueChanged(); }
294
295     QObject *objectProperty() const { return m_object; }
296     void setObjectProperty(QObject *obj) { m_object = obj; }
297
298     QObject *objectProperty2() const { return m_object2; }
299     void setObjectProperty2(QObject *obj) { m_object2 = obj; }
300
301 signals:
302     void valueChanged();
303
304 private:
305     int m_value;
306     QObject *m_object;
307     QObject *m_object2;
308 };
309
310 class MyBaseExtendedObject : public QObject
311 {
312 Q_OBJECT
313 Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty)
314 public:
315     MyBaseExtendedObject() : m_value(0) {}
316
317     int baseProperty() const { return m_value; }
318     void setBaseProperty(int v) { m_value = v; }
319
320 private:
321     int m_value;
322 };
323
324 class MyExtendedObject : public MyBaseExtendedObject
325 {
326 Q_OBJECT
327 Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty)
328 public:
329     MyExtendedObject() : m_value(0) {}
330
331     int coreProperty() const { return m_value; }
332     void setCoreProperty(int v) { m_value = v; }
333
334 private:
335     int m_value;
336 };
337
338 class MyTypeObject : public QObject
339 {
340     Q_OBJECT
341     Q_ENUMS(MyEnum)
342     Q_FLAGS(MyFlags)
343
344     Q_PROPERTY(QString id READ id WRITE setId)
345     Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
346     Q_PROPERTY(QQmlComponent *componentProperty READ componentProperty WRITE setComponentProperty)
347     Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
348     Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
349     Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
350     Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
351     Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
352     Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
353     Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
354     Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
355     Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
356     Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
357     Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
358     Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
359     Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
360     Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
361     Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
362     Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
363     Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
364     Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
365     Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
366     Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
367     Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
368     Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
369     Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
370
371     Q_PROPERTY(QQmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
372
373 public:
374     MyTypeObject()
375         : objectPropertyValue(0), componentPropertyValue(0) {}
376
377     QString idValue;
378     QString id() const {
379         return idValue;
380     }
381     void setId(const QString &v) {
382         idValue = v;
383     }
384
385     QObject *objectPropertyValue;
386     QObject *objectProperty() const {
387         return objectPropertyValue;
388     }
389     void setObjectProperty(QObject *v) {
390         objectPropertyValue = v;
391     }
392
393     QQmlComponent *componentPropertyValue;
394     QQmlComponent *componentProperty() const {
395         return componentPropertyValue;
396     }
397     void setComponentProperty(QQmlComponent *v) {
398         componentPropertyValue = v;
399     }
400
401     enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
402     Q_DECLARE_FLAGS(MyFlags, MyFlag)
403     MyFlags flagPropertyValue;
404     MyFlags flagProperty() const {
405         return flagPropertyValue;
406     }
407     void setFlagProperty(MyFlags v) {
408         flagPropertyValue = v;
409     }
410
411     enum MyEnum { EnumVal1, EnumVal2 };
412     MyEnum enumPropertyValue;
413     MyEnum enumProperty() const {
414         return enumPropertyValue;
415     }
416     void setEnumProperty(MyEnum v) {
417         enumPropertyValue = v;
418     }
419
420     QString stringPropertyValue;
421     QString stringProperty() const {
422        return stringPropertyValue;
423     }
424     void setStringProperty(const QString &v) {
425         stringPropertyValue = v;
426     }
427
428     uint uintPropertyValue;
429     uint uintProperty() const {
430        return uintPropertyValue;
431     }
432     void setUintProperty(const uint &v) {
433         uintPropertyValue = v;
434     }
435
436     int intPropertyValue;
437     int intProperty() const {
438        return intPropertyValue;
439     }
440     void setIntProperty(const int &v) {
441         intPropertyValue = v;
442     }
443
444     qreal realPropertyValue;
445     qreal realProperty() const {
446        return realPropertyValue;
447     }
448     void setRealProperty(const qreal &v) {
449         realPropertyValue = v;
450     }
451
452     double doublePropertyValue;
453     double doubleProperty() const {
454        return doublePropertyValue;
455     }
456     void setDoubleProperty(const double &v) {
457         doublePropertyValue = v;
458     }
459
460     float floatPropertyValue;
461     float floatProperty() const {
462        return floatPropertyValue;
463     }
464     void setFloatProperty(const float &v) {
465         floatPropertyValue = v;
466     }
467
468     QColor colorPropertyValue;
469     QColor colorProperty() const {
470        return colorPropertyValue;
471     }
472     void setColorProperty(const QColor &v) {
473         colorPropertyValue = v;
474     }
475
476     QDate datePropertyValue;
477     QDate dateProperty() const {
478        return datePropertyValue;
479     }
480     void setDateProperty(const QDate &v) {
481         datePropertyValue = v;
482     }
483
484     QTime timePropertyValue;
485     QTime timeProperty() const {
486        return timePropertyValue;
487     }
488     void setTimeProperty(const QTime &v) {
489         timePropertyValue = v;
490     }
491
492     QDateTime dateTimePropertyValue;
493     QDateTime dateTimeProperty() const {
494        return dateTimePropertyValue;
495     }
496     void setDateTimeProperty(const QDateTime &v) {
497         dateTimePropertyValue = v;
498     }
499
500     QPoint pointPropertyValue;
501     QPoint pointProperty() const {
502        return pointPropertyValue;
503     }
504     void setPointProperty(const QPoint &v) {
505         pointPropertyValue = v;
506     }
507
508     QPointF pointFPropertyValue;
509     QPointF pointFProperty() const {
510        return pointFPropertyValue;
511     }
512     void setPointFProperty(const QPointF &v) {
513         pointFPropertyValue = v;
514     }
515
516     QSize sizePropertyValue;
517     QSize sizeProperty() const {
518        return sizePropertyValue;
519     }
520     void setSizeProperty(const QSize &v) {
521         sizePropertyValue = v;
522     }
523
524     QSizeF sizeFPropertyValue;
525     QSizeF sizeFProperty() const {
526        return sizeFPropertyValue;
527     }
528     void setSizeFProperty(const QSizeF &v) {
529         sizeFPropertyValue = v;
530     }
531
532     QRect rectPropertyValue;
533     QRect rectProperty() const {
534        return rectPropertyValue;
535     }
536     void setRectProperty(const QRect &v) {
537         rectPropertyValue = v;
538         emit rectPropertyChanged();
539     }
540
541     QRect rectPropertyValue2;
542     QRect rectProperty2() const {
543        return rectPropertyValue2;
544     }
545     void setRectProperty2(const QRect &v) {
546         rectPropertyValue2 = v;
547     }
548
549     QRectF rectFPropertyValue;
550     QRectF rectFProperty() const {
551        return rectFPropertyValue;
552     }
553     void setRectFProperty(const QRectF &v) {
554         rectFPropertyValue = v;
555     }
556
557     bool boolPropertyValue;
558     bool boolProperty() const {
559        return boolPropertyValue;
560     }
561     void setBoolProperty(const bool &v) {
562         boolPropertyValue = v;
563     }
564
565     QVariant variantPropertyValue;
566     QVariant variantProperty() const {
567        return variantPropertyValue;
568     }
569     void setVariantProperty(const QVariant &v) {
570         variantPropertyValue = v;
571     }
572
573     QVector3D vectorPropertyValue;
574     QVector3D vectorProperty() const {
575         return vectorPropertyValue;
576     }
577     void setVectorProperty(const QVector3D &v) {
578         vectorPropertyValue = v;
579     }
580
581     QUrl urlPropertyValue;
582     QUrl urlProperty() const {
583         return urlPropertyValue;
584     }
585     void setUrlProperty(const QUrl &v) {
586         urlPropertyValue = v;
587     }
588
589     QQmlScriptString scriptPropertyValue;
590     QQmlScriptString scriptProperty() const {
591         return scriptPropertyValue;
592     }
593     void setScriptProperty(const QQmlScriptString &v) {
594         scriptPropertyValue = v;
595     }
596
597     void doAction() { emit action(); }
598 signals:
599     void action();
600     void rectPropertyChanged();
601 };
602 Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
603
604 class MyDerivedObject : public MyTypeObject
605 {
606     Q_OBJECT
607 public:
608     Q_INVOKABLE bool intProperty() const {
609         return true;
610     }
611 };
612
613 Q_DECLARE_METATYPE(QJSValue);
614 class MyInvokableBaseObject : public QObject
615 {
616     Q_OBJECT
617 public:
618     inline ~MyInvokableBaseObject() = 0;
619
620     Q_INVOKABLE inline void method_inherited(int a);
621     Q_INVOKABLE inline void method_overload();
622 };
623
624 class MyInvokableObject : public MyInvokableBaseObject
625 {
626     Q_OBJECT
627     Q_ENUMS(TestEnum)
628 public:
629     enum TestEnum { EnumValue1, EnumValue2 };
630     MyInvokableObject() { reset(); }
631
632     int invoked() const { return m_invoked; }
633     bool error() const { return m_invokedError; }
634     const QVariantList &actuals() const { return m_actuals; }
635     void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); }
636
637     Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); }
638     Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); }
639
640     Q_INVOKABLE void method_NoArgs() { invoke(0); }
641     Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; }
642     Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.75; }
643     Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); }
644     Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; }
645     Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; }
646     Q_INVOKABLE QJSValue method_NoArgs_QScriptValue() { invoke(6); return QJSValue("Hello world"); }
647     Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); }
648
649     Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; }
650     Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; }
651     Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; }
652     Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; }
653     Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; }
654     Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
655     Q_INVOKABLE void method_QScriptValue(QJSValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
656     Q_INVOKABLE void method_intQScriptValue(int a, QJSValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
657     
658     Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
659     Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
660     Q_INVOKABLE void method_overload(QString a) { invoke(18); m_actuals << a; }
661
662     Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(19); m_actuals << (int)e; }
663
664     Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; }
665
666     Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; }
667
668 private:
669     friend class MyInvokableBaseObject;
670     void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
671     int m_invoked;
672     bool m_invokedError;
673     QVariantList m_actuals;
674 };
675
676 MyInvokableBaseObject::~MyInvokableBaseObject() {}
677
678 void MyInvokableBaseObject::method_inherited(int a)
679 {
680     static_cast<MyInvokableObject *>(this)->invoke(-3);
681     static_cast<MyInvokableObject *>(this)->m_actuals << a;
682 }
683
684 // This is a hidden overload of the MyInvokableObject::method_overload() method
685 void MyInvokableBaseObject::method_overload()
686 {
687     static_cast<MyInvokableObject *>(this)->invoke(-2);
688 }
689
690 class NumberAssignment : public QObject
691 {
692     Q_OBJECT
693 public:
694     Q_PROPERTY(qreal test1 READ test1 WRITE setTest1)
695     qreal _test1;
696     qreal test1() const { return _test1; }
697     void setTest1(qreal v) { _test1 = v; }
698
699     Q_PROPERTY(qreal test2 READ test2 WRITE setTest2)
700     qreal _test2;
701     qreal test2() const { return _test2; }
702     void setTest2(qreal v) { _test2 = v; }
703
704     Q_PROPERTY(qreal test3 READ test3 WRITE setTest3)
705     qreal _test3;
706     qreal test3() const { return _test3; }
707     void setTest3(qreal v) { _test3 = v; }
708
709     Q_PROPERTY(qreal test4 READ test4 WRITE setTest4)
710     qreal _test4;
711     qreal test4() const { return _test4; }
712     void setTest4(qreal v) { _test4 = v; }
713
714     Q_PROPERTY(int test5 READ test5 WRITE setTest5)
715     int _test5;
716     int test5() const { return _test5; }
717     void setTest5(int v) { _test5 = v; }
718
719     Q_PROPERTY(int test6 READ test6 WRITE setTest6)
720     int _test6;
721     int test6() const { return _test6; }
722     void setTest6(int v) { _test6 = v; }
723
724     Q_PROPERTY(int test7 READ test7 WRITE setTest7)
725     int _test7;
726     int test7() const { return _test7; }
727     void setTest7(int v) { _test7 = v; }
728
729     Q_PROPERTY(int test8 READ test8 WRITE setTest8)
730     int _test8;
731     int test8() const { return _test8; }
732     void setTest8(int v) { _test8 = v; }
733
734     Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9)
735     unsigned int _test9;
736     unsigned int test9() const { return _test9; }
737     void setTest9(unsigned int v) { _test9 = v; }
738
739     Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10)
740     unsigned int _test10;
741     unsigned int test10() const { return _test10; }
742     void setTest10(unsigned int v) { _test10 = v; }
743
744     Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11)
745     unsigned int _test11;
746     unsigned int test11() const { return _test11; }
747     void setTest11(unsigned int v) { _test11 = v; }
748
749     Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12)
750     unsigned int _test12;
751     unsigned int test12() const { return _test12; }
752     void setTest12(unsigned int v) { _test12 = v; }
753 };
754
755 class DefaultPropertyExtendedObject : public QObject
756 {
757     Q_OBJECT
758     Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty)
759     Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty)
760 public:
761     DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {}
762
763     QObject *firstProperty() const { return m_firstProperty; }
764     QObject *secondProperty() const { return m_secondProperty; }
765     void setFirstProperty(QObject *property) { m_firstProperty = property; }
766     void setSecondProperty(QObject *property) { m_secondProperty = property; }
767 private:
768     QObject* m_firstProperty;
769     QObject* m_secondProperty;
770 };
771
772 class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject
773 {
774     Q_OBJECT
775     Q_CLASSINFO("DefaultProperty", "secondProperty")
776 public:
777     OverrideDefaultPropertyObject() {}
778 };
779
780 class MyRevisionedBaseClassRegistered : public QObject
781 {
782 Q_OBJECT
783     Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
784     Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
785
786 public:
787     MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
788
789     qreal propA() const { return m_pa; }
790     void setPropA(qreal p) {
791         if (p != m_pa) {
792             m_pa = p;
793             emit propAChanged();
794         }
795     }
796     qreal propB() const { return m_pb; }
797     void setPropB(qreal p) {
798         if (p != m_pb) {
799             m_pb = p;
800             emit propBChanged();
801         }
802     }
803
804     Q_INVOKABLE void methodA() { }
805     Q_INVOKABLE Q_REVISION(1) void methodB() { }
806
807 signals:
808     void propAChanged();
809     void propBChanged();
810
811     void signalA();
812     Q_REVISION(1) void signalB();
813
814 protected:
815     qreal m_pa;
816     qreal m_pb;
817 };
818
819 class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
820 {
821 Q_OBJECT
822     Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
823     Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
824
825 public:
826     MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
827
828     qreal propC() const { return m_pc; }
829     void setPropC(qreal p) {
830         if (p != m_pc) {
831             m_pc = p;
832             emit propCChanged();
833         }
834     }
835     qreal propD() const { return m_pd; }
836     void setPropD(qreal p) {
837         if (p != m_pd) {
838             m_pd = p;
839             emit propDChanged();
840         }
841     }
842
843     Q_INVOKABLE void methodC() { }
844     Q_INVOKABLE Q_REVISION(1) void methodD() { }
845
846 signals:
847     void propCChanged();
848     void propDChanged();
849
850     void signalC();
851     Q_REVISION(1) void signalD();
852
853 protected:
854     qreal m_pc;
855     qreal m_pd;
856 };
857
858 class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
859 {
860     Q_OBJECT
861     Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
862     Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
863
864 public:
865     MyRevisionedClass() {}
866
867     qreal prop1() const { return m_p1; }
868     void setProp1(qreal p) {
869         if (p != m_p1) {
870             m_p1 = p;
871             emit prop1Changed();
872         }
873     }
874     qreal prop2() const { return m_p2; }
875     void setProp2(qreal p) {
876         if (p != m_p2) {
877             m_p2 = p;
878             emit prop2Changed();
879         }
880     }
881
882     Q_INVOKABLE void method1() { }
883     Q_INVOKABLE Q_REVISION(1) void method2() { }
884
885 signals:
886     void prop1Changed();
887     void prop2Changed();
888
889     void signal1();
890     Q_REVISION(1) void signal2();
891
892 protected:
893     qreal m_p1;
894     qreal m_p2;
895 };
896
897 class MyRevisionedSubclass : public MyRevisionedClass
898 {
899     Q_OBJECT
900     Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
901     Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
902
903 public:
904     MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
905
906     qreal prop3() const { return m_p3; }
907     void setProp3(qreal p) {
908         if (p != m_p3) {
909             m_p3 = p;
910             emit prop3Changed();
911         }
912     }
913     qreal prop4() const { return m_p4; }
914     void setProp4(qreal p) {
915         if (p != m_p4) {
916             m_p4 = p;
917             emit prop4Changed();
918         }
919     }
920
921     Q_INVOKABLE void method3() { }
922     Q_INVOKABLE Q_REVISION(1) void method4() { }
923
924 signals:
925     void prop3Changed();
926     void prop4Changed();
927
928     void signal3();
929     Q_REVISION(1) void signal4();
930
931 protected:
932     qreal m_p3;
933     qreal m_p4;
934 };
935
936 QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
937 QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
938 QML_DECLARE_TYPE(MyRevisionedClass)
939 QML_DECLARE_TYPE(MyRevisionedSubclass)
940 Q_DECLARE_METATYPE(MyQmlObject::MyType)
941
942
943 class ScarceResourceObject : public QObject
944 {
945     Q_OBJECT
946     Q_PROPERTY(QPixmap scarceResource READ scarceResource WRITE setScarceResource NOTIFY scarceResourceChanged)
947 public:
948     ScarceResourceObject(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); }
949     ~ScarceResourceObject() {}
950
951     QPixmap scarceResource() const { return m_value; }
952     void setScarceResource(QPixmap v) { m_value = v; emit scarceResourceChanged(); }
953
954     bool scarceResourceIsDetached() const { return m_value.isDetached(); }
955
956     // this particular one returns a new one each time
957     // this means that every Scarce Resource Copy will
958     // consume resources (so that we can track disposal
959     // of v8 handles with circular references).
960     Q_INVOKABLE QPixmap newScarceResource() const
961     {
962         QPixmap retn(800, 600);
963         retn.fill(QColor(100, 110, 120, 45));
964         return retn;
965     }
966
967 signals:
968     void scarceResourceChanged();
969
970 private:
971     QPixmap m_value;
972 };
973 QML_DECLARE_TYPE(ScarceResourceObject)
974
975 class testQObjectApi : public QObject
976 {
977     Q_OBJECT
978     Q_ENUMS(MyEnum)
979     Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged)
980     Q_PROPERTY (int qobjectTestWritableProperty READ qobjectTestWritableProperty WRITE setQObjectTestWritableProperty NOTIFY qobjectTestWritablePropertyChanged)
981     Q_PROPERTY (int qobjectTestWritableFinalProperty READ qobjectTestWritableFinalProperty WRITE setQObjectTestWritableFinalProperty NOTIFY qobjectTestWritableFinalPropertyChanged FINAL)
982
983 public:
984     testQObjectApi(QObject* parent = 0)
985         : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_testWritableFinalProperty(0), m_methodCallCount(0), m_trackedObject(0)
986     {
987     }
988
989     ~testQObjectApi() {}
990
991     enum MyEnum { EnumValue1 = 25, EnumValue2 = 42 };
992     Q_INVOKABLE int qobjectEnumTestMethod(MyEnum val) { return (static_cast<int>(val) + 5); }
993     Q_INVOKABLE int qobjectTestMethod(int increment = 1) { m_methodCallCount += increment; return m_methodCallCount; }
994
995     Q_INVOKABLE void trackObject(QObject *obj) { m_trackedObject = obj; }
996     Q_INVOKABLE QObject *trackedObject() const { return m_trackedObject; }
997     Q_INVOKABLE void setTrackedObjectProperty(const QString &propName) const { m_trackedObject->setProperty(qPrintable(propName), QVariant(5)); }
998     Q_INVOKABLE QVariant trackedObjectProperty(const QString &propName) const { return m_trackedObject->property(qPrintable(propName)); }
999
1000     int qobjectTestProperty() const { return m_testProperty; }
1001     void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); }
1002
1003     int qobjectTestWritableProperty() const { return m_testWritableProperty; }
1004     void setQObjectTestWritableProperty(int tp) { m_testWritableProperty = tp; emit qobjectTestWritablePropertyChanged(tp); }
1005
1006     int qobjectTestWritableFinalProperty() const { return m_testWritableFinalProperty; }
1007     void setQObjectTestWritableFinalProperty(int tp) { m_testWritableFinalProperty = tp; emit qobjectTestWritableFinalPropertyChanged(); }
1008
1009 signals:
1010     void qobjectTestPropertyChanged(int testProperty);
1011     void qobjectTestWritablePropertyChanged(int testWritableProperty);
1012     void qobjectTestWritableFinalPropertyChanged();
1013
1014 private:
1015     int m_testProperty;
1016     int m_testWritableProperty;
1017     int m_testWritableFinalProperty;
1018     int m_methodCallCount;
1019     QObject *m_trackedObject;
1020 };
1021
1022 class CircularReferenceObject : public QObject,
1023                                 public QV8GCCallback::Node
1024 {
1025     Q_OBJECT
1026
1027 public:
1028     CircularReferenceObject(QObject *parent = 0)
1029         : QObject(parent), QV8GCCallback::Node(callback), m_referenced(0), m_dtorCount(0)
1030     {
1031         QV8GCCallback::addGcCallbackNode(this);
1032     }
1033
1034     ~CircularReferenceObject()
1035     {
1036         if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
1037     }
1038
1039     Q_INVOKABLE void setDtorCount(int *dtorCount)
1040     {
1041         m_dtorCount = dtorCount;
1042     }
1043
1044     Q_INVOKABLE CircularReferenceObject *generate(QObject *parent = 0)
1045     {
1046         CircularReferenceObject *retn = new CircularReferenceObject(parent);
1047         retn->m_dtorCount = m_dtorCount;
1048         retn->m_engine = m_engine;
1049         return retn;
1050     }
1051
1052     Q_INVOKABLE void addReference(QObject *other)
1053     {
1054         m_referenced = other;
1055     }
1056
1057     static void callback(QV8GCCallback::Node *n)
1058     {
1059         CircularReferenceObject *cro = static_cast<CircularReferenceObject*>(n);
1060         if (cro->m_referenced) {
1061             cro->m_engine->addRelationshipForGC(cro, cro->m_referenced);
1062         }
1063     }
1064
1065     void setEngine(QQmlEngine* declarativeEngine)
1066     {
1067         m_engine = QQmlEnginePrivate::get(declarativeEngine)->v8engine();
1068     }
1069
1070 private:
1071     QObject *m_referenced;
1072     int *m_dtorCount;
1073     QV8Engine* m_engine;
1074 };
1075 Q_DECLARE_METATYPE(CircularReferenceObject*)
1076
1077 class CircularReferenceHandle : public QObject,
1078                                 public QV8GCCallback::Node
1079 {
1080     Q_OBJECT
1081
1082 public:
1083     CircularReferenceHandle(QObject *parent = 0)
1084         : QObject(parent), QV8GCCallback::Node(gccallback), m_dtorCount(0), m_engine(0)
1085     {
1086         QV8GCCallback::addGcCallbackNode(this);
1087     }
1088
1089     ~CircularReferenceHandle()
1090     {
1091         if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
1092     }
1093
1094     Q_INVOKABLE void setDtorCount(int *dtorCount)
1095     {
1096         m_dtorCount = dtorCount;
1097     }
1098
1099     Q_INVOKABLE CircularReferenceHandle *generate(QObject *parent = 0)
1100     {
1101         CircularReferenceHandle *retn = new CircularReferenceHandle(parent);
1102         retn->m_dtorCount = m_dtorCount;
1103         retn->m_engine = m_engine;
1104         return retn;
1105     }
1106
1107     Q_INVOKABLE void addReference(v8::Persistent<v8::Value> handle)
1108     {
1109         m_referenced = qPersistentNew(handle);
1110         m_referenced.MakeWeak(static_cast<void*>(this), wrcallback);
1111     }
1112
1113     static void wrcallback(v8::Persistent<v8::Value> handle, void *params)
1114     {
1115         CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(params);
1116         qPersistentDispose(handle);
1117         crh->m_referenced.Clear();
1118     }
1119
1120     static void gccallback(QV8GCCallback::Node *n)
1121     {
1122         CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(n);
1123         crh->m_engine->addRelationshipForGC(crh, crh->m_referenced);
1124     }
1125
1126     void setEngine(QQmlEngine* declarativeEngine)
1127     {
1128         m_engine = QQmlEnginePrivate::get(declarativeEngine)->v8engine();
1129     }
1130
1131 private:
1132     v8::Persistent<v8::Value> m_referenced;
1133     int *m_dtorCount;
1134     QV8Engine* m_engine;
1135 };
1136 Q_DECLARE_METATYPE(CircularReferenceHandle*)
1137
1138 class MyDynamicCreationDestructionObject : public QObject
1139 {
1140     Q_OBJECT
1141     Q_PROPERTY (int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged)
1142
1143 public:
1144     MyDynamicCreationDestructionObject(QObject *parent = 0) : QObject(parent), m_intProperty(0), m_dtorCount(0)
1145     {
1146     }
1147
1148     ~MyDynamicCreationDestructionObject()
1149     {
1150         if (m_dtorCount) {
1151             (*m_dtorCount)++;
1152         }
1153     }
1154
1155     int intProperty() const { return m_intProperty; }
1156     void setIntProperty(int val) { m_intProperty = val; emit intPropertyChanged(); }
1157
1158     Q_INVOKABLE MyDynamicCreationDestructionObject *createNew()
1159     {
1160         // no parent == ownership transfers to JS; same dtor counter.
1161         MyDynamicCreationDestructionObject *retn = new MyDynamicCreationDestructionObject;
1162         retn->setDtorCount(m_dtorCount);
1163         return retn;
1164     }
1165
1166     void setDtorCount(int *dtorCount)
1167     {
1168         m_dtorCount = dtorCount;
1169     }
1170
1171 signals:
1172     void intPropertyChanged();
1173
1174 private:
1175     int m_intProperty;
1176     int *m_dtorCount;
1177 };
1178
1179 class WriteCounter : public QObject
1180 {
1181     Q_OBJECT
1182     Q_PROPERTY(int value READ value WRITE setValue);
1183 public:
1184     WriteCounter() : m_value(0), m_count(0) {}
1185
1186     int value() const { return m_value; }
1187     void setValue(int v) { m_value = v; ++m_count; }
1188
1189     int count() const { return m_count; }
1190
1191 private:
1192     int m_value;
1193     int m_count;
1194 };
1195
1196 class MySequenceConversionObject : public QObject
1197 {
1198     Q_OBJECT
1199
1200     Q_PROPERTY (QList<int> intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged)
1201     Q_PROPERTY (QList<int> intListProperty2 READ intListProperty2 WRITE setIntListProperty2 NOTIFY intListProperty2Changed)
1202     Q_PROPERTY (QList<qreal> qrealListProperty READ qrealListProperty WRITE setQrealListProperty NOTIFY qrealListPropertyChanged)
1203     Q_PROPERTY (QList<bool> boolListProperty READ boolListProperty WRITE setBoolListProperty NOTIFY boolListPropertyChanged)
1204     Q_PROPERTY (QList<QString> stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged)
1205     Q_PROPERTY (QList<QUrl> urlListProperty READ urlListProperty WRITE setUrlListProperty NOTIFY urlListPropertyChanged)
1206     Q_PROPERTY (QStringList qstringListProperty READ qstringListProperty WRITE setQStringListProperty NOTIFY qstringListPropertyChanged)
1207
1208     Q_PROPERTY (QList<QPoint> pointListProperty READ pointListProperty WRITE setPointListProperty NOTIFY pointListPropertyChanged)
1209     Q_PROPERTY (QList<QVariant> variantListProperty READ variantListProperty WRITE setVariantListProperty NOTIFY variantListPropertyChanged)
1210
1211     Q_PROPERTY (qint32 maxIndex READ maxIndex CONSTANT)
1212     Q_PROPERTY (quint32 tooBigIndex READ tooBigIndex CONSTANT)
1213     Q_PROPERTY (qint32 negativeIndex READ negativeIndex CONSTANT)
1214
1215 public:
1216     MySequenceConversionObject()
1217     {
1218         m_intList << 1 << 2 << 3 << 4;
1219         m_intList2 << 1 << 2 << 3 << 4;
1220         m_qrealList << 1.1 << 2.2 << 3.3 << 4.4;
1221         m_boolList << true << false << true << false;
1222         m_stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
1223         m_urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
1224         m_qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
1225
1226         m_pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6);
1227         m_variantList << QVariant(QLatin1String("one")) << QVariant(true) << QVariant(3);
1228     }
1229
1230     ~MySequenceConversionObject() {}
1231
1232     qint32 maxIndex() const
1233     {
1234         return INT_MAX;
1235     }
1236     quint32 tooBigIndex() const
1237     {
1238         quint32 retn = 7;
1239         retn += INT_MAX;
1240         return retn;
1241     }
1242     qint32 negativeIndex() const
1243     {
1244         return -5;
1245     }
1246
1247     QList<int> intListProperty() const { return m_intList; }
1248     void setIntListProperty(const QList<int> &list) { m_intList = list; emit intListPropertyChanged(); }
1249     QList<int> intListProperty2() const { return m_intList2; }
1250     void setIntListProperty2(const QList<int> &list) { m_intList2 = list; emit intListProperty2Changed(); }
1251     QList<qreal> qrealListProperty() const { return m_qrealList; }
1252     void setQrealListProperty(const QList<qreal> &list) { m_qrealList = list; emit qrealListPropertyChanged(); }
1253     QList<bool> boolListProperty() const { return m_boolList; }
1254     void setBoolListProperty(const QList<bool> &list) { m_boolList = list; emit boolListPropertyChanged(); }
1255     QList<QString> stringListProperty() const { return m_stringList; }
1256     void setStringListProperty(const QList<QString> &list) { m_stringList = list; emit stringListPropertyChanged(); }
1257     QList<QUrl> urlListProperty() const { return m_urlList; }
1258     void setUrlListProperty(const QList<QUrl> &list) { m_urlList = list; emit urlListPropertyChanged(); }
1259     QStringList qstringListProperty() const { return m_qstringList; }
1260     void setQStringListProperty(const QStringList &list) { m_qstringList = list; emit qstringListPropertyChanged(); }
1261     QList<QPoint> pointListProperty() const { return m_pointList; }
1262     void setPointListProperty(const QList<QPoint> &list) { m_pointList = list; emit pointListPropertyChanged(); }
1263     QList<QVariant> variantListProperty() const { return m_variantList; }
1264     void setVariantListProperty(const QList<QVariant> &list) { m_variantList = list; emit variantListPropertyChanged(); }
1265
1266     // now for "copy resource" sequences:
1267     Q_INVOKABLE QList<int> generateIntSequence() const { QList<int> retn; retn << 1 << 2 << 3; return retn; }
1268     Q_INVOKABLE QList<qreal> generateQrealSequence() const { QList<qreal> retn; retn << 1.1 << 2.2 << 3.3; return retn; }
1269     Q_INVOKABLE QList<bool> generateBoolSequence() const { QList<bool> retn; retn << true << false << true; return retn; }
1270     Q_INVOKABLE QList<QString> generateStringSequence() const { QList<QString> retn; retn << "one" << "two" << "three"; return retn; }
1271     Q_INVOKABLE QList<QUrl> generateUrlSequence() const { QList<QUrl> retn; retn << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); return retn; }
1272     Q_INVOKABLE QStringList generateQStringSequence() const { QStringList retn; retn << "one" << "two" << "three"; return retn; }
1273
1274     // "reference resource" underlying qobject deletion test:
1275     Q_INVOKABLE MySequenceConversionObject *generateTestObject() const { return new MySequenceConversionObject; }
1276     Q_INVOKABLE void deleteTestObject(QObject *object) const { delete object; }
1277
1278 signals:
1279     void intListPropertyChanged();
1280     void intListProperty2Changed();
1281     void qrealListPropertyChanged();
1282     void boolListPropertyChanged();
1283     void stringListPropertyChanged();
1284     void urlListPropertyChanged();
1285     void qstringListPropertyChanged();
1286     void pointListPropertyChanged();
1287     void variantListPropertyChanged();
1288
1289 private:
1290     QList<int> m_intList;
1291     QList<int> m_intList2;
1292     QList<qreal> m_qrealList;
1293     QList<bool> m_boolList;
1294     QList<QString> m_stringList;
1295     QList<QUrl> m_urlList;
1296     QStringList m_qstringList;
1297
1298     QList<QPoint> m_pointList; // not a supported sequence type
1299     QList<QVariant> m_variantList; // not a supported sequence type, but QVariantList support is hardcoded.
1300 };
1301
1302 class MyDeleteObject : public QObject
1303 {
1304     Q_OBJECT
1305     Q_PROPERTY(QObject *nestedObject READ nestedObject NOTIFY nestedObjectChanged);
1306     Q_PROPERTY(int deleteNestedObject READ deleteNestedObject NOTIFY deleteNestedObjectChanged);
1307
1308 public:
1309     MyDeleteObject() : m_nestedObject(new MyQmlObject) {}
1310
1311     QObject *nestedObject() const { return m_nestedObject; }
1312     int deleteNestedObject() { delete m_nestedObject; m_nestedObject = 0; return 1; }
1313
1314 signals:
1315     void nestedObjectChanged();
1316     void deleteNestedObjectChanged();
1317
1318 private:
1319     MyQmlObject *m_nestedObject;
1320 };
1321
1322 void registerTypes();
1323
1324 #endif // TESTTYPES_H
1325