summaryrefslogtreecommitdiffstats
path: root/headergenerator.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-11-05 10:55:09 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-05 13:18:10 -0300
commite3ccffb6b50c3508f0c92280dd314b8393c4ff03 (patch)
treea42bb6f374bef539fc1a8e1511c31ef4a872fff8 /headergenerator.cpp
parent934fa3cb1a2672120bd82bb65764dc6a355ead35 (diff)
downloadshiboken-e3ccffb6b50c3508f0c92280dd314b8393c4ff03.tar.gz
shiboken-e3ccffb6b50c3508f0c92280dd314b8393c4ff03.tar.xz
shiboken-e3ccffb6b50c3508f0c92280dd314b8393c4ff03.zip
updated Python representation of C++ enums and flags (only QFlags at the
moment): the enum/flags numeric operators are shorter and only flags allow new instances to be created and the libshiboken Reviewd by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'headergenerator.cpp')
-rw-r--r--headergenerator.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/headergenerator.cpp b/headergenerator.cpp
index ab5e563c..75d7333a 100644
--- a/headergenerator.cpp
+++ b/headergenerator.cpp
@@ -246,13 +246,7 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty
s << "PyBaseWrapper_New(&" << pyTypeName << ", &" << pyTypeName << ',';
} else {
// Type is enum or flag
- s << "PyEnumObject_New(" << endl;
- {
- Indentation indent1(INDENT);
- Indentation indent2(INDENT);
- s << INDENT << '&' << pyTypeName << ',' << endl;
- s << INDENT << "\"ReturnedValue\", (long)";
- }
+ s << "PyEnumObject_New(&" << pyTypeName << ", (long)";
}
s << " cppobj);" << endl;
s << '}' << endl << endl;
@@ -350,6 +344,9 @@ void HeaderGenerator::finishGeneration()
if (!incFile.isEmpty())
enumIncludes << cppEnum->includeFile();
writeTypeCheckMacro(s_pts, cppEnum->typeEntry());
+ FlagsTypeEntry* flags = cppEnum->typeEntry()->flags();
+ if (flags)
+ writeTypeCheckMacro(s_pts, flags);
s_pts << endl;
writeTypeConverterDecl(convDecl, cppEnum->typeEntry());
writeTypeConverterImpl(convImpl, cppEnum->typeEntry());
@@ -371,14 +368,15 @@ void HeaderGenerator::finishGeneration()
foreach (const AbstractMetaEnum* cppEnum, metaClass->enums()) {
writeTypeCheckMacro(s_pts, cppEnum->typeEntry());
- s_pts << endl;
writeTypeConverterDecl(convDecl, cppEnum->typeEntry());
writeTypeConverterImpl(convImpl, cppEnum->typeEntry());
FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
if (flagsEntry) {
+ writeTypeCheckMacro(s_pts, flagsEntry);
writeTypeConverterDecl(convDecl, flagsEntry);
writeTypeConverterImpl(convImpl, flagsEntry);
}
+ s_pts << endl;
convDecl << endl;
}