summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-09-30 10:54:30 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-09-30 11:54:43 -0300
commitdcf1b0969fc4e5fc7c92232140ac1d1d751905a2 (patch)
treefcda77e186a54024c708323ff9e8bc2b92951058
parent385c5799cacd75523a1456cc28c05cade2b11ea5 (diff)
downloadshiboken-dcf1b0969fc4e5fc7c92232140ac1d1d751905a2.tar.gz
shiboken-dcf1b0969fc4e5fc7c92232140ac1d1d751905a2.tar.xz
shiboken-dcf1b0969fc4e5fc7c92232140ac1d1d751905a2.zip
Shiboken avoids generating code for private enums.
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Ara├║jo <renato.filho@openbossa.org>
-rw-r--r--generator/cppgenerator.cpp16
-rw-r--r--generator/headergenerator.cpp9
-rw-r--r--tests/libsample/abstract.h10
3 files changed, 26 insertions, 9 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 26fea059..da15c4d4 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -385,7 +385,7 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl
foreach (AbstractMetaEnum* cppEnum, metaClass->enums()) {
- if (cppEnum->isAnonymous())
+ if (cppEnum->isAnonymous() || cppEnum->isPrivate())
continue;
bool hasFlags = cppEnum->typeEntry()->flags();
@@ -3326,8 +3326,11 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
s << INDENT << "PyObject* enum_item;" << endl << endl;
}
- foreach (const AbstractMetaEnum* cppEnum, metaClass->enums())
+ foreach (const AbstractMetaEnum* cppEnum, metaClass->enums()) {
+ if (cppEnum->isPrivate())
+ continue;
writeEnumInitialization(s, cppEnum);
+ }
if (metaClass->hasSignals())
writeSignalInitialization(s, metaClass);
@@ -3591,7 +3594,7 @@ void CppGenerator::finishGeneration()
s << "// Enum definitions ";
s << "------------------------------------------------------------" << endl;
foreach (const AbstractMetaEnum* cppEnum, globalEnums()) {
- if (cppEnum->isAnonymous())
+ if (cppEnum->isAnonymous() || cppEnum->isPrivate())
continue;
writeEnumDefinition(s, cppEnum);
s << endl;
@@ -3674,8 +3677,11 @@ void CppGenerator::finishGeneration()
s << INDENT << "PyObject* enum_item;" << endl << endl;
}
- foreach (const AbstractMetaEnum* cppEnum, globalEnums())
- writeEnumInitialization(s, cppEnum);
+ foreach (const AbstractMetaEnum* cppEnum, globalEnums()) {
+ if (cppEnum->isPrivate())
+ continue;
+ writeEnumInitialization(s, cppEnum);
+ }
// Register primitive types on TypeResolver
s << INDENT << "// Register primitive types on TypeResolver" << endl;
diff --git a/generator/headergenerator.cpp b/generator/headergenerator.cpp
index 095febb7..f9384d58 100644
--- a/generator/headergenerator.cpp
+++ b/generator/headergenerator.cpp
@@ -281,8 +281,11 @@ void HeaderGenerator::writeTypeIndexDefine(QTextStream& s, const AbstractMetaCla
if (!metaClass->typeEntry()->generateCode())
return;
writeTypeIndexDefineLine(s, metaClass->typeEntry(), idx);
- foreach (const AbstractMetaEnum* metaEnum, metaClass->enums())
+ foreach (const AbstractMetaEnum* metaEnum, metaClass->enums()) {
+ if (metaEnum->isPrivate())
+ continue;
writeTypeIndexDefineLine(s, metaEnum->typeEntry(), idx);
+ }
}
void HeaderGenerator::finishGeneration()
@@ -321,7 +324,7 @@ void HeaderGenerator::finishGeneration()
macrosStream << "// Macros for type check" << endl;
foreach (const AbstractMetaEnum* cppEnum, globalEnums()) {
- if (cppEnum->isAnonymous())
+ if (cppEnum->isAnonymous() || cppEnum->isPrivate())
continue;
includes << cppEnum->typeEntry()->include();
writeTypeConverterDecl(convDecl, cppEnum->typeEntry());
@@ -338,7 +341,7 @@ void HeaderGenerator::finishGeneration()
includes << classType->include();
foreach (const AbstractMetaEnum* cppEnum, metaClass->enums()) {
- if (cppEnum->isAnonymous())
+ if (cppEnum->isAnonymous() || cppEnum->isPrivate())
continue;
EnumTypeEntry* enumType = cppEnum->typeEntry();
includes << enumType->include();
diff --git a/tests/libsample/abstract.h b/tests/libsample/abstract.h
index 7a9f3e09..bbe39efa 100644
--- a/tests/libsample/abstract.h
+++ b/tests/libsample/abstract.h
@@ -30,12 +30,20 @@ class ObjectType;
class LIBSAMPLE_API Abstract
{
+private:
+ enum PrivateEnum {
+ PrivValue0,
+ PrivValue1,
+ PrivValue2 = PrivValue1 + 2
+ };
public:
enum PrintFormat {
Short,
Verbose,
OnlyId,
- ClassNameAndId
+ ClassNameAndId,
+ DummyItemToTestPrivateEnum1 = Abstract::PrivValue1,
+ DummyItemToTestPrivateEnum2 = PrivValue2,
};
enum Type {