Skip to content

Commit

Permalink
Add QJSValue::isCallable() function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kent Hansen authored and Qt by Nokia committed Jan 20, 2012
1 parent 846b66d commit dfad490
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 109 deletions.
18 changes: 15 additions & 3 deletions src/declarative/qml/v8/qjsvalue.cpp
Expand Up @@ -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().
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/declarative/qml/v8/qjsvalue.h
Expand Up @@ -140,6 +140,7 @@ class Q_DECLARATIVE_EXPORT QJSValue

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());
Expand Down

0 comments on commit dfad490

Please sign in to comment.