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

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

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

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: XS typemap and C++ multiple inheritance
by John M. Dlugosz (Monsignor) on Aug 06, 2001 at 22:44 UTC
    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