kingkongrevenge has asked for the wisdom of the Perl Monks concerning the following question:

How do you manipulate @ISA from C? The documentation for the "magic" stuff is lousy. I guess it has something to do with vtbl_isa and sv_magic but damned if I can find an example.

I have a little thing working where the constructor of a C++ object blesses itself into a perl class. This works fine, but I want to use inheritance on the perl side for the resulting blessed scalar.

/* C++ ctor */ SomeClassName::SomeClassName() { ... sv_setref_pv( mySv, "SomeClassName", (void*)this ); //This works fine. /* How do I tell mySv it @ISA "SomeBaseClass"? */ ... }

Replies are listed 'Best First'.
Re: perlapi magic: setting ISA from C code
by almut (Canon) on Feb 23, 2009 at 00:39 UTC

    I think you should be able to manipulate @ISA just like any other array, i.e. something like (untested):

    av_push( get_av("SomeClassName::ISA",1), newSVpv("SomeBaseClass",0) );
      We have a winner! Thanks. Don't know why I couldn't think of that.

      The sv_magic documentation is still confusing...

        Too many bananas?

         

         

        ;)