Once again syncing after too long an absence
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / typemap
index 9961f2d..c59c3dc 100644 (file)
@@ -40,7 +40,8 @@ Boolean                       T_IV
 double                 T_DOUBLE
 SysRet                 T_SYSRET
 SysRetLong             T_SYSRET
-FILE *                 T_IN
+FILE *                 T_STDIO
+PerlIO *               T_INOUT
 FileHandle             T_PTROBJ
 InputStream            T_IN
 InOutStream            T_INOUT
@@ -55,22 +56,22 @@ T_SVREF
        if (sv_isa($arg, \"${ntype}\"))
            $var = (SV*)SvRV($arg);
        else
-           croak(\"$var is not of type ${ntype}\")
+           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
 T_AVREF
        if (sv_isa($arg, \"${ntype}\"))
            $var = (AV*)SvRV($arg);
        else
-           croak(\"$var is not of type ${ntype}\")
+           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
 T_HVREF
        if (sv_isa($arg, \"${ntype}\"))
            $var = (HV*)SvRV($arg);
        else
-           croak(\"$var is not of type ${ntype}\")
+           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
 T_CVREF
        if (sv_isa($arg, \"${ntype}\"))
            $var = (CV*)SvRV($arg);
        else
-           croak(\"$var is not of type ${ntype}\")
+           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
 T_SYSRET
        $var NOT IMPLEMENTED
 T_UV
@@ -113,50 +114,50 @@ T_PTRREF
            $var = INT2PTR($type,tmp);
        }
        else
-           croak(\"$var is not a reference\")
+           Perl_croak(aTHX_ \"$var is not a reference\")
 T_REF_IV_REF
        if (sv_isa($arg, \"${type}\")) {
            IV tmp = SvIV((SV*)SvRV($arg));
            $var = *($type *) tmp;
        }
        else
-           croak(\"$var is not of type ${ntype}\")
+           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
 T_REF_IV_PTR
        if (sv_isa($arg, \"${type}\")) {
            IV tmp = SvIV((SV*)SvRV($arg));
            $var = ($type) tmp;
        }
        else
-           croak(\"$var is not of type ${ntype}\")
+           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
 T_PTROBJ
        if (sv_derived_from($arg, \"${ntype}\")) {
            IV tmp = SvIV((SV*)SvRV($arg));
            $var = INT2PTR($type,tmp);
        }
        else
-           croak(\"$var is not of type ${ntype}\")
+           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
 T_PTRDESC
        if (sv_isa($arg, \"${ntype}\")) {
            IV tmp = SvIV((SV*)SvRV($arg));
-           ${type}_desc = (\U${type}_DESC\E*) tmp; 
+           ${type}_desc = (\U${type}_DESC\E*) tmp;
            $var = ${type}_desc->ptr;
        }
        else
-           croak(\"$var is not of type ${ntype}\")
+           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
 T_REFREF
        if (SvROK($arg)) {
            IV tmp = SvIV((SV*)SvRV($arg));
            $var = *INT2PTR($type,tmp);
        }
        else
-           croak(\"$var is not a reference\")
+           Perl_croak(aTHX_ \"$var is not a reference\")
 T_REFOBJ
        if (sv_isa($arg, \"${ntype}\")) {
            IV tmp = SvIV((SV*)SvRV($arg));
            $var = *INT2PTR($type,tmp);
        }
        else
-           croak(\"$var is not of type ${ntype}\")
+           Perl_croak(aTHX_ \"$var is not of type ${ntype}\")
 T_OPAQUE
        $var NOT IMPLEMENTED
 T_OPAQUEPTR
@@ -173,6 +174,8 @@ T_ARRAY
        while (items--) {
            DO_ARRAY_ELEM;
        }
+T_STDIO
+       $var = PerlIO_findFILE(IoIFP(sv_2io($arg)))
 T_IN
        $var = IoIFP(sv_2io($arg))
 T_INOUT
@@ -267,6 +270,15 @@ T_ARRAY
        DO_ARRAY_ELEM
        }
        SP += $var.size - 1;
+T_STDIO
+       {
+           GV *gv = newGVgen("$Package");
+           PerlIO *fp = PerlIO_importFILE($var,0);
+           if ( fp && do_open(gv, "+<&", 3, FALSE, 0, 0, fp) )
+               sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1)));
+           else
+               $arg = &PL_sv_undef;
+       }
 T_IN
        {
            GV *gv = newGVgen("$Package");