Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: XSUBs with variable input types

by crenz (Priest)
on Oct 25, 2004 at 09:01 UTC ( [id://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?

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://402171]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-23 22:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found