Qt 4.8
|
The QScriptValue class acts as a container for the Qt Script data types. More...
#include <qscriptvalue.h>
Public Types | |
enum | PropertyFlag { ReadOnly = 0x00000001, Undeletable = 0x00000002, SkipInEnumeration = 0x00000004, PropertyGetter = 0x00000008, PropertySetter = 0x00000010, QObjectMember = 0x00000020, KeepExistingFlags = 0x00000800, UserRange = 0xff000000 } |
This enum describes the attributes of a property. More... | |
enum | ResolveFlag { ResolveLocal = 0x00, ResolvePrototype = 0x01, ResolveScope = 0x02, ResolveFull = ResolvePrototype | ResolveScope } |
This enum specifies how to look up a property of an object. More... | |
enum | SpecialValue { NullValue, UndefinedValue } |
This enum is used to specify a single-valued type. More... | |
Public Functions | |
QScriptValue | call (const QScriptValue &thisObject=QScriptValue(), const QScriptValueList &args=QScriptValueList()) |
Calls this QScriptValue as a function, using thisObject as the `this' object in the function call, and passing args as arguments to the function. More... | |
QScriptValue | call (const QScriptValue &thisObject, const QScriptValue &arguments) |
Calls this QScriptValue as a function, using thisObject as the `this' object in the function call, and passing arguments as arguments to the function. More... | |
QScriptValue | construct (const QScriptValueList &args=QScriptValueList()) |
Creates a new Object and calls this QScriptValue as a constructor, using the created object as the `this' object and passing args as arguments. More... | |
QScriptValue | construct (const QScriptValue &arguments) |
Creates a new Object and calls this QScriptValue as a constructor, using the created object as the `this' object and passing arguments as arguments. More... | |
QScriptValue | data () const |
Returns the internal data of this QScriptValue object. More... | |
QScriptEngine * | engine () const |
Returns the QScriptEngine that created this QScriptValue, or 0 if this QScriptValue is invalid or the value is not associated with a particular engine. More... | |
bool | equals (const QScriptValue &other) const |
Returns true if this QScriptValue is equal to other, otherwise returns false. More... | |
bool | instanceOf (const QScriptValue &other) const |
Returns true if this QScriptValue is an instance of other; otherwise returns false. More... | |
bool | isArray () const |
Returns true if this QScriptValue is an object of the Array class; otherwise returns false. More... | |
bool | isBool () const |
Returns true if this QScriptValue is of the primitive type Boolean; otherwise returns false. More... | |
bool | isBoolean () const |
Use isBool() instead. More... | |
bool | isDate () const |
Returns true if this QScriptValue is an object of the Date class; otherwise returns false. More... | |
bool | isError () const |
Returns true if this QScriptValue is an object of the Error class; otherwise returns false. More... | |
bool | isFunction () const |
Returns true if this QScriptValue is a function; otherwise returns false. More... | |
bool | isNull () const |
Returns true if this QScriptValue is of the primitive type Null; otherwise returns false. More... | |
bool | isNumber () const |
Returns true if this QScriptValue is of the primitive type Number; otherwise returns false. More... | |
bool | isObject () const |
Returns true if this QScriptValue is of the Object type; otherwise returns false. More... | |
bool | isQMetaObject () const |
Returns true if this QScriptValue is a QMetaObject; otherwise returns false. More... | |
bool | isQObject () const |
Returns true if this QScriptValue is a QObject; otherwise returns false. More... | |
bool | isRegExp () const |
Returns true if this QScriptValue is an object of the RegExp class; otherwise returns false. More... | |
bool | isString () const |
Returns true if this QScriptValue is of the primitive type String; otherwise returns false. More... | |
bool | isUndefined () const |
Returns true if this QScriptValue is of the primitive type Undefined; otherwise returns false. More... | |
bool | isValid () const |
Returns true if this QScriptValue is valid; otherwise returns false. More... | |
bool | isVariant () const |
Returns true if this QScriptValue is a variant value; otherwise returns false. More... | |
bool | lessThan (const QScriptValue &other) const |
Returns true if this QScriptValue is less than other, otherwise returns false. More... | |
qint64 | objectId () const |
Returns the ID of this object, or -1 if this QScriptValue is not an object. More... | |
QScriptValue & | operator= (const QScriptValue &other) |
Assigns the other value to this QScriptValue. More... | |
QScriptValue | property (const QString &name, const ResolveFlags &mode=ResolvePrototype) const |
Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property. More... | |
QScriptValue | property (quint32 arrayIndex, const ResolveFlags &mode=ResolvePrototype) const |
Returns the property at the given arrayIndex, using the given mode to resolve the property. More... | |
QScriptValue | property (const QScriptString &name, const ResolveFlags &mode=ResolvePrototype) const |
Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property. More... | |
QScriptValue::PropertyFlags | propertyFlags (const QString &name, const ResolveFlags &mode=ResolvePrototype) const |
Returns the flags of the property with the given name, using the given mode to resolve the property. More... | |
QScriptValue::PropertyFlags | propertyFlags (const QScriptString &name, const ResolveFlags &mode=ResolvePrototype) const |
Returns the flags of the property with the given name, using the given mode to resolve the property. More... | |
QScriptValue | prototype () const |
If this QScriptValue is an object, returns the internal prototype (__proto__ property) of this object; otherwise returns an invalid QScriptValue. More... | |
QScriptValue () | |
Constructs an invalid QScriptValue. More... | |
QScriptValue (const QScriptValue &other) | |
Constructs a new QScriptValue that is a copy of other. More... | |
QScriptValue (QScriptEngine *engine, SpecialValue val) | |
Constructs a new QScriptValue with the special value and registers it with the script engine. More... | |
QScriptValue (QScriptEngine *engine, bool val) | |
QScriptValue (QScriptEngine *engine, int val) | |
QScriptValue (QScriptEngine *engine, uint val) | |
QScriptValue (QScriptEngine *engine, qsreal val) | |
QScriptValue (QScriptEngine *engine, const QString &val) | |
QT_ASCII_CAST_WARN_CONSTRUCTOR | QScriptValue (QScriptEngine *engine, const char *val) |
QScriptValue (SpecialValue value) | |
Constructs a new QScriptValue with a special value. More... | |
QScriptValue (bool value) | |
Constructs a new QScriptValue with a boolean value. More... | |
QScriptValue (int value) | |
Constructs a new QScriptValue with a number value. More... | |
QScriptValue (uint value) | |
Constructs a new QScriptValue with a number value. More... | |
QScriptValue (qsreal value) | |
Constructs a new QScriptValue with a number value. More... | |
QScriptValue (const QString &value) | |
Constructs a new QScriptValue with a string value. More... | |
QScriptValue (const QLatin1String &value) | |
Constructs a new QScriptValue with a string value. More... | |
QT_ASCII_CAST_WARN_CONSTRUCTOR | QScriptValue (const char *value) |
Constructs a new QScriptValue with a string value. More... | |
QScriptValue | scope () const |
QScriptClass * | scriptClass () const |
Returns the custom script class that this script object is an instance of, or 0 if the object is not of a custom class. More... | |
void | setData (const QScriptValue &data) |
Sets the internal data of this QScriptValue object. More... | |
void | setProperty (const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags) |
Sets the value of this QScriptValue's property with the given name to the given value. More... | |
void | setProperty (quint32 arrayIndex, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags) |
Sets the property at the given arrayIndex to the given value. More... | |
void | setProperty (const QScriptString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags) |
Sets the value of this QScriptValue's property with the given name to the given value. More... | |
void | setPrototype (const QScriptValue &prototype) |
If this QScriptValue is an object, sets the internal prototype (__proto__ property) of this object to be prototype; otherwise does nothing. More... | |
void | setScope (const QScriptValue &scope) |
void | setScriptClass (QScriptClass *scriptClass) |
Sets the custom script class of this script object to scriptClass. More... | |
bool | strictlyEquals (const QScriptValue &other) const |
Returns true if this QScriptValue is equal to other using strict comparison (no conversion), otherwise returns false. More... | |
bool | toBool () const |
Returns the boolean value of this QScriptValue, using the conversion rules described in ECMA-262 section 9. More... | |
bool | toBoolean () const |
Use toBool() instead. More... | |
QDateTime | toDateTime () const |
Returns a QDateTime representation of this value, in local time. More... | |
qint32 | toInt32 () const |
Returns the signed 32-bit integer value of this QScriptValue, using the conversion rules described in ECMA-262 section 9.5, "ToInt32". More... | |
qsreal | toInteger () const |
Returns the integer value of this QScriptValue, using the conversion rules described in ECMA-262 section 9.4, "ToInteger". More... | |
qsreal | toNumber () const |
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber". More... | |
QScriptValue | toObject () const |
This function is obsolete; use QScriptEngine::toObject() instead. More... | |
const QMetaObject * | toQMetaObject () const |
If this QScriptValue is a QMetaObject, returns the QMetaObject pointer that the QScriptValue represents; otherwise, returns 0. More... | |
QObject * | toQObject () const |
If this QScriptValue is a QObject, returns the QObject pointer that the QScriptValue represents; otherwise, returns 0. More... | |
QRegExp | toRegExp () const |
Returns the QRegExp representation of this value. More... | |
QString | toString () const |
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString". More... | |
quint16 | toUInt16 () const |
Returns the unsigned 16-bit integer value of this QScriptValue, using the conversion rules described in ECMA-262 section 9.7, "ToUint16". More... | |
quint32 | toUInt32 () const |
Returns the unsigned 32-bit integer value of this QScriptValue, using the conversion rules described in ECMA-262 section 9.6, "ToUint32". More... | |
QVariant | toVariant () const |
Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise returns an invalid QVariant. More... | |
~QScriptValue () | |
Destroys this QScriptValue. More... | |
Private Functions | |
QScriptValue (void *) | |
QScriptValue (QScriptEngine *, void *) | |
QScriptValue (QScriptValuePrivate *) | |
Properties | |
QExplicitlySharedDataPointer< QScriptValuePrivate > | d_ptr |
Friends | |
class | QScriptEnginePrivate |
Related Functions | |
(Note that these are not member functions.) | |
T | qscriptvalue_cast (const QScriptValue &value) |
Returns the given value converted to the template type T . More... | |
The QScriptValue class acts as a container for the Qt Script data types.
QScriptValue supports the types defined in the ECMA-262 standard: The primitive types, which are Undefined, Null, Boolean, Number, and String; and the Object type. Additionally, Qt Script has built-in support for QVariant, QObject and QMetaObject.
For the object-based types (including Date and RegExp), use the newT() functions in QScriptEngine (e.g. QScriptEngine::newObject()) to create a QScriptValue of the desired type. For the primitive types, use one of the QScriptValue constructor overloads.
The methods named isT() (e.g. isBool(), isUndefined()) can be used to test if a value is of a certain type. The methods named toT() (e.g. toBool(), toString()) can be used to convert a QScriptValue to another type. You can also use the generic qscriptvalue_cast() function.
Object values have zero or more properties which are themselves QScriptValues. Use setProperty() to set a property of an object, and call property() to retrieve the value of a property.
Each property can have a set of attributes; these are specified as the third (optional) argument to setProperty(). The attributes of a property can be queried by calling the propertyFlags() function. The following code snippet creates a property that cannot be modified by script code:
If you want to iterate over the properties of a script object, use the QScriptValueIterator class.
Object values have an internal prototype
property, which can be accessed with prototype() and setPrototype(). Properties added to a prototype are shared by all objects having that prototype; this is referred to as prototype-based inheritance. In practice, it means that (by default) the property() function will automatically attempt to look up look the property in the prototype() (and in the prototype of the prototype(), and so on), if the object itself does not have the requested property. Note that this prototype-based lookup is not performed by setProperty(); setProperty() will always create the property in the script object itself. For more information, see the QtScript documentation.
Function objects (objects for which isFunction() returns true) can be invoked by calling call(). Constructor functions can be used to construct new objects by calling construct().
Use equals(), strictlyEquals() and lessThan() to compare a QScriptValue to another.
Object values can have custom data associated with them; see the setData() and data() functions. By default, this data is not accessible to scripts; it can be used to store any data you want to associate with the script object. Typically this is used by custom class objects (see QScriptClass) to store a C++ type that contains the "native" object data.
Note that a QScriptValue for which isObject() is true only carries a reference to an actual object; copying the QScriptValue will only copy the object reference, not the object itself. If you want to clone an object (i.e. copy an object's properties to another object), you can do so with the help of a for-in
statement in script code, or QScriptValueIterator in C++.
Definition at line 57 of file qscriptvalue.h.
This enum describes the attributes of a property.
delete
the property will be ignored.for-in
enumeration.Enumerator | |
---|---|
ReadOnly | |
Undeletable | |
SkipInEnumeration | |
PropertyGetter | |
PropertySetter | |
QObjectMember | |
KeepExistingFlags | |
UserRange |
Definition at line 69 of file qscriptvalue.h.
This enum specifies how to look up a property of an object.
Enumerator | |
---|---|
ResolveLocal | |
ResolvePrototype | |
ResolveScope | |
ResolveFull |
Definition at line 60 of file qscriptvalue.h.
This enum is used to specify a single-valued type.
Enumerator | |
---|---|
NullValue | |
UndefinedValue |
Definition at line 85 of file qscriptvalue.h.
QScriptValue::QScriptValue | ( | ) |
Constructs an invalid QScriptValue.
Definition at line 201 of file qscriptvalue.cpp.
Referenced by call(), construct(), data(), property(), prototype(), scope(), and toObject().
QScriptValue::~QScriptValue | ( | ) |
QScriptValue::QScriptValue | ( | const QScriptValue & | other | ) |
Constructs a new QScriptValue that is a copy of other.
Note that if other is an object (i.e., isObject() would return true), then only a reference to the underlying object is copied into the new script value (i.e., the object itself is not copied).
Definition at line 220 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | QScriptEngine * | engine, |
QScriptValue::SpecialValue | value | ||
) |
Constructs a new QScriptValue with the special value and registers it with the script engine.
Definition at line 234 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | QScriptEngine * | engine, |
bool | value | ||
) |
Constructs a new QScriptValue with the boolean value and registers it with the script engine.
Definition at line 255 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | QScriptEngine * | engine, |
int | value | ||
) |
Constructs a new QScriptValue with the integer value and registers it with the script engine.
Definition at line 268 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | QScriptEngine * | engine, |
uint | value | ||
) |
Constructs a new QScriptValue with the unsigned integer value and registers it with the script engine.
Definition at line 286 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | QScriptEngine * | engine, |
qsreal | value | ||
) |
Constructs a new QScriptValue with the qsreal value and registers it with the script engine.
Definition at line 304 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | QScriptEngine * | engine, |
const QString & | value | ||
) |
Constructs a new QScriptValue with the string value and registers it with the script engine.
Definition at line 322 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | QScriptEngine * | engine, |
const char * | value | ||
) |
Constructs a new QScriptValue with the string value and registers it with the script engine.
Definition at line 343 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | SpecialValue | value | ) |
Constructs a new QScriptValue with a special value.
Definition at line 364 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | bool | value | ) |
Constructs a new QScriptValue with a boolean value.
Definition at line 385 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | int | value | ) |
Constructs a new QScriptValue with a number value.
Definition at line 399 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | uint | value | ) |
Constructs a new QScriptValue with a number value.
Definition at line 413 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | qsreal | value | ) |
Constructs a new QScriptValue with a number value.
Definition at line 427 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | const QString & | value | ) |
Constructs a new QScriptValue with a string value.
Definition at line 441 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | const QLatin1String & | value | ) |
Constructs a new QScriptValue with a string value.
Definition at line 455 of file qscriptvalue.cpp.
QScriptValue::QScriptValue | ( | const char * | value | ) |
Constructs a new QScriptValue with a string value.
Definition at line 471 of file qscriptvalue.cpp.
|
private |
|
private |
|
private |
Definition at line 193 of file qscriptvalue.cpp.
QScriptValue QScriptValue::call | ( | const QScriptValue & | thisObject = QScriptValue() , |
const QScriptValueList & | args = QScriptValueList() |
||
) |
Calls this QScriptValue as a function, using thisObject as the `this' object in the function call, and passing args as arguments to the function.
Returns the value returned from the function.
If this QScriptValue is not a function, call() does nothing and returns an invalid QScriptValue.
Note that if thisObject is not an object, the global object (see QScriptEngine::globalObject()) will be used as the `this' object.
Calling call() can cause an exception to occur in the script engine; in that case, call() returns the value that was thrown (typically an Error
object). You can call QScriptEngine::hasUncaughtException() to determine if an exception occurred.
Definition at line 1621 of file qscriptvalue.cpp.
Referenced by QDeclarativeInclude::callback(), QDeclarativeXMLHttpRequest::dispatchCallback(), QDeclarativeQtScriptExpression::eval(), QScriptEngine::importExtension(), QDeclarativeVMEMetaObject::metaCall(), QDeclarativeWorkerScriptEnginePrivate::processMessage(), qmlsqldatabase_change_version(), and qmlsqldatabase_open_sync().
QScriptValue QScriptValue::call | ( | const QScriptValue & | thisObject, |
const QScriptValue & | arguments | ||
) |
Calls this QScriptValue as a function, using thisObject as the `this' object in the function call, and passing arguments as arguments to the function.
Returns the value returned from the function.
If this QScriptValue is not a function, call() does nothing and returns an invalid QScriptValue.
arguments can be an arguments object, an array, null or undefined; any other type will cause a TypeError to be thrown.
Note that if thisObject is not an object, the global object (see QScriptEngine::globalObject()) will be used as the `this' object.
One common usage of this function is to forward native function calls to another function:
Definition at line 1699 of file qscriptvalue.cpp.
QScriptValue QScriptValue::construct | ( | const QScriptValueList & | args = QScriptValueList() | ) |
Creates a new Object
and calls this QScriptValue as a constructor, using the created object as the `this' object and passing args as arguments.
If the return value from the constructor call is an object, then that object is returned; otherwise the default constructed object is returned.
If this QScriptValue is not a function, construct() does nothing and returns an invalid QScriptValue.
Calling construct() can cause an exception to occur in the script engine; in that case, construct() returns the value that was thrown (typically an Error
object). You can call QScriptEngine::hasUncaughtException() to determine if an exception occurred.
Definition at line 1775 of file qscriptvalue.cpp.
QScriptValue QScriptValue::construct | ( | const QScriptValue & | arguments | ) |
Creates a new Object
and calls this QScriptValue as a constructor, using the created object as the `this' object and passing arguments as arguments.
If the return value from the constructor call is an object, then that object is returned; otherwise the default constructed object is returned.
If this QScriptValue is not a function, construct() does nothing and returns an invalid QScriptValue.
arguments can be an arguments object, an array, null or undefined. Any other type will cause a TypeError to be thrown.
Definition at line 1834 of file qscriptvalue.cpp.
QScriptValue QScriptValue::data | ( | ) | const |
Returns the internal data of this QScriptValue object.
QtScript uses this property to store the primitive value of Date, String, Number and Boolean objects. For other types of object, custom data may be stored using setData().
Definition at line 2094 of file qscriptvalue.cpp.
Referenced by NamedNodeMap::length(), NodeList::length(), QDeclarativeWorkerScriptEnginePrivate::onMessage(), QScript::FunctionWrapper::proxyCall(), QScript::FunctionWithArgWrapper::proxyCall(), QScript::FunctionWrapper::proxyConstruct(), QScript::FunctionWithArgWrapper::proxyConstruct(), qmlsqldatabase_item(), qmlxmlhttprequest_abort(), qmlxmlhttprequest_getAllResponseHeaders(), qmlxmlhttprequest_getResponseHeader(), qmlxmlhttprequest_onreadystatechange(), qmlxmlhttprequest_open(), qmlxmlhttprequest_readyState(), qmlxmlhttprequest_responseText(), qmlxmlhttprequest_responseXML(), qmlxmlhttprequest_send(), qmlxmlhttprequest_setRequestHeader(), qmlxmlhttprequest_status(), qmlxmlhttprequest_statusText(), QDeclarativeWorkerScriptEnginePrivate::sendMessage(), QScriptDebuggerBackendPrivate::trace(), and QDeclarativeInclude::worker_include().
QScriptEngine * QScriptValue::engine | ( | ) | const |
Returns the QScriptEngine that created this QScriptValue, or 0 if this QScriptValue is invalid or the value is not associated with a particular engine.
Definition at line 1892 of file qscriptvalue.cpp.
Referenced by QScriptValueIteratorPrivate::engine(), QDeclarativeItem::mapFromItem(), QDeclarativeItem::mapToItem(), QDeclarativeObjectScriptClass::newQObject(), QDeclarativeXMLHttpRequest::printError(), QScriptEngine::qScriptConnect(), QScriptEngine::qScriptDisconnect(), QScriptContext::setActivationObject(), QScriptContext::setThisObject(), and toObject().
bool QScriptValue::equals | ( | const QScriptValue & | other | ) | const |
Returns true if this QScriptValue is equal to other, otherwise returns false.
The comparison follows the behavior described in ECMA-262 section 11.9.3, "The Abstract Equality Comparison Algorithm".
This function can return true even if the type of this QScriptValue is different from the type of the other value; i.e. the comparison is not strict. For example, comparing the number 9 to the string "9" returns true; comparing an undefined value to a null value returns true; comparing a Number
object whose primitive value is 6 to a String
object whose primitive value is "6" returns true; and comparing the number 1 to the boolean value true
returns true. If you want to perform a comparison without such implicit value conversion, use strictlyEquals().
Note that if this QScriptValue or the 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).
Definition at line 883 of file qscriptvalue.cpp.
bool QScriptValue::instanceOf | ( | const QScriptValue & | other | ) | const |
Returns true if this QScriptValue is an instance of other; otherwise returns false.
This QScriptValue is considered to be an instance of other if other is a function and the value of the prototype
property of other is in the prototype chain of this QScriptValue.
Definition at line 662 of file qscriptvalue.cpp.
bool QScriptValue::isArray | ( | ) | const |
Returns true if this QScriptValue is an object of the Array class; otherwise returns false.
Definition at line 511 of file qscriptvalue.cpp.
Referenced by QDeclarativeListModel::append(), QDeclarativeComponent::createObject(), QDeclarativeComponentPrivate::createObject(), fromScriptValue(), QDeclarativeListModel::insert(), QDeclarativeObjectMethodScriptClass::matchScore(), QDeclarativeObjectMethodScriptClass::property(), qmlsqldatabase_executeSql(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QDeclarativeEnginePrivate::scriptValueToVariant(), QDeclarativeListModel::set(), ModelNode::setListValue(), and ModelNode::setObjectValue().
bool QScriptValue::isBool | ( | ) | const |
Returns true if this QScriptValue is of the primitive type Boolean; otherwise returns false.
Definition at line 1925 of file qscriptvalue.cpp.
Referenced by QScript::Equals(), fromScriptValue(), QScript::IsNumerical(), and QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant().
bool QScriptValue::isBoolean | ( | ) | const |
Use isBool() instead.
Definition at line 1908 of file qscriptvalue.cpp.
Referenced by QDeclarativeObjectMethodScriptClass::matchScore(), QScriptDebuggerValue::QScriptDebuggerValue(), and QScript::type().
bool QScriptValue::isDate | ( | ) | const |
Returns true if this QScriptValue is an object of the Date class; otherwise returns false.
Definition at line 525 of file qscriptvalue.cpp.
Referenced by FlatListModel::addValue(), QDeclarativeEnginePrivate::formatTime(), fromScriptValue(), QDeclarativeObjectMethodScriptClass::matchScore(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), and FlatListScriptClass::setProperty().
bool QScriptValue::isError | ( | ) | const |
Returns true if this QScriptValue is an object of the Error class; otherwise returns false.
Definition at line 497 of file qscriptvalue.cpp.
Referenced by QDeclarativeXMLHttpRequest::abort(), QDeclarativeXMLHttpRequest::downloadProgress(), QDeclarativeXMLHttpRequest::error(), QScriptEnginePrivate::evaluateHelper(), QDeclarativeExpressionPrivate::exceptionToError(), QDeclarativeXMLHttpRequest::finished(), fromScriptValue(), QScriptDebuggerScriptedConsoleCommandJob::handleResponse(), QScriptDebuggerAgent::positionChange(), QScriptDebuggerScriptedConsoleCommandJob::start(), and QScriptEngine::uncaughtExceptionBacktrace().
bool QScriptValue::isFunction | ( | ) | const |
Returns true if this QScriptValue is a function; otherwise returns false.
Definition at line 1981 of file qscriptvalue.cpp.
Referenced by expandObject(), fromScriptValue(), QScriptEngine::importExtension(), QDeclarativeInclude::include(), QDeclarativeWorkerScriptEnginePrivate::processMessage(), qmlsqldatabase_change_version(), qmlsqldatabase_open_sync(), QDeclarativeValueTypeScriptClass::setProperty(), QDeclarativeObjectScriptClass::setProperty(), QDeclarativeBinding::update(), and QDeclarativeInclude::worker_include().
bool QScriptValue::isNull | ( | ) | const |
Returns true if this QScriptValue is of the primitive type Null; otherwise returns false.
Definition at line 1995 of file qscriptvalue.cpp.
Referenced by QScript::Equals(), fromScriptValue(), QDeclarativeItem::mapFromItem(), QDeclarativeItem::mapToItem(), QDeclarativeObjectMethodScriptClass::matchScore(), QDeclarativeObjectMethodScriptClass::property(), QScriptDebuggerValue::QScriptDebuggerValue(), QDeclarativeObjectScriptClass::setProperty(), QScript::type(), and QDeclarativeBinding::update().
bool QScriptValue::isNumber | ( | ) | const |
Returns true if this QScriptValue is of the primitive type Number; otherwise returns false.
Definition at line 1937 of file qscriptvalue.cpp.
Referenced by _q_equal(), QScriptDebuggerBackendPrivate::exception(), QDeclarativeEnginePrivate::formatDate(), QDeclarativeEnginePrivate::formatDateTime(), QDeclarativeEnginePrivate::formatTime(), fromScriptValue(), QScript::IsNumerical(), QDeclarativeObjectMethodScriptClass::matchScore(), QScriptDebuggerValue::QScriptDebuggerValue(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QDeclarativeObjectScriptClass::setProperty(), and QScript::type().
bool QScriptValue::isObject | ( | ) | const |
Returns true if this QScriptValue is of the Object type; otherwise returns false.
Note that function values, variant values, and QObject values are objects, so this function returns true for such values.
Definition at line 2022 of file qscriptvalue.cpp.
Referenced by FlatListModel::addValue(), QDeclarativeListModel::append(), QScript::ClassObjectDelegate::construct(), QDeclarativeComponent::createObject(), QDeclarativeComponentPrivate::createObject(), QScript::Equals(), QScriptDebuggerCommandExecutor::execute(), fromScriptValue(), QJSDebuggerAgentPrivate::getLocals(), QDeclarativeListModel::insert(), instanceOf(), QScript::LessThan(), QScriptEngine::newQObject(), QScript::FunctionWrapper::proxyConstruct(), QScript::FunctionWithArgWrapper::proxyConstruct(), qmlsqldatabase_executeSql(), QScriptEngine::qScriptConnect(), QScriptDebuggerValue::QScriptDebuggerValue(), QScriptEngine::qScriptDisconnect(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QDeclarativeListModel::set(), QScriptContext::setActivationObject(), ModelNode::setListValue(), FlatListScriptClass::setProperty(), QScriptContext::setThisObject(), QScript::ToPrimitive(), and QScript::type().
bool QScriptValue::isQMetaObject | ( | ) | const |
Returns true if this QScriptValue is a QMetaObject; otherwise returns false.
Definition at line 2065 of file qscriptvalue.cpp.
bool QScriptValue::isQObject | ( | ) | const |
Returns true if this QScriptValue is a QObject; otherwise returns false.
Note: This function returns true even if the QObject that this QScriptValue wraps has been deleted.
Definition at line 2051 of file qscriptvalue.cpp.
Referenced by QScript::Equals(), fromScriptValue(), QDeclarativeObjectMethodScriptClass::matchScore(), QScriptEngine::newQObject(), QDeclarativeObjectMethodScriptClass::property(), and QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant().
bool QScriptValue::isRegExp | ( | ) | const |
Returns true if this QScriptValue is an object of the RegExp class; otherwise returns false.
Definition at line 539 of file qscriptvalue.cpp.
Referenced by FlatListModel::addValue(), fromScriptValue(), QDeclarativeObjectMethodScriptClass::matchScore(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QDeclarativeValueTypeScriptClass::setProperty(), FlatListScriptClass::setProperty(), QDeclarativeObjectScriptClass::setProperty(), and QDeclarativeBinding::update().
bool QScriptValue::isString | ( | ) | const |
Returns true if this QScriptValue is of the primitive type String; otherwise returns false.
Definition at line 1959 of file qscriptvalue.cpp.
Referenced by QScript::Equals(), QScriptDebuggerBackendPrivate::exception(), QDeclarativeEnginePrivate::formatDate(), QDeclarativeEnginePrivate::formatDateTime(), QDeclarativeEnginePrivate::formatTime(), fromScriptValue(), QScript::LessThan(), QDeclarativeObjectMethodScriptClass::matchScore(), QScriptDebuggerScriptedConsoleCommand::parse(), QScriptDebuggerValue::QScriptDebuggerValue(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QDeclarativeObjectScriptClass::setProperty(), QScriptContext::toString(), and QScript::type().
bool QScriptValue::isUndefined | ( | ) | const |
Returns true if this QScriptValue is of the primitive type Undefined; otherwise returns false.
Definition at line 2007 of file qscriptvalue.cpp.
Referenced by QScriptDebuggerBackend::doPendingEvaluate(), QScript::Equals(), QDeclarativeQtScriptExpression::eval(), fromScriptValue(), QDeclarativeObjectMethodScriptClass::property(), QScriptDebuggerValue::QScriptDebuggerValue(), QDeclarativeObjectScriptClass::setProperty(), QScriptDebuggerBackendPrivate::stepped(), and QScript::type().
bool QScriptValue::isValid | ( | ) | const |
Returns true if this QScriptValue is valid; otherwise returns false.
Definition at line 2077 of file qscriptvalue.cpp.
Referenced by QScript::__setupPackage__(), breakpointDataFromScriptValue(), call(), QDeclarativeInclude::callback(), construct(), QScript::Equals(), QScriptDebuggerCommandExecutor::execute(), QDeclarativeEnginePrivate::getContext(), QScript::ClassObjectDelegate::getOwnPropertyDescriptor(), QScript::ClassObjectDelegate::getOwnPropertySlot(), QDeclarativeEnginePrivate::getUrl(), QDeclarativeInclude::include(), lessThan(), QScriptEngine::newObject(), QScript::FunctionWrapper::proxyCall(), QScriptDebuggerValue::QScriptDebuggerValue(), QDeclarativeObjectScriptClass::queryProperty(), setData(), QDeclarativeObjectScriptClass::setProperty(), setScope(), and QScriptExtensionPlugin::setupPackage().
bool QScriptValue::isVariant | ( | ) | const |
Returns true if this QScriptValue is a variant value; otherwise returns false.
Definition at line 2034 of file qscriptvalue.cpp.
Referenced by FlatListModel::addValue(), QScript::Equals(), fromScriptValue(), QDeclarativeObjectMethodScriptClass::matchScore(), qscriptvalue_cast(), and FlatListScriptClass::setProperty().
bool QScriptValue::lessThan | ( | const QScriptValue & | other | ) | const |
Returns true if this QScriptValue is less than other, otherwise returns false.
The comparison follows the behavior described in ECMA-262 section 11.8.5, "The Abstract Relational Comparison Algorithm".
Note that if this QScriptValue or the 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).
Definition at line 843 of file qscriptvalue.cpp.
qint64 QScriptValue::objectId | ( | ) | const |
Returns the ID of this object, or -1 if this QScriptValue is not an object.
Definition at line 2216 of file qscriptvalue.cpp.
Referenced by fromScriptValue(), QJSDebuggerAgentPrivate::getLocals(), and QScriptDebuggerValue::QScriptDebuggerValue().
QScriptValue & QScriptValue::operator= | ( | const QScriptValue & | other | ) |
Assigns the other value to this QScriptValue.
Note that if other is an object (isObject() returns true), only a reference to the underlying object will be assigned; the object itself will not be copied.
Definition at line 485 of file qscriptvalue.cpp.
QScriptValue QScriptValue::property | ( | const QString & | name, |
const ResolveFlags & | mode = ResolvePrototype |
||
) | const |
Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property.
If no such property exists, an invalid QScriptValue is returned.
If the property is implemented using a getter function (i.e. has the PropertyGetter flag set), calling property() has side-effects on the script engine, since the getter function will be called (possibly resulting in an uncaught script exception). If an exception occurred, property() returns the value that was thrown (typically an Error
object).
Definition at line 1432 of file qscriptvalue.cpp.
Referenced by QScript::__setupPackage__(), QScriptContext::argument(), QScriptDebuggerBackend::attachTo(), breakpointDataFromScriptValue(), QDeclarativeComponentPrivate::createObject(), data(), debuggerScriptValuePropertyFromScriptValue(), QDeclarativeXMLHttpRequest::dispatchCallback(), do_dbus_call(), QScriptDebuggerBackendPrivate::exception(), QScriptEngineAgentPrivate::exceptionThrow(), QDeclarativeExpressionPrivate::exceptionToError(), QScriptDebuggerCommandExecutor::execute(), fromScriptValue(), QScriptEngine::importExtension(), QDeclarativeEnginePrivate::init(), instanceOf(), QScriptDebuggerScriptedConsoleCommand::parse(), QDeclarativeObjectMethodScriptClass::property(), QDBusConnectionConstructor::QDBusConnectionConstructor(), qmlsqldatabase_change_version(), qmlsqldatabase_executeSql(), qmlxmlhttprequest_onreadystatechange(), qScriptValueToSequence(), scriptDataFromScriptValue(), scriptValueToMessage(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QDeclarativeEnginePrivate::scriptValueToVariant(), ModelNode::setListValue(), QScriptExtensionPlugin::setupPackage(), QScriptEngine::uncaughtExceptionBacktrace(), and QScriptEngine::uncaughtExceptionLineNumber().
QScriptValue QScriptValue::property | ( | quint32 | arrayIndex, |
const ResolveFlags & | mode = ResolvePrototype |
||
) | const |
Returns the property at the given arrayIndex, using the given mode to resolve the property.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function is provided for convenience and performance when working with array objects.
If this QScriptValue is not an Array object, this function behaves as if property() was called with the string representation of arrayIndex.
Definition at line 1458 of file qscriptvalue.cpp.
QScriptValue QScriptValue::property | ( | const QScriptString & | name, |
const ResolveFlags & | mode = ResolvePrototype |
||
) | const |
Returns the value of this QScriptValue's property with the given name, using the given mode to resolve the property.
This overload of property() is useful when you need to look up the same property repeatedly, since the lookup can be performed faster when the name is represented as an interned string.
Definition at line 1515 of file qscriptvalue.cpp.
QScriptValue::PropertyFlags QScriptValue::propertyFlags | ( | const QString & | name, |
const ResolveFlags & | mode = ResolvePrototype |
||
) | const |
Returns the flags of the property with the given name, using the given mode to resolve the property.
Definition at line 1566 of file qscriptvalue.cpp.
Referenced by QScriptClassPropertyIterator::flags().
QScriptValue::PropertyFlags QScriptValue::propertyFlags | ( | const QScriptString & | name, |
const ResolveFlags & | mode = ResolvePrototype |
||
) | const |
Returns the flags of the property with the given name, using the given mode to resolve the property.
Definition at line 1589 of file qscriptvalue.cpp.
QScriptValue QScriptValue::prototype | ( | ) | const |
If this QScriptValue is an object, returns the internal prototype (__proto__
property) of this object; otherwise returns an invalid QScriptValue.
Definition at line 554 of file qscriptvalue.cpp.
Referenced by QScriptDebuggerCommandExecutor::execute().
QScriptValue QScriptValue::scope | ( | ) | const |
Definition at line 616 of file qscriptvalue.cpp.
QScriptClass * QScriptValue::scriptClass | ( | ) | const |
Returns the custom script class that this script object is an instance of, or 0 if the object is not of a custom class.
Definition at line 2154 of file qscriptvalue.cpp.
void QScriptValue::setData | ( | const QScriptValue & | data | ) |
Sets the internal data of this QScriptValue object.
You can use this function to set object-specific data that won't be directly accessible to scripts, but may be retrieved in C++ using the data() function.
Definition at line 2121 of file qscriptvalue.cpp.
Referenced by NamedNodeMap::create(), NodeList::create(), QDeclarativeWorkerScriptEnginePrivate::getWorker(), QScriptEngine::newObject(), QDeclarativeWorkerScriptEnginePrivate::processLoad(), qmlsqldatabase_executeSql(), qmlxmlhttprequest_new(), QScriptDebuggerBackend::traceFunction(), QDeclarativeWorkerScriptEnginePrivate::variantToScriptValue(), and QDeclarativeInclude::worker_include().
void QScriptValue::setProperty | ( | const QString & | name, |
const QScriptValue & | value, | ||
const PropertyFlags & | flags = KeepExistingFlags |
||
) |
Sets the value of this QScriptValue's property with the given name to the given value.
If this QScriptValue is not an object, this function does nothing.
If this QScriptValue does not already have a property with name name, a new property is created; the given flags then specify how this property may be accessed by script code.
If value is invalid, the property is removed.
If the property is implemented using a setter function (i.e. has the PropertySetter flag set), calling setProperty() has side-effects on the script engine, since the setter function will be called with the given value as argument (possibly resulting in an uncaught script exception).
Note that you cannot specify custom getter or setter functions for built-in properties, such as the length
property of Array objects or meta properties of QObject objects.
Definition at line 1399 of file qscriptvalue.cpp.
Referenced by QScript::__setupPackage__(), QScriptDebuggerBackend::attachTo(), breakpointDataToScriptValue(), breakpointMapToScriptValue(), QDeclarativeInclude::callback(), consoleCommandGroupDataToScriptValue(), consoleCommandGroupMapToScriptValue(), consoleCommandToScriptValue(), contextInfoToScriptValue(), QDeclarativeComponentPrivate::createObject(), QDeclarativeEnginePrivate::createQmlObject(), debuggerResponseToScriptValue(), debuggerScriptValuePropertyToScriptValue(), QScriptDebuggerBackend::detach(), QScriptDebuggerCommandExecutor::execute(), QDeclarativeGlobalScriptClass::explicitSetProperty(), QDeclarativeInclude::finished(), QDeclarativeXmlListModel::get(), QDeclarativeWorkerScriptEnginePrivate::getWorker(), QScriptEngine::importExtension(), QDeclarativeInclude::include(), QDeclarativeEnginePrivate::init(), QtDBusScriptPlugin::initialize(), QDeclarativeItem::mapFromItem(), QDeclarativeItem::mapToItem(), messageToScriptValue(), QScriptEngine::newFunction(), QScriptDebuggerScriptedConsoleCommand::parse(), QDeclarativeWorkerScriptEnginePrivate::processMessage(), QDeclarativeObjectMethodScriptClass::property(), ModelNodeMetaObject::propertyWritten(), NamedNodeMap::prototype(), NodeList::prototype(), Node::prototype(), Element::prototype(), Attr::prototype(), CharacterData::prototype(), Text::prototype(), Document::prototype(), QDBusConnectionConstructor::QDBusConnectionConstructor(), qDBusErrorToScriptValue(), qDBusReplyToScriptValue(), QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(), QDeclarativeScriptEngine::QDeclarativeScriptEngine(), qmlsqldatabase_change_version(), qmlsqldatabase_executeSql(), qmlsqldatabase_item(), qmlsqldatabase_open_sync(), qmlsqldatabase_transaction_shared(), qmlxmlhttprequest_onreadystatechange(), QScriptDebuggerBackendPrivate::qsassert(), QScriptDBusInterfaceConstructor::QScriptDBusInterfaceConstructor(), QScriptDBusMessageConstructor::QScriptDBusMessageConstructor(), qScriptValueFromSequence(), qt_add_qmlsqldatabase(), qt_add_qmlxmlhttprequest(), QDeclarativeInclude::resultValue(), scriptDataToScriptValue(), scriptMapToScriptValue(), QDeclarativeEnginePrivate::scriptValueFromVariant(), QJSDebuggerAgent::setProperty(), setupDBusInterface(), QScriptExtensionPlugin::setupPackage(), QDeclarativeWorkerScriptEnginePrivate::variantToScriptValue(), and QDeclarativeInclude::worker_include().
void QScriptValue::setProperty | ( | quint32 | arrayIndex, |
const QScriptValue & | value, | ||
const PropertyFlags & | flags = KeepExistingFlags |
||
) |
Sets the property at the given arrayIndex to the given value.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function is provided for convenience and performance when working with array objects.
If this QScriptValue is not an Array object, this function behaves as if setProperty() was called with the string representation of arrayIndex.
Definition at line 1483 of file qscriptvalue.cpp.
void QScriptValue::setProperty | ( | const QScriptString & | name, |
const QScriptValue & | value, | ||
const PropertyFlags & | flags = KeepExistingFlags |
||
) |
Sets the value of this QScriptValue's property with the given name to the given value.
The given flags specify how this property may be accessed by script code.
This overload of setProperty() is useful when you need to set the same property repeatedly, since the operation can be performed faster when the name is represented as an interned string.
Definition at line 1541 of file qscriptvalue.cpp.
void QScriptValue::setPrototype | ( | const QScriptValue & | prototype | ) |
If this QScriptValue is an object, sets the internal prototype (__proto__
property) of this object to be 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.
Definition at line 573 of file qscriptvalue.cpp.
Referenced by NamedNodeMap::create(), NodeList::create(), Node::create(), Document::load(), QScriptEngine::newObject(), Element::prototype(), Attr::prototype(), CharacterData::prototype(), Text::prototype(), CDATA::prototype(), Document::prototype(), and QDBusConnectionConstructor::QDBusConnectionConstructor().
void QScriptValue::setScope | ( | const QScriptValue & | scope | ) |
Definition at line 630 of file qscriptvalue.cpp.
void QScriptValue::setScriptClass | ( | QScriptClass * | scriptClass | ) |
Sets the custom script class of this script object to scriptClass.
This can be used to "promote" a plain script object (e.g. created by the "new" operator in a script, or by QScriptEngine::newObject() in C++) to an object of a custom type.
If scriptClass is 0, the object will be demoted to a plain script object.
Definition at line 2182 of file qscriptvalue.cpp.
Referenced by NamedNodeMap::create(), NodeList::create(), QDeclarativeGlobalScriptClass::explicitSetProperty(), and QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass().
bool QScriptValue::strictlyEquals | ( | const QScriptValue & | other | ) | const |
Returns true if this QScriptValue is equal to other using strict comparison (no conversion), otherwise returns false.
The comparison follows the behavior described in ECMA-262 section 11.9.6, "The Strict Equality Comparison Algorithm".
If the type of this QScriptValue is different from the type of the other value, this function returns false. If the types are equal, the result depends on the type, as shown in the following table:
Type | Result |
Undefined | true |
Null | true |
Boolean | true if both values are true, false otherwise |
Number | false if either value is NaN (Not-a-Number); true if values are equal, false otherwise |
String | true if both values are exactly the same sequence of characters, false otherwise |
Object | true if both values refer to the same object, false otherwise |
Definition at line 934 of file qscriptvalue.cpp.
Referenced by _q_equal(), and QScript::Equals().
bool QScriptValue::toBool | ( | ) | const |
Returns the boolean value of this QScriptValue, using the conversion rules described in 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).
Definition at line 1088 of file qscriptvalue.cpp.
Referenced by QScript::Equals(), QScript::LessThan(), QDeclarativeObjectMethodScriptClass::property(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), and QDeclarativeSqlQueryScriptClass::setProperty().
bool QScriptValue::toBoolean | ( | ) | const |
Use toBool() instead.
Definition at line 1049 of file qscriptvalue.cpp.
Referenced by breakpointDataFromScriptValue(), QScriptDebuggerAgent::positionChange(), qmlxmlhttprequest_open(), QScriptDebuggerBackendPrivate::qsassert(), QScriptDebuggerValue::QScriptDebuggerValue(), and scriptValueToMessage().
QDateTime QScriptValue::toDateTime | ( | ) | const |
Returns a QDateTime representation of this value, in local time.
If this QScriptValue is not a date, or the value of the date is NaN (Not-a-Number), an invalid QDateTime is returned.
Definition at line 1313 of file qscriptvalue.cpp.
Referenced by QDeclarativeEnginePrivate::formatDate(), QDeclarativeEnginePrivate::formatDateTime(), QDeclarativeEnginePrivate::formatTime(), fromScriptValue(), and QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant().
qint32 QScriptValue::toInt32 | ( | ) | const |
Returns the signed 32-bit integer value of this QScriptValue, using the conversion rules described in 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).
Definition at line 1122 of file qscriptvalue.cpp.
Referenced by breakpointDataFromScriptValue(), debuggerScriptValuePropertyFromScriptValue(), QDeclarativeObjectScriptClass::destroy(), QScriptDebuggerBackendPrivate::exception(), QScriptEngineAgentPrivate::exceptionThrow(), QDeclarativeObjectMethodScriptClass::property(), qmlsqldatabase_executeSql(), scriptDataFromScriptValue(), QDeclarativeEnginePrivate::scriptValueToVariant(), ModelNode::setListValue(), QScriptEngine::uncaughtExceptionBacktrace(), and QScriptEngine::uncaughtExceptionLineNumber().
qsreal QScriptValue::toInteger | ( | ) | const |
Returns the integer value of this QScriptValue, using the conversion rules described in 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).
Definition at line 1224 of file qscriptvalue.cpp.
qsreal QScriptValue::toNumber | ( | ) | const |
Returns the number value of this QScriptValue, as defined in 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).
Definition at line 1019 of file qscriptvalue.cpp.
Referenced by _q_equal(), breakpointDataFromScriptValue(), QDeclarativeEnginePrivate::darker(), QScript::Equals(), QDeclarativeEnginePrivate::hsla(), QScript::LessThan(), QDeclarativeEnginePrivate::lighter(), QDeclarativeEnginePrivate::point(), QDeclarativeObjectMethodScriptClass::property(), qmlsqldatabase_item(), qmlsqldatabase_open_sync(), QScriptDebuggerValue::QScriptDebuggerValue(), QDeclarativeEnginePrivate::rect(), QDeclarativeEnginePrivate::rgba(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QDeclarativeObjectScriptClass::setProperty(), QDeclarativeEnginePrivate::size(), and QDeclarativeEnginePrivate::vector3d().
QScriptValue QScriptValue::toObject | ( | ) | const |
This function is obsolete; use QScriptEngine::toObject() instead.
Definition at line 1298 of file qscriptvalue.cpp.
const QMetaObject * QScriptValue::toQMetaObject | ( | ) | const |
If this QScriptValue is a QMetaObject, returns the QMetaObject pointer that the QScriptValue represents; otherwise, returns 0.
Definition at line 1365 of file qscriptvalue.cpp.
QObject * QScriptValue::toQObject | ( | ) | const |
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).
Definition at line 1350 of file qscriptvalue.cpp.
Referenced by do_dbus_call(), QScript::Equals(), fromScriptValue(), QDeclarativeEnginePrivate::isQtObject(), QDeclarativeItem::mapFromItem(), QDeclarativeItem::mapToItem(), QDeclarativeObjectMethodScriptClass::property(), qmlxmlhttprequest_abort(), qmlxmlhttprequest_getAllResponseHeaders(), qmlxmlhttprequest_getResponseHeader(), qmlxmlhttprequest_onreadystatechange(), qmlxmlhttprequest_open(), qmlxmlhttprequest_readyState(), qmlxmlhttprequest_responseText(), qmlxmlhttprequest_responseXML(), qmlxmlhttprequest_send(), qmlxmlhttprequest_setRequestHeader(), qmlxmlhttprequest_status(), qmlxmlhttprequest_statusText(), QScriptDBusInterfaceConstructor::qscript_call(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QDeclarativeEnginePrivate::scriptValueToVariant(), QScriptDebuggerScriptedConsoleCommandJob::start(), QDeclarativeObjectScriptClass::toQObject(), and QDeclarativeObjectScriptClass::tostring().
QRegExp QScriptValue::toRegExp | ( | ) | const |
Returns the QRegExp representation of this value.
If this QScriptValue is not a regular expression, an empty QRegExp is returned.
Definition at line 1330 of file qscriptvalue.cpp.
Referenced by QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant().
QString QScriptValue::toString | ( | ) | const |
Returns the string value of this QScriptValue, as defined in 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).
Definition at line 986 of file qscriptvalue.cpp.
Referenced by QScript::__setupPackage__(), QDeclarativeEnginePrivate::atob(), breakpointDataFromScriptValue(), QDeclarativeEnginePrivate::btoa(), QDeclarativeEnginePrivate::consoleLog(), QDeclarativeEnginePrivate::createComponent(), QScriptDBusMessageConstructor::createErrorReply(), QDeclarativeEnginePrivate::createQmlObject(), debuggerScriptValuePropertyFromScriptValue(), QDeclarativeEnginePrivate::desktopOpenUrl(), do_dbus_call(), QScriptDebuggerBackend::doPendingEvaluate(), QScript::Equals(), QScriptDebuggerBackendPrivate::exception(), QDeclarativeExpressionPrivate::exceptionToError(), QScriptDebuggerCommandExecutor::execute(), QDeclarativeEnginePrivate::formatDate(), QDeclarativeEnginePrivate::formatDateTime(), QDeclarativeEnginePrivate::formatTime(), fromScriptValue(), QJSDebuggerAgent::functionExit(), QScriptDebuggerScriptedConsoleCommandJob::handleResponse(), QDeclarativeInclude::include(), QDeclarativeExpressionPrivate::init(), QScript::LessThan(), QDeclarativeItem::mapFromItem(), QDeclarativeItem::mapToItem(), QDeclarativeEnginePrivate::md5(), QScriptDebuggerScriptedConsoleCommand::parse(), QDeclarativeObjectMethodScriptClass::property(), qmlsqldatabase_change_version(), qmlsqldatabase_executeSql(), qmlsqldatabase_executeSql_readonly(), qmlsqldatabase_open_sync(), qmlxmlhttprequest_getResponseHeader(), qmlxmlhttprequest_open(), qmlxmlhttprequest_send(), qmlxmlhttprequest_setRequestHeader(), QScriptDebuggerBackendPrivate::qsassert(), QScriptDebuggerValue::QScriptDebuggerValue(), QDeclarativeScriptEngine::resolvedUrl(), scriptDataFromScriptValue(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QDeclarativeObjectScriptClass::setProperty(), QScriptDebuggerScriptedConsoleCommandJob::start(), QScriptDebuggerBackendPrivate::stepped(), QJSDebuggerAgentPrivate::stopped(), QScriptContext::toString(), QScriptDebuggerBackendPrivate::trace(), QScriptEngine::uncaughtExceptionBacktrace(), and QDeclarativeInclude::worker_include().
quint16 QScriptValue::toUInt16 | ( | ) | const |
Returns the unsigned 16-bit integer value of this QScriptValue, using the conversion rules described in 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).
Definition at line 1190 of file qscriptvalue.cpp.
quint32 QScriptValue::toUInt32 | ( | ) | const |
Returns the unsigned 32-bit integer value of this QScriptValue, using the conversion rules described in 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).
Definition at line 1156 of file qscriptvalue.cpp.
Referenced by call(), construct(), QDeclarativeEnginePrivate::formatDate(), QDeclarativeEnginePrivate::formatDateTime(), QDeclarativeEnginePrivate::formatTime(), QDeclarativeObjectMethodScriptClass::property(), qScriptValueToSequence(), and scriptValueToMessage().
QVariant QScriptValue::toVariant | ( | ) | const |
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:
Input Type | Result |
Undefined | An invalid QVariant. |
Null | An invalid QVariant. |
Boolean | A QVariant containing the value of the boolean. |
Number | A QVariant containing the value of the number. |
String | A QVariant containing the value of the string. |
QVariant Object | The result is the QVariant value of the object (no conversion). |
QObject Object | A QVariant containing a pointer to the QObject. |
Date Object | A QVariant containing the date value (toDateTime()). |
RegExp Object | A QVariant containing the regular expression value (toRegExp()). |
Array Object | The array is converted to a QVariantList. Each element is converted to a QVariant, recursively; cyclic references are not followed. |
Object | The object is converted to a QVariantMap. Each property is converted to a QVariant, recursively; cyclic references are not followed. |
Definition at line 1268 of file qscriptvalue.cpp.
Referenced by FlatListModel::addValue(), QScriptDBusMessageConstructor::createReply(), QDeclarativeEnginePrivate::darker(), do_dbus_call(), QScript::Equals(), QDeclarativeEnginePrivate::formatTime(), QDeclarativeEnginePrivate::lighter(), QDeclarativeObjectMethodScriptClass::matchScore(), QDeclarativeWorkerScriptEnginePrivate::onMessage(), qmlsqldatabase_executeSql(), qscriptvalue_cast(), scriptValueToMessage(), QDeclarativeEnginePrivate::scriptValueToVariant(), QDeclarativeWorkerScriptEnginePrivate::sendMessage(), ModelNode::setListValue(), ModelNode::setObjectValue(), FlatListScriptClass::setProperty(), and QDeclarativeEnginePrivate::tint().
|
friend |
Definition at line 213 of file qscriptvalue.h.
|
related |
Returns the given value converted to the template type T
.
Definition at line 344 of file qscriptengine.h.
Referenced by debuggerScriptValuePropertyFromScriptValue(), and qscriptQMetaObjectConstructor().
|
private |
Definition at line 209 of file qscriptvalue.h.
Referenced by equals(), QScriptValuePrivate::getEngine(), objectId(), operator=(), QScriptValue(), and strictlyEquals().