Writing C Modules with Inline::C
use Inline C => DATA ,
NAME => "Gnome::MIME",
VERSION => "0.01",
LIBS => gnome config gnome libs ,
INC => gnome config gnome cflags ,
TYPEMAPS => typemap ;
The TYPEMAPS option is set to the path of the typemap file. For example, to use
the gchar type in the file_type(), I would create a file called typemap and put a
single line in it:
gchar * T_PV
Now the file_type() function can written as follows:
char * file_type (gchar * filename) {
return gnome_mime_type(filename);
}
Inline::C uses typemap files in two ways. They're used by the generated XS to
bind function parameters and return values in the same way as in the XS section.
However, they're also used by the Inline::C parser to determine which functions
can be wrapped for use by Perl. Inline::C will silently ignore functions with signa
tures that don't have matching typemaps. The result is that if Inline::C doesn't
accept your typemap for one reason or another, it will simply ignore functions that
are trying to use that typemap. You can find out if this is happening by setting the
PRINT_INFO option:
use Inline C => DATA ,
NAME => "Gnome::MIME",
VERSION => "0.01",
LIBS => gnome config gnome libs ,
INC => gnome config gnome cflags ,
TYPEMAPS => typemap ,
PRINT_INFO => 1;
This will cause Inline::C to produce the same information block shown earlier with
the MInline=INFO invocation. Included is a list of functions bound by Inline::C; if
functions are missing, then you may have a problem with your typemaps.
24
245
5
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