On Mar 26, 2009, at 5:22 PM, Christian Andreetta wrote:
> Hi!
>
> First of all, thanks to everybody for the *great* tool called cython
Glad you're liking it.
> th question: is there a way to declare a dynamic_cast in cython?
> Practically, a polymorphism: I would like to address the same memory
> space with two different object types. The C++ lib has this function:
>
> Node* base() { return dynamic_cast<Node*>(this); } // "this" is an
> instance of the class SuperDuperNode(Node)
>
> Some helper functions can of course go around this problem, but I was
> wondering if there was a way of letting cython know that:
>
> SuperDuperNode_this and Node_this=SuperDuperNode_this.base()
>
> are actually referring to the same memory address.
No, there is no way to do this in pure Cython. What you could do is
write it as a macro, then use "cdef extern from" to declare it as a
function in the Cython scope. BTW, I don't think they're always the
same memory address (e.g. in the case of multiple inheritance).
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev