Make CV * typemap entry support overloading
authorSteffen Mueller <smueller@cpan.org>
Tue, 22 May 2012 21:04:06 +0000 (23:04 +0200)
committerSteffen Mueller <smueller@cpan.org>
Tue, 22 May 2012 21:04:06 +0000 (23:04 +0200)
See RT #96872.

lib/ExtUtils/typemap

index 607c6c8..0fa14fb 100644 (file)
@@ -143,12 +143,12 @@ T_HVREF_REFCOUNT_FIXED
        } STMT_END
 T_CVREF
        STMT_START {
-               SV* const xsub_tmp_sv = $arg;
+                HV *st;
+                GV *gvp;
+               SV * const xsub_tmp_sv = $arg;
                SvGETMAGIC(xsub_tmp_sv);
-               if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVCV){
-                   $var = (CV*)SvRV(xsub_tmp_sv);
-               }
-               else{
+                $var = sv_2cv(xsub_tmp_sv, &st, &gvp, 0);
+               if (!$var) {
                    Perl_croak(aTHX_ \"%s: %s is not a CODE reference\",
                                ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
                                \"$var\");
@@ -156,12 +156,12 @@ T_CVREF
        } STMT_END
 T_CVREF_REFCOUNT_FIXED
        STMT_START {
-               SV* const xsub_tmp_sv = $arg;
+                HV *st;
+                GV *gvp;
+               SV * const xsub_tmp_sv = $arg;
                SvGETMAGIC(xsub_tmp_sv);
-               if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVCV){
-                   $var = (CV*)SvRV(xsub_tmp_sv);
-               }
-               else{
+                $var = sv_2cv(xsub_tmp_sv, &st, &gvp, 0);
+               if (!$var) {
                    Perl_croak(aTHX_ \"%s: %s is not a CODE reference\",
                                ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
                                \"$var\");