summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-02-10 18:34:15 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2011-02-11 15:07:46 -0200
commitc167d196107f074d4f814a6bf06729effe0fa80d (patch)
tree063b0332cb610ee1d8158f4d216fffb82a1be17c
parent0374b254dfd955686856d2d13ce5d6b051224130 (diff)
downloadshiboken-c167d196107f074d4f814a6bf06729effe0fa80d.tar.gz
shiboken-c167d196107f074d4f814a6bf06729effe0fa80d.tar.xz
shiboken-c167d196107f074d4f814a6bf06729effe0fa80d.zip
Fix string used in tp_name on inner types.
Reviewer: Lauro Moura <lauro.neto@openbossa.org> Renato Ara├║jo <renato.filho@openbossa.org>
-rw-r--r--generator/cppgenerator.cpp5
-rw-r--r--tests/samplebinding/enum_test.py2
-rw-r--r--tests/samplebinding/namespace_test.py5
3 files changed, 9 insertions, 3 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 65ec116d..615bd72b 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -2512,7 +2512,7 @@ void CppGenerator::writeClassDefinition(QTextStream& s, const AbstractMetaClass*
s << "static SbkObjectType " << className + "_Type" << " = { { {" << endl;
s << INDENT << "PyObject_HEAD_INIT(&SbkObjectType_Type)" << endl;
s << INDENT << "/*ob_size*/ 0," << endl;
- s << INDENT << "/*tp_name*/ \"" << metaClass->fullName() << "\"," << endl;
+ s << INDENT << "/*tp_name*/ \"" << getClassTargetFullName(metaClass) << "\"," << endl;
s << INDENT << "/*tp_basicsize*/ sizeof(SbkObject)," << endl;
s << INDENT << "/*tp_itemsize*/ 0," << endl;
s << INDENT << "/*tp_dealloc*/ " << tp_dealloc << ',' << endl;
@@ -3026,7 +3026,8 @@ void CppGenerator::writeEnumInitialization(QTextStream& s, const AbstractMetaEnu
s << cppEnum->name() << endl;
if (!cppEnum->isAnonymous()) {
- s << INDENT << "PyTypeObject* " << cpythonName << " = Shiboken::Enum::newType(\"" << cppEnum->name() << "\");" << endl;
+
+ s << INDENT << "PyTypeObject* " << cpythonName << " = Shiboken::Enum::newType(\"" << getClassTargetFullName(cppEnum) << "\");" << endl;
if (cppEnum->typeEntry()->flags())
s << INDENT << cpythonName << "->tp_as_number = &" << cpythonName << "_as_number;" << endl;
diff --git a/tests/samplebinding/enum_test.py b/tests/samplebinding/enum_test.py
index 22e6b917..4d67fcea 100644
--- a/tests/samplebinding/enum_test.py
+++ b/tests/samplebinding/enum_test.py
@@ -106,7 +106,7 @@ class MyEvent(Event):
class OutOfBoundsTest(unittest.TestCase):
def testValue(self):
e = MyEvent()
- self.assertEqual(repr(e.eventType()), '<enum-item EventType.#out of bounds# (999)>')
+ self.assertEqual(repr(e.eventType()), '<enum-item sample.Event.EventType.#out of bounds# (999)>')
class EnumOverloadTest(unittest.TestCase):
'''Test case for overloads involving enums'''
diff --git a/tests/samplebinding/namespace_test.py b/tests/samplebinding/namespace_test.py
index 29633f38..20637cae 100644
--- a/tests/samplebinding/namespace_test.py
+++ b/tests/samplebinding/namespace_test.py
@@ -40,5 +40,10 @@ class TestClassesUnderNamespace(unittest.TestCase):
res = SampleNamespace.ImInsideANamespace(2, 2)
self.assertEquals(res, 4)
+ def testTpNames(self):
+ self.assertEquals(str(SampleNamespace.SomeClass), "<type 'sample.SampleNamespace.SomeClass'>")
+ self.assertEquals(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough), "<type 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough'>")
+ self.assertEquals(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum), "<type 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum'>")
+
if __name__ == '__main__':
unittest.main()