Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: XSUBs with variable input types

by crenz (Priest)
on Oct 25, 2004 at 09:01 UTC ( #402171=note: print w/ replies, xml ) Need Help??


in reply to Re: XSUBs with variable input types
in thread XSUBs with variable input types

Thanks for the hints! However, Perl can't know about the relationship with the Perl classes, since in my typemap, I declared the following:

fooRef T_PTROBJ barRef T_PTROBJ bazRef T_PTROBJ

How should I go about telling Perl that fooRef actually is a Foo object?


Comment on Re^2: XSUBs with variable input types
Select or Download Code
Re^3: XSUBs with variable input types
by thospel (Hermit) on Oct 25, 2004 at 09:40 UTC
    Please read the section "Perl Objects And C Structures" in perlxs (ignore the part about "Ptr" getting appended). You probably want your typemap to say:
    Foo T_PTROBJ Bar T_PTROBJ Baz T_PTROBJ
    and then have typedefs in your XS code to map these to your C level types. The perl level object hierarchy you define in the normal way in .pm files with e.g. things like:
    package Bar; ... use base qw(Foo); ...
    (and supposedly Foo.pm does the dynaload)

    Again, this last is not necessarily a good idea unless it's ok to call Foo functions on Bar objects for XS methods that exist in Foo but not in Bar (they will get called through inheritance if you apply that method to a Bar object)

      Thanks a lot, that works exactly as expected! I use @ISA for inheritance, but apart from that adopted your solution.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://402171]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2014-12-21 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls