This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix error in tryAMAGICunDEREF() introduced in 25a9ffce153b0e67.
[perl5.git] / ext / XS-APItest / APItest.xs
index 3bad328..23dd963 100644 (file)
@@ -923,6 +923,39 @@ amagic_deref_call(sv, what)
        /* The reference is owned by something else.  */
        PUSHs(amagic_deref_call(sv, what));
 
+# I'd certainly like to discourage the use of this macro, given that we now
+# have amagic_deref_call
+
+SV *
+tryAMAGICunDEREF_var(sv, what)
+       SV *sv
+       int what
+    PPCODE:
+       {
+           SV **sp = &sv;
+           switch(what) {
+           case to_av_amg:
+               tryAMAGICunDEREF(to_av);
+               break;
+           case to_cv_amg:
+               tryAMAGICunDEREF(to_cv);
+               break;
+           case to_gv_amg:
+               tryAMAGICunDEREF(to_gv);
+               break;
+           case to_hv_amg:
+               tryAMAGICunDEREF(to_hv);
+               break;
+           case to_sv_amg:
+               tryAMAGICunDEREF(to_sv);
+               break;
+           default:
+               croak("Invalid value %d passed to tryAMAGICunDEREF_var", what);
+           }
+       }
+       /* The reference is owned by something else.  */
+       PUSHs(sv);
+
 MODULE = XS::APItest           PACKAGE = XS::APItest::XSUB
 
 BOOT: