1
/****************************************************************************
3
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
** Contact: Nokia Corporation (qt-info@nokia.com)
6
** This file is part of the QtScript module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
10
** Licensees holding valid Qt Commercial licenses may use this file in
11
** accordance with the Qt Commercial License Agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Nokia.
15
** GNU Lesser General Public License Usage
16
** Alternatively, this file may be used under the terms of the GNU Lesser
17
** General Public License version 2.1 as published by the Free Software
18
** Foundation and appearing in the file LICENSE.LGPL included in the
19
** packaging of this file. Please review the following information to
20
** ensure the GNU Lesser General Public License version 2.1 requirements
21
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
** In addition, as a special exception, Nokia gives you certain
24
** additional rights. These rights are described in the Nokia Qt LGPL
25
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
28
** GNU General Public License Usage
29
** Alternatively, this file may be used under the terms of the GNU
30
** General Public License version 3.0 as published by the Free Software
31
** Foundation and appearing in the file LICENSE.GPL included in the
32
** packaging of this file. Please review the following information to
33
** ensure the GNU General Public License version 3.0 requirements will be
34
** met: http://www.gnu.org/copyleft/gpl.html.
36
** If you are unsure which license is appropriate for your use, please
37
** contact the sales department at http://www.qtsoftware.com/contact.
40
****************************************************************************/
42
#ifndef QSCRIPTVALUE_H
43
#define QSCRIPTVALUE_H
45
#include <QtCore/qstring.h>
49
#include <QtCore/qlist.h>
69
typedef QList<QScriptValue> QScriptValueList;
71
typedef double qsreal;
73
class QScriptValuePrivate;
74
class Q_SCRIPT_EXPORT QScriptValue
79
ResolvePrototype = 0x01,
81
ResolveFull = ResolvePrototype | ResolveScope
84
Q_DECLARE_FLAGS(ResolveFlags, ResolveFlag)
87
ReadOnly = 0x00000001,
88
Undeletable = 0x00000002,
89
SkipInEnumeration = 0x00000004,
91
PropertyGetter = 0x00000008,
92
PropertySetter = 0x00000010,
94
QObjectMember = 0x00000020,
96
KeepExistingFlags = 0x00000800,
98
UserRange = 0xff000000 // Users may use these as they see fit.
100
Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag)
110
QScriptValue(const QScriptValue &other);
111
QScriptValue(QScriptEngine *engine, SpecialValue val);
112
QScriptValue(QScriptEngine *engine, bool val);
113
QScriptValue(QScriptEngine *engine, int val);
114
QScriptValue(QScriptEngine *engine, uint val);
115
QScriptValue(QScriptEngine *engine, qsreal val);
116
QScriptValue(QScriptEngine *engine, const QString &val);
117
#ifndef QT_NO_CAST_FROM_ASCII
118
QT_ASCII_CAST_WARN_CONSTRUCTOR QScriptValue(QScriptEngine *engine, const char *val);
121
QScriptValue(SpecialValue value);
122
QScriptValue(bool value);
123
QScriptValue(int value);
124
QScriptValue(uint value);
125
QScriptValue(qsreal value);
126
QScriptValue(const QString &value);
127
QScriptValue(const QLatin1String &value);
128
#ifndef QT_NO_CAST_FROM_ASCII
129
QT_ASCII_CAST_WARN_CONSTRUCTOR QScriptValue(const char *value);
132
QScriptValue &operator=(const QScriptValue &other);
134
QScriptEngine *engine() const;
136
bool isValid() const;
138
bool isBoolean() const;
139
bool isNumber() const;
140
bool isFunction() const;
142
bool isString() const;
143
bool isUndefined() const;
144
bool isVariant() const;
145
bool isQObject() const;
146
bool isQMetaObject() const;
147
bool isObject() const;
149
bool isRegExp() const;
150
bool isArray() const;
151
bool isError() const;
153
QString toString() const;
154
qsreal toNumber() const;
156
bool toBoolean() const;
157
qsreal toInteger() const;
158
qint32 toInt32() const;
159
quint32 toUInt32() const;
160
quint16 toUInt16() const;
161
QVariant toVariant() const;
162
QObject *toQObject() const;
163
const QMetaObject *toQMetaObject() const;
164
QScriptValue toObject() const;
165
QDateTime toDateTime() const;
167
QRegExp toRegExp() const;
170
bool instanceOf(const QScriptValue &other) const;
172
bool lessThan(const QScriptValue &other) const;
173
bool equals(const QScriptValue &other) const;
174
bool strictlyEquals(const QScriptValue &other) const;
176
QScriptValue prototype() const;
177
void setPrototype(const QScriptValue &prototype);
179
QScriptValue scope() const;
180
void setScope(const QScriptValue &scope);
182
QScriptValue property(const QString &name,
183
const ResolveFlags &mode = ResolvePrototype) const;
184
void setProperty(const QString &name, const QScriptValue &value,
185
const PropertyFlags &flags = KeepExistingFlags);
187
QScriptValue property(quint32 arrayIndex,
188
const ResolveFlags &mode = ResolvePrototype) const;
189
void setProperty(quint32 arrayIndex, const QScriptValue &value,
190
const PropertyFlags &flags = KeepExistingFlags);
192
QScriptValue property(const QScriptString &name,
193
const ResolveFlags &mode = ResolvePrototype) const;
194
void setProperty(const QScriptString &name, const QScriptValue &value,
195
const PropertyFlags &flags = KeepExistingFlags);
197
QScriptValue::PropertyFlags propertyFlags(
198
const QString &name, const ResolveFlags &mode = ResolvePrototype) const;
199
QScriptValue::PropertyFlags propertyFlags(
200
const QScriptString &name, const ResolveFlags &mode = ResolvePrototype) const;
202
QScriptValue call(const QScriptValue &thisObject = QScriptValue(),
203
const QScriptValueList &args = QScriptValueList());
204
QScriptValue call(const QScriptValue &thisObject,
205
const QScriptValue &arguments);
206
QScriptValue construct(const QScriptValueList &args = QScriptValueList());
207
QScriptValue construct(const QScriptValue &arguments);
209
QScriptValue data() const;
210
void setData(const QScriptValue &data);
212
QScriptClass *scriptClass() const;
213
void setScriptClass(QScriptClass *scriptClass);
215
qint64 objectId() const;
218
// force compile error, prevent QScriptValue(bool) to be called
219
inline QScriptValue(void *) { Q_ASSERT(false); }
220
// force compile error, prevent QScriptValue(QScriptEngine*, bool) to be called
221
inline QScriptValue(QScriptEngine *, void *) { Q_ASSERT(false); }
224
QScriptValuePrivate *d_ptr;
226
Q_DECLARE_PRIVATE(QScriptValue)
229
Q_DECLARE_OPERATORS_FOR_FLAGS(QScriptValue::ResolveFlags)
230
Q_DECLARE_OPERATORS_FOR_FLAGS(QScriptValue::PropertyFlags)
236
#endif // QT_NO_SCRIPT