Forrest Cahoon <[EMAIL PROTECTED]> writes:
>
>I'm using 5.6.1 (on Linux) and may have to run on 5.00503 (on VMS) as
>well: are these things that I can add to my local typemap?  

They should be there on older perls too - but prior to 5.7 a PerlIO *
is really as FILE *. 

>Or should
>I stay away from PerlIO and use the former interface (which I also
>have no clue about)?  I had really hoped to use the latest and
>greatest, but I have to stick to what people are really using in
>production environments.

PerlIO * has been there since 5.003_02

>
>> >>
>> >> If I create an IO::File object in perl and pass it into my XS
>function, can
>> >> I just cast the SV * into a PerlIO * and work with that?  Is that what
>I'm
>> >> supposed to do?
>>
>> No. In general the SV will be a reference-to-a-glob.
>
>I thought IO::File was going to be the "new way" in Perl and we were
>going to do away with all those ugly \*FOO -style parameters.  Is that
>not correct?  

IO::File is considered by some to be an unnessary extra abstraction.
perl5.7.* can do :

open(my $fh,...)

and create the glob-ref as required itself.

>Is IO::File just a blessed globref, or what?  

Yes it is.

>If I do
>want to pass an IO::File object to my XS function, do I need to do
>something different here?

No. Perl level file handles are (in perl5) globs (strictly the 
IO part of the glob but that is not really an issue here).
Deep inside is a PerlIO * - which in older perls is #define-d to FILE *. 

>
>>                                    You need to dereference
>> it and then use GvIO to get the IO - sv_2io() does that for you,
>> you then and then IoIFP() to get the PerlIO * - unless you want IoOFP of
>course.
>> - more indirections that one could possibly want :-(
>>
>> For INPUT
>>
>>          $var = IoIFP(sv_2io($arg))
>
>OK, I think I actually understand this (scary!).  So does sv_2io() get
>a FILE * from my SV * that was passed into XS as a globref and IoIFP()
>turn that FILE * into a PerlIO * ?

It fished out a PerlIO *.
On older perls IoIFP _is_ a FILE *. On perl5.7.* PerlIO * is a structure 
of our own.

>
>> >>
>> >> If I create a PerlIO * in my XS code, do I pass it back to perl as an
>SV *?
>> >> Is it blessed in some appropriate way?  What would it be, IO::Handle?
>>
>> The default typemap creates a blessed reference to a new glob in the
>> XS's package and then uses a messy call to the internals to import the
>> PerlIO *
>
>This is the 5.7.x typemap, right?  (I guess in earlier Perls I'm not
>gonna be using PerlIO *, or should I?)  

You should use PerlIO * unless you have something 5.003_01 or earlier,
and I hope you don't. Unless you have perl5.7 the PerlIO * will _be_ 
a FILE * but you should pretend you don't know that and use 
the PerlIO_xxxxx() functions. That way when perl5.8 hits the streets
you will be ready.

>And what is the glob reference
>blessed to ... IO::Handle, as I guessed earlier?

It is blessed into your XS's package.

Your perl's standard typemap should have entries for these things
by one name or another.

>
>> >>
>> >> I also can't find any way to search the perl-xs archives ... I suspect
>this
>> >> has been covered many times already.  Sorry about the probable
>repitition.
>
>I actually did find searchable archives at
>http://www.xray.mpe.mpg.de/mailing-lists/perl-xs/
>but I still didn't find any useful discussion (for a clueless person
>like myself) of this topic.
>
>> >> I really appreciate any help I might receive.
>
>Yeah, I meant that.  Thanks, Nick!
>
>Forrest Cahoon
>not speaking for merrill corporation
-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/

Reply via email to