|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtDeclarative module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL-ONLY$ |
|
10 ** GNU Lesser General Public License Usage |
|
11 ** This file may be used under the terms of the GNU Lesser |
|
12 ** General Public License version 2.1 as published by the Free Software |
|
13 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
14 ** packaging of this file. Please review the following information to |
|
15 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
16 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
17 ** |
|
18 ** If you have questions regarding the use of this file, please contact |
|
19 ** Nokia at qt-info@nokia.com. |
|
20 ** $QT_END_LICENSE$ |
|
21 ** |
|
22 ****************************************************************************/ |
|
23 |
|
24 #ifndef QSCRIPTDECLARATIVECLASS_P_H |
|
25 #define QSCRIPTDECLARATIVECLASS_P_H |
|
26 |
|
27 // |
|
28 // W A R N I N G |
|
29 // ------------- |
|
30 // |
|
31 // This file is not part of the Qt API. It exists purely as an |
|
32 // implementation detail. This header file may change from version to |
|
33 // version without notice, or even be removed. |
|
34 // |
|
35 // We mean it. |
|
36 // |
|
37 |
|
38 #include <QtCore/qobjectdefs.h> |
|
39 #include <QtScript/qscriptvalue.h> |
|
40 #include <QtScript/qscriptclass.h> |
|
41 |
|
42 QT_BEGIN_NAMESPACE |
|
43 |
|
44 class QScriptDeclarativeClassPrivate; |
|
45 class PersistentIdentifierPrivate; |
|
46 class QScriptContext; |
|
47 class Q_SCRIPT_EXPORT QScriptDeclarativeClass |
|
48 { |
|
49 public: |
|
50 typedef void* Identifier; |
|
51 |
|
52 struct Object { virtual ~Object() {} }; |
|
53 |
|
54 static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *); |
|
55 static QScriptDeclarativeClass *scriptClass(const QScriptValue &); |
|
56 static Object *object(const QScriptValue &); |
|
57 |
|
58 static QScriptValue function(const QScriptValue &, const Identifier &); |
|
59 static QScriptValue property(const QScriptValue &, const Identifier &); |
|
60 |
|
61 static QScriptValue scopeChainValue(QScriptContext *, int index); |
|
62 static QScriptContext *pushCleanContext(QScriptEngine *); |
|
63 |
|
64 class Q_SCRIPT_EXPORT PersistentIdentifier |
|
65 { |
|
66 public: |
|
67 Identifier identifier; |
|
68 |
|
69 PersistentIdentifier(); |
|
70 ~PersistentIdentifier(); |
|
71 PersistentIdentifier(const PersistentIdentifier &other); |
|
72 PersistentIdentifier &operator=(const PersistentIdentifier &other); |
|
73 |
|
74 private: |
|
75 friend class QScriptDeclarativeClass; |
|
76 PersistentIdentifier(bool) : identifier(0), d(0) {} |
|
77 void *d; |
|
78 }; |
|
79 |
|
80 QScriptDeclarativeClass(QScriptEngine *engine); |
|
81 virtual ~QScriptDeclarativeClass(); |
|
82 |
|
83 QScriptEngine *engine() const; |
|
84 |
|
85 PersistentIdentifier createPersistentIdentifier(const QString &); |
|
86 PersistentIdentifier createPersistentIdentifier(const Identifier &); |
|
87 |
|
88 QString toString(const Identifier &); |
|
89 quint32 toArrayIndex(const Identifier &, bool *ok); |
|
90 |
|
91 virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, |
|
92 QScriptClass::QueryFlags flags); |
|
93 |
|
94 virtual QScriptValue property(Object *, const Identifier &); |
|
95 virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); |
|
96 virtual QScriptValue::PropertyFlags propertyFlags(Object *, const Identifier &); |
|
97 |
|
98 virtual QStringList propertyNames(Object *); |
|
99 |
|
100 virtual QObject *toQObject(Object *, bool *ok = 0); |
|
101 virtual QVariant toVariant(Object *, bool *ok = 0); |
|
102 |
|
103 QScriptContext *context() const; |
|
104 protected: |
|
105 friend class QScriptDeclarativeClassPrivate; |
|
106 QScopedPointer<QScriptDeclarativeClassPrivate> d_ptr; |
|
107 }; |
|
108 |
|
109 QT_END_NAMESPACE |
|
110 |
|
111 #endif |