X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDevel%2FBeginLift.pm;fp=lib%2FDevel%2FBeginLift.pm;h=1eee8797d23a67365bb059ec02824b2e7fb3bd7a;hb=353e53a4d12b39e2161583d098ed36f9ca4fd294;hp=c8341b0f11ad545f8652d8776dde471992f5d41d;hpb=4ebcd16b11bd1e801871999cabe6dd0a228edb19;p=p5sagit%2FDevel-BeginLift.git diff --git a/lib/Devel/BeginLift.pm b/lib/Devel/BeginLift.pm index c8341b0..1eee879 100644 --- a/lib/Devel/BeginLift.pm +++ b/lib/Devel/BeginLift.pm @@ -8,6 +8,7 @@ our $VERSION = 0.001000; use vars qw(%lift); use base qw(DynaLoader); +use B::Hooks::OP::Check::EntersubForCV; bootstrap Devel::BeginLift; @@ -25,14 +26,20 @@ sub unimport { sub setup_for { my ($class, $target, $args) = @_; - setup(); - $lift{$target}{$_} = 1 for @$args; + $lift{$target} ||= []; + push @{ $lift{$target} }, map { + $class->setup_for_cv($_); + } map { + ref $_ eq 'CODE' + ? $_ + : \&{ "${target}::${_}" } + } @{ $args }; } sub teardown_for { my ($class, $target) = @_; + $class->teardown_for_cv($_) for @{ $lift{$target} }; delete $lift{$target}; - teardown(); } =head1 NAME @@ -104,6 +111,19 @@ Deregisters all subs currently registered for $package and uninstalls begin lifting magic is number of teardown_for calls matches number of setup_for calls. +=head2 setup_for_cv + + $id = Devel::BeginLift->setup_for_cv(\&code); + +Same as C, but only registers begin lifting magic for one code +reference. Returns an id to be used in C. + +=head2 teardown_for_cv + + Devel::BeginLift->teardown_for_cv($id); + +Deregisters begin lifting magic referred to by C<$id>. + =head1 AUTHOR Matt S Trout -