summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-04-16 16:09:52 -0300
committerHugo Parente Lima <hugo.lima@openbossa.org>2010-04-22 19:45:25 -0300
commit5c59d232ecd1c03f920a11cd899e0699fc70c96b (patch)
tree1d686915970788e857fc7c36ee1281c54bb593cf
parentee42bc70bf41683d99a6862af22a1f4b3e006311 (diff)
downloadshiboken-5c59d232ecd1c03f920a11cd899e0699fc70c96b.tar.gz
shiboken-5c59d232ecd1c03f920a11cd899e0699fc70c96b.tar.xz
shiboken-5c59d232ecd1c03f920a11cd899e0699fc70c96b.zip
Added support for enums inside classes inside namespaces.
-rw-r--r--cppgenerator.cpp9
-rw-r--r--tests/libsample/samplenamespace.h4
-rwxr-xr-xtests/samplebinding/namespace_test.py1
-rw-r--r--tests/samplebinding/typesystem_sample.xml1
4 files changed, 9 insertions, 6 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index 28809330..4214c157 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -2318,13 +2318,10 @@ void CppGenerator::writeEnumInitialization(QTextStream& s, const AbstractMetaEnu
{
QString cpythonName = cpythonEnumName(cppEnum);
QString addFunction;
- if (cppEnum->enclosingClass()) {
- addFunction = QString("PyDict_SetItemString(Sbk")
- + cppEnum->enclosingClass()->name()
- + "_Type.super.ht_type.tp_dict,";
- } else {
+ if (cppEnum->enclosingClass())
+ addFunction = "PyDict_SetItemString(" + cpythonTypeName(cppEnum->enclosingClass()) + ".super.ht_type.tp_dict,";
+ else
addFunction = "PyModule_AddObject(module,";
- }
s << INDENT << "// init enum class: " << cppEnum->name() << endl;
s << INDENT << cpythonTypeNameExt(cppEnum->typeEntry()) << " = &" << cpythonTypeName(cppEnum->typeEntry()) << ';' << endl;
diff --git a/tests/libsample/samplenamespace.h b/tests/libsample/samplenamespace.h
index 2cc371e3..b3b3a822 100644
--- a/tests/libsample/samplenamespace.h
+++ b/tests/libsample/samplenamespace.h
@@ -76,6 +76,10 @@ public:
public:
class OkThisIsRecursiveEnough
{
+ public:
+ enum NiceEnum {
+ NiceValue1, NiceValue2
+ };
};
};
};
diff --git a/tests/samplebinding/namespace_test.py b/tests/samplebinding/namespace_test.py
index 942b6556..003d81b1 100755
--- a/tests/samplebinding/namespace_test.py
+++ b/tests/samplebinding/namespace_test.py
@@ -34,6 +34,7 @@ class TestClassesUnderNamespace(unittest.TestCase):
c1 = SampleNamespace.SomeClass()
c2 = SampleNamespace.SomeClass.SomeInnerClass()
c3 = SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough()
+ e3 = SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum()
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index bb0d98e1..85fc3e3d 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -100,6 +100,7 @@
<value-type name="SampleNamespace::SomeClass" />
<value-type name="SampleNamespace::SomeClass::SomeInnerClass" />
<value-type name="SampleNamespace::SomeClass::SomeInnerClass::OkThisIsRecursiveEnough" />
+ <enum-type name="SampleNamespace::SomeClass::SomeInnerClass::OkThisIsRecursiveEnough::NiceEnum" />
<object-type name="Abstract">
<modify-function signature="id()" rename="id_"/>