diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2016-11-15 11:38:56 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2016-11-18 10:33:01 +0000 |
commit | d6a9501fad89a1bb3df4b400e73d7814bddf863a (patch) | |
tree | 93a0b0ff5b65942523130b586761b65b3eadcbe4 | |
parent | 4abb5ae0e1d4b80c0dc6e5dc3ffd26cd4a52d22b (diff) |
Remove the concept of an "Export Scope"
It turns out that it is not (no longer?) needed, and it introduced
subtle differences between Export items and normal modules.
Task-number: QBS-1039
Change-Id: Iece1a4ee9ca3ceba16291b31552008ab0bcd60f7
Reviewed-by: Denis Klychkov <kd.snake@gmail.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | src/lib/corelib/language/evaluatorscriptclass.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/language/moduleloader.cpp | 37 | ||||
-rw-r--r-- | src/lib/corelib/language/modulemerger.cpp | 6 | ||||
-rw-r--r-- | src/lib/corelib/language/testdata/ParentWithExport.qbs | 6 | ||||
-rw-r--r-- | src/lib/corelib/language/testdata/exports.qbs | 28 | ||||
-rw-r--r-- | src/lib/corelib/language/tst_language.cpp | 12 | ||||
-rw-r--r-- | src/lib/corelib/language/value.cpp | 12 | ||||
-rw-r--r-- | src/lib/corelib/language/value.h | 5 |
8 files changed, 50 insertions, 58 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp index 71818915f..bfac9d6ac 100644 --- a/src/lib/corelib/language/evaluatorscriptclass.cpp +++ b/src/lib/corelib/language/evaluatorscriptclass.cpp @@ -266,8 +266,6 @@ private: } if (value->definingItem()) pushItemScopes(value->definingItem()); - if (value->exportScope()) - pushScope(data->evaluator->scriptValue(value->exportScope())); pushScope(extraScope); *result = engine->evaluate(value->sourceCodeForEvaluation(), value->file()->filePath(), value->line()); diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index 33fa51e23..b2bbd24d7 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -1935,17 +1935,6 @@ static QList<Item *> collectItemsWithId(Item *item) return result; } -static void copyPropertiesFromExportItem(const Item *src, Item *dst) -{ - const Item::PropertyMap &srcProps = src->properties(); - for (auto it = srcProps.constBegin(); it != srcProps.constEnd(); ++it) { - if (it.value()->type() != Value::JSSourceValueType) - continue; - QBS_CHECK(!dst->hasOwnProperty(it.key())); - dst->setProperty(it.key(), it.value()->clone()); - } -} - void ModuleLoader::instantiateModule(ProductContext *productContext, Item *exportingProduct, Item *instanceScope, Item *moduleInstance, Item *modulePrototype, const QualifiedId &moduleName, bool isProduct) @@ -1982,35 +1971,15 @@ void ModuleLoader::instantiateModule(ProductContext *productContext, Item *expor } if (exportingProduct) { - if (!isProduct) { - copyPropertiesFromExportItem(modulePrototype, moduleInstance); - moduleInstance->setPrototype(modulePrototype->prototype()); - } - - Item *exportScope = Item::create(moduleInstance->pool()); - exportScope->setFile(instanceScope->file()); - exportScope->setScope(instanceScope); - // TODO: For consistency with modules, it should be the other way around, i.e. // "exportingProduct" and just "product". - exportScope->setProperty(QLatin1String("product"), ItemValue::create(exportingProduct)); - exportScope->setProperty(QLatin1String("importingProduct"), + moduleScope->setProperty(QLatin1String("product"), ItemValue::create(exportingProduct)); + moduleScope->setProperty(QLatin1String("importingProduct"), ItemValue::create(productContext->item)); - exportScope->setProperty(QLatin1String("project"), + moduleScope->setProperty(QLatin1String("project"), ItemValue::create(exportingProduct->parent())); - for (auto it = moduleInstance->properties().begin(); - it != moduleInstance->properties().end(); ++it) { - if (it.value()->type() != Value::JSSourceValueType) - continue; - JSSourceValuePtr v = it.value().staticCast<JSSourceValue>(); - do { - v->setExportScope(exportScope); - v = v->baseValue(); - } while (v); - } - PropertyDeclaration pd(QLatin1String("_qbs_sourceDir"), PropertyDeclaration::String, PropertyDeclaration::PropertyNotAvailableInConfig); moduleInstance->setPropertyDeclaration(pd.name(), pd); diff --git a/src/lib/corelib/language/modulemerger.cpp b/src/lib/corelib/language/modulemerger.cpp index b5aeb995f..d0dc3e356 100644 --- a/src/lib/corelib/language/modulemerger.cpp +++ b/src/lib/corelib/language/modulemerger.cpp @@ -198,15 +198,13 @@ void ModuleMerger::mergeOutProps(Item::PropertyMap *dst, const Item::PropertyMap QBS_CHECK(pd.isValid()); if (pd.isScalar()) { - if (dstVal->sourceCode() != srcVal->sourceCode() - && dstVal->isInExportItem() == srcVal->isInExportItem()) { + if (dstVal->sourceCode() != srcVal->sourceCode()) { m_logger.qbsWarning() << Tr::tr("Conflicting scalar values at %1 and %2.").arg( dstVal->location().toString(), srcVal->location().toString()); // TODO: yield error with a hint how to solve the conflict. } - if (!dstVal->isInExportItem()) - v = it.value(); + v = it.value(); } else { lastInNextChain(dstVal)->setNext(srcVal); } diff --git a/src/lib/corelib/language/testdata/ParentWithExport.qbs b/src/lib/corelib/language/testdata/ParentWithExport.qbs new file mode 100644 index 000000000..16f9a2cd1 --- /dev/null +++ b/src/lib/corelib/language/testdata/ParentWithExport.qbs @@ -0,0 +1,6 @@ +Product { + Export { + Depends { name: "dummy" } + dummy.defines: [product.name.toUpperCase()] + } +} diff --git a/src/lib/corelib/language/testdata/exports.qbs b/src/lib/corelib/language/testdata/exports.qbs index 01a1ac72e..c480f0097 100644 --- a/src/lib/corelib/language/testdata/exports.qbs +++ b/src/lib/corelib/language/testdata/exports.qbs @@ -74,4 +74,32 @@ Project { Depends { name: "sub p1" } } } + + ParentWithExport { + name: "libA" + Export { Depends { name: "libB" } } + } + + ParentWithExport { name: "libB" } + + ParentWithExport { + name: "libC" + Export { Depends { name: "libA" } } + } + + ParentWithExport { + name: "libD" + Export { Depends { name: "libA" } } + } + + Product { + name: "libE" + + Depends { name: "libD" } + Depends { name: "libC" } + + Group { + qbs.install: false + } + } } diff --git a/src/lib/corelib/language/tst_language.cpp b/src/lib/corelib/language/tst_language.cpp index e23869567..f865190eb 100644 --- a/src/lib/corelib/language/tst_language.cpp +++ b/src/lib/corelib/language/tst_language.cpp @@ -578,7 +578,7 @@ void TestLanguage::exports() TopLevelProjectPtr project = loader->loadProject(defaultParameters); QVERIFY(project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); - QCOMPARE(products.count(), 12); + QCOMPARE(products.count(), 17); ResolvedProductPtr product; product = products.value("myapp"); QVERIFY(product); @@ -655,6 +655,16 @@ void TestLanguage::exports() QVERIFY(product); QCOMPARE(PropertyFinder().propertyValue(product->moduleProperties->value(), "dummy", "someString").toString(), QString("sub1")); + + product = products.value("libE"); + QVERIFY(product); + propertyName = QStringList() << "modules" << "dummy" << "defines"; + propertyValue = getConfigProperty(product->moduleProperties->value(), propertyName); + QCOMPARE(propertyValue.toStringList(), + QStringList() << "LIBA" << "LIBB" << "LIBC" << "LIBD"); + propertyName = QStringList() << "modules" << "dummy" << "productName"; + propertyValue = getConfigProperty(product->moduleProperties->value(), propertyName); + QCOMPARE(propertyValue.toString(), QString("libE")); } catch (const ErrorInfo &e) { exceptionCaught = true; diff --git a/src/lib/corelib/language/value.cpp b/src/lib/corelib/language/value.cpp index a9396338c..2dce8d027 100644 --- a/src/lib/corelib/language/value.cpp +++ b/src/lib/corelib/language/value.cpp @@ -90,7 +90,6 @@ JSSourceValue::JSSourceValue(bool createdByPropertiesBlock) : Value(JSSourceValueType, createdByPropertiesBlock) , m_line(-1) , m_column(-1) - , m_exportScope(nullptr) { } @@ -145,17 +144,6 @@ void JSSourceValue::setDefiningItem(Item *item) a.value->setDefiningItem(item); } -Item *JSSourceValue::exportScope() const -{ - return m_exportScope; -} - -void JSSourceValue::setExportScope(Item *extraScope) -{ - m_exportScope = extraScope; -} - - ItemValue::ItemValue(Item *item, bool createdByPropertiesBlock) : Value(ItemValueType, createdByPropertiesBlock) , m_item(item) diff --git a/src/lib/corelib/language/value.h b/src/lib/corelib/language/value.h index 74cc3f35c..4231f4c34 100644 --- a/src/lib/corelib/language/value.h +++ b/src/lib/corelib/language/value.h @@ -130,7 +130,6 @@ public: bool sourceUsesBase() const { return m_flags.testFlag(SourceUsesBase); } bool sourceUsesOuter() const { return m_flags.testFlag(SourceUsesOuter); } bool sourceUsesOriginal() const { return m_flags.testFlag(SourceUsesOriginal); } - bool isInExportItem() const { return m_exportScope; } bool hasFunctionForm() const { return m_flags.testFlag(HasFunctionForm); } void setHasFunctionForm(bool b); void setIsExclusiveListValue() { m_flags |= ExclusiveListValue; } @@ -152,9 +151,6 @@ public: void setDefiningItem(Item *item); - Item *exportScope() const; - void setExportScope(Item *exportScope); - private: QStringRef m_sourceCode; int m_line; @@ -163,7 +159,6 @@ private: Flags m_flags; JSSourceValuePtr m_baseValue; QList<Alternative> m_alternatives; - Item *m_exportScope; }; |