diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-01-07 11:43:23 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-01-07 12:51:48 +0100 |
commit | 1cd696cf9e10f62caf69cd671fb5c34964a1c107 (patch) | |
tree | 369ab7defea8de5265587f616c2ee7b0a61f7ad7 /src | |
parent | 8e713ad53883e16c27801ae3a6aec1c400d05cc3 (diff) |
QJSManagedValue: Add JavaScript 'function' type
'function' is a separate type in JavaScript and should be treated that
way. Replace the isCallable() method with a new isFunction() to reflect
that, and add an entry to the Type enum.
Change-Id: I09cc28a9edf8aa0380eb9caeb738dfc298a02567
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsapi/qjsmanagedvalue.cpp | 19 | ||||
-rw-r--r-- | src/qml/jsapi/qjsmanagedvalue.h | 5 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/qml/jsapi/qjsmanagedvalue.cpp b/src/qml/jsapi/qjsmanagedvalue.cpp index 49088d6d0c..4c88636850 100644 --- a/src/qml/jsapi/qjsmanagedvalue.cpp +++ b/src/qml/jsapi/qjsmanagedvalue.cpp @@ -115,6 +115,7 @@ QT_BEGIN_NAMESPACE * \value String The \c string type * \value Object The \c object type * \value Symbol The \c symbol type + * \value Function The \c function type * * Note that the \c null value is not a type of itself but rather a special kind * of object. You can query a QJSManagedValue for this condition using the @@ -380,6 +381,8 @@ QJSManagedValue::Type QJSManagedValue::type() const return String; if (d->isSymbol()) return Symbol; + if (d->isFunctionObject()) + return Function; return Object; } @@ -426,6 +429,13 @@ QJSManagedValue::Type QJSManagedValue::type() const */ /*! + * \fn QJSManagedValue::isFunction() const + * + * Returns \c true if the type of this QJSManagedValue is \c function, + * \c false otherwise. + */ + +/*! * Returns \c true if this QJSManagedValue holds the JavaScript \c null value, * or \c false otherwise. */ @@ -907,15 +917,6 @@ bool QJSManagedValue::deleteProperty(quint32 arrayIndex) return false; } -/*! - * Returns \c true if this QJSManagedValue is a JavaScript FunctionObject, or - * \c false otherwise. - */ -bool QJSManagedValue::isCallable() const -{ - return d && d->isFunctionObject(); -} - static const QV4::FunctionObject *functionObjectForCall(QV4::Value *d) { if (Q_UNLIKELY(!d)) { diff --git a/src/qml/jsapi/qjsmanagedvalue.h b/src/qml/jsapi/qjsmanagedvalue.h index 67a3f3758a..702f2507f0 100644 --- a/src/qml/jsapi/qjsmanagedvalue.h +++ b/src/qml/jsapi/qjsmanagedvalue.h @@ -62,7 +62,8 @@ public: Number, String, Object, - Symbol + Symbol, + Function }; QJSManagedValue() = default; @@ -92,6 +93,7 @@ public: bool isString() const { return type() == String; } bool isObject() const { return type() == Object; } bool isSymbol() const { return type() == Symbol; } + bool isFunction() const { return type() == Function; } // Special case of Number bool isInteger() const; @@ -106,7 +108,6 @@ public: bool isQMetaObject() const; bool isDate() const; bool isError() const; - bool isCallable() const; // Native type transformations QString toString() const; |