diff options
author | Hugo Lima <hugo.lima@openbossa.org> | 2010-03-03 17:47:12 -0300 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2010-03-03 17:47:12 -0300 |
commit | 36376eb1c97cad139b40197cefd6650e8afc49b2 (patch) | |
tree | ee632b8b4e745a546921ec94f32e06e9875e3087 /tests | |
parent | a6c665dd07b5841e033f1558b2fcf391d5fba403 (diff) | |
parent | 8287b5b65ac0bd697f45bdebe833ad36263dfc75 (diff) |
Merge remote branch 'hugopl/typediscovery2'
Conflicts:
libshiboken/conversions.h
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libother/number.h | 2 | ||||
-rw-r--r-- | tests/libsample/abstract.h | 5 | ||||
-rw-r--r-- | tests/libsample/derived.cpp | 8 | ||||
-rw-r--r-- | tests/libsample/derived.h | 2 | ||||
-rwxr-xr-x | tests/samplebinding/typediscovery_test.py | 5 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 3 |
6 files changed, 23 insertions, 2 deletions
diff --git a/tests/libother/number.h b/tests/libother/number.h index bbbd830ba..d739802d8 100644 --- a/tests/libother/number.h +++ b/tests/libother/number.h @@ -47,7 +47,7 @@ public: Str toStr() const; operator Str() const { return toStr(); } -protected: +private: int m_value; }; #endif // NUMBER_H diff --git a/tests/libsample/abstract.h b/tests/libsample/abstract.h index 06f8d983e..008570560 100644 --- a/tests/libsample/abstract.h +++ b/tests/libsample/abstract.h @@ -50,6 +50,10 @@ public: ClassNameAndId }; + enum Type { + TpAbstract, TpDerived + }; + int primitiveField; Point valueTypeField; ObjectType* objectTypeField; @@ -76,6 +80,7 @@ public: void callUnpureVirtual(); void show(PrintFormat format = Verbose); + virtual Type type() const { return TpAbstract; } protected: virtual const char* className() { return "Abstract"; } diff --git a/tests/libsample/derived.cpp b/tests/libsample/derived.cpp index 0a3646258..39d9f30e6 100644 --- a/tests/libsample/derived.cpp +++ b/tests/libsample/derived.cpp @@ -107,3 +107,11 @@ Abstract* Derived::triggerImpossibleTypeDiscovery() { return new SecrectClass; } + +struct AnotherSecretClass : public Derived { +}; + +Abstract* Derived::triggerAnotherImpossibleTypeDiscovery() +{ + return new AnotherSecretClass; +} diff --git a/tests/libsample/derived.h b/tests/libsample/derived.h index 832148e35..c5acb9488 100644 --- a/tests/libsample/derived.h +++ b/tests/libsample/derived.h @@ -64,6 +64,7 @@ public: virtual void unpureVirtual(); virtual PrintFormat returnAnEnum() { return Short; } + virtual Type type() const { return TpDerived; } // factory method static Abstract* createObject(); @@ -85,6 +86,7 @@ public: SomeInnerClass returnMyParameter(const SomeInnerClass& s) { return s; } static Abstract* triggerImpossibleTypeDiscovery(); + static Abstract* triggerAnotherImpossibleTypeDiscovery(); protected: const char* getClassName() { return className(); } virtual const char* className() { return "Derived"; } diff --git a/tests/samplebinding/typediscovery_test.py b/tests/samplebinding/typediscovery_test.py index 14fd79e6b..3c1bfdb98 100755 --- a/tests/samplebinding/typediscovery_test.py +++ b/tests/samplebinding/typediscovery_test.py @@ -34,9 +34,14 @@ class TypeDiscoveryTest(unittest.TestCase): def testPureVirtualsOfImpossibleTypeDiscovery(self): a = Derived.triggerImpossibleTypeDiscovery() + self.assertEqual(type(a), Abstract) # call some pure virtual method a.pureVirtual() + def testAnotherImpossibleTypeDiscovery(self): + a = Derived.triggerAnotherImpossibleTypeDiscovery() + self.assertEqual(type(a), Derived) + if __name__ == '__main__': unittest.main() diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index 597bed610..40bb840ef 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -53,6 +53,7 @@ <enum-type name="Overload::FunctionEnum"/> <enum-type name="Overload::ParamEnum"/> <enum-type name="Event::EventType"/> + <enum-type name="Abstract::Type"/> <namespace-type name="SampleNamespace"/> @@ -60,7 +61,7 @@ <modify-function signature="id()" rename="id_"/> </object-type> - <object-type name="Derived"/> + <object-type name="Derived" polymorphic-id-expression="%1->type() == Derived::TpDerived" /> <value-type name="Derived::SomeInnerClass" /> <object-type name="ObjectType"> |