📄 qscriptvalue.cpp
字号:
(\c{__proto__} property) of this object; otherwise returns an invalid QScriptValue. \sa setPrototype(), isObject()*/QScriptValue QScriptValue::prototype() const{ return QScriptValuePrivate::valueOf(*this).prototype();}/*! If this QScriptValue is an object, sets the internal prototype (\c{__proto__} property) of this object to be \a prototype; otherwise does nothing. The internal prototype should not be confused with the public property with name "prototype"; the public prototype is usually only set on functions that act as constructors. \sa prototype(), isObject()*/void QScriptValue::setPrototype(const QScriptValue &prototype){ if (!isObject()) return; if (prototype.isValid() && (prototype.engine() != engine())) { qWarning("QScriptValue::setPrototype() failed: " "cannot set a prototype created in " "a different engine"); return; } QScriptValueImpl self = QScriptValuePrivate::valueOf(*this); QScriptValueImpl was = self.prototype(); self.setPrototype(QScriptValuePrivate::valueOf(prototype)); if (self.detectedCycle()) { qWarning("QScriptValue::setPrototype() failed: " "cyclic prototype value"); self.setPrototype(was); }}/*! \internal*/QScriptValue QScriptValue::scope() const{ if (!isObject()) return QScriptValue(); return QScriptValuePrivate::valueOf(*this).scope();}/*! \internal*/void QScriptValue::setScope(const QScriptValue &scope){ if (!isObject()) return; if (scope.isValid() && (scope.engine() != engine())) { qWarning("QScriptValue::setScope() failed: " "cannot set a scope object created in " "a different engine"); return; } QScriptValuePrivate::valueOf(*this).setScope(QScriptValuePrivate::valueOf(scope));}/*! Returns true if this QScriptValue is an instance of \a other; otherwise returns false. This QScriptValue is considered to be an instance of \a other if \a other is a function and the value of the \c{prototype} property of \a other is in the prototype chain of this QScriptValue.*/bool QScriptValue::instanceOf(const QScriptValue &other) const{ if (!other.isValid()) return false; return QScriptValuePrivate::valueOf(*this) .instanceOf(QScriptValuePrivate::valueOf(other));}/*! Returns true if this QScriptValue is less than \a other, otherwise returns false. The comparison follows the behavior described in \l{ECMA-262} section 11.8.5, "The Abstract Relational Comparison Algorithm". Note that if this QScriptValue or the \a other value are objects, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception). \sa equals()*/bool QScriptValue::lessThan(const QScriptValue &other) const{ if (isValid() && other.isValid() && (other.engine() != engine())) { qWarning("QScriptValue::lessThan: " "cannot compare to a value created in " "a different engine"); return false; } return QScriptValuePrivate::valueOf(*this).lessThan(QScriptValuePrivate::valueOf(other));}/*! Returns true if this QScriptValue is equal to \a other, otherwise returns false. The comparison follows the behavior described in \l{ECMA-262} section 11.9.3, "The Abstract Equality Comparison Algorithm". Note that if this QScriptValue or the \a other value are objects, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception). \sa strictlyEquals(), lessThan()*/bool QScriptValue::equals(const QScriptValue &other) const{ if (isValid() && other.isValid() && (other.engine() != engine())) { qWarning("QScriptValue::equals: " "cannot compare to a value created in " "a different engine"); return false; } return QScriptValuePrivate::valueOf(*this).equals(QScriptValuePrivate::valueOf(other));}/*! Returns true if this QScriptValue is equal to \a other using strict comparison (no conversion), otherwise returns false. The comparison follows the behavior described in \l{ECMA-262} section 11.9.6, "The Strict Equality Comparison Algorithm". \sa equals()*/bool QScriptValue::strictlyEquals(const QScriptValue &other) const{ if (isValid() && other.isValid() && (other.engine() != engine())) { qWarning("QScriptValue::strictlyEquals: " "cannot compare to a value created in " "a different engine"); return false; } return QScriptValuePrivate::valueOf(*this).strictlyEquals(QScriptValuePrivate::valueOf(other));}/*! Returns the string value of this QScriptValue, as defined in \l{ECMA-262} section 9.8, "ToString". Note that if this QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's toString() function (and possibly valueOf()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception). \sa isString()*/QString QScriptValue::toString() const{ return QScriptValuePrivate::valueOf(*this).toString();}/*! Returns the number value of this QScriptValue, as defined in \l{ECMA-262} section 9.3, "ToNumber". Note that if this QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception). \sa isNumber(), toInteger(), toInt32(), toUInt32(), toUInt16()*/qsreal QScriptValue::toNumber() const{ return QScriptValuePrivate::valueOf(*this).toNumber();}/*! Returns the boolean value of this QScriptValue, using the conversion rules described in \l{ECMA-262} section 9.2, "ToBoolean". Note that if this QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception). \sa isBoolean()*/bool QScriptValue::toBoolean() const{ return QScriptValuePrivate::valueOf(*this).toBoolean();}/*! Returns the signed 32-bit integer value of this QScriptValue, using the conversion rules described in \l{ECMA-262} section 9.5, "ToInt32". Note that if this QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception). \sa toNumber(), toUInt32()*/qint32 QScriptValue::toInt32() const{ return QScriptValuePrivate::valueOf(*this).toInt32();}/*! Returns the unsigned 32-bit integer value of this QScriptValue, using the conversion rules described in \l{ECMA-262} section 9.6, "ToUint32". Note that if this QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception). \sa toNumber(), toInt32()*/quint32 QScriptValue::toUInt32() const{ return QScriptValuePrivate::valueOf(*this).toUInt32();}/*! Returns the unsigned 16-bit integer value of this QScriptValue, using the conversion rules described in \l{ECMA-262} section 9.7, "ToUint16". Note that if this QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception). \sa toNumber()*/quint16 QScriptValue::toUInt16() const{ return QScriptValuePrivate::valueOf(*this).toUInt16();}/*! Returns the integer value of this QScriptValue, using the conversion rules described in \l{ECMA-262} section 9.4, "ToInteger". Note that if this QScriptValue is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly toString()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception). \sa toNumber()*/qsreal QScriptValue::toInteger() const{ return QScriptValuePrivate::valueOf(*this).toInteger();}/*! Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise returns an invalid QVariant. The conversion is performed according to the following table: \table \header \o Input Type \o Result \row \o Undefined \o An invalid QVariant. \row \o Null \o An invalid QVariant. \row \o Boolean \o A QVariant containing the value of the boolean. \row \o Number \o A QVariant containing the value of the number. \row \o String \o A QVariant containing the value of the string. \row \o QVariant Object \o The result is the QVariant value of the object (no conversion). \row \o QObject Object \o A QVariant containing a pointer to the QObject. \row \o Date Object \o A QVariant containing the date value (toDateTime()). \row \o RegExp Object \o A QVariant containing the regular expression value (toRegExp()). \row \o Object \o If the value is primitive, then the result is converted to a QVariant according to the above rules; otherwise, an invalid QVariant is returned. \endtable \sa isVariant()*/QVariant QScriptValue::toVariant() const{ return QScriptValuePrivate::valueOf(*this).toVariant();}/*! Returns the object value of this QScriptValue, if it can be converted to an object; otherwise returns an invalid QScriptValue. The conversion is performed according to the following table: \table \header \o Input Type \o Result \row \o Undefined \o An invalid QScriptValue. \row \o Null \o An invalid QScriptValue. \row \o Boolean \o A new Boolean object whose internal value is set to the value of the boolean. \row \o Number \o A new Number object whose internal value is set to the value of the number. \row \o String \o A new String object whose internal value is set to the value of the string. \row \o Object \o The result is the object itself (no conversion). \endtable \sa isObject(), QScriptEngine::newObject()*/QScriptValue QScriptValue::toObject() const{ return QScriptValuePrivate::valueOf(*this).toObject();}/*! Returns the QDateTime representation of this value. If this QScriptValue is not a date, or the value of the date is NaN (Not-a-Number), an invalid QDateTime is returned. \sa isDate()*/QDateTime QScriptValue::toDateTime() const{ return QScriptValuePrivate::valueOf(*this).toDateTime();}#ifndef QT_NO_REGEXP/*! Returns the QRegExp representation of this value. If this QScriptValue is not a regular expression, an empty QRegExp is returned. \sa isRegExp()*/QRegExp QScriptValue::toRegExp() const{ return QScriptValuePrivate::valueOf(*this).toRegExp();}#endif // QT_NO_REGEXP/*! If this QScriptValue is a QObject, returns the QObject pointer that the QScriptValue represents; otherwise, returns 0. If the QObject that this QScriptValue wraps has been deleted, this function returns 0 (i.e. it is possible for toQObject() to return 0 even when isQObject() returns true). \sa isQObject()*/QObject *QScriptValue::toQObject() const{ return QScriptValuePrivate::valueOf(*this).toQObject();}/*! If this QScriptValue is a QMetaObject, returns the QMetaObject pointer that the QScriptValue represents; otherwise, returns 0.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -