Writing C Modules with XS
To get started, I would create two literal XSUBs:
MODULE = Gnome::MIME PACKAGE = Gnome::MIME PREFIX = gnome_mime_
GList *
gnome_mime_get_keys(type)
const char * type
const char *
gnome_mime_get_value(type, key)
const char * type
const char * key
But this generates a compilation error:
Error: GList * not in typemap in MIME.xs, line 10
The last time you saw this error, it was for const char * and const gchar *, and
the solution was to simply alias those types to the type used for char *. In this case, the
solution won't be so easy there's no existing typemap with the behavior I'm
looking for. In particular, I want a typemap that will take a GList* and return a ref
erence to an AV*. You can find the completed typemap file in Listing 9 9.
Listing 9 9. typemap File with GList* Typemap
const char * T_PV
const gchar * T_PV
GList * T_GLIST
INPUT
T_GLIST
croak("GList * input typemap unimplemented!");
OUTPUT
T_GLIST
$arg = GList_to_AVref($var);
A typemap file has three sections. The first is a list of C type names and corre
sponding typemap names. This allows a group of C types to share a single typemap.
This section already has two lines in my typemap file:
const char * T_PV
const gchar * T_PV
23
233
3
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