aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-01-18 13:23:16 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-20 23:35:18 +0100
commitdfad4902b7227540baa2a15f894fe8937c3c6e15 (patch)
tree4df0ba8edd593afddc310fa20e1388f3f11ab52b /src/declarative
parent846b66d46a1e0f4f0baf9bed387c588f6faf8e0c (diff)
Add QJSValue::isCallable() function
This replaces the isFunction() function. isFunction() will be removed. It's possible that objects are callable even if they aren't Function instances. Also, "isCallable" is consistent with call(). Task-number: QTBUG-23604 Change-Id: I42e0ab2ad9dc84e7793199254bbd89d5c9466e6a Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/v8/qjsvalue.cpp18
-rw-r--r--src/declarative/qml/v8/qjsvalue.h1
2 files changed, 16 insertions, 3 deletions
diff --git a/src/declarative/qml/v8/qjsvalue.cpp b/src/declarative/qml/v8/qjsvalue.cpp
index 482216ac49..a43dd33f14 100644
--- a/src/declarative/qml/v8/qjsvalue.cpp
+++ b/src/declarative/qml/v8/qjsvalue.cpp
@@ -71,7 +71,7 @@
Object values have an internal \c{prototype} property, which can be
accessed with prototype() and setPrototype().
- Function objects (objects for which isFunction() returns true) can
+ Function objects (objects for which isCallable()) returns true) can
be invoked by calling call(). Constructor functions can be used to
construct new objects by calling construct().
@@ -461,11 +461,23 @@ bool QJSValue::isObject() const
}
/*!
- Returns true if this QJSValue is a function; otherwise returns
- false.
+ Returns true if this QJSValue can be called a function, otherwise
+ returns false.
\sa call()
*/
+bool QJSValue::isCallable() const
+{
+ Q_D(const QJSValue);
+ QScriptIsolate api(d->engine());
+ return d->isCallable();
+}
+
+/*!
+ \obsolete
+
+ Use isCallable() instead.
+*/
bool QJSValue::isFunction() const
{
Q_D(const QJSValue);
diff --git a/src/declarative/qml/v8/qjsvalue.h b/src/declarative/qml/v8/qjsvalue.h
index 4467cef354..8a15c4e0f2 100644
--- a/src/declarative/qml/v8/qjsvalue.h
+++ b/src/declarative/qml/v8/qjsvalue.h
@@ -140,6 +140,7 @@ public:
QJSValue::PropertyFlags propertyFlags(const QString &name) const;
+ bool isCallable() const;
QJSValue call(const QJSValue &thisObject = QJSValue(),
const QJSValueList &args = QJSValueList());
QJSValue construct(const QJSValueList &args = QJSValueList());