aboutsummaryrefslogtreecommitdiffstats
path: root/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-03-30 19:30:25 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:09:59 -0300
commit6acf826b4b2eab32237845f98228171bb8be213c (patch)
tree13dff04c39b74817851a5f8f99a483aff8adf040 /abstractmetabuilder.cpp
parent458735ffaf282cf703698a86ec54f25a0df077d9 (diff)
Adds reverse operator functions to the proper classes.
AbstractMetaBuilder::traverseOperatorFunction does additional checks to avoid mistaken a class' reverse operator as a direct operator of another class. An unit test was added to check for this case. Reviewed by Anderson Lizardo <anderson.lizardo@openbossa.org> Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Diffstat (limited to 'abstractmetabuilder.cpp')
-rw-r--r--abstractmetabuilder.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 211c82a4..ac1dcd02 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -168,12 +168,25 @@ void AbstractMetaBuilder::traverseOperatorFunction(FunctionModelItem item)
bool unaryOperator = false;
baseoperandClass = argumentToClass(arguments.at(0));
+
if (arguments.size() == 1) {
unaryOperator = true;
} else if (!baseoperandClass
|| !(baseoperandClass->typeEntry()->codeGeneration() & TypeEntry::GenerateTargetLang)) {
baseoperandClass = argumentToClass(arguments.at(1));
firstArgumentIsSelf = false;
+ } else {
+ bool ok;
+ AbstractMetaType* type = translateType(item->type(), &ok);
+ const TypeEntry* retType = ok ? type->typeEntry() : 0;
+ AbstractMetaClass* otherArgClass = argumentToClass(arguments.at(1));
+ if (otherArgClass && retType
+ && (retType->isValue() || retType->isObject())
+ && retType != baseoperandClass->typeEntry()
+ && retType == otherArgClass->typeEntry()) {
+ baseoperandClass = m_metaClasses.findClass(retType);
+ firstArgumentIsSelf = false;
+ }
}
if (baseoperandClass) {