You can set up the skeleton like this:
%define "cast" "dynamic_cast"
%define "cast" "static_cast"
%define "cast" "" (or default) -> union
...
In the C++ class polymorphy variations, I had to write something like
dynamic_cast<type>(*$k.data())
static_cast<type>(*$k.data())
... if you are ok with
dynamic_cast<type>(*$k)
that is, instead of
struct container {
top_class *member;
top_class *data () { return member; }
}
you have to write this:
struct container {
top_class *member;
top_class &operator *() { return *member; }
}