Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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/qv4qmetaobjectwrapper_p.h>
20#include <private/qv4stackframe_p.h>
21#include <private/qv4module_p.h>
22#include <private/qv4symbol_p.h>
23
24#include <QtCore/qdatetime.h>
25#include <QtCore/qmetaobject.h>
26#include <QtCore/qstringlist.h>
27#include <QtCore/qvariant.h>
28#include <QtCore/qdatetime.h>
29
30#include <QtCore/qcoreapplication.h>
31#include <QtCore/qdir.h>
32#include <QtCore/qfile.h>
33#include <QtCore/qfileinfo.h>
34#include <QtCore/qpluginloader.h>
35#include <qthread.h>
36#include <qmutex.h>
37#include <qwaitcondition.h>
38#include <private/qqmlglobal_p.h>
39#include <qqmlengine.h>
40
41Q_DECLARE_METATYPE(QList<int>)
42
43
323
325{
327 qFatal("QJSEngine: Must construct a QCoreApplication before a QJSEngine");
328}
329
340
353
358 : QObject(dd, parent)
359 , m_v4Engine(new QV4::ExecutionEngine(this))
360{
362}
363
372{
373 m_v4Engine->inShutdown = true;
375 delete m_v4Engine;
376}
377
399{
400 m_v4Engine->memoryManager->runGC();
401}
402
420void QJSEngine::installExtensions(QJSEngine::Extensions extensions, const QJSValue &object)
421{
422 QV4::ExecutionEngine *otherEngine = QJSValuePrivate::engine(&object);
423 if (otherEngine && otherEngine != m_v4Engine) {
424 qWarning("QJSEngine: Trying to install extensions from a different engine");
425 return;
426 }
427
428 QV4::Scope scope(m_v4Engine);
430 if (!obj)
431 obj = scope.engine->globalObject;
432
433 QV4::GlobalExtensions::init(obj, extensions);
434}
435
447void QJSEngine::setInterrupted(bool interrupted)
448{
449 m_v4Engine->isInterrupted.storeRelaxed(interrupted);
450}
451
459{
460 return m_v4Engine->isInterrupted.loadRelaxed();
461}
462
464{
465 if (!fileName.startsWith(QLatin1Char(':')))
467
468 QUrl url;
469 url.setPath(fileName.mid(1));
471 return url;
472}
473
516QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, int lineNumber, QStringList *exceptionStackTrace)
517{
518 QV4::ExecutionEngine *v4 = m_v4Engine;
519 QV4::Scope scope(v4);
521
523 script.strictMode = false;
524 if (v4->currentStackFrame)
526 else if (v4->globalCode)
527 script.strictMode = v4->globalCode->isStrict();
528 script.inheritContext = true;
529 script.parse();
530 if (!scope.hasException())
531 result = script.run();
532 if (exceptionStackTrace)
533 exceptionStackTrace->clear();
534 if (scope.hasException()) {
537 if (exceptionStackTrace) {
538 for (auto &&frame: trace)
539 exceptionStackTrace->push_back(QLatin1StringView("%1:%2:%3:%4").arg(
540 frame.function,
542 QString::number(frame.column),
543 frame.source)
544 );
545 }
546 }
547 if (v4->isInterrupted.loadRelaxed())
548 result = v4->newErrorObject(QStringLiteral("Interrupted"));
549
550 return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
551}
552
576{
577 const QUrl url = urlForFileName(QFileInfo(fileName).canonicalFilePath());
578 const auto module = m_v4Engine->loadModule(url);
579 if (m_v4Engine->hasException)
581
582 QV4::Scope scope(m_v4Engine);
583 if (const auto compiled = module.compiled) {
584 QV4::Scoped<QV4::Module> moduleNamespace(scope, compiled->instantiate());
585 if (m_v4Engine->hasException)
587 compiled->evaluate();
588 if (!m_v4Engine->isInterrupted.loadRelaxed())
589 return QJSValuePrivate::fromReturnedValue(moduleNamespace->asReturnedValue());
591 m_v4Engine->newErrorObject(QStringLiteral("Interrupted"))->asReturnedValue());
592 }
593
594 // If there is neither a native nor a compiled module, we should have seen an exception
595 Q_ASSERT(module.native);
596
597 return QJSValuePrivate::fromReturnedValue(module.native->asReturnedValue());
598}
599
625bool QJSEngine::registerModule(const QString &moduleName, const QJSValue &value)
626{
627 QV4::Scope scope(m_v4Engine);
629 m_v4Engine->registerNativeModule(QUrl(moduleName), v4Value);
630 if (m_v4Engine->hasException)
631 return false;
632 return true;
633}
634
644{
645 QV4::Scope scope(m_v4Engine);
646 QV4::ScopedValue v(scope, m_v4Engine->newObject());
647 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
648}
649
660{
661 QV4::Scope scope(m_v4Engine);
662 QV4::ScopedValue v(scope, QV4::Symbol::create(m_v4Engine, u'@' + name));
663 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
664}
665
677{
678 QV4::Scope scope(m_v4Engine);
680 switch (errorType) {
682 error = m_v4Engine->newRangeErrorObject(message);
683 break;
685 error = m_v4Engine->newSyntaxErrorObject(message);
686 break;
688 error = m_v4Engine->newTypeErrorObject(message);
689 break;
691 error = m_v4Engine->newURIErrorObject(message);
692 break;
695 break;
697 error = m_v4Engine->newEvalErrorObject(message);
698 break;
700 error = m_v4Engine->newErrorObject(message);
701 break;
704 }
705 return QJSValuePrivate::fromReturnedValue(error->asReturnedValue());
706}
707
714{
715 QV4::Scope scope(m_v4Engine);
716 QV4::ScopedArrayObject array(scope, m_v4Engine->newArrayObject());
717 if (length < 0x1000)
718 array->arrayReserve(length);
719 array->setArrayLengthUnchecked(length);
720 return QJSValuePrivate::fromReturnedValue(array.asReturnedValue());
721}
722
744{
745 QV4::ExecutionEngine *v4 = m_v4Engine;
746 QV4::Scope scope(v4);
747 if (object) {
748 QQmlData *ddata = QQmlData::get(object, true);
749 if (!ddata || !ddata->explicitIndestructibleSet)
751 }
752 QV4::ScopedValue v(scope, QV4::QObjectWrapper::wrap(v4, object));
753 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
754}
755
776
798{
799 QV4::Scope scope(m_v4Engine);
800 QV4::ScopedValue v(scope, m_v4Engine->globalObject);
801 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
802}
803
804QJSPrimitiveValue QJSEngine::createPrimitive(QMetaType type, const void *ptr)
805{
806 QV4::Scope scope(m_v4Engine);
807 QV4::ScopedValue v(scope, m_v4Engine->metaTypeToJS(type, ptr));
809}
810
811QJSManagedValue QJSEngine::createManaged(QMetaType type, const void *ptr)
812{
813 QJSManagedValue result(m_v4Engine);
814 *result.d = m_v4Engine->metaTypeToJS(type, ptr);
815 return result;
816}
817
822QJSValue QJSEngine::create(QMetaType type, const void *ptr)
823{
824 QV4::Scope scope(m_v4Engine);
825 QV4::ScopedValue v(scope, scope.engine->metaTypeToJS(type, ptr));
826 return QJSValuePrivate::fromReturnedValue(v->asReturnedValue());
827}
828
829bool QJSEngine::convertPrimitive(const QJSPrimitiveValue &value, QMetaType type, void *ptr)
830{
831 switch (value.type()) {
843 return convertString(value.toString(), type, ptr);
844 }
845
846 Q_UNREACHABLE_RETURN(false);
847}
848
849bool QJSEngine::convertManaged(const QJSManagedValue &value, int type, void *ptr)
850{
851 return convertManaged(value, QMetaType(type), ptr);
852}
853
854bool QJSEngine::convertManaged(const QJSManagedValue &value, QMetaType type, void *ptr)
855{
857}
858
859bool QJSEngine::convertString(const QString &string, QMetaType metaType, void *ptr)
860{
861 // have a string based value without engine. Do conversion manually
862 if (metaType == QMetaType::fromType<bool>()) {
863 *reinterpret_cast<bool*>(ptr) = string.size() != 0;
864 return true;
865 }
866 if (metaType == QMetaType::fromType<QString>()) {
867 *reinterpret_cast<QString*>(ptr) = string;
868 return true;
869 }
870 if (metaType == QMetaType::fromType<QUrl>()) {
871 *reinterpret_cast<QUrl *>(ptr) = QUrl(string);
872 return true;
873 }
874
875 double d = QV4::RuntimeHelpers::stringToNumber(string);
876 switch (metaType.id()) {
877 case QMetaType::Int:
878 *reinterpret_cast<int*>(ptr) = QV4::Value::toInt32(d);
879 return true;
880 case QMetaType::UInt:
881 *reinterpret_cast<uint*>(ptr) = QV4::Value::toUInt32(d);
882 return true;
883 case QMetaType::Long:
884 *reinterpret_cast<long*>(ptr) = QV4::Value::toInteger(d);
885 return true;
886 case QMetaType::ULong:
887 *reinterpret_cast<ulong*>(ptr) = QV4::Value::toInteger(d);
888 return true;
889 case QMetaType::LongLong:
890 *reinterpret_cast<qlonglong*>(ptr) = QV4::Value::toInteger(d);
891 return true;
892 case QMetaType::ULongLong:
893 *reinterpret_cast<qulonglong*>(ptr) = QV4::Value::toInteger(d);
894 return true;
895 case QMetaType::Double:
896 *reinterpret_cast<double*>(ptr) = d;
897 return true;
898 case QMetaType::Float:
899 *reinterpret_cast<float*>(ptr) = d;
900 return true;
901 case QMetaType::Short:
902 *reinterpret_cast<short*>(ptr) = QV4::Value::toInt32(d);
903 return true;
904 case QMetaType::UShort:
905 *reinterpret_cast<unsigned short*>(ptr) = QV4::Value::toUInt32(d);
906 return true;
907 case QMetaType::Char:
908 *reinterpret_cast<char*>(ptr) = QV4::Value::toInt32(d);
909 return true;
910 case QMetaType::UChar:
911 *reinterpret_cast<unsigned char*>(ptr) = QV4::Value::toUInt32(d);
912 return true;
913 case QMetaType::QChar:
914 *reinterpret_cast<QChar*>(ptr) = QChar(QV4::Value::toUInt32(d));
915 return true;
916 case QMetaType::Char16:
917 *reinterpret_cast<char16_t *>(ptr) = QV4::Value::toUInt32(d);
918 return true;
919 default:
920 return false;
921 }
922}
923
928bool QJSEngine::convertV2(const QJSValue &value, QMetaType metaType, void *ptr)
929{
930 if (const QString *string = QJSValuePrivate::asQString(&value))
931 return convertString(*string, metaType, ptr);
932
933 // Does not need scoping since QJSValue still holds on to the value.
935}
936
937bool QJSEngine::convertVariant(const QVariant &value, QMetaType metaType, void *ptr)
938{
939 // TODO: We could probably avoid creating a QV4::Value in many cases, but we'd have to
940 // duplicate much of metaTypeFromJS and some methods of QV4::Value itself here.
941 QV4::Scope scope(handle());
942 QV4::ScopedValue scoped(scope, scope.engine->fromVariant(value));
943 return QV4::ExecutionEngine::metaTypeFromJS(scoped, metaType, ptr);
944}
945
946bool QJSEngine::convertMetaType(QMetaType fromType, const void *from, QMetaType toType, void *to)
947{
948 // TODO: We could probably avoid creating a QV4::Value in many cases, but we'd have to
949 // duplicate much of metaTypeFromJS and some methods of QV4::Value itself here.
950 QV4::Scope scope(handle());
951 QV4::ScopedValue scoped(scope, scope.engine->fromData(fromType, from));
952 return QV4::ExecutionEngine::metaTypeFromJS(scoped, toType, to);
953}
954
955QString QJSEngine::convertQObjectToString(QObject *object)
956{
958 handle(), object ? object->metaObject() : nullptr, object);
959}
960
961QString QJSEngine::convertDateTimeToString(const QDateTime &dateTime)
962{
964}
965
966double QJSEngine::convertDateTimeToNumber(const QDateTime &dateTime)
967{
969}
970
971QDate QJSEngine::convertDateTimeToDate(const QDateTime &dateTime)
972{
974}
975
1118{
1119 m_v4Engine->throwError(message);
1120}
1121
1146{
1147 QV4::Scope scope(m_v4Engine);
1148 QJSValue error = newErrorObject(errorType, message);
1150 if (!e)
1151 return;
1152 m_v4Engine->throwError(e);
1153}
1154
1168
1177{
1178 return m_v4Engine->hasException;
1179}
1180
1189{
1190 if (m_v4Engine->hasException)
1192 else
1193 return QJSValue();
1194}
1195
1211 Q_D(QJSEngine);
1212 d->uiLanguage = language; // property takes care of signal emission if necessary
1213}
1214
1216{
1217 Q_D(const QJSEngine);
1218 return d->uiLanguage;
1219}
1220
1222{
1223 return e->jsEngine()->d_func();
1224}
1225
1230
1232{
1233 if (QCoreApplication::instance()->thread() != q->thread())
1234 return;
1235
1237 if (!server || server->hasEngine(q))
1238 return;
1239
1240 server->open();
1241 server->addEngine(q);
1242}
1243
1245{
1247 if (server && server->hasEngine(q))
1248 server->removeEngine(q);
1249}
1250
1262{
1263 QQmlData *data = QQmlData::get(object);
1264 if (!data || data->jsWrapper.isNullOrUndefined())
1265 return nullptr;
1266 return data->jsWrapper.engine()->jsEngine();
1267}
1268
1269
1315{
1316 if (!object)
1317 return;
1318
1319 QQmlData *ddata = QQmlData::get(object, true);
1320 if (!ddata)
1321 return;
1322
1323 ddata->indestructible = (ownership == CppOwnership)?true:false;
1324 ddata->explicitIndestructibleSet = true;
1325}
1326
1333{
1334 if (!object)
1335 return CppOwnership;
1336
1337 QQmlData *ddata = QQmlData::get(object, false);
1338 if (!ddata)
1339 return CppOwnership;
1340 else
1341 return ddata->indestructible?CppOwnership:JavaScriptOwnership;
1342}
1343
1345
1346#include "moc_qjsengine.cpp"
\inmodule QtCore
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
\inmodule QtCore\reentrant
Definition qdatetime.h:283
\inmodule QtCore \reentrant
Definition qdatetime.h:29
~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:298
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:281
@ JavaScriptOwnership
Definition qjsengine.h:281
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:197
static QV4::ExecutionEngine * engine(const QJSValue *jsval)
Definition qjsvalue_p.h:321
static QV4::ReturnedValue asReturnedValue(const QJSValue *jsval)
Definition qjsvalue_p.h:257
static const QString * asQString(const QJSValue *jsval)
Definition qjsvalue_p.h:248
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
QString arg(Args &&...args) const
Definition qlist.h:75
\inmodule QtCore
Definition qmetatype.h:341
int id(int=0) const
Definition qmetatype.h:475
\inmodule QtCore
Definition qobject.h:103
static QQmlData * get(QObjectPrivate *priv, bool create)
Definition qqmldata_p.h:199
static QQmlDebugConnector * instance()
static void freeUnusedTypesAndCaches()
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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:8084
\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:3368
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
Definition qurl.cpp:1967
void setPath(const QString &path, ParsingMode mode=DecodedMode)
Sets the path of the URL to path.
Definition qurl.cpp:2414
\inmodule QtCore
Definition qvariant.h:65
#define this
Definition dialogs.cpp:9
static QUrl urlForFileName(const QString &fileName)
static QT_BEGIN_NAMESPACE void checkForApplicationInstance()
Combined button and popup list for selecting options.
Definition qctf_p.h:75
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:166
#define qFatal
Definition qlogging.h:168
static ControlElement< T > * ptr(QWidget *widget)
#define Q_DECLARE_METATYPE(TYPE)
Definition qmetatype.h:1525
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]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLuint program
GLuint GLsizei const GLchar * message
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:35
quint64 qulonglong
Definition qtypes.h:64
unsigned int uint
Definition qtypes.h:34
qint64 qlonglong
Definition qtypes.h:63
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:18
\inmodule QtCore
static QDate dateTimeToDate(const QDateTime &dateTime)
static QString dateTimeToString(const QDateTime &dateTime, ExecutionEngine *engine)
static double dateTimeToNumber(const QDateTime &dateTime)
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)
QJSEngine * jsEngine() const
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)
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
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:44
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:353
unsigned int toUInt32() const
Definition qv4value_p.h:364
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:394