Chapter 10
The module can then be built and tested:
$ perl Makefile.PL && make && make test
Checking if your kit is complete...
Looks good
Writing Makefile for Gnome::MIME
cp MIME.pm blib/lib/Gnome/MIME.pm
/usr/local/bin/perl Mblib MInline=_INSTALL_ MGnome::MIME e1 0.01 blib/arch
Using /home/sam/Gnome/MIME/blib
PERL_DL_NONLAZY=1 /usr/local/bin/perl Iblib/arch Iblib/lib \
I/usr/local/lib/perl5/5.6.1/i686 linux I/usr/local/lib/perl5/5.6.1 test.pl
ok 1 use Gnome::MIME;
ok 2 recognizes .gif
ok 3 recognizes .jpg
ok 4 recognizes .html
1..4
That's all there is to it! No extra files; just a pure C function in the body of the module.
Notice that this case is different from the starting point with XS, where the
simplest XSUB was one without any code at all. XS and Inline::C are tuned for dif
ferent uses. XS is tuned to produce direct mappings from C function signatures to
Perl functions. Inline::C prefers full C functions. However, just as XS has CODE and
PPCODE to support full C functions, Inline::C has facilities for generating wrappers
from function signatures. The difference is more one of emphasis than of capability.
Inline::C Techniques
This section will explore ways that Inline::C can be used to enhance the basic
inlined function shown earlier. Many of these techniques will be very similar to
those shown in the XS Techniques section in Chapter 9. This is natural; Inline::C
is just a layer on top of XS, so many of the things that can be done with XS can be
done the same way in Inline::C.
Using Typemaps
Typemaps work mostly the same way in Inline::C as they do in XS. The biggest dif
ference is that to use a typemap with Inline::C, you have to include the TYPEMAPS
option:
244
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved