Michael Drumheller wrote:
> 
> Brian,
> 
> Another question:  having never used typemaps in
> XS, I am having a little trouble appreciating the
> true impact of the manpage statement "...The wrapper
> handles typemapping..."  Can you enlighten me on that
> a
> little?  If you want to just point me to more docs,
> that's fine!!!

All values are passed to subroutines (and XS subs) on the Perl stack.
The stack is an array of pointers to Scalar Values, or SV*. (see
/usr/lib/perl5/5.00503/i586-linux/CORE/sv.h or similar. Or read perlguts
manpage) That's the way Perl works. (Thus @_)

When your function definition looks like:

    int func(double var1, char* var2) {}

something has to worry about turning SV*-s into C types and back. That's
what typemaps do. Inline::C now gets all of its types from typemap
files. The default one is /usr/lib/perl5/5.00503/ExtUtils/typemap (or
similar) which is always distributed with Perl.

Inline generates an XS wrapper for each C function. That's where the
typemapping happens. Try running:

    perl -MInline=force,info,noclean somescript.pl

This will leave the build area intact, and tell you where to find it.
You can then look at the .xs and .c files. (xsubpp turns a .xs file into
a .c file) 

One nice thing about the wrapper approach is that your Inlined C
functions are callable from both Perl and other C functions.

By the way, I have never written a single typemap. I just hacked the
typemap parsing code out of Larry's xsubpp program. If Inline see's a
type listed in the typemap file it considers it valid. Then XS does the
real work later.

For the record, Inline does not do anything very difficult. All of the
hard stuff is done with existing tools. Inline just does all the right
things at the right time. I am not even a C programmer. I basically
learned enough C to do this module. :-)

> 
> By the way, the manpage has a few very minor typos &
> grammatical errors.  Do you want to know about them?

Yes, definitely. I put the doc out quickly because the last release was
3 months in the making and it needed to get out. I will start putting
out smaller releases a couple times a month now.

Also, I would prefer a patch rather than just comments. And if you like
writing you can help add some sections. I have completely ommitted some
things that really need doc. Let me know if you want to do this.

Brian

-- 
perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf
("Just Another %s Hacker",x);}};print JAxH+Perl'

Reply via email to