aboutsummaryrefslogtreecommitdiffstats
path: root/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-09-28 15:19:06 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:10 -0300
commit0dd7d12ca18255ec186293bc00918cd68e516fa6 (patch)
treeaf555aee35239d622417ee09dcb83820d5ccc9f9 /abstractmetabuilder.cpp
parent2bfe59a2b8a588b338da7b9472d4ec6f66c2d10a (diff)
Fixed AbstractMetaBuilder to handle enum values receiving boolean values.
In other words, this enum { Positive = true, Negative = false }; is now properly recognized. Tests were added as usual. Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Ara├║jo <renato.filho@openbossa.org>
Diffstat (limited to 'abstractmetabuilder.cpp')
-rw-r--r--abstractmetabuilder.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 9ae66241b..d4c75dc1f 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -792,16 +792,19 @@ int AbstractMetaBuilder::figureOutEnumValue(const QString &stringValue,
AbstractMetaClass* enumEnclosingClass = metaEnum ? metaEnum->enclosingClass() : 0;
if (metaEnum) {
- if ((ev = metaEnum->values().find(s))) {
+ matched = true;
+ if (s == "true" || s == "false") {
+ v = (s == "true");
+ } else if ((ev = metaEnum->values().find(s))) {
v = ev->value();
- matched = true;
} else if (enumEnclosingClass && (ev = enumEnclosingClass->findEnumValue(s, metaEnum))) {
v = ev->value();
- matched = true;
} else {
+ matched = false;
ReportHandler::warning("unhandled enum value: " + s + " in "
+ (enumEnclosingClass ? QString("%1::").arg(enumEnclosingClass->name()) : QString())
- + metaEnum->name());
+ + metaEnum->name()
+ + " from header '" + metaEnum->typeEntry()->include().name() + "'");
}
} else {
ReportHandler::warning("unhandled enum value: Unknown enum");
@@ -820,6 +823,7 @@ int AbstractMetaBuilder::figureOutEnumValue(const QString &stringValue,
.arg(metaFunction->name())
.arg(metaFunction->implementingClass()->name());
}
+ warn += " from header '" + metaEnum->typeEntry()->include().name() + "'";
ReportHandler::warning(warn);
returnValue = oldValuevalue;
@@ -1945,23 +1949,27 @@ AbstractMetaType* AbstractMetaBuilder::translateType(const TypeInfo& _typei, boo
int elems = s.toInt(&ok);
if (!ok) {
- AbstractMetaEnumValue* enumValue = m_metaClasses.findEnumValue(s);
- if (!enumValue) {
- foreach (AbstractMetaEnum* metaEnum, m_globalEnums) {
- foreach (AbstractMetaEnumValue* ev, metaEnum->values()) {
- if (ev->name() == s) {
- enumValue = ev;
- break;
+ if (s == "true" or s == "false") {
+ elems = (s == "true");
+ } else {
+ AbstractMetaEnumValue* enumValue = m_metaClasses.findEnumValue(s);
+ if (!enumValue) {
+ foreach (AbstractMetaEnum* metaEnum, m_globalEnums) {
+ foreach (AbstractMetaEnumValue* ev, metaEnum->values()) {
+ if (ev->name() == s) {
+ enumValue = ev;
+ break;
+ }
}
+ if (enumValue)
+ break;
}
- if (enumValue)
- break;
}
- }
- if (!enumValue)
- return 0;
- elems = enumValue->value();
+ if (!enumValue)
+ return 0;
+ elems = enumValue->value();
+ }
}
AbstractMetaType* arrayType = createMetaType();