Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qjsengine.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 "qjsengine.h"
5#include "qjsengine_p.h"
6#include "qjsvalue.h"
7#include "qjsvalue_p.h"
8
9#include "private/qv4engine_p.h"
10#include "private/qv4mm_p.h"
11#include "private/qv4errorobject_p.h"
12#include "private/qv4globalobject_p.h"
13#include "private/qv4script_p.h"
14#include "private/qv4runtime_p.h"
15#include <private/qv4dateobject_p.h>
16#include <private/qqmlbuiltinfunctions_p.h>
17#include <private/qqmldebugconnector_p.h>
18#include <private/qv4qobjectwrapper_p.h>
19#include <private/qv4stackframe_p.h>
20#include <private/qv4module_p.h>
21#include <private/qv4symbol_p.h>
22
23#include <QtCore/qdatetime.h>
24#include <QtCore/qmetaobject.h>
25#include <QtCore/qstringlist.h>
26#include <QtCore/qvariant.h>
27#include <QtCore/qdatetime.h>
28
29#include <QtCore/qcoreapplication.h>
30#include <QtCore/qdir.h>
31#include <QtCore/qfile.h>
32#include <QtCore/qfileinfo.h>
33#include <QtCore/qpluginloader.h>
34#include <qthread.h>
35#include <qmutex.h>
36#include <qwaitcondition.h>
37#include <private/qqmlglobal_p.h>
38#include <qqmlengine.h>
39
41
42
322
324{
326 qFatal("QJSEngine: Must construct a QCoreApplication before a QJSEngine");
327}
328
337{
338}
339
349 , m_v4Engine(new QV4::ExecutionEngine(this))
350{
352
354}
355
360 : QObject(dd, parent)
361 , m_v4Engine(new QV4::ExecutionEngine(this))
362{
364}
365
374{
376 delete m_v4Engine;
377}
378
396{
397 m_v4Engine->memoryManager->runGC();
398}
399
417void QJSEngine::installExtensions(QJSEngine::Extensions extensions, const QJSValue &object)
418{
419 QV4::ExecutionEngine *otherEngine = QJSValuePrivate::engine(&object);
420 if (otherEngine && otherEngine != m_v4Engine) {
421 qWarning("QJSEngine: Trying to install extensions from a different engine");
422 return;
423 }
424
425 QV4::Scope scope(m_v4Engine);
427 if (!obj)
428 obj = scope.engine->globalObject;
429
430 QV4::GlobalExtensions::init(obj, extensions);
431}
432
444void QJSEngine::setInterrupted(bool interrupted)
445{
446 m_v4Engine->isInterrupted.storeRelaxed(interrupted);
447}
448
456{
457 return m_v4Engine->isInterrupted.loadRelaxed();
458}
459
461{
462 if (!fileName.startsWith(QLatin1Char(':')))
464
465 QUrl url;
466 url.setPath(fileName.mid(1));
468 return url;
469}
470
508QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, int lineNumber, QStringList *exceptionStackTrace)
509{
510 QV4::ExecutionEngine *v4 = m_v4Engine;
511 QV4::Scope scope(v4);
513
515 script.strictMode = false;
516 if (v4->currentStackFrame)
518 else if (v4->globalCode)
519 script.strictMode = v4->globalCode->isStrict();
520 script.inheritContext = true;
521 script.parse();
522 if (!scope.hasException())
523 result = script.run();
524 if (exceptionStackTrace)
525 exceptionStackTrace->clear();
526 if (scope.hasException()) {
529 if (exceptionStackTrace) {
530 for (auto &&frame: trace)
531 exceptionStackTrace->push_back(QString::fromLatin1("%1:%2:%3:%4").arg(
532 frame.function,
534 QString::number(frame.column),
535 frame.source)
536 );
537 }
538 }
539 if (v4->isInterrupted.loadRelaxed())
540 result = v4->newErrorObject(QStringLiteral("Interrupted"));
541
542 return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
543}
544
568{
569 const QUrl url = urlForFileName(QFileInfo(fileName).canonicalFilePath());
570 const auto module = m_v4Engine->loadModule(url);
571 if (m_v4Engine->hasException)
573
574 QV4::Scope scope(m_v4Engine);
575 if (const auto compiled = module.compiled) {
576 QV4::Scoped<QV4::Module> moduleNamespace(scope, compiled->instantiate(m_v4Engine));
577 if (m_v4Engine->hasException)
579 compiled->evaluate();
580 if (!m_v4Engine->isInterrupted.loadRelaxed())
581 return QJSValuePrivate::fromReturnedValue(moduleNamespace->asReturnedValue());
583 m_v4Engine->newErrorObject(QStringLiteral("Interrupted"))->asReturnedValue());
584 }
585
586 // If there is neither a native nor a compiled module, we should have seen an exception
587 Q_ASSERT(module.native);
588
589 return QJSValuePrivate::fromReturnedValue(module.native->asReturnedValue());
590}
591
617bool QJSEngine::registerModule(const QString &moduleName, const QJSValue &value)
618{
619 QV4::Scope scope(m_v4Engine);
621 m_v4Engine->registerNativeModule(QUrl(moduleName), v4Value);
622 if (m_v4Engine->hasException)
623 return false;
624 return true;
625}
626
636{
637 QV4::Scope scope(m_v4Engine);
638 QV4::ScopedValue v(scope, m_v4Engine->newObject());
639 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
640}
641
652{
653 QV4::Scope scope(m_v4Engine);
654 QV4::ScopedValue v(scope, QV4::Symbol::create(m_v4Engine, u'@' + name));
655 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
656}
657
669{
670 QV4::Scope scope(m_v4Engine);
672 switch (errorType) {
674 error = m_v4Engine->newRangeErrorObject(message);
675 break;
677 error = m_v4Engine->newSyntaxErrorObject(message);
678 break;
680 error = m_v4Engine->newTypeErrorObject(message);
681 break;
683 error = m_v4Engine->newURIErrorObject(message);
684 break;
687 break;
689 error = m_v4Engine->newEvalErrorObject(message);
690 break;
692 error = m_v4Engine->newErrorObject(message);
693 break;
696 }
697 return QJSValuePrivate::fromReturnedValue(error->asReturnedValue());
698}
699
706{
707 QV4::Scope scope(m_v4Engine);
708 QV4::ScopedArrayObject array(scope, m_v4Engine->newArrayObject());
709 if (length < 0x1000)
710 array->arrayReserve(length);
711 array->setArrayLengthUnchecked(length);
712 return QJSValuePrivate::fromReturnedValue(array.asReturnedValue());
713}
714
736{
737 QV4::ExecutionEngine *v4 = m_v4Engine;
738 QV4::Scope scope(v4);
739 if (object) {
740 QQmlData *ddata = QQmlData::get(object, true);
741 if (!ddata || !ddata->explicitIndestructibleSet)
743 }
744 QV4::ScopedValue v(scope, QV4::QObjectWrapper::wrap(v4, object));
745 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
746}
747
763 QV4::ExecutionEngine *v4 = m_v4Engine;
764 QV4::Scope scope(v4);
766 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
767}
768
790{
791 QV4::Scope scope(m_v4Engine);
792 QV4::ScopedValue v(scope, m_v4Engine->globalObject);
793 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
794}
795
796QJSPrimitiveValue QJSEngine::createPrimitive(QMetaType type, const void *ptr)
797{
798 QV4::Scope scope(m_v4Engine);
799 QV4::ScopedValue v(scope, m_v4Engine->metaTypeToJS(type, ptr));
801}
802
803QJSManagedValue QJSEngine::createManaged(QMetaType type, const void *ptr)
804{
805 QJSManagedValue result(m_v4Engine);
806 *result.d = m_v4Engine->metaTypeToJS(type, ptr);
807 return result;
808}
809
814QJSValue QJSEngine::create(QMetaType type, const void *ptr)
815{
816 QV4::Scope scope(m_v4Engine);
817 QV4::ScopedValue v(scope, scope.engine->metaTypeToJS(type, ptr));
818 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
819}
820
821bool QJSEngine::convertPrimitive(const QJSPrimitiveValue &value, QMetaType type, void *ptr)
822{
823 switch (value.type()) {
835 return convertString(value.toString(), type, ptr);
836 }
837
838 Q_UNREACHABLE_RETURN(false);
839}
840
841bool QJSEngine::convertManaged(const QJSManagedValue &value, int type, void *ptr)
842{
843 return convertManaged(value, QMetaType(type), ptr);
844}
845
846bool QJSEngine::convertManaged(const QJSManagedValue &value, QMetaType type, void *ptr)
847{
849}
850
851bool QJSEngine::convertString(const QString &string, QMetaType metaType, void *ptr)
852{
853 // have a string based value without engine. Do conversion manually
854 if (metaType == QMetaType::fromType<bool>()) {
855 *reinterpret_cast<bool*>(ptr) = string.size() != 0;
856 return true;
857 }
858 if (metaType == QMetaType::fromType<QString>()) {
859 *reinterpret_cast<QString*>(ptr) = string;
860 return true;
861 }
862 if (metaType == QMetaType::fromType<QUrl>()) {
863 *reinterpret_cast<QUrl *>(ptr) = QUrl(string);
864 return true;
865 }
866
867 double d = QV4::RuntimeHelpers::stringToNumber(string);
868 switch (metaType.id()) {
869 case QMetaType::Int:
870 *reinterpret_cast<int*>(ptr) = QV4::Value::toInt32(d);
871 return true;
872 case QMetaType::UInt:
873 *reinterpret_cast<uint*>(ptr) = QV4::Value::toUInt32(d);
874 return true;
875 case QMetaType::Long:
876 *reinterpret_cast<long*>(ptr) = QV4::Value::toInteger(d);
877 return true;
878 case QMetaType::ULong:
879 *reinterpret_cast<ulong*>(ptr) = QV4::Value::toInteger(d);
880 return true;
881 case QMetaType::LongLong:
882 *reinterpret_cast<qlonglong*>(ptr) = QV4::Value::toInteger(d);
883 return true;
884 case QMetaType::ULongLong:
885 *reinterpret_cast<qulonglong*>(ptr) = QV4::Value::toInteger(d);
886 return true;
887 case QMetaType::Double:
888 *reinterpret_cast<double*>(ptr) = d;
889 return true;
890 case QMetaType::Float:
891 *reinterpret_cast<float*>(ptr) = d;
892 return true;
893 case QMetaType::Short:
894 *reinterpret_cast<short*>(ptr) = QV4::Value::toInt32(d);
895 return true;
896 case QMetaType::UShort:
897 *reinterpret_cast<unsigned short*>(ptr) = QV4::Value::toUInt32(d);
898 return true;
899 case QMetaType::Char:
900 *reinterpret_cast<char*>(ptr) = QV4::Value::toInt32(d);
901 return true;
902 case QMetaType::UChar:
903 *reinterpret_cast<unsigned char*>(ptr) = QV4::Value::toUInt32(d);
904 return true;
905 case QMetaType::QChar:
906 *reinterpret_cast<QChar*>(ptr) = QChar(QV4::Value::toUInt32(d));
907 return true;
908 case QMetaType::Char16:
909 *reinterpret_cast<char16_t *>(ptr) = QV4::Value::toUInt32(d);
910 return true;
911 default:
912 return false;
913 }
914}
915
920bool QJSEngine::convertV2(const QJSValue &value, QMetaType metaType, void *ptr)
921{
922 if (const QString *string = QJSValuePrivate::asQString(&value))
923 return convertString(*string, metaType, ptr);
924
925 // Does not need scoping since QJSValue still holds on to the value.
927}
928
929bool QJSEngine::convertVariant(const QVariant &value, QMetaType metaType, void *ptr)
930{
931 // TODO: We could probably avoid creating a QV4::Value in many cases, but we'd have to
932 // duplicate much of metaTypeFromJS and some methods of QV4::Value itself here.
933 QV4::Scope scope(handle());
934 QV4::ScopedValue scoped(scope, scope.engine->fromVariant(value));
935 return QV4::ExecutionEngine::metaTypeFromJS(scoped, metaType, ptr);
936}
937
938bool QJSEngine::convertMetaType(QMetaType fromType, const void *from, QMetaType toType, void *to)
939{
940 // TODO: We could probably avoid creating a QV4::Value in many cases, but we'd have to
941 // duplicate much of metaTypeFromJS and some methods of QV4::Value itself here.
942 QV4::Scope scope(handle());
943 QV4::ScopedValue scoped(scope, scope.engine->fromData(fromType, from));
944 return QV4::ExecutionEngine::metaTypeFromJS(scoped, toType, to);
945}
946
947QString QJSEngine::convertQObjectToString(QObject *object)
948{
950 handle(), object ? object->metaObject() : nullptr, object);
951}
952
953QString QJSEngine::convertDateTimeToString(const QDateTime &dateTime)
954{
956}
957
958QDate QJSEngine::convertDateTimeToDate(const QDateTime &dateTime)
959{
961}
962
1105{
1106 m_v4Engine->throwError(message);
1107}
1108
1133{
1134 QV4::Scope scope(m_v4Engine);
1135 QJSValue error = newErrorObject(errorType, message);
1137 if (!e)
1138 return;
1139 m_v4Engine->throwError(e);
1140}
1141
1152{
1154}
1155
1164{
1165 return m_v4Engine->hasException;
1166}
1167
1176{
1177 if (m_v4Engine->hasException)
1179 else
1180 return QJSValue();
1181}
1182
1198 Q_D(QJSEngine);
1199 d->uiLanguage = language; // property takes care of signal emission if necessary
1200}
1201
1203{
1204 Q_D(const QJSEngine);
1205 return d->uiLanguage;
1206}
1207
1209{
1210 return e->jsEngine()->d_func();
1211}
1212
1214{
1216}
1217
1219{
1220 if (QCoreApplication::instance()->thread() != q->thread())
1221 return;
1222
1224 if (!server || server->hasEngine(q))
1225 return;
1226
1227 server->open();
1228 server->addEngine(q);
1229}
1230
1232{
1234 if (server && server->hasEngine(q))
1235 server->removeEngine(q);
1236}
1237
1249{
1250 QQmlData *data = QQmlData::get(object);
1251 if (!data || data->jsWrapper.isNullOrUndefined())
1252 return nullptr;
1253 return data->jsWrapper.engine()->jsEngine();
1254}
1255
1256
1302{
1303 if (!object)
1304 return;
1305
1306 QQmlData *ddata = QQmlData::get(object, true);
1307 if (!ddata)
1308 return;
1309
1310 ddata->indestructible = (ownership == CppOwnership)?true:false;
1311 ddata->explicitIndestructibleSet = true;
1312}
1313
1320{
1321 if (!object)
1322 return CppOwnership;
1323
1324 QQmlData *ddata = QQmlData::get(object, false);
1325 if (!ddata)
1326 return CppOwnership;
1327 else
1329}
1330
1332
1333#include "moc_qjsengine.cpp"
\inmodule QtCore
Definition qchar.h:48
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
\inmodule QtCore\reentrant
Definition qdatetime.h:257
\inmodule QtCore \reentrant
Definition qdatetime.h:27
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
~QJSEnginePrivate() override
static QJSEnginePrivate * get(QJSEngine *e)
Definition qjsengine_p.h:38
static void addToDebugServer(QJSEngine *q)
static void removeFromDebugServer(QJSEngine *q)
The QJSEngine class provides an environment for evaluating JavaScript code.
Definition qjsengine.h:26
QV4::ExecutionEngine * handle() const
Definition qjsengine.h:292
static ObjectOwnership objectOwnership(QObject *)
Returns the ownership of object.
void throwError(const QString &message)
Throws a run-time error (exception) with the given message.
QJSValue globalObject() const
Returns this engine's Global Object.
bool hasError() const
Returns true if the last JavaScript execution resulted in an exception or if throwError() was called.
QJSValue newObject()
Creates a JavaScript object of class Object.
QJSValue newQObject(QObject *object)
Creates a JavaScript object that wraps the given QObject object, using JavaScriptOwnership.
QJSValue newArray(uint length=0)
Creates a JavaScript object of class Array with the given length.
void setInterrupted(bool interrupted)
bool registerModule(const QString &moduleName, const QJSValue &value)
Registers a QJSValue to serve as a module.
QJSValue catchError()
If an exception is currently pending, catches it and returns it as a QJSValue.
QJSValue evaluate(const QString &program, const QString &fileName=QString(), int lineNumber=1, QStringList *exceptionStackTrace=nullptr)
Evaluates program, using lineNumber as the base line number, and returns the result of the evaluation...
QJSValue newErrorObject(QJSValue::ErrorType errorType, const QString &message=QString())
QJSValue importModule(const QString &fileName)
Imports the module located at fileName and returns a module namespace object that contains all export...
void installExtensions(Extensions extensions, const QJSValue &object=QJSValue())
~QJSEngine() override
Destroys this QJSEngine.
bool isInterrupted() const
void setUiLanguage(const QString &language)
static void setObjectOwnership(QObject *, ObjectOwnership)
Sets the ownership of object.
void collectGarbage()
Runs the garbage collector.
QJSValue newQMetaObject()
Definition qjsengine.h:50
QJSValue newSymbol(const QString &name)
QString uiLanguage
the language to be used for translating user interface strings
Definition qjsengine.h:28
ObjectOwnership
ObjectOwnership controls whether or not the JavaScript memory manager automatically destroys the QObj...
Definition qjsengine.h:275
@ JavaScriptOwnership
Definition qjsengine.h:275
QJSEngine * qjsEngine(const QObject *object)
QJSEngine()
Constructs a QJSEngine object.
\inmodule QtQml
The QJSPrimitiveValue class operates on primitive types in JavaScript semantics.
static QJSValue fromReturnedValue(QV4::ReturnedValue d)
Definition qjsvalue_p.h:189
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
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
@ 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
@ UndefinedValue
Definition qjsvalue.h:35
Definition qlist.h:74
\inmodule QtCore
Definition qmetatype.h:320
int id(int=0) const
Definition qmetatype.h:454
\inmodule QtCore
Definition qobject.h:90
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1561
quint32 explicitIndestructibleSet
Definition qqmldata_p.h:95
static QQmlData * get(QObjectPrivate *priv, bool create)
Definition qqmldata_p.h:199
quint32 indestructible
Definition qqmldata_p.h:92
static QQmlDebugConnector * instance()
static void freeUnusedTypesAndCaches()
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5710
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Definition qstring.cpp:8606
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:7822
\inmodule QtCore
Definition qurl.h:94
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition qurl.cpp:3354
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
Definition qurl.cpp:1959
void setPath(const QString &path, ParsingMode mode=DecodedMode)
Sets the path of the URL to path.
Definition qurl.cpp:2411
\inmodule QtCore
Definition qvariant.h:64
#define this
Definition dialogs.cpp:9
double e
static QUrl urlForFileName(const QString &fileName)
static QT_BEGIN_NAMESPACE void checkForApplicationInstance()
Combined button and popup list for selecting options.
\qmltype Particle \inqmlmodule QtQuick.Particles
Definition qctf_p.h:77
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage return DBusPendingCall DBusPendingCall return DBusPendingCall return dbus_int32_t return DBusServer * server
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:162
#define qFatal
Definition qlogging.h:164
static ControlElement< T > * ptr(QWidget *widget)
#define Q_DECLARE_METATYPE(TYPE)
Definition qmetatype.h:1504
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
GLsizei const GLfloat * v
[13]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLuint object
[3]
GLenum type
GLuint program
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
GLhandleARB obj
[2]
GLenum array
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QStringLiteral(str)
unsigned long ulong
Definition qtypes.h:30
quint64 qulonglong
Definition qtypes.h:59
unsigned int uint
Definition qtypes.h:29
qint64 qlonglong
Definition qtypes.h:58
QUrl url("example.com")
[constructor-url-reference]
obj metaObject() -> className()
QObject::connect nullptr
QDateTime dateTime
[12]
QFrame frame
[0]
char * toString(const MyType &t)
[31]
\inmodule QtCore \reentrant
Definition qchar.h:17
\inmodule QtCore
static QDate dateTimeToDate(const QDateTime &dateTime)
static QString dateTimeToString(const QDateTime &dateTime, ExecutionEngine *engine)
MemoryManager * memoryManager
CppStackFrame * currentStackFrame
static bool metaTypeFromJS(const Value &value, QMetaType type, void *data)
ExecutionContext * rootContext() const
Heap::Object * newURIErrorObject(const QString &message)
ReturnedValue throwError(const Value &value)
Heap::Object * newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column)
Heap::Object * newEvalErrorObject(const QString &message)
Heap::Object * newObject()
QV4::ReturnedValue metaTypeToJS(QMetaType type, const void *data)
static QJSPrimitiveValue createPrimitive(const Value &v)
Heap::Object * newReferenceErrorObject(const QString &message)
Heap::Object * newRangeErrorObject(const QString &message)
Heap::ArrayObject * newArrayObject(int count=0)
Heap::Object * newTypeErrorObject(const QString &message)
QV4::Value * registerNativeModule(const QUrl &url, const QV4::Value &module)
ReturnedValue catchException(StackTrace *trace=nullptr)
Heap::Object * newErrorObject(const Value &value)
Module loadModule(const QUrl &_url, const ExecutableCompilationUnit *referrer=nullptr)
bool isStrict() const
static void init(Object *globalObject, QJSEngine::Extensions extensions)
static V4_NEEDS_DESTROY ReturnedValue create(ExecutionEngine *engine, const QMetaObject *metaObject)
static QString objectToString(ExecutionEngine *engine, const QMetaObject *metaObject, QObject *object)
static ReturnedValue wrap(ExecutionEngine *engine, QObject *object)
static double stringToNumber(const QString &s)
bool hasException() const
ExecutionEngine * engine
QML_NEARLY_ALWAYS_INLINE ReturnedValue asReturnedValue() const
ReturnedValue run(const QV4::Value *thisObject=nullptr)
bool strictMode
Definition qv4script_p.h:54
bool inheritContext
Definition qv4script_p.h:55
void parse()
Definition qv4script.cpp:43
static V4_NEEDS_DESTROY Heap::Symbol * create(ExecutionEngine *e, const QString &s)
static constexpr Value fromInt32(int i)
Definition qv4value_p.h:187
int toInt32() const
Definition qv4value_p.h:350
unsigned int toUInt32() const
Definition qv4value_p.h:361
static constexpr Value fromBoolean(bool b)
Definition qv4value_p.h:183
static constexpr Value undefinedValue()
Definition qv4value_p.h:191
static Value fromDouble(double d)
Definition qv4value_p.h:199
static constexpr Value nullValue()
Definition qv4value_p.h:195
double toInteger() const
Definition qv4value_p.h:391
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent