This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Cleanup: Condense tests and add a few
[perl5.git] / ext / XS-Typemap / Typemap.xs
CommitLineData
ea035a69
JH
1/*
2 XS code to test the typemap entries
3
4 Copyright (C) 2001 Tim Jenness.
5 All Rights Reserved
6
7*/
8
3c53ff3f
NC
9#define PERL_NO_GET_CONTEXT
10
ea035a69
JH
11#include "EXTERN.h" /* std perl include */
12#include "perl.h" /* std perl include */
13#include "XSUB.h" /* XSUB include */
14
15/* Prototypes for external functions */
16FILE * xsfopen( const char * );
17int xsfclose( FILE * );
18int xsfprintf( FILE *, const char *);
19
20/* Type definitions required for the XS typemaps */
21typedef SV * SVREF; /* T_SVREF */
22typedef int SysRet; /* T_SYSRET */
23typedef int Int; /* T_INT */
24typedef int intRef; /* T_PTRREF */
25typedef int intObj; /* T_PTROBJ */
26typedef int intRefIv; /* T_REF_IV_PTR */
27typedef int intArray; /* T_ARRAY */
28typedef short shortOPQ; /* T_OPAQUE */
29typedef int intOpq; /* T_OPAQUEPTR */
30
5abff6f9
TJ
31/* A structure to test T_OPAQUEPTR */
32struct t_opaqueptr {
33 int a;
34 int b;
35 double c;
36};
37
38typedef struct t_opaqueptr astruct;
39
ea035a69 40/* Some static memory for the tests */
052980ee
TJ
41static I32 xst_anint;
42static intRef xst_anintref;
43static intObj xst_anintobj;
44static intRefIv xst_anintrefiv;
45static intOpq xst_anintopq;
ea035a69 46
b64f48ff 47/* A different type to refer to for testing the different
1d2615b4 48 * AV*, HV*, etc typemaps */
b64f48ff
SM
49typedef AV AV_FIXED;
50typedef HV HV_FIXED;
1d2615b4
SM
51typedef CV CV_FIXED;
52typedef SVREF SVREF_FIXED;
b64f48ff 53
ea035a69
JH
54/* Helper functions */
55
56/* T_ARRAY - allocate some memory */
57intArray * intArrayPtr( int nelem ) {
58 intArray * array;
a02a5408 59 Newx(array, nelem, intArray);
ea035a69
JH
60 return array;
61}
62
63
64MODULE = XS::Typemap PACKAGE = XS::Typemap
65
66PROTOTYPES: DISABLE
67
68=head1 TYPEMAPS
69
70Each C type is represented by an entry in the typemap file that
ac23f157
SM
71is responsible for converting perl variables (SV, AV, HV, CV, etc.)
72to and from that type.
ea035a69
JH
73
74=over 4
75
76=item T_SV
77
78This simply passes the C representation of the Perl variable (an SV*)
79in and out of the XS layer. This can be used if the C code wants
80to deal directly with the Perl variable.
81
82=cut
83
84SV *
85T_SV( sv )
86 SV * sv
87 CODE:
88 /* create a new sv for return that is a copy of the input
89 do not simply copy the pointer since the SV will be marked
90 mortal by the INPUT typemap when it is pushed back onto the stack */
91 RETVAL = sv_mortalcopy( sv );
92 /* increment the refcount since the default INPUT typemap mortalizes
93 by default and we don't want to decrement the ref count twice
94 by mistake */
95 SvREFCNT_inc(RETVAL);
96 OUTPUT:
97 RETVAL
98
99=item T_SVREF
100
101Used to pass in and return a reference to an SV.
102
1d2615b4
SM
103Note that this typemap does not decrement the reference count
104when returning the reference to an SV*.
105See also: T_SVREF_REFCOUNT_FIXED
106
ea035a69
JH
107=cut
108
109SVREF
110T_SVREF( svref )
111 SVREF svref
112 CODE:
113 RETVAL = svref;
114 OUTPUT:
115 RETVAL
116
1d2615b4
SM
117=item T_SVREF_FIXED
118
119Used to pass in and return a reference to an SV.
120This is a fixed
121variant of T_SVREF that decrements the refcount appropriately
122when returning a reference to an SV*. Introduced in perl 5.15.4.
123
124=cut
125
126SVREF_FIXED
127T_SVREF_REFCOUNT_FIXED( svref )
128 SVREF_FIXED svref
129 CODE:
130 SvREFCNT_inc(svref);
131 RETVAL = svref;
132 OUTPUT:
133 RETVAL
134
ea035a69
JH
135=item T_AVREF
136
137From the perl level this is a reference to a perl array.
138From the C level this is a pointer to an AV.
139
b64f48ff
SM
140Note that this typemap does not decrement the reference count
141when returning an AV*. See also: T_AVREF_REFCOUNT_FIXED
142
ea035a69
JH
143=cut
144
145AV *
146T_AVREF( av )
147 AV * av
148 CODE:
149 RETVAL = av;
150 OUTPUT:
151 RETVAL
152
b64f48ff
SM
153=item T_AVREF_REFCOUNT_FIXED
154
155From the perl level this is a reference to a perl array.
156From the C level this is a pointer to an AV. This is a fixed
157variant of T_AVREF that decrements the refcount appropriately
158when returning an AV*. Introduced in perl 5.15.4.
159
160=cut
161
162AV_FIXED*
163T_AVREF_REFCOUNT_FIXED( av )
164 AV_FIXED * av
165 CODE:
166 SvREFCNT_inc(av);
167 RETVAL = av;
168 OUTPUT:
169 RETVAL
170
ea035a69
JH
171=item T_HVREF
172
173From the perl level this is a reference to a perl hash.
d1be9408 174From the C level this is a pointer to an HV.
ea035a69 175
b64f48ff
SM
176Note that this typemap does not decrement the reference count
177when returning an HV*. See also: T_HVREF_REFCOUNT_FIXED
178
ea035a69
JH
179=cut
180
181HV *
182T_HVREF( hv )
183 HV * hv
184 CODE:
185 RETVAL = hv;
186 OUTPUT:
187 RETVAL
188
b64f48ff
SM
189=item T_HVREF_REFCOUNT_FIXED
190
191From the perl level this is a reference to a perl hash.
192From the C level this is a pointer to an HV. This is a fixed
193variant of T_HVREF that decrements the refcount appropriately
194when returning an HV*. Introduced in perl 5.15.4.
195
196=cut
197
198HV_FIXED*
199T_HVREF_REFCOUNT_FIXED( hv )
200 HV_FIXED * hv
201 CODE:
202 SvREFCNT_inc(hv);
203 RETVAL = hv;
204 OUTPUT:
205 RETVAL
206
207
ea035a69
JH
208=item T_CVREF
209
210From the perl level this is a reference to a perl subroutine
211(e.g. $sub = sub { 1 };). From the C level this is a pointer
212to a CV.
213
1d2615b4
SM
214Note that this typemap does not decrement the reference count
215when returning an HV*. See also: T_HVREF_REFCOUNT_FIXED
216
ea035a69
JH
217=cut
218
219CV *
220T_CVREF( cv )
221 CV * cv
222 CODE:
223 RETVAL = cv;
224 OUTPUT:
225 RETVAL
226
1d2615b4
SM
227=item T_CVREF_REFCOUNT_FIXED
228
229From the perl level this is a reference to a perl subroutine
230(e.g. $sub = sub { 1 };). From the C level this is a pointer
231to a CV.
232
233This is a fixed
234variant of T_HVREF that decrements the refcount appropriately
235when returning an HV*. Introduced in perl 5.15.4.
236
237=cut
238
239CV_FIXED *
240T_CVREF_REFCOUNT_FIXED( cv )
241 CV_FIXED * cv
242 CODE:
243 SvREFCNT_inc(cv);
244 RETVAL = cv;
245 OUTPUT:
246 RETVAL
ea035a69
JH
247
248=item T_SYSRET
249
250The T_SYSRET typemap is used to process return values from system calls.
251It is only meaningful when passing values from C to perl (there is
252no concept of passing a system return value from Perl to C).
253
254System calls return -1 on error (setting ERRNO with the reason)
255and (usually) 0 on success. If the return value is -1 this typemap
256returns C<undef>. If the return value is not -1, this typemap
257translates a 0 (perl false) to "0 but true" (which
258is perl true) or returns the value itself, to indicate that the
259command succeeded.
260
261The L<POSIX|POSIX> module makes extensive use of this type.
262
263=cut
264
265# Test a successful return
266
267SysRet
268T_SYSRET_pass()
269 CODE:
270 RETVAL = 0;
271 OUTPUT:
272 RETVAL
273
274# Test failure
275
276SysRet
277T_SYSRET_fail()
278 CODE:
279 RETVAL = -1;
280 OUTPUT:
281 RETVAL
282
283=item T_UV
284
285An unsigned integer.
286
287=cut
288
289unsigned int
290T_UV( uv )
291 unsigned int uv
292 CODE:
293 RETVAL = uv;
294 OUTPUT:
295 RETVAL
296
297=item T_IV
298
ac23f157 299A signed integer. This is cast to the required integer type when
d1be9408 300passed to C and converted to an IV when passed back to Perl.
ea035a69
JH
301
302=cut
303
304long
305T_IV( iv )
306 long iv
307 CODE:
308 RETVAL = iv;
309 OUTPUT:
310 RETVAL
311
312=item T_INT
313
314A signed integer. This typemap converts the Perl value to a native
315integer type (the C<int> type on the current platform). When returning
316the value to perl it is processed in the same way as for T_IV.
317
318Its behaviour is identical to using an C<int> type in XS with T_IV.
319
320=item T_ENUM
321
322An enum value. Used to transfer an enum component
323from C. There is no reason to pass an enum value to C since
324it is stored as an IV inside perl.
325
326=cut
327
328# The test should return the value for SVt_PVHV.
329# 11 at the present time but we can't not rely on this
330# for testing purposes.
331
332svtype
333T_ENUM()
334 CODE:
335 RETVAL = SVt_PVHV;
336 OUTPUT:
337 RETVAL
338
339=item T_BOOL
340
341A boolean type. This can be used to pass true and false values to and
342from C.
343
344=cut
345
346bool
347T_BOOL( in )
348 bool in
349 CODE:
350 RETVAL = in;
351 OUTPUT:
352 RETVAL
353
354=item T_U_INT
355
356This is for unsigned integers. It is equivalent to using T_UV
357but explicitly casts the variable to type C<unsigned int>.
358The default type for C<unsigned int> is T_UV.
359
360=item T_SHORT
361
362Short integers. This is equivalent to T_IV but explicitly casts
363the return to type C<short>. The default typemap for C<short>
364is T_IV.
365
366=item T_U_SHORT
367
368Unsigned short integers. This is equivalent to T_UV but explicitly
369casts the return to type C<unsigned short>. The default typemap for
370C<unsigned short> is T_UV.
371
372T_U_SHORT is used for type C<U16> in the standard typemap.
373
374=cut
375
376U16
377T_U_SHORT( in )
378 U16 in
379 CODE:
380 RETVAL = in;
381 OUTPUT:
382 RETVAL
383
384
385=item T_LONG
386
387Long integers. This is equivalent to T_IV but explicitly casts
388the return to type C<long>. The default typemap for C<long>
389is T_IV.
390
391=item T_U_LONG
392
393Unsigned long integers. This is equivalent to T_UV but explicitly
394casts the return to type C<unsigned long>. The default typemap for
395C<unsigned long> is T_UV.
396
397T_U_LONG is used for type C<U32> in the standard typemap.
398
399=cut
400
401U32
402T_U_LONG( in )
403 U32 in
404 CODE:
405 RETVAL = in;
406 OUTPUT:
407 RETVAL
408
409=item T_CHAR
410
411Single 8-bit characters.
412
413=cut
414
415char
416T_CHAR( in );
417 char in
418 CODE:
419 RETVAL = in;
420 OUTPUT:
421 RETVAL
422
423
424=item T_U_CHAR
425
426An unsigned byte.
427
428=cut
429
430unsigned char
431T_U_CHAR( in );
432 unsigned char in
433 CODE:
434 RETVAL = in;
435 OUTPUT:
436 RETVAL
437
438
439=item T_FLOAT
440
441A floating point number. This typemap guarantees to return a variable
442cast to a C<float>.
443
444=cut
445
446float
447T_FLOAT( in )
448 float in
449 CODE:
450 RETVAL = in;
451 OUTPUT:
452 RETVAL
453
454=item T_NV
455
456A Perl floating point number. Similar to T_IV and T_UV in that the
457return type is cast to the requested numeric type rather than
458to a specific type.
459
460=cut
461
462NV
463T_NV( in )
464 NV in
465 CODE:
466 RETVAL = in;
467 OUTPUT:
468 RETVAL
469
470=item T_DOUBLE
471
472A double precision floating point number. This typemap guarantees to
473return a variable cast to a C<double>.
474
475=cut
476
477double
478T_DOUBLE( in )
479 double in
480 CODE:
481 RETVAL = in;
482 OUTPUT:
483 RETVAL
484
485=item T_PV
486
487A string (char *).
488
489=cut
490
491char *
492T_PV( in )
493 char * in
494 CODE:
495 RETVAL = in;
496 OUTPUT:
497 RETVAL
498
499=item T_PTR
500
501A memory address (pointer). Typically associated with a C<void *>
502type.
503
504=cut
505
506# Pass in a value. Store the value in some static memory and
507# then return the pointer
508
509void *
510T_PTR_OUT( in )
511 int in;
512 CODE:
052980ee
TJ
513 xst_anint = in;
514 RETVAL = &xst_anint;
ea035a69
JH
515 OUTPUT:
516 RETVAL
517
518# pass in the pointer and return the value
519
520int
521T_PTR_IN( ptr )
522 void * ptr
523 CODE:
524 RETVAL = *(int *)ptr;
525 OUTPUT:
526 RETVAL
527
528=item T_PTRREF
529
530Similar to T_PTR except that the pointer is stored in a scalar and the
531reference to that scalar is returned to the caller. This can be used
532to hide the actual pointer value from the programmer since it is usually
533not required directly from within perl.
534
535The typemap checks that a scalar reference is passed from perl to XS.
536
537=cut
538
539# Similar test to T_PTR
540# Pass in a value. Store the value in some static memory and
541# then return the pointer
542
543intRef *
544T_PTRREF_OUT( in )
545 intRef in;
546 CODE:
052980ee
TJ
547 xst_anintref = in;
548 RETVAL = &xst_anintref;
ea035a69
JH
549 OUTPUT:
550 RETVAL
551
552# pass in the pointer and return the value
553
554intRef
555T_PTRREF_IN( ptr )
556 intRef * ptr
557 CODE:
558 RETVAL = *ptr;
559 OUTPUT:
560 RETVAL
561
562
563
564=item T_PTROBJ
565
566Similar to T_PTRREF except that the reference is blessed into a class.
567This allows the pointer to be used as an object. Most commonly used to
568deal with C structs. The typemap checks that the perl object passed
569into the XS routine is of the correct class (or part of a subclass).
570
571The pointer is blessed into a class that is derived from the name
572of type of the pointer but with all '*' in the name replaced with
573'Ptr'.
574
575=cut
576
577# Similar test to T_PTRREF
578# Pass in a value. Store the value in some static memory and
579# then return the pointer
580
581intObj *
582T_PTROBJ_OUT( in )
583 intObj in;
584 CODE:
052980ee
TJ
585 xst_anintobj = in;
586 RETVAL = &xst_anintobj;
ea035a69
JH
587 OUTPUT:
588 RETVAL
589
590# pass in the pointer and return the value
591
592MODULE = XS::Typemap PACKAGE = intObjPtr
593
594intObj
595T_PTROBJ_IN( ptr )
596 intObj * ptr
597 CODE:
598 RETVAL = *ptr;
599 OUTPUT:
600 RETVAL
601
602MODULE = XS::Typemap PACKAGE = XS::Typemap
603
604=item T_REF_IV_REF
605
606NOT YET
607
608=item T_REF_IV_PTR
609
610Similar to T_PTROBJ in that the pointer is blessed into a scalar object.
611The difference is that when the object is passed back into XS it must be
612of the correct type (inheritance is not supported).
613
614The pointer is blessed into a class that is derived from the name
615of type of the pointer but with all '*' in the name replaced with
616'Ptr'.
617
618=cut
619
620# Similar test to T_PTROBJ
621# Pass in a value. Store the value in some static memory and
622# then return the pointer
623
624intRefIv *
625T_REF_IV_PTR_OUT( in )
626 intRefIv in;
627 CODE:
052980ee
TJ
628 xst_anintrefiv = in;
629 RETVAL = &xst_anintrefiv;
ea035a69
JH
630 OUTPUT:
631 RETVAL
632
633# pass in the pointer and return the value
634
635MODULE = XS::Typemap PACKAGE = intRefIvPtr
636
637intRefIv
638T_REF_IV_PTR_IN( ptr )
639 intRefIv * ptr
640 CODE:
641 RETVAL = *ptr;
642 OUTPUT:
643 RETVAL
644
645
646MODULE = XS::Typemap PACKAGE = XS::Typemap
647
648=item T_PTRDESC
649
650NOT YET
651
652=item T_REFREF
653
654NOT YET
655
656=item T_REFOBJ
657
658NOT YET
659
660=item T_OPAQUEPTR
661
5abff6f9
TJ
662This can be used to store bytes in the string component of the
663SV. Here the representation of the data is irrelevant to perl and the
664bytes themselves are just stored in the SV. It is assumed that the C
665variable is a pointer (the bytes are copied from that memory
666location). If the pointer is pointing to something that is
667represented by 8 bytes then those 8 bytes are stored in the SV (and
668length() will report a value of 8). This entry is similar to T_OPAQUE.
ea035a69 669
5abff6f9
TJ
670In principal the unpack() command can be used to convert the bytes
671back to a number (if the underlying type is known to be a number).
672
673This entry can be used to store a C structure (the number
674of bytes to be copied is calculated using the C C<sizeof> function)
675and can be used as an alternative to T_PTRREF without having to worry
676about a memory leak (since Perl will clean up the SV).
ea035a69
JH
677
678=cut
679
680intOpq *
681T_OPAQUEPTR_IN( val )
682 intOpq val
683 CODE:
052980ee
TJ
684 xst_anintopq = val;
685 RETVAL = &xst_anintopq;
ea035a69
JH
686 OUTPUT:
687 RETVAL
688
689intOpq
690T_OPAQUEPTR_OUT( ptr )
691 intOpq * ptr
692 CODE:
693 RETVAL = *ptr;
694 OUTPUT:
695 RETVAL
696
aa921f48
TJ
697short
698T_OPAQUEPTR_OUT_short( ptr )
699 shortOPQ * ptr
700 CODE:
701 RETVAL = *ptr;
702 OUTPUT:
703 RETVAL
704
5abff6f9
TJ
705# Test it with a structure
706astruct *
707T_OPAQUEPTR_IN_struct( a,b,c )
708 int a
709 int b
710 double c
711 PREINIT:
712 struct t_opaqueptr test;
713 CODE:
714 test.a = a;
715 test.b = b;
716 test.c = c;
717 RETVAL = &test;
718 OUTPUT:
719 RETVAL
720
721void
722T_OPAQUEPTR_OUT_struct( test )
723 astruct * test
724 PPCODE:
725 XPUSHs(sv_2mortal(newSViv(test->a)));
726 XPUSHs(sv_2mortal(newSViv(test->b)));
727 XPUSHs(sv_2mortal(newSVnv(test->c)));
728
729
ea035a69
JH
730=item T_OPAQUE
731
5abff6f9
TJ
732This can be used to store data from non-pointer types in the string
733part of an SV. It is similar to T_OPAQUEPTR except that the
734typemap retrieves the pointer directly rather than assuming it
ac23f157 735is being supplied. For example, if an integer is imported into
052980ee
TJ
736Perl using T_OPAQUE rather than T_IV the underlying bytes representing
737the integer will be stored in the SV but the actual integer value will not
738be available. i.e. The data is opaque to perl.
ea035a69 739
5abff6f9
TJ
740The data may be retrieved using the C<unpack> function if the
741underlying type of the byte stream is known.
742
743T_OPAQUE supports input and output of simple types.
744T_OPAQUEPTR can be used to pass these bytes back into C if a pointer
745is acceptable.
ea035a69
JH
746
747=cut
748
749shortOPQ
750T_OPAQUE_IN( val )
751 int val
752 CODE:
753 RETVAL = (shortOPQ)val;
754 OUTPUT:
755 RETVAL
756
5abff6f9
TJ
757IV
758T_OPAQUE_OUT( val )
759 shortOPQ val
760 CODE:
761 RETVAL = (IV)val;
762 OUTPUT:
763 RETVAL
764
ea035a69
JH
765=item Implicit array
766
767xsubpp supports a special syntax for returning
768packed C arrays to perl. If the XS return type is given as
769
770 array(type, nelem)
771
772xsubpp will copy the contents of C<nelem * sizeof(type)> bytes from
773RETVAL to an SV and push it onto the stack. This is only really useful
774if the number of items to be returned is known at compile time and you
775don't mind having a string of bytes in your SV. Use T_ARRAY to push a
776variable number of arguments onto the return stack (they won't be
777packed as a single string though).
778
779This is similar to using T_OPAQUEPTR but can be used to process more than
780one element.
781
782=cut
783
784array(int,3)
785T_OPAQUE_array( a,b,c)
786 int a
787 int b
788 int c
789 PREINIT:
3d5d53b8 790 int array[3];
ea035a69
JH
791 CODE:
792 array[0] = a;
793 array[1] = b;
794 array[2] = c;
795 RETVAL = array;
796 OUTPUT:
797 RETVAL
798
799
800=item T_PACKED
801
802NOT YET
803
804=item T_PACKEDARRAY
805
806NOT YET
807
808=item T_DATAUNIT
809
810NOT YET
811
812=item T_CALLBACK
813
814NOT YET
815
816=item T_ARRAY
817
818This is used to convert the perl argument list to a C array
819and for pushing the contents of a C array onto the perl
820argument stack.
821
822The usual calling signature is
823
824 @out = array_func( @in );
825
826Any number of arguments can occur in the list before the array but
827the input and output arrays must be the last elements in the list.
828
829When used to pass a perl list to C the XS writer must provide a
830function (named after the array type but with 'Ptr' substituted for
831'*') to allocate the memory required to hold the list. A pointer
832should be returned. It is up to the XS writer to free the memory on
833exit from the function. The variable C<ix_$var> is set to the number
834of elements in the new array.
835
836When returning a C array to Perl the XS writer must provide an integer
837variable called C<size_$var> containing the number of elements in the
838array. This is used to determine how many elements should be pushed
839onto the return argument stack. This is not required on input since
840Perl knows how many arguments are on the stack when the routine is
841called. Ordinarily this variable would be called C<size_RETVAL>.
842
843Additionally, the type of each element is determined from the type of
844the array. If the array uses type C<intArray *> xsubpp will
845automatically work out that it contains variables of type C<int> and
846use that typemap entry to perform the copy of each element. All
847pointer '*' and 'Array' tags are removed from the name to determine
848the subtype.
849
850=cut
851
852# Test passes in an integer array and returns it along with
853# the number of elements
854# Pass in a dummy value to test offsetting
855
856# Problem is that xsubpp does XSRETURN(1) because we arent
857# using PPCODE. This means that only the first element
858# is returned. KLUGE this by using CLEANUP to return before the
859# end.
ac23f157
SM
860# Note: I read this as: The "T_ARRAY" typemap is really rather broken,
861# at least for OUTPUT. That is apart from the general design
862# weaknesses. --Steffen
ea035a69
JH
863
864intArray *
865T_ARRAY( dummy, array, ... )
4d0439ce 866 int dummy = 0;
ea035a69
JH
867 intArray * array
868 PREINIT:
869 U32 size_RETVAL;
870 CODE:
8876ff82 871 dummy += 0; /* Fix -Wall */
ea035a69
JH
872 size_RETVAL = ix_array;
873 RETVAL = array;
874 OUTPUT:
875 RETVAL
876 CLEANUP:
877 Safefree(array);
878 XSRETURN(size_RETVAL);
879
880
881=item T_STDIO
882
883This is used for passing perl filehandles to and from C using
884C<FILE *> structures.
885
886=cut
887
888FILE *
889T_STDIO_open( file )
890 const char * file
891 CODE:
892 RETVAL = xsfopen( file );
893 OUTPUT:
894 RETVAL
895
896SysRet
c72de6e4
TJ
897T_STDIO_close( f )
898 PerlIO * f
899 PREINIT:
900 FILE * stream;
ea035a69 901 CODE:
c72de6e4
TJ
902 /* Get the FILE* */
903 stream = PerlIO_findFILE( f );
c72de6e4
TJ
904 /* Release the FILE* from the PerlIO system so that we do
905 not close the file twice */
906 PerlIO_releaseFILE(f,stream);
6b54a403
NC
907 /* Must release the file before closing it */
908 RETVAL = xsfclose( stream );
ea035a69
JH
909 OUTPUT:
910 RETVAL
911
912int
913T_STDIO_print( stream, string )
914 FILE * stream
915 const char * string
916 CODE:
917 RETVAL = xsfprintf( stream, string );
918 OUTPUT:
919 RETVAL
920
921
922=item T_IN
923
924NOT YET
925
926=item T_INOUT
927
928This is used for passing perl filehandles to and from C using
929C<PerlIO *> structures. The file handle can used for reading and
930writing.
931
932See L<perliol> for more information on the Perl IO abstraction
933layer. Perl must have been built with C<-Duseperlio>.
934
935=item T_OUT
936
937NOT YET
938
939=back
940
941=cut
942