Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qjsvalue.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtCore/qstring.h>
5#include <QtCore/qvarlengtharray.h>
6#include <QtCore/qdatetime.h>
7#include "qjsvalue.h"
8#include "qjsprimitivevalue.h"
9#include "qjsmanagedvalue.h"
10#include "qjsvalue_p.h"
11#include "qv4value_p.h"
12#include "qv4object_p.h"
13#include "qv4functionobject_p.h"
14#include "qv4dateobject_p.h"
15#include "qv4runtime_p.h"
16#include "qv4variantobject_p.h"
17#include "qv4regexpobject_p.h"
18#include "qv4errorobject_p.h"
19#include <private/qv4mm_p.h>
20#include <private/qv4jscall_p.h>
21#include <private/qv4qobjectwrapper_p.h>
22#include <private/qv4urlobject_p.h>
23
176
177using namespace QV4;
178
183{
184}
185
190{
191}
192
197{
198}
199
204{
205}
206
211{
212}
213
218 : d(value == NullValue ? QJSValuePrivate::encodeNull() : QJSValuePrivate::encodeUndefined())
219{
220}
221
226{
227}
228
232#ifndef QT_NO_CAST_FROM_ASCII
234{
235}
236#endif
237
246{
247 switch (QJSValuePrivate::tag(d)) {
252 return;
255 return;
258 return;
261 break;
262 }
263}
264
281{
283}
284
292{
294}
295
303{
304 switch (QJSValuePrivate::tag(d)) {
307 return true;
308 default:
309 break;
310 }
311
312 return false;
313}
314
320{
322}
323
331{
332 switch (QJSValuePrivate::tag(d)) {
334 return true;
337 }
338 default:
339 break;
340 }
341
342 return false;
343}
344
350{
351 switch (QJSValuePrivate::tag(d)) {
353 return true;
356 default:
357 break;
358 }
359
360 return false;
361}
362
370{
371 return QJSValuePrivate::asManagedType<ErrorObject>(this);
372}
373
378bool QJSValue::isUrl() const
379{
380 return QJSValuePrivate::asManagedType<UrlObject>(this);
381}
382
391{
392 const QV4::ErrorObject *error = QJSValuePrivate::asManagedType<ErrorObject>(this);
393 if (!error)
394 return NoError;
395 switch (error->d()->errorType) {
396 case QV4::Heap::ErrorObject::Error:
397 return GenericError;
398 case QV4::Heap::ErrorObject::EvalError:
399 return EvalError;
400 case QV4::Heap::ErrorObject::RangeError:
401 return RangeError;
402 case QV4::Heap::ErrorObject::ReferenceError:
403 return ReferenceError;
404 case QV4::Heap::ErrorObject::SyntaxError:
405 return SyntaxError;
406 case QV4::Heap::ErrorObject::TypeError:
407 return TypeError;
408 case QV4::Heap::ErrorObject::URIError:
409 return URIError;
410 }
411 Q_UNREACHABLE_RETURN(NoError);
412}
413
421{
422 return QJSValuePrivate::asManagedType<ArrayObject>(this);
423}
424
435{
436 return QJSValuePrivate::asManagedType<QV4::Object>(this);
437}
438
446{
447 return QJSValuePrivate::asManagedType<FunctionObject>(this);
448}
449
457{
458 return QJSValuePrivate::asManagedType<QV4::VariantObject>(this);
459}
460
474{
475 if (const QString *string = QJSValuePrivate::asQString(this))
476 return *string;
477
479}
480
481template<typename T>
482T caughtResult(const QJSValue *v, T (QV4::Value::*convert)() const)
483{
486 if (engine && engine->hasException) {
487 engine->catchException();
488 return T();
489 }
490 return result;
491}
492
505double QJSValue::toNumber() const
506{
507 if (const QString *string = QJSValuePrivate::asQString(this))
508 return RuntimeHelpers::stringToNumber(*string);
509
510 return caughtResult<double>(this, &QV4::Value::toNumber);
511}
512
526{
527 if (const QString *string = QJSValuePrivate::asQString(this))
528 return string->size() > 0;
529
530 return caughtResult<bool>(this, &QV4::Value::toBoolean);
531}
532
546{
547 if (const QString *string = QJSValuePrivate::asQString(this))
549
550 return caughtResult<qint32>(this, &QV4::Value::toInt32);
551}
552
566{
567 if (const QString *string = QJSValuePrivate::asQString(this))
569
570 return caughtResult<quint32>(this, &QV4::Value::toUInt32);
571}
572
581{
583}
584
617{
618 if (const QString *string = QJSValuePrivate::asQString(this))
619 return QVariant(*string);
620
622 if (val.isUndefined())
623 return QVariant();
624 if (val.isNull())
625 return QVariant(QMetaType::fromType<std::nullptr_t>(), nullptr);
626 if (val.isBoolean())
627 return QVariant(val.booleanValue());
628 if (val.isInt32()) // Includes doubles that can be losslessly casted to int
629 return QVariant(val.integerValue());
630 if (val.isNumber())
631 return QVariant(val.doubleValue());
632
633 Q_ASSERT(val.isManaged());
634
635 if (val.isString())
636 return QVariant(val.toQString());
637 if (val.as<QV4::Managed>()) {
639 val, /*typeHint*/ QMetaType{}, behavior == RetainJSObjects);
640 }
641
642 Q_ASSERT(false);
643 return QVariant();
644}
645
658{
659 if (const QString *string = QJSValuePrivate::asQString(this))
660 return *string;
661
664}
665
682{
683 const FunctionObject *f = QJSValuePrivate::asManagedType<FunctionObject>(this);
684 if (!f)
685 return QJSValue();
686
689
690 Scope scope(engine);
691 JSCallArguments jsCallData(scope, args.size());
692 *jsCallData.thisObject = engine->globalObject;
693 for (int i = 0; i < args.size(); ++i) {
695 qWarning("QJSValue::call() failed: cannot call function with argument created in a different engine");
696 return QJSValue();
697 }
699 }
700
701 ScopedValue result(scope, f->call(jsCallData));
702 if (engine->hasException)
703 result = engine->catchException();
704 if (engine->isInterrupted.loadRelaxed())
705 result = engine->newErrorObject(QStringLiteral("Interrupted"));
706
707 return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
708}
709
731{
732 const FunctionObject *f = QJSValuePrivate::asManagedType<FunctionObject>(this);
733 if (!f)
734 return QJSValue();
735
738 Scope scope(engine);
739
740 if (!QJSValuePrivate::checkEngine(engine, instance)) {
741 qWarning("QJSValue::call() failed: cannot call function with thisObject created in a different engine");
742 return QJSValue();
743 }
744
745 JSCallArguments jsCallData(scope, args.size());
747 for (int i = 0; i < args.size(); ++i) {
749 qWarning("QJSValue::call() failed: cannot call function with argument created in a different engine");
750 return QJSValue();
751 }
753 }
754
755 ScopedValue result(scope, f->call(jsCallData));
756 if (engine->hasException)
757 result = engine->catchException();
758 if (engine->isInterrupted.loadRelaxed())
759 result = engine->newErrorObject(QStringLiteral("Interrupted"));
760
761 return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
762}
763
783{
784 const FunctionObject *f = QJSValuePrivate::asManagedType<FunctionObject>(this);
785 if (!f)
786 return QJSValue();
787
790
791 Scope scope(engine);
792 JSCallArguments jsCallData(scope, args.size());
793 for (int i = 0; i < args.size(); ++i) {
795 qWarning("QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine");
796 return QJSValue();
797 }
799 }
800
801 ScopedValue result(scope, f->callAsConstructor(jsCallData));
802 if (engine->hasException)
803 result = engine->catchException();
804 if (engine->isInterrupted.loadRelaxed())
805 result = engine->newErrorObject(QStringLiteral("Interrupted"));
806
807 return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
808}
809
818{
820 if (!engine)
821 return QJSValue();
822 QV4::Scope scope(engine);
823 ScopedObject o(scope, QJSValuePrivate::asManagedType<QV4::Object>(this));
824 if (!o)
825 return QJSValue();
826 ScopedObject p(scope, o->getPrototypeOf());
827 if (!p)
828 return QJSValue(NullValue);
829 return QJSValuePrivate::fromReturnedValue(p.asReturnedValue());
830}
831
844void QJSValue::setPrototype(const QJSValue& prototype)
845{
847 if (!engine)
848 return;
849 Scope scope(engine);
851 if (!o)
852 return;
854 if (val.isNull()) {
855 o->setPrototypeOf(nullptr);
856 return;
857 }
858
859 ScopedObject p(scope, val);
860 if (!p)
861 return;
862 if (o->engine() != p->engine()) {
863 qWarning("QJSValue::setPrototype() failed: cannot set a prototype created in a different engine");
864 return;
865 }
866 if (!o->setPrototypeOf(p))
867 qWarning("QJSValue::setPrototype() failed: cyclic prototype value");
868}
869
878{
879 if (d == other.d)
880 return *this;
881
883 d = 0;
884
885 if (const QString *string = QJSValuePrivate::asQString(&other))
886 QJSValuePrivate::setString(this, *string);
887 else
889
890 return *this;
891}
892
894{
895 switch (value.type()) {
898 return;
901 return;
903 d = QJSValuePrivate::encode(value.asBoolean());
904 return;
906 d = QJSValuePrivate::encode(value.asInteger());
907 return;
909 d = QJSValuePrivate::encode(value.asDouble());
910 return;
912 d = QJSValuePrivate::encode(value.asString());
913 return;
914 }
915
916 Q_UNREACHABLE();
917}
918
920{
921 if (!value.d) {
923 } else if (value.d->isManaged()) {
924 // If it's managed, we can adopt the persistent value.
926 value.d = nullptr;
927 } else {
930 value.d = nullptr;
931 }
932}
933
934static bool js_equal(const QString &string, const QV4::Value &value)
935{
936 if (String *s = value.stringValue())
937 return string == s->toQString();
938 if (value.isNumber())
939 return RuntimeHelpers::stringToNumber(string) == value.asDouble();
940 if (value.isBoolean())
941 return RuntimeHelpers::stringToNumber(string) == double(value.booleanValue());
942 if (QV4::Object *o = value.objectValue()) {
943 Scope scope(o->engine());
945 return js_equal(string, p);
946 }
947 return false;
948}
949
975{
976 if (const QString *string = QJSValuePrivate::asQString(this)) {
977 if (const QString *otherString = QJSValuePrivate::asQString(&other))
978 return *string == *otherString;
980 }
981
982 if (const QString *otherString = QJSValuePrivate::asQString(&other))
983 return js_equal(*otherString, QJSValuePrivate::asReturnedValue(this));
984
987}
988
1012{
1013 if (const QString *string = QJSValuePrivate::asQString(this)) {
1014 if (const QString *otherString = QJSValuePrivate::asQString(&other))
1015 return *string == *otherString;
1016 if (const String *s = QJSValuePrivate::asManagedType<String>(&other))
1017 return *string == s->toQString();
1018 return false;
1019 }
1020
1021 if (const QString *otherString = QJSValuePrivate::asQString(&other)) {
1022 if (const String *s = QJSValuePrivate::asManagedType<String>(this))
1023 return *otherString == s->toQString();
1024 return false;
1025 }
1026
1029}
1030
1049{
1051 if (!engine)
1052 return QJSValue();
1053
1054 QV4::Scope scope(engine);
1056 if (!o)
1057 return QJSValue();
1058
1059 ScopedString s(scope, engine->newString(name));
1060 QV4::ScopedValue result(scope, o->get(s->toPropertyKey()));
1061 if (engine->hasException)
1062 result = engine->catchException();
1063
1064 return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
1065}
1066
1097{
1099 if (!engine)
1100 return QJSValue();
1101
1102 QV4::Scope scope(engine);
1104 if (!o)
1105 return QJSValue();
1106
1107 QV4::ScopedValue result(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax()) : o->get(arrayIndex));
1108 if (engine->hasException)
1109 engine->catchException();
1110 return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
1111}
1112
1129{
1131 if (!engine)
1132 return;
1133 Scope scope(engine);
1134
1136 if (!o)
1137 return;
1138
1140 qWarning("QJSValue::setProperty(%s) failed: cannot set value created in a different engine", name.toUtf8().constData());
1141 return;
1142 }
1143
1144 ScopedString s(scope, engine->newString(name));
1146 o->put(s->toPropertyKey(), v);
1147 if (engine->hasException)
1148 engine->catchException();
1149}
1150
1183{
1185 if (!engine)
1186 return;
1187 Scope scope(engine);
1188
1190 if (!o)
1191 return;
1192
1194 qWarning("QJSValue::setProperty(%d) failed: cannot set value created in a different engine", arrayIndex);
1195 return;
1196 }
1197
1199 PropertyKey id = arrayIndex != UINT_MAX ? PropertyKey::fromArrayIndex(arrayIndex) : engine->id_uintMax()->propertyKey();
1200 o->put(id, v);
1201 if (engine->hasException)
1202 engine->catchException();
1203}
1204
1226{
1228 if (!engine)
1229 return false;
1230
1231 Scope scope(engine);
1233 if (!o)
1234 return false;
1235
1236 ScopedString s(scope, engine->newString(name));
1237 return o->deleteProperty(s->toPropertyKey());
1238}
1239
1247{
1249 if (!engine)
1250 return false;
1251
1252 Scope scope(engine);
1254 if (!o)
1255 return false;
1256
1257 ScopedString s(scope, engine->newString(name));
1258 return o->hasProperty(s->toPropertyKey());
1259}
1260
1268{
1270 if (!engine)
1271 return false;
1272
1273 Scope scope(engine);
1275 if (!o)
1276 return false;
1277
1278 ScopedString s(scope, engine->newIdentifier(name));
1279 return o->getOwnProperty(s->propertyKey()) != Attr_Invalid;
1280}
1281
1293{
1295 if (!engine)
1296 return nullptr;
1297 QV4::Scope scope(engine);
1299 if (!wrapper)
1300 return nullptr;
1301
1302 return wrapper->object();
1303}
1304
1314{
1316 if (!engine)
1317 return nullptr;
1318 QV4::Scope scope(engine);
1320 if (!wrapper)
1321 return nullptr;
1322
1323 return wrapper->metaObject();
1324}
1325
1326
1335{
1336 if (const QV4::DateObject *date = QJSValuePrivate::asManagedType<DateObject>(this))
1337 return date->toQDateTime();
1338 return QDateTime();
1339}
1340
1346{
1347 return QJSValuePrivate::asManagedType<DateObject>(this);
1348}
1349
1355{
1356 return QJSValuePrivate::asManagedType<RegExpObject>(this);
1357}
1358
1369{
1370 return QJSValuePrivate::asManagedType<QV4::QObjectWrapper>(this);
1371}
1372
1382{
1383 return QJSValuePrivate::asManagedType<QV4::QMetaObjectWrapper>(this);
1384}
1385
1386#ifndef QT_NO_DATASTREAM
1388{
1389 quint32 isNullOrUndefined = 0;
1390 if (jsv.isNull())
1391 isNullOrUndefined |= 0x1;
1392 if (jsv.isUndefined())
1393 isNullOrUndefined |= 0x2;
1394 stream << isNullOrUndefined;
1395 if (!isNullOrUndefined) {
1396 const QVariant v = jsv.toVariant();
1397 switch (v.userType()) {
1398 case QMetaType::Bool:
1399 case QMetaType::Double:
1400 case QMetaType::Int:
1401 case QMetaType::QString:
1402 v.save(stream);
1403 break;
1404 default:
1405 qWarning() << "QDataStream::operator<< was to save a non-trivial QJSValue."
1406 << "This is not supported anymore, please stream a QVariant instead.";
1407 QVariant().save(stream);
1408 break;
1409 }
1410
1411 }
1412 return stream;
1413}
1414
1416{
1417 quint32 isNullOrUndefined;
1418 stream >> isNullOrUndefined;
1419
1420 if (isNullOrUndefined & 0x1) {
1422 } else if (isNullOrUndefined & 0x2) {
1423 jsv = QJSValue();
1424 } else {
1425 QVariant v;
1426 v.load(stream);
1427
1428 switch (v.userType()) {
1429 case QMetaType::Bool:
1430 jsv = QJSValue(v.toBool());
1431 break;
1432 case QMetaType::Double:
1433 jsv = QJSValue(v.toDouble());
1434 break;
1435 case QMetaType::Int:
1436 jsv = QJSValue(v.toInt());
1437 break;
1438 case QMetaType::QString:
1439 jsv = QJSValue(v.toString());
1440 break;
1441 default:
1442 qWarning() << "QDataStream::operator>> to restore a non-trivial QJSValue."
1443 << "This is not supported anymore, please stream a QVariant instead.";
1444 break;
1445 }
1446 }
1447 return stream;
1448}
1449#endif
1450
\inmodule QtCore\reentrant
Definition qdatastream.h:30
\inmodule QtCore\reentrant
Definition qdatetime.h:257
QJSValue globalObject() const
Returns this engine's Global Object.
QJSValue newErrorObject(QJSValue::ErrorType errorType, const QString &message=QString())
bool isInterrupted() const
\inmodule QtQml
The QJSPrimitiveValue class operates on primitive types in JavaScript semantics.
static QJSValue fromReturnedValue(QV4::ReturnedValue d)
Definition qjsvalue_p.h:189
static void setString(QJSValue *jsval, QString s)
Definition qjsvalue_p.h:270
static QV4::Value * qv4ValuePtr(quint64 v)
Definition qjsvalue_p.h:139
static double * doublePtr(quint64 v)
Definition qjsvalue_p.h:128
static bool checkEngine(QV4::ExecutionEngine *e, const QJSValue &jsval)
Definition qjsvalue_p.h:323
static QV4::ExecutionEngine * engine(const QJSValue *jsval)
Definition qjsvalue_p.h:313
static QV4::ReturnedValue asReturnedValue(const QJSValue *jsval)
Definition qjsvalue_p.h:249
static const QString * asQString(const QJSValue *jsval)
Definition qjsvalue_p.h:240
static quint64 encodeNull()
Definition qjsvalue_p.h:94
static QString * qStringPtr(quint64 v)
Definition qjsvalue_p.h:173
static QV4::ReturnedValue convertToReturnedValue(QV4::ExecutionEngine *e, const QJSValue &jsval)
Definition qjsvalue_p.h:298
static void adoptPersistentValue(QJSValue *jsval, QV4::Value *v)
Definition qjsvalue_p.h:277
static void setValue(QJSValue *jsval, const QV4::Value &v)
Definition qjsvalue_p.h:282
static quint64 encode(int intValue)
Definition qjsvalue_p.h:105
static quint64 encodeUndefined()
Definition qjsvalue_p.h:89
static void free(QJSValue *jsval)
Definition qjsvalue_p.h:329
static Kind tag(quint64 raw)
Definition qjsvalue_p.h:56
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
QDateTime toDateTime() const
Returns a QDateTime representation of this value, in local time.
bool hasOwnProperty(const QString &name) const
Returns true if this object has an own (not prototype-inherited) property of the given name,...
bool isUrl() const
Returns true if this QJSValue is an object of the URL class; otherwise returns false.
Definition qjsvalue.cpp:378
@ RangeError
Definition qjsvalue.h:42
@ SyntaxError
Definition qjsvalue.h:44
@ ReferenceError
Definition qjsvalue.h:43
@ URIError
Definition qjsvalue.h:46
@ GenericError
Definition qjsvalue.h:40
@ EvalError
Definition qjsvalue.h:41
@ TypeError
Definition qjsvalue.h:45
@ NoError
Definition qjsvalue.h:39
bool isVariant() const
Returns true if this QJSValue is a variant value; otherwise returns false.
Definition qjsvalue.cpp:456
bool isCallable() const
Returns true if this QJSValue is a function, otherwise returns false.
Definition qjsvalue.cpp:445
bool hasProperty(const QString &name) const
Returns true if this object has a property of the given name, otherwise returns false.
bool deleteProperty(const QString &name)
Attempts to delete this object's property of the given name.
SpecialValue
This enum is used to specify a single-valued type.
Definition qjsvalue.h:33
@ NullValue
Definition qjsvalue.h:34
QJSValue & operator=(QJSValue &&other)
Move-assigns other to this QJSValue object.
Definition qjsvalue.h:60
bool toBool() const
Returns the boolean value of this QJSValue, using the conversion rules described in \l{ECMA-262} sect...
Definition qjsvalue.cpp:525
QJSValue call(const QJSValueList &args=QJSValueList()) const
Calls this QJSValue as a function, passing args as arguments to the function, and using the globalObj...
Definition qjsvalue.cpp:681
ErrorType errorType() const
Definition qjsvalue.cpp:390
QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &args=QJSValueList()) const
Calls this QJSValue as a function, using instance as the ‘this’ object in the function call,...
Definition qjsvalue.cpp:730
QJSValue prototype() const
If this QJSValue is an object, returns the internal prototype ({proto} property) of this object; othe...
Definition qjsvalue.cpp:817
bool isError() const
Returns true if this QJSValue is an object of the Error class; otherwise returns false.
Definition qjsvalue.cpp:369
bool isObject() const
Returns true if this QJSValue is of the Object type; otherwise returns false.
Definition qjsvalue.cpp:434
const QMetaObject * toQMetaObject() const
~QJSValue()
Destroys this QJSValue.
Definition qjsvalue.cpp:280
qint32 toInt() const
Returns the signed 32-bit integer value of this QJSValue, using the conversion rules described in \l{...
Definition qjsvalue.cpp:545
double toNumber() const
Returns the number value of this QJSValue, as defined in \l{ECMA-262} section 9.3,...
Definition qjsvalue.cpp:505
ObjectConversionBehavior
This enum is used to specify how JavaScript objects and symbols without an equivalent native Qt type ...
Definition qjsvalue.h:49
@ ConvertJSObjects
Definition qjsvalue.h:50
@ RetainJSObjects
Definition qjsvalue.h:51
bool isArray() const
Returns true if this QJSValue is an object of the Array class; otherwise returns false.
Definition qjsvalue.cpp:420
void setProperty(const QString &name, const QJSValue &value)
Sets the value of this QJSValue's property with the given name to the given value.
bool isQObject() const
Returns true if this QJSValue is a QObject; otherwise returns false.
bool isNumber() const
Returns true if this QJSValue is of the primitive type Number; otherwise returns false.
Definition qjsvalue.cpp:302
bool isUndefined() const
Returns true if this QJSValue is of the primitive type Undefined or if the managed value has been cle...
Definition qjsvalue.cpp:349
bool isBool() const
Returns true if this QJSValue is of the primitive type Boolean; otherwise returns false.
Definition qjsvalue.cpp:291
bool strictlyEquals(const QJSValue &other) const
Returns true if this QJSValue is equal to other using strict comparison (no conversion),...
bool isDate() const
Returns true if this QJSValue is an object of the Date class; otherwise returns false.
void setPrototype(const QJSValue &prototype)
If this QJSValue is an object, sets the internal prototype ({proto} property) of this object to be pr...
Definition qjsvalue.cpp:844
QJSPrimitiveValue toPrimitive() const
Converts the value to a QJSPrimitiveValue.
Definition qjsvalue.cpp:657
QObject * toQObject() const
If this QJSValue is a QObject, returns the QObject pointer that the QJSValue represents; otherwise,...
bool isNull() const
Returns true if this QJSValue is of the primitive type Null; otherwise returns false.
Definition qjsvalue.cpp:319
bool isString() const
Returns true if this QJSValue is of the primitive type String; otherwise returns false.
Definition qjsvalue.cpp:330
QString toString() const
Returns the string value of this QJSValue, as defined in \l{ECMA-262} section 9.8,...
Definition qjsvalue.cpp:473
bool equals(const QJSValue &other) const
Returns true if this QJSValue is equal to other, otherwise returns false.
Definition qjsvalue.cpp:974
quint32 toUInt() const
Returns the unsigned 32-bit integer value of this QJSValue, using the conversion rules described in \...
Definition qjsvalue.cpp:565
bool isRegExp() const
Returns true if this QJSValue is an object of the RegExp class; otherwise returns false.
bool isQMetaObject() const
QJSValue property(const QString &name) const
Returns the value of this QJSValue's property with the given name.
QVariant toVariant() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qjsvalue.cpp:580
QJSValue callAsConstructor(const QJSValueList &args=QJSValueList()) const
Creates a new {Object} and calls this QJSValue as a constructor, using the created object as the ‘thi...
Definition qjsvalue.cpp:782
QJSValue(SpecialValue value=UndefinedValue)
Constructs a new QJSValue with a special value.
Definition qjsvalue.cpp:217
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
\inmodule QtCore
Definition qmetatype.h:320
\inmodule QtCore
Definition qobject.h:90
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qvariant.h:64
void save(QDataStream &ds) const
Internal function for saving a variant to the stream s.
QDate date
[1]
Combined button and popup list for selecting options.
\qmltype Particle \inqmlmodule QtQuick.Particles
@ PREFERREDTYPE_HINT
@ Attr_Invalid
DBusConnection const char DBusError * error
EGLStreamKHR stream
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
T caughtResult(const QJSValue *v, T(QV4::Value::*convert)() const)
Definition qjsvalue.cpp:482
static bool js_equal(const QString &string, const QV4::Value &value)
Definition qjsvalue.cpp:934
QDataStream & operator<<(QDataStream &stream, const QJSValue &jsv)
QDataStream & operator>>(QDataStream &stream, QJSValue &jsv)
#define qWarning
Definition qlogging.h:162
GLsizei const GLfloat * v
[13]
GLfloat GLfloat f
GLuint name
GLuint GLfloat * val
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLsizei const GLchar *const * string
[0]
Definition qopenglext.h:694
static constexpr To convert(const std::array< Mapping, N > &mapping, From Mapping::*from, To Mapping::*to, From value, To defaultValue)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QStringLiteral(str)
unsigned int quint32
Definition qtypes.h:45
int qint32
Definition qtypes.h:44
unsigned int uint
Definition qtypes.h:29
#define encode(x)
QSharedPointer< T > other(t)
[5]
QJSValueList args
QJSEngine engine
[0]
\inmodule QtCore
static constexpr ReturnedValue undefined()
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols=true)
static QJSPrimitiveValue createPrimitive(const Value &v)
static void free(Value *v)
static PropertyKey fromArrayIndex(uint idx)
static Bool strictEqual(const Value &x, const Value &y)
static ReturnedValue toPrimitive(const Value &value, TypeHint typeHint)
static double stringToNumber(const QString &s)
static Bool call(const Value &, const Value &)
bool isUndefined() const
bool isString() const
Definition qv4value_p.h:284
int toInt32() const
Definition qv4value_p.h:350
bool toBoolean() const
Definition qv4value_p.h:97
unsigned int toUInt32() const
Definition qv4value_p.h:361
QML_NEARLY_ALWAYS_INLINE String * stringValue() const
Definition qv4value_p.h:55
double toNumber() const
Definition qv4value_p.h:320
static constexpr Value fromReturnedValue(ReturnedValue val)
Definition qv4value_p.h:165
QString toQStringNoThrow() const
Definition qv4value.cpp:122
void wrapper()