1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtScript module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser
11 ** General Public License version 2.1 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.LGPL included in the
13 ** packaging of this file. Please review the following information to
14 ** ensure the GNU Lesser General Public License version 2.1 requirements
15 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** If you have questions regarding the use of this file, please contact
18 ** us via http://www.qt-project.org/.
22 ****************************************************************************/
27 #include <QtCore/qstring.h>
29 #include <QtCore/qlist.h>
30 #include <QtCore/qsharedpointer.h>
31 #include <QtCore/qshareddata.h>
45 typedef QList<QJSValue> QJSValueList;
47 class QJSValuePrivate;
48 struct QScriptValuePrivatePointerDeleter;
49 template <class T> class QScriptPassPointer;
51 class Q_DECLARATIVE_EXPORT QJSValue
60 QJSValue(SpecialValue value = UndefinedValue);
62 QJSValue(const QJSValue &other);
67 QJSValue(double value);
68 QJSValue(const QString &value);
69 QJSValue(const QLatin1String &value);
70 #ifndef QT_NO_CAST_FROM_ASCII
71 QT_ASCII_CAST_WARN_CONSTRUCTOR QJSValue(const char *str);
74 QJSValue &operator=(const QJSValue &other);
77 bool isNumber() const;
79 bool isString() const;
80 bool isUndefined() const;
81 bool isVariant() const;
82 bool isQObject() const;
83 bool isObject() const;
85 bool isRegExp() const;
89 QString toString() const;
90 double toNumber() const;
92 quint32 toUInt() const;
94 QVariant toVariant() const;
95 QObject *toQObject() const;
96 QDateTime toDateTime() const;
98 bool equals(const QJSValue &other) const;
99 bool strictlyEquals(const QJSValue &other) const;
101 QJSValue prototype() const;
102 void setPrototype(const QJSValue &prototype);
104 QJSValue property(const QString &name) const;
105 void setProperty(const QString &name, const QJSValue &value);
107 bool hasProperty(const QString &name) const;
108 bool hasOwnProperty(const QString &name) const;
110 QJSValue property(quint32 arrayIndex) const;
111 void setProperty(quint32 arrayIndex, const QJSValue &value);
113 bool deleteProperty(const QString &name);
115 bool isCallable() const;
116 QJSValue call(const QJSValueList &args);
117 QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &args = QJSValueList());
118 QJSValue callAsConstructor(const QJSValueList &args = QJSValueList());
121 QT_DEPRECATED QJSEngine *engine() const;
123 QT_DEPRECATED bool isFunction() const;
124 QT_DEPRECATED qint32 toInt32() const;
125 QT_DEPRECATED quint32 toUInt32() const;
127 QT_DEPRECATED QJSValue call(const QJSValue &thisObject = QJSValue(),
128 const QJSValueList &args = QJSValueList());
129 QT_DEPRECATED QJSValue construct(const QJSValueList &args = QJSValueList());
133 // force compile error, prevent QJSValue(bool) to be called
136 QJSValue(QJSValuePrivate*);
137 QJSValue(QScriptPassPointer<QJSValuePrivate>);
140 QExplicitlySharedDataPointer<QJSValuePrivate> d_ptr;
142 Q_DECLARE_PRIVATE(QJSValue)