Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

perlapi magic: setting ISA from C code

by kingkongrevenge (Scribe)
on Feb 23, 2009 at 00:20 UTC ( [id://745675]=perlquestion: print w/replies, xml ) Need Help??

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?

         

         

        ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://745675]
Approved by almut
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-23 21:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found