From: Aaron Kennedy Date: Fri, 1 Jul 2011 01:30:00 +0000 (+1000) Subject: Merge branch 'master' into v8-clean X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=d09d7aec4c3f4db0c4d6a09c33aff863551a8369;p=konrad%2Fqtdeclarative.git Merge branch 'master' into v8-clean Conflicts: src/declarative/qml/qdeclarativevme.cpp Change-Id: I0bbc12c06d40c70433730cb33c4e9b461520263f --- d09d7aec4c3f4db0c4d6a09c33aff863551a8369 diff --cc src/declarative/qml/qdeclarativeinstruction_p.h index 107d774,3db55a6..a48c44c --- a/src/declarative/qml/qdeclarativeinstruction_p.h +++ b/src/declarative/qml/qdeclarativeinstruction_p.h @@@ -368,13 -360,13 +368,8 @@@ union QDeclarativeInstructio QML_INSTR_HEADER int propertyIndex; struct QPoint { --#if defined(Q_OS_MAC) -- int yp; -- int xp; --#else int xp; int yp; --#endif } point; }; struct instr_storePointF { diff --cc src/declarative/qml/qdeclarativevme.cpp index 95a8ca0,8959f17..96b71ac --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@@ -1005,65 -975,59 +1005,68 @@@ v8::Persistent QDeclarative bool shared = script->pragmas & QDeclarativeParser::Object::ScriptBlock::Shared; - // Create the script context if required - QDeclarativeContextData *ctxt = 0; - if (!shared) { - ctxt = new QDeclarativeContextData; - ctxt->isInternal = true; - ctxt->url = script->url; - - // For backward compatibility, if there are no imports, we need to use the - // imports from the parent context. See QTBUG-17518. - if (!script->importCache->isEmpty()) { - ctxt->imports = script->importCache; - } else { - ctxt->imports = parentCtxt->imports; - ctxt->importedScripts = parentCtxt->importedScripts; - } - - if (ctxt->imports) { - ctxt->imports->addref(); - } + QDeclarativeContextData *effectiveCtxt = parentCtxt; + if (shared) + effectiveCtxt = 0; - ctxt->setParent(parentCtxt, true); + // Create the script context if required + QDeclarativeContextData *ctxt = new QDeclarativeContextData; + ctxt->isInternal = true; + ctxt->isJSContext = true; + if (shared) + ctxt->isPragmaLibraryContext = true; + else + ctxt->isPragmaLibraryContext = parentCtxt->isPragmaLibraryContext; + ctxt->url = script->url; + + // For backward compatibility, if there are no imports, we need to use the + // imports from the parent context. See QTBUG-17518. + if (!script->importCache->isEmpty()) { + ctxt->imports = script->importCache; + } else if (effectiveCtxt) { + ctxt->imports = effectiveCtxt->imports; ++ ctxt->importedScripts = effectiveCtxt->importedScripts; ++ for (int ii = 0; ii < ctxt->importedScripts.count(); ++ii) ++ ctxt->importedScripts[ii] = qPersistentNew(ctxt->importedScripts[ii]); + } - for (int ii = 0; ii < script->scripts.count(); ++ii) - ctxt->importedScripts << run(ctxt, script->scripts.at(ii)->scriptData()); + if (ctxt->imports) { + ctxt->imports->addref(); } - QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); - if (shared) { - scriptContext->pushScope(enginePriv->contextClass->newUrlContext(script->url.toString())); // XXX toString()? - } else { - scriptContext->pushScope(enginePriv->contextClass->newUrlContext(ctxt, 0, script->url.toString())); + if (effectiveCtxt) + ctxt->setParent(effectiveCtxt, true); + + for (int ii = 0; ii < script->scripts.count(); ++ii) { + ctxt->importedScripts << run(ctxt, script->scripts.at(ii)->scriptData()); } - scriptContext->pushScope(enginePriv->globalClass->staticGlobalObject()); - QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(scriptEngine); - scriptContext->pushScope(scope); + v8::HandleScope handle_scope; + v8::Context::Scope scope(v8engine->context()); - scriptEngine->evaluate(script->m_program); + v8::Local qmlglobal = v8engine->qmlScope(ctxt, 0); - if (scriptEngine->hasUncaughtException()) { - QDeclarativeError error; - QDeclarativeExpressionPrivate::exceptionToError(scriptEngine, error); - enginePriv->warning(error); - } + v8::TryCatch try_catch; + script->m_program->Run(qmlglobal); - scriptEngine->popContext(); + v8::Persistent rv; + + if (try_catch.HasCaught()) { + v8::Local message = try_catch.Message(); + if (!message.IsEmpty()) { + QDeclarativeError error; + QDeclarativeExpressionPrivate::exceptionToError(message, error); + ep->warning(error); + } + } + rv = qPersistentNew(qmlglobal); if (shared) { + script->m_value = qPersistentNew(qmlglobal); script->m_loaded = true; - script->m_value = scope; } - return scope; + return rv; } QT_END_NAMESPACE