summaryrefslogtreecommitdiffstats
path: root/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-04-25 15:01:35 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:16 -0300
commitfd5c0f2a8a114ce11390fee445976d7cc0d213f3 (patch)
tree7066002de7a3c849f4ff446125960a3e5f10667b /abstractmetabuilder.cpp
parent427992fc248b60dc38e21a4a2e2a48f64c1cbe2c (diff)
Add support to template types as arguments on user added functions.sb-0.10.2
Reviewer: Renato Ara├║jo <renato.filho@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'abstractmetabuilder.cpp')
-rw-r--r--abstractmetabuilder.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 41c09a3e..4b8f2e10 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -1897,10 +1897,27 @@ AbstractMetaType* AbstractMetaBuilder::translateType(double vr, const AddedFunct
TypeDatabase* typeDb = TypeDatabase::instance();
TypeEntry* type;
- if (typeInfo.name == "void")
+ QString typeName = typeInfo.name;
+
+ if (typeName == "void")
return 0;
- type = typeDb->findType(typeInfo.name);
+ type = typeDb->findType(typeName);
+
+ // test if the type is a template, like a container
+ bool isTemplate = false;
+ QString templateArg;
+ if (!type) {
+ QRegExp r("(.*)<(.*)>$");
+ if (r.indexIn(typeInfo.name) != -1) {
+ templateArg = r.cap(2);
+ if (templateArg.contains(','))
+ ReportHandler::warning("add-function tag doesn't support container types with more than one argument or template arguments.");
+ else
+ isTemplate = (type = typeDb->findContainerType(r.cap(1)));
+ }
+ }
+
if (!type) {
type = new TypeEntry(typeInfo.name, TypeEntry::CustomType, vr);
typeDb->addType(type);
@@ -1911,6 +1928,16 @@ AbstractMetaType* AbstractMetaBuilder::translateType(double vr, const AddedFunct
metaType->setIndirections(typeInfo.indirections);
metaType->setReference(typeInfo.isReference);
metaType->setConstant(typeInfo.isConstant);
+ if (isTemplate) {
+ type = typeDb->findType(templateArg);
+ if (type) {
+ AbstractMetaType* metaArgType = createMetaType();
+ metaArgType->setTypeEntry(type);
+ metaType->addInstantiation(metaArgType);
+ metaType->setTypeUsagePattern(AbstractMetaType::ContainerPattern);
+ }
+ }
+
return metaType;
}