summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-12-29 16:36:26 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:13 -0300
commitb6fdc5e8e6555aa7ee2cfe709fc68725ddc68ea4 (patch)
tree4906b8ec911e73ffca1ebaf4db58623133dcd3b4
parent82aaafc79c78a16717be5433e84aed3c51c4a4c8 (diff)
Add support to fix bug#493 - "__eq__ and friends not implemented for QKeyEvent == QKeySequence"
Reviewer: Renato Ara├║jo <renato.filho@openbossa.org> Lauro Moura <lauro.neto@openbossa.org>
-rw-r--r--abstractmetabuilder.cpp8
-rw-r--r--abstractmetalang.h18
-rw-r--r--tests/testreverseoperators.cpp17
3 files changed, 39 insertions, 4 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 1ef12bc4..780ea700 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -201,7 +201,9 @@ void AbstractMetaBuilder::traverseOperatorFunction(FunctionModelItem item)
// Strip away first argument, since that is the containing object
AbstractMetaArgumentList arguments = metaFunction->arguments();
if (firstArgumentIsSelf || unaryOperator) {
- AbstractMetaArgument *first = arguments.takeFirst();
+ AbstractMetaArgument* first = arguments.takeFirst();
+ if (!unaryOperator && first->type()->indirections())
+ metaFunction->setPointerOperator(true);
delete first;
metaFunction->setArguments(arguments);
} else {
@@ -210,7 +212,9 @@ void AbstractMetaBuilder::traverseOperatorFunction(FunctionModelItem item)
// must be an reverse operator (e.g. CLASS::operator(TYPE, CLASS)).
// All operator overloads that operate over a class are already
// being added as member functions of that class by the API Extractor.
- AbstractMetaArgument *last = arguments.takeLast();
+ AbstractMetaArgument* last = arguments.takeLast();
+ if (last->type()->indirections())
+ metaFunction->setPointerOperator(true);
delete last;
metaFunction->setArguments(arguments);
diff --git a/abstractmetalang.h b/abstractmetalang.h
index 1f1dc485..5671d606 100644
--- a/abstractmetalang.h
+++ b/abstractmetalang.h
@@ -799,7 +799,8 @@ public:
m_invalid(false),
m_reverse(false),
m_userAdded(false),
- m_explicit(false)
+ m_explicit(false),
+ m_pointerOperator(false)
{
}
@@ -835,6 +836,20 @@ public:
return m_reverse;
}
+ /**
+ * Returns true if this is a operator and the "self" operand is a pointer.
+ * e.g. class Foo {}; operator+(SomeEnum, Foo*);
+ */
+ bool isPointerOperator() const
+ {
+ return m_pointerOperator;
+ }
+
+ void setPointerOperator(bool value)
+ {
+ m_pointerOperator = value;
+ }
+
void setExplicit(bool isExplicit)
{
m_explicit = isExplicit;
@@ -1161,6 +1176,7 @@ private:
uint m_reverse : 1;
uint m_userAdded : 1;
uint m_explicit : 1;
+ uint m_pointerOperator : 1;
};
diff --git a/tests/testreverseoperators.cpp b/tests/testreverseoperators.cpp
index a13e0036..ab9cee0f 100644
--- a/tests/testreverseoperators.cpp
+++ b/tests/testreverseoperators.cpp
@@ -70,6 +70,8 @@ void TestReverseOperators::testReverseSumWithAmbiguity()
struct B {};\
B operator+(const A&, const B&);\
B operator+(const B&, const A&);\
+ int operator-(int, const A*);\
+ int operator/(const A*, int);\
";
const char xmlCode[] = "\
<typesystem package=\"Foo\">\
@@ -82,7 +84,7 @@ void TestReverseOperators::testReverseSumWithAmbiguity()
AbstractMetaClassList classes = t.builder()->classes();
AbstractMetaClass* classA = classes.findClass("A");
QVERIFY(classA);
- QCOMPARE(classA->functions().count(), 4);
+ QCOMPARE(classA->functions().count(), 6);
AbstractMetaClass* classB = classes.findClass("B");
QVERIFY(classB);
@@ -106,6 +108,19 @@ void TestReverseOperators::testReverseSumWithAmbiguity()
QVERIFY(reverseOp->isReverseOperator());
QCOMPARE(reverseOp->arguments().count(), 1);
QCOMPARE(reverseOp->minimalSignature(), QString("operator+(A,B)"));
+
+ reverseOp = classA->findFunction("operator-");
+ QVERIFY(reverseOp);
+ QCOMPARE(reverseOp->arguments().count(), 1);
+ QVERIFY(reverseOp->isPointerOperator());
+ QVERIFY(reverseOp->isReverseOperator());
+
+ normalOp = classA->findFunction("operator/");
+ QVERIFY(normalOp);
+ QCOMPARE(normalOp->arguments().count(), 1);
+ QVERIFY(normalOp->isPointerOperator());
+ QVERIFY(!normalOp->isReverseOperator());
+
}