diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2018-03-08 18:35:03 +0100 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2018-03-08 18:35:03 +0100 |
commit | d9ea4917ca97aeee050a86151fbfa069771b498d (patch) | |
tree | 21fd6960d8a866bf6f5a5a8f9db9be801f8065c1 /src/qml/jsruntime/qv4include.cpp | |
parent | f9beafddd256cd0b79bf2478a812053ef61241fc (diff) | |
parent | c6a26c248e8abc421b87c3dd6b2466d490ea902e (diff) |
Merge remote-tracking branch 'gerrit/5.11' into wip/webassembly
Change-Id: I729af792166fd2f6c5843ba564e63adf8ae09a97
Diffstat (limited to 'src/qml/jsruntime/qv4include.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4include.cpp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 3e04ed63df..aaf5e3b857 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -61,7 +61,7 @@ QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &callback) : v4(engine), m_url(url) #if QT_CONFIG(qml_network) - , m_redirectCount(0), m_network(0) , m_reply(0) + , m_redirectCount(0), m_network(nullptr) , m_reply(nullptr) #endif { if (qmlContext) @@ -88,7 +88,7 @@ QV4Include::~QV4Include() { #if QT_CONFIG(qml_network) delete m_reply; - m_reply = 0; + m_reply = nullptr; #endif } @@ -196,10 +196,10 @@ void QV4Include::finished() /* Documented in qv8engine.cpp */ -QV4::ReturnedValue QV4Include::method_include(const QV4::BuiltinFunction *b, QV4::CallData *callData) +QV4::ReturnedValue QV4Include::method_include(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - if (!callData->argc()) + if (!argc) RETURN_UNDEFINED(); QQmlContextData *context = scope.engine->callingQmlContext(); @@ -208,11 +208,11 @@ QV4::ReturnedValue QV4Include::method_include(const QV4::BuiltinFunction *b, QV4 RETURN_RESULT(scope.engine->throwError(QString::fromUtf8("Qt.include(): Can only be called from JavaScript files"))); QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue()); - if (callData->argc() >= 2 && callData->args[1].as<QV4::FunctionObject>()) - callbackFunction = callData->args[1]; + if (argc >= 2 && argv[1].as<QV4::FunctionObject>()) + callbackFunction = argv[1]; #if QT_CONFIG(qml_network) - QUrl url(scope.engine->resolvedUrl(callData->args[0].toQStringNoThrow())); + QUrl url(scope.engine->resolvedUrl(argv[0].toQStringNoThrow())); if (scope.engine->qmlEngine() && scope.engine->qmlEngine()->urlInterceptor()) url = scope.engine->qmlEngine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::JavaScriptFile); @@ -227,21 +227,7 @@ QV4::ReturnedValue QV4Include::method_include(const QV4::BuiltinFunction *b, QV4 } else { QScopedPointer<QV4::Script> script; - - if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(url)) { - QV4::CompiledData::CompilationUnit *jsUnit = cachedUnit->createCompilationUnit(); - script.reset(new QV4::Script(scope.engine, qmlcontext, jsUnit)); - } else { - QFile f(localFile); - - if (f.open(QIODevice::ReadOnly)) { - QByteArray data = f.readAll(); - QString code = QString::fromUtf8(data); - QmlIR::Document::removeScriptPragmas(code); - - script.reset(new QV4::Script(scope.engine, qmlcontext, code, url.toString())); - } - } + script.reset(QV4::Script::createFromFileOrCache(scope.engine, qmlcontext, localFile, url)); if (!script.isNull()) { script->parse(); |