ok, here is my first go - I'm not sure if it is sylistically what you were
after, but I will rework it some to suit now that the proof-of-concept is
over...

just out of curiosity, I tried to get the method name from the gv returned
from sv_2cv using GvNAME and kept segfaulting, then I noticed you never used
that gv in similar calls... is that gv unreliable?

at any rate

sub foo ($$) : method {...}

seems to be working like a charm...

--Geoff

Index: mod_perl.c
===================================================================
RCS file: /home/cvspublic/modperl/src/modules/perl/mod_perl.c,v
retrieving revision 1.141
diff -u -r1.141 mod_perl.c
--- mod_perl.c  2001/07/10 03:30:27     1.141
+++ mod_perl.c  2001/08/27 12:06:12
@@ -1199,11 +1199,8 @@
        if (gvp) cv = GvCV(gvp);
     }
 
-#ifdef CVf_METHOD
-    if (cv && (CvFLAGS(cv) & CVf_METHOD)) {
-        is_method = 1;
-    }
-#endif
+    is_method = perl_cv_ismethod(cv);
+
     if (!is_method && (cv && SvPOK(cv))) {
        is_method = strnEQ(SvPVX(cv), "$$", 2);
     }
@@ -1213,6 +1210,20 @@
     SvREFCNT_dec(sv);
     return is_method;
 }
+
+int perl_cv_ismethod(CV *cv)
+{
+    int is_method=0;
+
+#ifdef CVf_METHOD
+    if (cv && (CvFLAGS(cv) & CVf_METHOD)) {
+        is_method = 1;
+    }
+#endif
+
+    return is_method;
+}
+
 #endif
 
 void mod_perl_noop(void *data) {}
@@ -1453,6 +1464,7 @@
     HV *stash = Nullhv;
     SV *pclass = newSVsv(sv), *dispsv = Nullsv;
     CV *cv = Nullcv;
+    GV *gv = Nullgv;
     char *method = "handler";
     int defined_sub = 0, anon = 0;
     char *dispatcher = NULL;
@@ -1587,8 +1599,25 @@
 #endif
     }
     else {
-       MP_TRACE_h(fprintf(stderr, "perl_call: handler is a %s\n", 
-                        dispatcher ? "dispatcher" : "cached CV"));
+        if (!dispatcher) {
+         MP_TRACE_h(fprintf(stderr, "perl_call: handler is a cached
CV\n"));
+#ifdef PERL_METHOD_HANDLERS
+          cv = sv_2cv(sv, &stash, &gv, FALSE);
+
+         is_method = perl_cv_ismethod(cv);
+
+          if (is_method) {
+              pclass = newSVpv(HvNAME(stash),0);
+              method = GvNAME(CvGV(cv));
+          }
+
+          MP_TRACE_h(fprintf(stderr, "checking if CV is a method...%s\n",
+                 (is_method ? "yes" : "no")));
+#endif
+        }
+       else {
+          MP_TRACE_h(fprintf(stderr, "perl_call: handler is a
dispatcher\n"));
+        }
     }
 
 callback:

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to