Chapter 9
I'll add a line for the GList* type:
GList *          T_GLIST
The next section in a typemap is the INPUT section. An INPUT typemap describes 
how to translate from an SV* to the specified type. It is used when an XSUB takes 
the type as a parameter. Since gnome_mime_get_keys() returns GList* and nothing 
I'm wrapping uses a GList* as a parameter, I'll leave this one unimplemented:
INPUT
T_GLIST
        croak("GList * input typemap unimplemented!");
Next comes the OUTPUT section, which specifies how to turn the type into an SV*:
OUTPUT
T_GLIST
        $arg = GList_to_AVref($var);
Typemap code uses two placeholder variables: $arg and $var. In an OUTPUT typemap, 
$var is a variable of the type being output and $arg is the SV* to be returned. As you 
can see, my OUTPUT typemap calls the GList_to_AVref() function. This function 
doesn't exist in either Perl or Gnome, so I'll have to write it!
Where to place external functions like GList_to_AVref() is a matter of pref 
erence. Some XS coders prefer to put them in a separate .c file compiled and 
linked separately. I prefer to place them in the C section above the XSUB decla 
rations, and that's the way I'll do it here (see Listing 9 10).
Listing 9 10. GList_to_AVref() Function Included in MIME.xs
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include 
SV * GList_to_AVref(GList *list) {
  GList *iter;       // list iterator
  AV *av = newAV();  // initialize new array
  // iterate through GList
  for (iter = list; iter; iter = iter >next) {
    // push data onto array
    av_push(av, newSVpv(iter >data,0));
  }
234






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

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