Writing C Modules with XS
MIME.xs The XS Source File
The new file generated by h2xs is MIME.xs (see Listing 9 3). This is the source file for
the XS half of the module.
Listing 9 3. MIME.xs Generated by h2xs A n Gnome::MIME
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
MODULE = Gnome::MIME PACKAGE = Gnome::MIME
The MIME.xs file consists of two parts. The first part is a series of #include
directives:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
These are passed straight through to the generated C source by xsubpp. In fact,
xsubpp passes through all text until it hits a line that starts with a MODULE directive:
MODULE = Gnome::MIME PACKAGE = Gnome::MIME
After this line, everything must be valid XS code, none of which is generated by h2xs.
2
Modifying Makefile.PL
The Makefile.PL generated by h2xs works right away. You can see the XS build
process without writing any XS code:
$ perl Makefile.PL && make
Checking if your kit is complete...
Looks good
Writing Makefile for Gnome::MIME
2. Actually, there is a way to get h2xs to generate some XS code for you. If you install the C::Scan
module from CPAN, then you can use the x option to attempt to auto generate XS from a C
header file. At present this process only succeeds with very simple header files. See the h2xs
documentation for more details.
21
211
1
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