aboutsummaryrefslogtreecommitdiffstats
path: root/typesystem.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-12-14 17:54:57 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-12-16 12:29:54 -0300
commitaeeb950b50a108a2475c0ee630d74420ccb3a0b3 (patch)
tree60d586e195ab17d75d1c1510ccfdf87129ad6206 /typesystem.cpp
parent00a880f4d61a6a32f3e1dcaa4a692a6e430c123a (diff)
Adds support for module level 'add-function' tag.
The TypeDatabase now stores global added functions as well as function modifications. The AbstractMetaFunction::modifications method was improved to check for global modifications. The test suite was updated with the changes.
Diffstat (limited to 'typesystem.cpp')
-rw-r--r--typesystem.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/typesystem.cpp b/typesystem.cpp
index 2e1fe0e52..74bb6c384 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -259,6 +259,11 @@ bool Handler::endElement(const QString &, const QString &localName, const QStrin
return true;
switch (m_current->type) {
+ case StackElement::Root: {
+ TypeDatabase::instance()->setAddedFunctions(m_addedFunctions);
+ TypeDatabase::instance()->setFunctionModifications(m_functionMods);
+ }
+ break;
case StackElement::ObjectTypeEntry:
case StackElement::ValueTypeEntry:
case StackElement::InterfaceTypeEntry:
@@ -803,6 +808,7 @@ bool Handler::startElement(const QString &, const QString &n,
|| element->type == StackElement::LoadTypesystem
|| element->type == StackElement::InjectCode
|| element->type == StackElement::ConversionRule
+ || element->type == StackElement::AddFunction
|| element->type == StackElement::Template;
if (!topLevel && m_current->type == StackElement::Root) {
@@ -1280,8 +1286,8 @@ bool Handler::startElement(const QString &, const QString &n,
}
break;
case StackElement::AddFunction: {
- if (!(topElement.type & StackElement::ComplexTypeEntryMask)) {
- m_error = QString::fromLatin1("Add function requires complex type as parent"
+ if (!(topElement.type & (StackElement::ComplexTypeEntryMask | StackElement::Root))) {
+ m_error = QString::fromLatin1("Add function requires a complex type or a root tag as parent"
", was=%1").arg(topElement.type, 0, 16);
return false;
}
@@ -1972,11 +1978,34 @@ FlagsTypeEntry *TypeDatabase::findFlagsType(const QString &name) const
return fte ? fte : (FlagsTypeEntry *) m_flagsEntries.value(name);
}
+AddedFunctionList TypeDatabase::findAddedFunctions(const QString& name) const
+{
+ AddedFunctionList addedFunctions;
+ foreach (AddedFunction func, m_addedFunctions) {
+ if (func.name() == name)
+ addedFunctions.append(func);
+ }
+ return addedFunctions;
+}
+
+
QString TypeDatabase::globalNamespaceClassName(const TypeEntry * /*entry*/)
{
return QLatin1String("Global");
}
+FunctionModificationList TypeDatabase::functionModifications(const QString& signature) const
+{
+ FunctionModificationList lst;
+ for (int i = 0; i < m_functionMods.count(); ++i) {
+ const FunctionModification& mod = m_functionMods.at(i);
+ if (mod.signature == signature)
+ lst << mod;
+ }
+
+ return lst;
+}
+
/*!
* The Visual Studio 2002 compiler doesn't support these symbols,