aboutsummaryrefslogtreecommitdiffstats
path: root/apiextractor.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-05-31 15:51:33 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:04 -0300
commitbf5dbc2df39d014860a21884f55209ace04d2846 (patch)
treed42a72131a58c8da3ffc133d807d6457993d9080 /apiextractor.cpp
parent0ae936e54e7f5e6a57db75dccfc8aa23b83fe6ef (diff)
Added methods ApiExtractor::findAbstractMetaEnum.
The new methods returns an AbstractMetaEnum for a given TypeEntry, EnumTypeEntry, FlagsTypeEntry or AbstractMetaType.
Diffstat (limited to 'apiextractor.cpp')
-rw-r--r--apiextractor.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/apiextractor.cpp b/apiextractor.cpp
index 2a44d56b..a8fe38b4 100644
--- a/apiextractor.cpp
+++ b/apiextractor.cpp
@@ -143,6 +143,59 @@ QSet<QString> ApiExtractor::qtMetaTypeDeclaredTypeNames() const
return m_builder->qtMetaTypeDeclaredTypeNames();
}
+static const AbstractMetaEnum* findEnumOnClasses(AbstractMetaClassList metaClasses, const EnumTypeEntry* typeEntry)
+{
+ const AbstractMetaEnum* result = 0;
+ foreach (const AbstractMetaClass* metaClass, metaClasses) {
+ foreach (const AbstractMetaEnum* metaEnum, metaClass->enums()) {
+ if (metaEnum->typeEntry() == typeEntry) {
+ result = metaEnum;
+ break;
+ }
+ }
+ if (result)
+ break;
+ result = findEnumOnClasses(metaClass->innerClasses(), typeEntry);
+ }
+ return result;
+}
+
+const AbstractMetaEnum* ApiExtractor::findAbstractMetaEnum(const EnumTypeEntry* typeEntry) const
+{
+ if (!typeEntry)
+ return 0;
+ foreach (AbstractMetaEnum* metaEnum, m_builder->globalEnums()) {
+ if (metaEnum->typeEntry() == typeEntry)
+ return metaEnum;
+ }
+ return findEnumOnClasses(m_builder->classes(), typeEntry);
+}
+
+const AbstractMetaEnum* ApiExtractor::findAbstractMetaEnum(const TypeEntry* typeEntry) const
+{
+ if (!typeEntry)
+ return 0;
+ if (typeEntry->isFlags())
+ return findAbstractMetaEnum(reinterpret_cast<const FlagsTypeEntry*>(typeEntry));
+ if (typeEntry->isEnum())
+ return findAbstractMetaEnum(reinterpret_cast<const EnumTypeEntry*>(typeEntry));
+ return 0;
+}
+
+const AbstractMetaEnum* ApiExtractor::findAbstractMetaEnum(const FlagsTypeEntry* typeEntry) const
+{
+ if (!typeEntry)
+ return 0;
+ return findAbstractMetaEnum(typeEntry->originator());
+}
+
+const AbstractMetaEnum* ApiExtractor::findAbstractMetaEnum(const AbstractMetaType* metaType) const
+{
+ if (!metaType)
+ return 0;
+ return findAbstractMetaEnum(metaType->typeEntry());
+}
+
int ApiExtractor::classCount() const
{
Q_ASSERT(m_builder);