aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/v8/qjsvalue.cpp
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-01-18 09:50:31 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-20 23:35:18 +0100
commit45a83b43ea431a27a7ea05e7e621013dfcfe409a (patch)
treefc379a3d1e7ba1297ca0cd7dd896f084447c4ca8 /src/declarative/qml/v8/qjsvalue.cpp
parentb4cd91c2409d5487cb576899f22f654a5bff93e2 (diff)
Add QJSValue::hasProperty() and hasOwnProperty() functions
These functions provide a way of querying whether a property exists, without relying on the QJSValue invalid type (which will be removed). Task-number: QTBUG-23604 Change-Id: I2efd53a1e54cc202ecc022d12730b2775384cf53 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'src/declarative/qml/v8/qjsvalue.cpp')
-rw-r--r--src/declarative/qml/v8/qjsvalue.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/declarative/qml/v8/qjsvalue.cpp b/src/declarative/qml/v8/qjsvalue.cpp
index 7df1d04847..9980463a8f 100644
--- a/src/declarative/qml/v8/qjsvalue.cpp
+++ b/src/declarative/qml/v8/qjsvalue.cpp
@@ -866,7 +866,7 @@ bool QJSValue::instanceOf(const QJSValue &other) const
occurred, property() returns the value that was thrown (typically
an \c{Error} object).
- \sa setProperty(), propertyFlags(), QJSValueIterator
+ \sa setProperty(), hasProperty(), QJSValueIterator
*/
QJSValue QJSValue::property(const QString& name) const
{
@@ -944,6 +944,32 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
}
/*!
+ Returns true if this object has a property of the given \a name,
+ otherwise returns false.
+
+ \sa property(), hasOwnProperty()
+*/
+bool QJSValue::hasProperty(const QString &name) const
+{
+ Q_D(const QJSValue);
+ QScriptIsolate api(d->engine());
+ return d->hasProperty(name);
+}
+
+/*!
+ Returns true if this object has an own (not prototype-inherited)
+ property of the given \a name, otherwise returns false.
+
+ \sa property(), hasProperty()
+*/
+bool QJSValue::hasOwnProperty(const QString &name) const
+{
+ Q_D(const QJSValue);
+ QScriptIsolate api(d->engine());
+ return d->hasOwnProperty(name);
+}
+
+/*!
Returns the flags of the property with the given \a name.
\sa property()