diff options
author | Lupe Christoph <lupe@lupe-christoph.de> | 2002-05-09 11:42:02 +0200 |
---|---|---|
committer | Abhijit Menon-Sen <ams@wiw.org> | 2002-05-09 06:50:24 +0000 |
commit | e8a52a58035b5a0e5584519ecc319d579c024d85 (patch) | |
tree | e364654a6bf7d83144ab092c17a3f4de758add0d /pod/perlxstut.pod | |
parent | 65dabbe3286e79f63edd4b43d9a84f46860dc2bc (diff) | |
download | perl-e8a52a58035b5a0e5584519ecc319d579c024d85.tar.gz |
[Patch] perlxstut.pod
Message-Id: <20020509074202.GJ1087@lupe-christoph.de>
(Applied with tweaks.)
p4raw-id: //depot/perl@16514
Diffstat (limited to 'pod/perlxstut.pod')
-rw-r--r-- | pod/perlxstut.pod | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/pod/perlxstut.pod b/pod/perlxstut.pod index c7723af887..420e989096 100644 --- a/pod/perlxstut.pod +++ b/pod/perlxstut.pod @@ -1229,15 +1229,20 @@ The real work is done in the standard typemap. B<But> you loose all the fine stuff done by the perlio layers. This calls the stdio function C<fputs()>, which knows nothing about them. -For PerlIO *'s, there considered to be three kinds in the -standard typemap C<InputStream> (T_IN), C<InOutStream> (T_INOUT) and -C<OutputStream> (T_OUT), a bare C<PerlIO *> is considered a T_INOUT. -If it matters in your code (see below for why it might) #define or typedef -one of the specific names and use that as the type in your XS file. +The standard typemap offers three variants of PerlIO *: +C<InputStream> (T_IN), C<InOutStream> (T_INOUT) and C<OutputStream> +(T_OUT). A bare C<PerlIO *> is considered a T_INOUT. If it matters +in your code (see below for why it might) #define or typedef +one of the specific names and use that as the argument or result +type in your XS file. + +The standard typemap does not contain PerlIO * before perl 5.7, +but it has the three stream variants. Using a PerlIO * directly +is not backwards compatible unless you provide your own typemap. For streams coming I<from> perl the main difference is that C<OutputStream> will get the output PerlIO * - which may make -a difference on a socket. +a difference on a socket. Like in our example... For streams being handed I<to> perl a new file handle is created (i.e. a reference to a new glob) and associated with the PerlIO * @@ -1272,13 +1277,13 @@ We have to use a C<CODE> section because C<PerlIO_puts()> has the arguments reversed compared to C<fputs()>, and we want to keep the arguments the same. Wanting to explore this thoroughly, we want to use the stdio C<fputs()> -on an explicit PerlIO *. This means we have to ask the perlio system -for a stdio C<FILE *>: +on a PerlIO *. This means we have to ask the perlio system for a stdio +C<FILE *>: int perliofputs(s, stream) char * s - PerlIO * stream + OutputStream stream PREINIT: FILE *fp = PerlIO_findFILE(stream); CODE: @@ -1290,10 +1295,6 @@ for a stdio C<FILE *>: OUTPUT: RETVAL -(We also using bare PerlIO * as the type - so we get the I<input> -PerlIO * of a socket - if this is undesirable use typedef or #define -as above.) - Note: C<PerlIO_findFILE()> will search the layers for a stdio layer. If it can't find one, it will call C<PerlIO_exportFILE()> to generate a new stdio C<FILE>. Please only call C<PerlIO_exportFILE()> if |