This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
A clearer implementation of B::SV::object_2svref()
authorNicholas Clark <nick@ccl4.org>
Fri, 29 Oct 2010 09:59:23 +0000 (10:59 +0100)
committerNicholas Clark <nick@ccl4.org>
Fri, 29 Oct 2010 09:59:23 +0000 (10:59 +0100)
The same number of lines of code, but it avoids using 2 #defines simply to
take advantage of typemap entries, which the reader may not be familiar with.

ext/B/B.xs

index 1b93e7d..6f1e17e 100644 (file)
@@ -1293,13 +1293,13 @@ REFCNT(sv)
     OUTPUT:
        RETVAL
 
-#define object_2svref(sv)      sv
-#define SVREF SV *
-       
-SVREF
+void
 object_2svref(sv)
        B::SV   sv
-
+    PPCODE:
+       ST(0) = sv_2mortal(newRV(sv));
+       XSRETURN(1);
+       
 MODULE = B     PACKAGE = B::IV         PREFIX = Sv
 
 IV