X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;ds=sidebyside;f=lib%2FSub%2FOp.pm;h=6b421c4be5a17f3f6b3a9a2f91e63386c48f53b5;hb=a0c0873977f66d8024a988b8dbd8e1c092927189;hp=c8f7c2e24d156c0686aa15e71a63fa5dd5a2fafb;hpb=b595e30107309e004eb11874cbbcf67b7f4093c9;p=perl%2Fmodules%2FSub-Op.git diff --git a/lib/Sub/Op.pm b/lib/Sub/Op.pm index c8f7c2e..6b421c4 100644 --- a/lib/Sub/Op.pm +++ b/lib/Sub/Op.pm @@ -50,11 +50,11 @@ In your XS file : BOOT: { sub_op_config_t c; - c.name = "reftype"; - c.len = sizeof("reftype")-1; - c.pp = scalar_util_reftype; - c.check = 0; - c.ud = NULL; + c.name = "reftype"; + c.namelen = sizeof("reftype")-1; + c.pp = scalar_util_reftype; + c.check = 0; + c.ud = NULL; sub_op_register(aTHX_ &c); } @@ -142,8 +142,14 @@ my $sw = Variable::Magic::wizard( my $pkg = $data->{pkg}; my $fqn = join '::', $pkg, $name; - no strict 'refs'; - *$fqn = $placeholder unless exists &$fqn; + { + local $SIG{__WARN__} = sub { + CORE::warn(@_) unless $_[0] =~ /^Constant subroutine.*redefined/; + } if _constant_sub(do { no strict 'refs'; \&$fqn }); + no strict 'refs'; + no warnings 'redefine'; + *$fqn = $placeholder; + } return; }, @@ -155,6 +161,7 @@ sub _tag { my $fqn = join '::', $pkg, $name; return { + old => _defined_sub($fqn) ? \&$fqn : undef, proto => prototype($fqn), }; } @@ -208,7 +215,7 @@ Allowed to be static. =item * -C +C C's length, in bytes. @@ -296,11 +303,22 @@ sub disable { my $pkg = @_ > 0 ? $_[0] : caller; my $map = _map($pkg); + my $fqn = join '::', $pkg, $name; + if (defined $map) { - my $proto = $map->{$name}->{proto}; + my $tag = $map->{$name}; + + my $old = $tag->{old}; + if (defined $old) { + no strict 'refs'; + no warnings 'redefine'; + *$fqn = $old; + } + + my $proto = $tag->{proto}; if (defined $proto) { no strict 'refs'; - Scalar::Util::set_prototype(\&{"${pkg}::$name"}, $proto); + Scalar::Util::set_prototype(\&$fqn, $proto); } delete $map->{$name};