From: Vincent Pit Date: Sun, 25 Jul 2010 09:57:59 +0000 (+0200) Subject: Use the op_info feature to prevent hooking of method calls X-Git-Tag: v0.06~5 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Fsubs-auto.git;a=commitdiff_plain;h=c6f479c1cfb222821a7770155ee3fd18f44e0992 Use the op_info feature to prevent hooking of method calls --- diff --git a/Makefile.PL b/Makefile.PL index ed2e049..0f5fccb 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -14,7 +14,7 @@ $file = "lib/$file.pm"; my %PREREQ_PM = ( 'B::Keywords' => 0, 'Carp' => 0, - 'Variable::Magic' => '0.08', + 'Variable::Magic' => '0.31', 'XSLoader' => 0, ); diff --git a/lib/subs/auto.pm b/lib/subs/auto.pm index 9ec0687..928ea7e 100644 --- a/lib/subs/auto.pm +++ b/lib/subs/auto.pm @@ -63,7 +63,7 @@ use B; use B::Keywords; -use Variable::Magic qw/wizard cast dispell getdata/; +use Variable::Magic 0.31 qw/wizard cast dispell getdata/; BEGIN { unless (Variable::Magic::VMG_UVAR) { @@ -108,9 +108,15 @@ sub _reset { sub _fetch { (undef, my $data, my $func) = @_; - return if $data->{guard} or $func =~ /::/ or exists $core{$func}; + return if $data->{guard}; local $data->{guard} = 1; + return if $func =~ /::/ + or exists $core{$func}; + + my $op_name = $_[-1] || ''; + return if $op_name =~ /method/; + my $pkg = $data->{pkg}; my $hints = (caller 0)[10]; @@ -155,9 +161,10 @@ sub _store { return; } -my $wiz = wizard data => sub { +{ pkg => $_[1], guard => 0 } }, - fetch => \&_fetch, - store => \&_store; +my $wiz = wizard data => sub { +{ pkg => $_[1], guard => 0 } }, + fetch => \&_fetch, + store => \&_store, + op_info => Variable::Magic::VMG_OP_INFO_NAME; my %pkgs;