Steven N . Hirsch <[EMAIL PROTECTED]> writes:
>On Thu, 29 Nov 2001, Forrest Cahoon wrote:
>
>> Lack of documentation is driving me nuts!
>>
>> All the references I can find point me to perlapio for information about
>> dealing with Perl I/O inside of XS functions.  That's nice ... now how do I
>> get one into or out of XS code?  That I can't find anywhere.

In theory (at least in perl5.7.*) the default typemap should have
an entry for PerlIO *

So :

PerlIO *
ThingThatReturnsOne(...)

and

ThingThatExpectsOne(PerlIO *f)

should "just work" - what gets messy is that that


>>
>> 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. 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))


>>
>> 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 *

>>
>> 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 really appreciate any help I might receive.
>
>That makes two of us.  I couldn't find so much as a shred of documentation
>on this.  Even some example code would be better than nothing.
>
>Steve
--
Nick Ing-Simmons
http://www.ni-s.u-net.com/


Reply via email to