This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
APItest: Move PERL_UNUSED_ARG after decl
[perl5.git] / ext / XS-APItest / APItest.xs
index 27c587a..640c0ec 100644 (file)
@@ -1065,8 +1065,8 @@ filter_call(pTHX_ int idx, SV *buf_sv, int maxlen)
 
 static AV *
 myget_linear_isa(pTHX_ HV *stash, U32 level) {
-    PERL_UNUSED_ARG(level);
     GV **gvp = (GV **)hv_fetchs(stash, "ISA", 0);
+    PERL_UNUSED_ARG(level);
     return gvp && *gvp && GvAV(*gvp)
         ? GvAV(*gvp)
         : (AV *)sv_2mortal((SV *)newAV());
@@ -1156,7 +1156,7 @@ BOOT:
     newXS("XS::APItest::XSUB::XS_VERSION_empty", XS_XS__APItest__XSUB_XS_VERSION_empty, __FILE__);
     newXS("XS::APItest::XSUB::XS_APIVERSION_invalid", XS_XS__APItest__XSUB_XS_APIVERSION_invalid, __FILE__);
     mymro.resolve = myget_linear_isa;
-    mymro.name    = "justinc";
+    mymro.name    = "justisa";
     mymro.length  = 7;
     mymro.kflags  = 0;
     mymro.hash    = 0;
@@ -2155,6 +2155,21 @@ bool
 sv_setsv_cow_hashkey_notcore()
 
 void
+sv_set_deref(SV *sv, SV *sv2, int which)
+    CODE:
+    {
+       STRLEN len;
+       const char *pv = SvPV(sv2,len);
+       if (!SvROK(sv)) croak("Not a ref");
+       sv = SvRV(sv);
+       switch (which) {
+           case 0: sv_setsv(sv,sv2); break;
+           case 1: sv_setpv(sv,pv); break;
+           case 2: sv_setpvn(sv,pv,len); break;
+       }
+    }
+
+void
 rmagical_cast(sv, type)
     SV *sv;
     SV *type;
@@ -3227,6 +3242,30 @@ OUTPUT:
     RETVAL
 
 
+MODULE = XS::APItest PACKAGE = XS::APItest::AUTOLOADtest
+
+int
+AUTOLOAD(...)
+  INIT:
+    SV* comms;
+    SV* class_and_method;
+    SV* tmp;
+  CODE:
+    class_and_method = GvSV(CvGV(cv));
+    comms = get_sv("main::the_method", 1);
+    if (class_and_method == NULL) {
+      RETVAL = 1;
+    } else if (!SvOK(class_and_method)) {
+      RETVAL = 2;
+    } else if (!SvPOK(class_and_method)) {
+      RETVAL = 3;
+    } else {
+      sv_setsv(comms, class_and_method);
+      RETVAL = 0;
+    }
+  OUTPUT: RETVAL
+
+
 MODULE = XS::APItest           PACKAGE = XS::APItest::Magic
 
 PROTOTYPES: DISABLE