This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Simplify the conditionals in the XS code for B::COP::{io,warnings}
authorNicholas Clark <nick@ccl4.org>
Wed, 27 Oct 2010 16:16:27 +0000 (17:16 +0100)
committerNicholas Clark <nick@ccl4.org>
Wed, 27 Oct 2010 16:16:27 +0000 (17:16 +0100)
The same post-processed C code will generated as before for PERL_VERSION >= 9,
and the same sequence of perl API calls for PERL_VERSION < 9.

ext/B/B.xs

index 9906dd2..95d76fc 100644 (file)
@@ -1196,10 +1196,6 @@ LOOP_lastop(o)
 #define COP_arybase(o) CopARYBASE_get(o)
 #define COP_line(o)    CopLINE(o)
 #define COP_hints(o)   CopHINTS_get(o)
-#if PERL_VERSION < 9
-#  define COP_warnings(o)  o->cop_warnings
-#  define COP_io(o)    o->cop_io
-#endif
 
 MODULE = B     PACKAGE = B::COP                PREFIX = COP_
 
@@ -1246,22 +1242,30 @@ U32
 COP_line(o)
        B::COP  o
 
-#if PERL_VERSION >= 9
-
 void
 COP_warnings(o)
        B::COP  o
        PPCODE:
+#if PERL_VERSION >= 9
        ST(0) = make_warnings_object(aTHX_ o->cop_warnings);
+#else
+       ST(0) = make_sv_object(aTHX_ NULL, o->cop_warnings);
+#endif
        XSRETURN(1);
 
 void
 COP_io(o)
        B::COP  o
        PPCODE:
+#if PERL_VERSION >= 9
        ST(0) = make_cop_io_object(aTHX_ o);
+#else
+       ST(0) = make_sv_object(aTHX_ NULL, o->cop_io);
+#endif
        XSRETURN(1);
 
+#if PERL_VERSION >= 9
+
 B::RHE
 COP_hints_hash(o)
        B::COP o
@@ -1270,16 +1274,6 @@ COP_hints_hash(o)
     OUTPUT:
        RETVAL
 
-#else
-
-B::SV
-COP_warnings(o)
-       B::COP  o
-
-B::SV
-COP_io(o)
-       B::COP  o
-
 #endif
 
 U32