[BioLib-dev] Perl file pointers

Pjotr Prins pjotr.public14 at thebird.nl
Tue Feb 9 13:10:59 UTC 2010


Hi Chris,

Thanks for testing! I would think the FILE* can be used as an
opaque SWIG pointer to an object - just like FILE * is handled
normally. Unless you need to access the contents of the struct, or
when you need to pass it into another Perl method (which may be the
case, for example, with your Perl::IO factory). 

If you need it fast, I may be able to look into it tomorrow.

There may be a hint in the SWIG PERL macros that come with SWIG itself
(/usr/share/swig?). SWIG is not well documented in this area. The guy
who did the Perl Math GSL mappings had quite a few tricks. See
http://leto.net/code/Math-GSL/. I can look into that in April. It is
one of those areas in SWIG... What may also help is read the generated C
code (at least, if C does not send you screaming). It helps.

Pj.

On Mon, Feb 08, 2010 at 01:30:05PM -0600, Chris Fields wrote:
> On Mon, 2010-02-08 at 13:23 -0600, Adam A Smith wrote:
> > > I'm guessing the appropriate mapping needs to be done in the 
> > > perl-specific SWIG files in src/mappings/swig/perl.  I'll see if I can 
> > > get it working, but for now we'll need to assume it's not implemented.
> > 
> > I ran into some of that when I was trying to SWIGify everything this last 
> > summer.  (I was beginning to look into it myself, when I got swept up in 
> > the rest of my life.)  Let me know if you find a solution--I'm very 
> > curious for my own sake.
> > 
> > Adam
> 
> I think it's just calling in a specific typemap, something along the
> lines of (for perl):
> 
> %typemap(in) FILE * {
>     $1 = PerlIO_findFILE(IoIFP(sv_2io($input)));
> }
> 
> Investigating it, perl uses a PerlIO * instead of a simple FILE *, so
> the above is necessary.  Python/Ruby/etc may not need that.  Regardless,
> I haven't managed to get that working, so I'm scrounging CPAN for a few
> SWIG-derived packages to see if there is anything there.
> 
> chris
> 
> _______________________________________________
> BioLib-dev mailing list
> BioLib-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biolib-dev



More information about the BioLib-dev mailing list