aboutsummaryrefslogtreecommitdiffstats
path: root/abstractmetalang.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 /abstractmetalang.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 'abstractmetalang.cpp')
-rw-r--r--abstractmetalang.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp
index 5e8020db7..9643d5f85 100644
--- a/abstractmetalang.cpp
+++ b/abstractmetalang.cpp
@@ -675,12 +675,22 @@ QString AbstractMetaFunction::minimalSignature() const
return minimalSignature;
}
-FunctionModificationList AbstractMetaFunction::modifications(const AbstractMetaClass *implementor) const
+FunctionModificationList AbstractMetaFunction::modifications(const AbstractMetaClass* implementor) const
{
- // FIXME Global functions do not support modifications
if (!implementor)
- return FunctionModificationList();
- return implementor->typeEntry()->functionModifications(minimalSignature());
+ implementor = ownerClass();
+
+ if (!implementor)
+ return TypeDatabase::instance()->functionModifications(minimalSignature());
+
+ FunctionModificationList mods;
+ while (implementor) {
+ mods += implementor->typeEntry()->functionModifications(minimalSignature());
+ if (implementor == implementor->baseClass())
+ break;
+ implementor = implementor->baseClass();
+ }
+ return mods;
}
bool AbstractMetaFunction::hasModifications(const AbstractMetaClass *implementor) const
@@ -714,7 +724,7 @@ CodeSnipList AbstractMetaFunction::injectedCodeSnips(CodeSnip::Position position
bool AbstractMetaFunction::hasSignatureModifications() const
{
- foreach (const FunctionModification mod, modifications(ownerClass())) {
+ foreach (const FunctionModification mod, modifications()) {
foreach (const ArgumentModification argmod, mod.argument_mods) {
// since zero represents the return type and we're
// interested only in checking the function arguments,