Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jdavidb (1361)

  (email not shown publicly)

J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.

Journal of jdavidb (1361)

Thursday June 27, 2002
02:55 PM

YAPC day 2: Embedding C in Perl

[ #6021 ]

Embedding C in Perl by Chris Brooks. I've never done XS before, so I'll be happy to see a bit.

Chris said by the time he finished his talk draft, he'd basically rewritten perlxstut.

target C subroutine: the one you want to use

Matt, Chris used AxPoint to put his presentation together and couldn't figure out how to put in angle brackets. Maybe a FAQ candidate?

XS source code file: glue code

Namespace resolution:

XS gives you 2 API functions to install xsubs as Perl subs: newXS() and newXSproto(). Takes

  • name to assign function
  • pointer to xsub
  • name of C source code file (just for debugging)

newXS() can't be called from your program. Instead you use DynaLoader, which calls newXS() for you. You subclass DynaLoader and call bootstrap(), a wrapper around some internal functions that eventually call newXS().

XS syntax. Use MODULE and PACKAGE keywords. Before that line, everything is C (or POD).

MODULE = Mytest2 PACKAGE = Mytest2

Perl scalars and things are not just C variables.

I'm being inspired to sit down and learn XS. Tonight. Somebody stop me. is the presentation slides. Worth reading, along with perlxstut. PerlMonth 1999 articles.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.