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

when writing a XS code, we can use lots of functions, global values and Macros which are defined in perl, such as PL_compcv,perl_get_cv() and so on. Actually many Macros just invoke functions of perl. My question is what kind of functions and global values are exported to be used by programmer? Is there any documents or something i can refer to?

Replies are listed 'Best First'.
Re: XS code block
by chromatic (Archbishop) on Sep 23, 2003 at 09:20 UTC
Re: XS code block
by demerphq (Chancellor) on Sep 23, 2003 at 13:35 UTC

    You should take a look at Inline. If you write your code as Inline::C, with the correct options you are left behind an XS module with all the correct includes, etc. Not only that but Inline sorts out a lot of the hassles for you. I strongly suggest you have a review. (Check out the NoClean option :-)

    Also, your comment about the macros just calling through to functions in the Perl libraries isnt entirely true. The macros resolve a lot of stuff without calling through to subs, or only fallback on the subs if they really are needed. Furthermore the subs arent necessarily included in perlapi so talking to them directly could leave you with trouble if people decide to change that part of things.


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


Re: XS code block
by edan (Curate) on Sep 23, 2003 at 10:53 UTC

    In addition to chromatic's pointers, I would think that the perlxs and perlguts man pages might also be helpful (I don't recommend reading the PM copies, since they appear to be helplessly borken).

    --
    3dan