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>
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>
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>
37#include <private/qqmlglobal_p.h>
326 qFatal(
"QJSEngine: Must construct a QCoreApplication before a QJSEngine");
349 , m_v4Engine(new
QV4::ExecutionEngine(
this))
361 , m_v4Engine(new
QV4::ExecutionEngine(
this))
420 if (otherEngine && otherEngine != m_v4Engine) {
421 qWarning(
"QJSEngine: Trying to install extensions from a different engine");
446 m_v4Engine->isInterrupted.storeRelaxed(interrupted);
457 return m_v4Engine->isInterrupted.loadRelaxed();
524 if (exceptionStackTrace)
525 exceptionStackTrace->clear();
529 if (exceptionStackTrace) {
539 if (v4->isInterrupted.loadRelaxed())
575 if (
const auto compiled = module.compiled) {
579 compiled->evaluate();
580 if (!m_v4Engine->isInterrupted.loadRelaxed())
823 switch (
value.type()) {
838 Q_UNREACHABLE_RETURN(
false);
854 if (metaType == QMetaType::fromType<bool>()) {
855 *
reinterpret_cast<bool*
>(
ptr) =
string.
size() != 0;
858 if (metaType == QMetaType::fromType<QString>()) {
862 if (metaType == QMetaType::fromType<QUrl>()) {
868 switch (metaType.
id()) {
872 case QMetaType::UInt:
875 case QMetaType::Long:
878 case QMetaType::ULong:
881 case QMetaType::LongLong:
884 case QMetaType::ULongLong:
887 case QMetaType::Double:
888 *
reinterpret_cast<double*
>(
ptr) =
d;
890 case QMetaType::Float:
891 *
reinterpret_cast<float*
>(
ptr) =
d;
893 case QMetaType::Short:
896 case QMetaType::UShort:
899 case QMetaType::Char:
902 case QMetaType::UChar:
905 case QMetaType::QChar:
908 case QMetaType::Char16:
923 return convertString(*
string, metaType,
ptr);
938bool QJSEngine::convertMetaType(
QMetaType fromType,
const void *from,
QMetaType toType,
void *to)
1205 return d->uiLanguage;
1210 return e->jsEngine()->d_func();
1251 if (!
data ||
data->jsWrapper.isNullOrUndefined())
1253 return data->jsWrapper.engine()->jsEngine();
1333#include "moc_qjsengine.cpp"
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
~QJSEnginePrivate() override
static QJSEnginePrivate * get(QJSEngine *e)
static void addToDebugServer(QJSEngine *q)
static void removeFromDebugServer(QJSEngine *q)
The QJSEngine class provides an environment for evaluating JavaScript code.
QV4::ExecutionEngine * handle() const
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()
QJSValue newSymbol(const QString &name)
QString uiLanguage
the language to be used for translating user interface strings
ObjectOwnership
ObjectOwnership controls whether or not the JavaScript memory manager automatically destroys the QObj...
QJSEngine * qjsEngine(const QObject *object)
QJSEngine()
Constructs a QJSEngine object.
The QJSPrimitiveValue class operates on primitive types in JavaScript semantics.
static QJSValue fromReturnedValue(QV4::ReturnedValue d)
static QV4::ExecutionEngine * engine(const QJSValue *jsval)
static QV4::ReturnedValue asReturnedValue(const QJSValue *jsval)
static const QString * asQString(const QJSValue *jsval)
The QJSValue class acts as a container for Qt/JavaScript data types.
QThread * thread() const
Returns the thread in which the object lives.
quint32 explicitIndestructibleSet
static QQmlData * get(QObjectPrivate *priv, bool create)
static QQmlDebugConnector * instance()
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
void setPath(const QString &path, ParsingMode mode=DecodedMode)
Sets the path of the URL to path.
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
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]
static ControlElement< T > * ptr(QWidget *widget)
constexpr T qAbs(const T &t)
GLsizei const GLfloat * v
[13]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLdouble GLdouble GLdouble GLdouble q
QLatin1StringView QLatin1String
#define QStringLiteral(str)
QUrl url("example.com")
[constructor-url-reference]
obj metaObject() -> className()
char * toString(const MyType &t)
[31]
\inmodule QtCore \reentrant
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)
static void init(Object *globalObject, QJSEngine::Extensions extensions)
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
QML_NEARLY_ALWAYS_INLINE ReturnedValue asReturnedValue() const
ReturnedValue run(const QV4::Value *thisObject=nullptr)
static V4_NEEDS_DESTROY Heap::Symbol * create(ExecutionEngine *e, const QString &s)
static constexpr Value fromInt32(int i)
unsigned int toUInt32() const
static constexpr Value fromBoolean(bool b)
static constexpr Value undefinedValue()
static Value fromDouble(double d)
static constexpr Value nullValue()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent