/usr/lib/x86_64-linux-gnu/perl5/5.20/B/Hooks/OP/Check/EntersubForCV.pm is in libb-hooks-op-check-entersubforcv-perl 0.09-3+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | use strict;
use warnings;
package B::Hooks::OP::Check::EntersubForCV;
use parent qw/DynaLoader/;
use B::Hooks::OP::Check 0.19;
use Scalar::Util qw/refaddr/;
use B::Utils 0.19 ();
our $VERSION = '0.09';
sub dl_load_flags { 0x01 }
__PACKAGE__->bootstrap($VERSION);
my %CALLBACKS;
sub import {
my $class = shift;
die 'odd number of arguments'
unless @_ % 2 == 0;
while (@_) {
my ($cv, $cb) = (shift, shift);
$CALLBACKS{ refaddr $cv } = register($cv, $cb);
}
return;
}
sub unimport {
my $class = shift;
unregister($_) for delete @CALLBACKS{ map { refaddr $_ } @_ };
return;
}
1;
__END__
=head1 NAME
B::Hooks::OP::Check::EntersubForCV - Invoke callbacks on construction of entersub OPs for certain CVs
=head1 SYNOPSIS
=head2 From Perl
sub foo {}
use B::Hooks::OP::Check::EntersubForCV
\&foo => sub { warn "entersub for foo() being compiled" };
foo(); # callback is invoked when this like is compiled
no B::Hooks::OP::Check::EntersubForCV \&foo;
foo(); # callback isn't invoked
=head2 From C/XS
#include "hook_op_check_entersubforcv.h"
STATIC OP *
my_callback (pTHX_ OP *op, CV *cv, void *user_data) {
/* ... */
return op;
}
hook_op_check_id id;
/* register callback */
id = hook_op_check_entersubforcv (cv, my_callback, NULL);
/* unregister */
hook_op_check_entersubforcv_remove (id);
=head1 DESCRIPTION
=head1 Perl API
=head2 import / register
use B::Hooks::OP::Check::EntersubForCV
\&code => \&handler;
# or
my $id = B::Hooks::OP::Check::EntersubForCV::register(\&code => \&handler);
Register C<handler> to be executed when an entersub opcode for the CV C<code>
points to is compiled.
When using C<register> an id that can be used for later removal of the handler
using C<unregister> is returned.
=head2 unimport / unregister
no B::Hooks::OP::Check::EntersubForCV \&code;
# or
B::Hooks::OP::Check::EntersubForCV::unregister($id);
Stop calling the registered handler for C<code> for all entersubs after this.
=head1 C API
=head2 TYPES
=head3 OP *(*hook_op_check_entersubforcv_cb) (pTHX_ OP *, CV *, void *)
The type the handlers need to implement.
=head2 FUNCTIONS
=head3 hook_op_check_id hook_op_check_entersubforcv (CV *cv, hook_op_check_entersubforcv_cb cb, void *user_data)
Register the callback C<cb> to be called when an entersub opcode for C<cv> is
compiled. C<user_data> will be passed to the callback as the last argument.
Returns an id that can be used to remove the handler using
C<hook_op_check_entersubforcv_remove>.
=head3 void *hook_op_check_entersubforcv_remove (hook_op_check_id id)
Remove a previously registered handler referred to by C<id>.
Returns the user data that was associated with the handler.
=head1 SEE ALSO
L<B::Hooks::OP::Check>
=head1 AUTHOR
Florian Ragwitz E<lt>rafl@debian.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2008, 2009 Florian Ragwitz
This module is free software.
You may distribute this code under the same terms as Perl itself.
=cut
|