Skip to content

Commit

Permalink
Fix PYSIDE-108 bug and add example
Browse files Browse the repository at this point in the history
Replace "::" with "_" in protected enum name to fix issue
Add test case to libsample and samplebinding

Change-Id: I2edea2dfa8adecfe5fa34f777da9f60cfe4c6ee4
Reviewed-by: Hugo Parente Lima <[email protected]>
  • Loading branch information
jcummings2 authored and hugopl committed Sep 11, 2012
1 parent a3cecba commit eb293c2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion generator/shiboken/shibokengenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunction* fu

QString ShibokenGenerator::protectedEnumSurrogateName(const AbstractMetaEnum* metaEnum)
{
return metaEnum->fullName().replace(".", "_") + "_Surrogate";
return metaEnum->fullName().replace(".", "_").replace("::", "_") + "_Surrogate";
}

QString ShibokenGenerator::protectedFieldGetterName(const AbstractMetaField* field)
Expand Down
10 changes: 10 additions & 0 deletions tests/libsample/samplenamespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,20 @@ class SomeClass
inline int someMethod(SomeInnerClass*) { return 0; }
virtual OkThisIsRecursiveEnough* someVirtualMethod(OkThisIsRecursiveEnough* arg) { return arg; }
};
protected:
enum ProtectedEnum {
ProtectedItem0,
ProtectedItem1
};
};
struct SomeOtherInnerClass {
std::list<SomeInnerClass> someInnerClasses;
};
protected:
enum ProtectedEnum {
ProtectedItem0,
ProtectedItem1
};
};

class DerivedFromNamespace : public SomeClass::SomeInnerClass::OkThisIsRecursiveEnough
Expand Down
4 changes: 4 additions & 0 deletions tests/samplebinding/namespace_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def testInvisibleNamespace(self):
class TestClassesUnderNamespace(unittest.TestCase):
def testIt(self):
c1 = SampleNamespace.SomeClass()
e1 = SampleNamespace.SomeClass.ProtectedEnum()
c2 = SampleNamespace.SomeClass.SomeInnerClass()
e2 = SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum()
c3 = SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough()
e3 = SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum()

Expand All @@ -53,6 +55,8 @@ def testFunctionAddedOnNamespace(self):

def testTpNames(self):
self.assertEquals(str(SampleNamespace.SomeClass), "<%s 'sample.SampleNamespace.SomeClass'>"%TYPE_STR)
self.assertEquals(str(SampleNamespace.SomeClass.ProtectedEnum), "<%s 'sample.SampleNamespace.SomeClass.ProtectedEnum'>"%TYPE_STR)
self.assertEquals(str(SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum), "<%s 'sample.SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum'>"%TYPE_STR)
self.assertEquals(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough), "<%s 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough'>"%TYPE_STR)
self.assertEquals(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum), "<%s 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum'>"%TYPE_STR)

Expand Down
2 changes: 2 additions & 0 deletions tests/samplebinding/typesystem_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,10 @@
<object-type name="OkThisIsRecursiveEnough">
<enum-type name="NiceEnum" />
</object-type>
<enum-type name="ProtectedEnum"/>
</value-type>
<value-type name="SomeOtherInnerClass"/>
<enum-type name="ProtectedEnum"/>
</value-type>

<modify-function signature="doSomethingWithArray(const unsigned char*, unsigned int, const char*)">
Expand Down

0 comments on commit eb293c2

Please sign in to comment.