File indexing completed on 2024-06-16 04:23:16

0001 /*
0002     SPDX-FileCopyrightText: 2002-2005 Roberto Raggi <roberto@kdevelop.org>
0003     SPDX-FileCopyrightText: 2006 Adam Treat <treat@kde.org>
0004     SPDX-FileCopyrightText: 2006-2008 Hamish Rodda <rodda@kde.org>
0005     SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-only
0008 */
0009 
0010 #include "enumerationtype.h"
0011 
0012 #include "typesystemdata.h"
0013 #include "typeregister.h"
0014 
0015 namespace KDevelop {
0016 //Because all these classes have no d-pointers, shallow copies are perfectly fine
0017 
0018 REGISTER_TYPE(EnumerationType);
0019 
0020 EnumerationType::EnumerationType(const EnumerationType& rhs)
0021     : EnumerationTypeBase(copyData<EnumerationType>(*rhs.d_func()))
0022 {
0023 }
0024 
0025 EnumerationType::EnumerationType(EnumerationTypeData& data)
0026     : EnumerationTypeBase(data)
0027 {
0028 }
0029 
0030 AbstractType* EnumerationType::clone() const
0031 {
0032     return new EnumerationType(*this);
0033 }
0034 
0035 bool EnumerationType::equals(const AbstractType* _rhs) const
0036 {
0037     if (this == _rhs)
0038         return true;
0039 
0040     if (!EnumerationTypeBase::equals(_rhs))
0041         return false;
0042 
0043     Q_ASSERT(dynamic_cast<const EnumerationType*>(_rhs));
0044 
0045     // Nothing enumeration type-specific to compare
0046     return true;
0047 }
0048 
0049 EnumerationType::EnumerationType()
0050     : EnumerationTypeBase(createData<EnumerationType>())
0051 {
0052     IntegralType::setDataType(TypeInt);
0053 }
0054 
0055 QString EnumerationType::toString() const
0056 {
0057     return qualifiedIdentifier().toString();
0058 }
0059 
0060 uint EnumerationType::hash() const
0061 {
0062     return KDevHash(IntegralType::hash()) << IdentifiedType::hash();
0063 }
0064 
0065 AbstractType::WhichType EnumerationType::whichType() const
0066 {
0067     return TypeEnumeration;
0068 }
0069 }