aboutsummaryrefslogtreecommitdiffstats
path: root/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-04-28 15:40:56 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:01 -0300
commitca3eac504857ade114fadb614631fe6ab78c5aad (patch)
tree37a0628c2c0e435f58078a3154ae7ec4c88fbcb8 /abstractmetabuilder.cpp
parent4adc6f3519a25060db98182eee66f3dcb9a60999 (diff)
Fixes template instanciation when the template parameter is a enum value.
Diffstat (limited to 'abstractmetabuilder.cpp')
-rw-r--r--abstractmetabuilder.cpp80
1 files changed, 33 insertions, 47 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index ea86ebe0d..3ebfa59e8 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -1827,17 +1827,7 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
TypeInfo info = typei;
bool subclassesDone = false;
while (!contexts.isEmpty() && !type) {
- //type = TypeDatabase::instance()->findType(contexts.at(0) + "::" + qualified_name);
-
- bool ok;
- info.setQualifiedName(QStringList() << contexts.at(0) << qualifiedName);
- AbstractMetaType *t = translateType(info, &ok, true, false);
- if (t && ok)
- return t;
-
- ClassModelItem item = m_dom->findClass(contexts.at(0));
- if (item)
- contexts += item->baseClasses();
+ type = TypeDatabase::instance()->findType(contexts.at(0) + "::" + qualifiedName);
contexts.pop_front();
// 10. Last resort: Special cased prefix of Qt namespace since the meta object implicitly inherits this, so
@@ -1869,45 +1859,22 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
metaType->setOriginalTypeDescription(_typei.toString());
decideUsagePattern(metaType);
- if (metaType->typeEntry()->isContainer()) {
- ContainerTypeEntry::Type container_type = static_cast<const ContainerTypeEntry *>(type)->type();
-
- if (container_type == ContainerTypeEntry::StringListContainer) {
- TypeInfo info;
- info.setQualifiedName(QStringList() << "QString");
- AbstractMetaType *targType = translateType(info, ok);
-
- Q_ASSERT(*ok);
- Q_ASSERT(targType);
-
- metaType->addInstantiation(targType);
- metaType->setInstantiationInCpp(false);
+ foreach (const TypeParser::Info &ta, typeInfo.template_instantiations) {
+ TypeInfo info;
+ info.setConstant(ta.is_constant);
+ info.setReference(ta.is_reference);
+ info.setIndirections(ta.indirections);
- } else {
- foreach (const TypeParser::Info &ta, typeInfo.template_instantiations) {
- TypeInfo info;
- info.setConstant(ta.is_constant);
- info.setReference(ta.is_reference);
- info.setIndirections(ta.indirections);
-
- info.setFunctionPointer(false);
- info.setQualifiedName(ta.instantiationName().split("::"));
-
- AbstractMetaType *targType = translateType(info, ok);
- if (!(*ok)) {
- delete metaType;
- return 0;
- }
+ info.setFunctionPointer(false);
+ info.setQualifiedName(ta.instantiationName().split("::"));
- metaType->addInstantiation(targType);
- }
+ AbstractMetaType *targType = translateType(info, ok);
+ if (!(*ok)) {
+ delete metaType;
+ return 0;
}
- if (container_type == ContainerTypeEntry::ListContainer
- || container_type == ContainerTypeEntry::VectorContainer
- || container_type == ContainerTypeEntry::StringListContainer) {
- Q_ASSERT(metaType->instantiations().size() == 1);
- }
+ metaType->addInstantiation(targType);
}
return metaType;
@@ -2199,7 +2166,24 @@ bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass *subclass,
QList<AbstractMetaType *> templateTypes;
foreach (const TypeParser::Info &i, targs) {
- TypeEntry *t = TypeDatabase::instance()->findType(i.qualified_name.join("::"));
+ QString typeName = i.qualified_name.join("::");
+ QStringList possibleNames;
+ possibleNames << subclass->qualifiedCppName() + "::" + typeName;
+ possibleNames << templateClass->qualifiedCppName() + "::" + typeName;
+ if (subclass->enclosingClass())
+ possibleNames << subclass->enclosingClass()->qualifiedCppName() + "::" + typeName;
+ possibleNames << typeName;
+
+ TypeDatabase* typeDb = TypeDatabase::instance();
+ TypeEntry* t;
+ QString templateParamName;
+ foreach (QString possibleName, possibleNames) {
+ t = typeDb->findType(possibleName);
+ if (t) {
+ QString templateParamName = possibleName;
+ break;
+ }
+ }
if (t) {
AbstractMetaType *temporaryType = createMetaType();
@@ -2208,6 +2192,8 @@ bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass *subclass,
temporaryType->setReference(i.is_reference);
temporaryType->setIndirections(i.indirections);
templateTypes << temporaryType;
+ } else {
+ ReportHandler::warning("Ignoring template parameter "+templateParamName+" from "+info.instantiationName()+", because I dont known what's it.");
}
}