1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "TypeMatcher.h"
35 #include "CoreTypes.h"
40 using namespace CPlusPlus;
42 TypeMatcher::TypeMatcher()
46 TypeMatcher::~TypeMatcher()
50 bool TypeMatcher::isEqualTo(const Name *name, const Name *otherName) const
52 if (name == otherName)
55 else if (! name || ! otherName)
58 return name->isEqualTo(otherName);
61 bool TypeMatcher::match(const UndefinedType *, const UndefinedType *)
66 bool TypeMatcher::match(const VoidType *, const VoidType *)
71 bool TypeMatcher::match(const IntegerType *type, const IntegerType *otherType)
73 if (type == otherType)
76 else if (type->kind() != otherType->kind())
82 bool TypeMatcher::match(const FloatType *type, const FloatType *otherType)
84 if (type == otherType)
87 else if (type->kind() != otherType->kind())
93 bool TypeMatcher::match(const PointerToMemberType *type, const PointerToMemberType *otherType)
95 if (type == otherType)
98 else if (! isEqualTo(type->memberName(), otherType->memberName()))
101 else if (! type->elementType().match(otherType->elementType(), this))
107 bool TypeMatcher::match(const PointerType *type, const PointerType *otherType)
109 if (type == otherType)
112 else if (! type->elementType().match(otherType->elementType(), this))
118 bool TypeMatcher::match(const ReferenceType *type, const ReferenceType *otherType)
120 if (type == otherType)
123 else if (type->isRvalueReference() != otherType->isRvalueReference())
126 else if (! type->elementType().match(otherType->elementType(), this))
132 bool TypeMatcher::match(const ArrayType *type, const ArrayType *otherType)
134 if (type == otherType)
137 else if (type->size() != otherType->size())
140 else if (! type->elementType().match(otherType->elementType(), this))
146 bool TypeMatcher::match(const NamedType *type, const NamedType *otherType)
148 if (type == otherType)
151 else if (! isEqualTo(type->name(), otherType->name()))
157 bool TypeMatcher::match(const Function *type, const Function *otherType)
159 if (type != otherType)
165 bool TypeMatcher::match(const Enum *type, const Enum *otherType)
167 if (type != otherType)
173 bool TypeMatcher::match(const Namespace *type, const Namespace *otherType)
175 if (type != otherType)
181 bool TypeMatcher::match(const Template *type, const Template *otherType)
183 if (type != otherType)
189 bool TypeMatcher::match(const ForwardClassDeclaration *type, const ForwardClassDeclaration *otherType)
191 if (type != otherType)
197 bool TypeMatcher::match(const Class *type, const Class *otherType)
199 if (type != otherType)
205 bool TypeMatcher::match(const ObjCClass *type, const ObjCClass *otherType)
207 if (type != otherType)
213 bool TypeMatcher::match(const ObjCProtocol *type, const ObjCProtocol *otherType)
215 if (type != otherType)
221 bool TypeMatcher::match(const ObjCForwardClassDeclaration *type, const ObjCForwardClassDeclaration *otherType)
223 if (type != otherType)
229 bool TypeMatcher::match(const ObjCForwardProtocolDeclaration *type, const ObjCForwardProtocolDeclaration *otherType)
231 if (type != otherType)
237 bool TypeMatcher::match(const ObjCMethod *type, const ObjCMethod *otherType)
239 if (type != otherType)