Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

XS Info

by dbp (Pilgrim)
on Sep 03, 2002 at 18:45 UTC ( #194852=perlquestion: print w/replies, xml ) Need Help??

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

I'm looking into embedding C into perl using XS. What are the best places to look for info and examples on this topic? Currently, I'm consulting the standard docs such as perlxs(1), perlxstut(1), perlguts(1), and the like. Also, I have read the pertinent chapters in Programming Perl and the Perl Cookbook. I've also looked at Dean Roehrich's cookbook, which has great examples, but little explanation. Know any friendly intros to XS that also delve into more complicated topics like passing data types between perl and c?

Replies are listed 'Best First'.
Re: XS Info
by Zaxo (Archbishop) on Sep 03, 2002 at 19:00 UTC

    Inline::C has a somewhat less vertical learning curve than straight XS, and also has generally useful cookbook.

    In any case, the typemap declarations are what you want to look at for data type passing. It may be most direct to look at an example typemap from some C library wrapper module, and compare it to the library's headers and EXTERN.h, perl.h, and XSUB.h.

    After Compline,
    Zaxo

      <toot>Getting Started with Inline::C</toot>

      But for more completeness check out manning's extending and embedding perl (link below in MZSanford's node). It is "dense" - in a good way - and definetly delves deep into the internals. You can also check out Advanced Perl Programming - especially chapters 18,19, and 20.

      -derby

Re: XS Info
by MZSanford (Curate) on Sep 03, 2002 at 20:43 UTC
    I suggest Extending and Embedding Perl (Pub: Manning , Auth: Jenness, Cozens) ... a great book on the subject. I recently read this after picking it up, and found that it filled in the gaps i found left by the standard docs.
    from the frivolous to the serious
      I second that suggestion, Great Book! It fills the gaps for Advance Perl Programming, although I recommend that book as well.
Re: XS Info
by toma (Vicar) on Sep 04, 2002 at 06:24 UTC
Re: XS Info
by Matts (Deacon) on Sep 04, 2002 at 13:35 UTC
    Dean's Cookbook (A and B) is where I learned from. I think you have to have a use-case for why you want to learn XS first though, but given that, and given that you can find something similar in Dean's cookbook, then you're pretty much set. And even though it hasn't been updated since 1996, it's still relevant and still a really great resource.

    The hard bits of XS are understanding the typemap, and figuring out how to access all the perl variable types in C (the HV's, AV's, and RV's for example), and making sure that in doing so you don't leak memory all over the floor. To learn those I just had more use-cases, and followed perlguts very carefully.

Re: XS Info
by feloniousMonk (Pilgrim) on Sep 04, 2002 at 14:33 UTC
    Let me cast another vote for Advanced Perl Programming -
    not only for the coverage of XS but also the fact that it explains the differences between XS and SWIG.

    -felonious--

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://194852]
Approved by VSarkiss
Front-paged by rob_au
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2020-05-28 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (165 votes). Check out past polls.

    Notices?