in reply to Re: Re: XS typemap and C++ multiple inheritance
in thread XS typemap and C++ multiple inheritance

If they are not all related into a single concrete derived class, then yes that's the way to do it. Your question showed an example of multiple inheritance, though, so the fix there is to always be consistant as to what you cast it to before sticking it in the void*.

—John

  • Comment on Re: Re: Re: XS typemap and C++ multiple inheritance

Replies are listed 'Best First'.
Re: Re: Re: Re: XS typemap and C++ multiple inheritance
by FrenchZ (Initiate) on Aug 06, 2001 at 18:19 UTC
    Hi John, My problem with this kind of solution is that all the type and inheritance hierarchy are hard-coded in the typemap.
    So if you add a new derived class or if you modify the inheritance (remove a base class) I will have to modify the typemap. If I miss one modification or do a wrong modif I would end up with really bad stuff.

    Don't you a automatic way of doing it or maybe a more extensible way than the enum Type ?

    TIA again,

    ~Xavier

      So define one base class whose only purpose is to serve as the hook to XS. Everything is dynamic_cast to that before storing in a void*, every void* is static_cast to that to restore it to the type system.

      Since it has no members but lives only for this purpose, it would be an error to remove it. Adding to the type hiarachy is not an issue. Any new code must still conform to this protocol.

      —John

        With this solution, I see 2 drawbacks :

        1 - I have to add a class in my C++ hierarchy only
        for XS. And I would like to have a clear spearation
        between my C++ classes and my XS code.
        I do not want to mix both .
        Moreover, my C++ classes are not only mapped to perl but
        also to TCL.

        2 - I will need to have one typemap for each mapped classes.

        am i right ?

        -- Xavier