aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-03-02 14:34:01 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-03-02 17:18:20 -0300
commit3a4263a603b8caa4f93dcd534971bf7ffaf65e9f (patch)
treefc98bf94b965e9f5f35c7150463b4966d7620e49 /tests
parentac7573693042bc8f9d4d94958d89d5b15add39f2 (diff)
Use polymorphic-id-expression to discover the correct type of a C++ object.
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/abstract.h5
-rw-r--r--tests/libsample/derived.h1
-rw-r--r--tests/samplebinding/typesystem_sample.xml3
3 files changed, 8 insertions, 1 deletions
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.h b/tests/libsample/derived.h
index 5a4543155..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();
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">