1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef QSCRIPTDECLARATIVECLASS_P_H
43 #define QSCRIPTDECLARATIVECLASS_P_H
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
56 #include <QtCore/qobjectdefs.h>
57 #include <QtScript/qscriptvalue.h>
58 #include <QtScript/qscriptclass.h>
62 class QScriptDeclarativeClassPrivate
;
63 class PersistentIdentifierPrivate
;
65 class Q_SCRIPT_EXPORT QScriptDeclarativeClass
68 typedef void* Identifier
;
70 struct Object
{ virtual ~Object() {} };
72 static QScriptValue
newObject(QScriptEngine
*, QScriptDeclarativeClass
*, Object
*);
73 static QScriptDeclarativeClass
*scriptClass(const QScriptValue
&);
74 static Object
*object(const QScriptValue
&);
76 static QScriptValue
function(const QScriptValue
&, const Identifier
&);
77 static QScriptValue
property(const QScriptValue
&, const Identifier
&);
79 static QScriptValue
scopeChainValue(QScriptContext
*, int index
);
80 static QScriptContext
*pushCleanContext(QScriptEngine
*);
82 class Q_SCRIPT_EXPORT PersistentIdentifier
85 Identifier identifier
;
87 PersistentIdentifier();
88 ~PersistentIdentifier();
89 PersistentIdentifier(const PersistentIdentifier
&other
);
90 PersistentIdentifier
&operator=(const PersistentIdentifier
&other
);
93 friend class QScriptDeclarativeClass
;
94 PersistentIdentifier(bool) : identifier(0), d(0) {}
98 QScriptDeclarativeClass(QScriptEngine
*engine
);
99 virtual ~QScriptDeclarativeClass();
101 QScriptEngine
*engine() const;
103 PersistentIdentifier
createPersistentIdentifier(const QString
&);
104 PersistentIdentifier
createPersistentIdentifier(const Identifier
&);
106 QString
toString(const Identifier
&);
107 quint32
toArrayIndex(const Identifier
&, bool *ok
);
109 virtual QScriptClass::QueryFlags
queryProperty(Object
*, const Identifier
&,
110 QScriptClass::QueryFlags flags
);
112 virtual QScriptValue
property(Object
*, const Identifier
&);
113 virtual void setProperty(Object
*, const Identifier
&name
, const QScriptValue
&);
114 virtual QScriptValue::PropertyFlags
propertyFlags(Object
*, const Identifier
&);
116 virtual QStringList
propertyNames(Object
*);
118 virtual QObject
*toQObject(Object
*, bool *ok
= 0);
119 virtual QVariant
toVariant(Object
*, bool *ok
= 0);
121 QScriptContext
*context() const;
123 friend class QScriptDeclarativeClassPrivate
;
124 QScopedPointer
<QScriptDeclarativeClassPrivate
> d_ptr
;