| 1 |
NAME |
| 2 |
B::Hooks::OP::Check::EntersubForCV - Invoke callbacks on construction of |
| 3 |
entersub OPs for certain CVs |
| 4 |
|
| 5 |
SYNOPSIS |
| 6 |
From Perl |
| 7 |
sub foo {} |
| 8 |
|
| 9 |
use B::Hooks::OP::Check::EntersubForCV |
| 10 |
\&foo => sub { warn "entersub for foo() being compiled" }; |
| 11 |
|
| 12 |
foo(); # callback is invoked when this like is compiled |
| 13 |
|
| 14 |
no B::Hooks::OP::Check::EntersubForCV \&foo; |
| 15 |
|
| 16 |
foo(); # callback isn't invoked |
| 17 |
|
| 18 |
From C/XS |
| 19 |
#include "hook_op_check_entersubforcv.h" |
| 20 |
|
| 21 |
STATIC OP * |
| 22 |
my_callback (pTHX_ OP *op, CV *cv, void *user_data) { |
| 23 |
/* ... */ |
| 24 |
return op; |
| 25 |
} |
| 26 |
|
| 27 |
hook_op_check_id id; |
| 28 |
|
| 29 |
/* register callback */ |
| 30 |
id = hook_op_check_entersubforcv (cv, my_callback, NULL); |
| 31 |
|
| 32 |
/* unregister */ |
| 33 |
hook_op_check_entersubforcv_remove (id); |
| 34 |
|
| 35 |
DESCRIPTION |
| 36 |
Perl API |
| 37 |
import / register |
| 38 |
use B::Hooks::OP::Check::EntersubForCV |
| 39 |
\&code => \&handler; |
| 40 |
|
| 41 |
# or |
| 42 |
my $id = B::Hooks::OP::Check::EntersubForCV::register(\&code => \&handler); |
| 43 |
|
| 44 |
Register "handler" to be executed when an entersub opcode for the CV |
| 45 |
"code" points to is compiled. |
| 46 |
|
| 47 |
When using "register" an id that can be used for later removal of the |
| 48 |
handler using "unregister" is returned. |
| 49 |
|
| 50 |
unimport / unregister |
| 51 |
no B::Hooks::OP::Check::EntersubForCV \&code; |
| 52 |
|
| 53 |
# or |
| 54 |
B::Hooks::OP::Check::EntersubForCV::unregister($id); |
| 55 |
|
| 56 |
Stop calling the registered handler for "code" for all entersubs after |
| 57 |
this. |
| 58 |
|
| 59 |
C API |
| 60 |
TYPES |
| 61 |
OP *(*hook_op_check_entersubforcv_cb) (pTHX_ OP *, CV *, void *) |
| 62 |
The type the handlers need to implement. |
| 63 |
|
| 64 |
FUNCTIONS |
| 65 |
hook_op_check_id hook_op_check_entersubforcv (CV *cv, hook_op_check_entersubforcv_cb cb, void *user_data) |
| 66 |
Register the callback "cb" to be called when an entersub opcode for "cv" |
| 67 |
is compiled. "user_data" will be passed to the callback as the last |
| 68 |
argument. |
| 69 |
|
| 70 |
Returns an id that can be used to remove the handler using |
| 71 |
"hook_op_check_entersubforcv_remove". |
| 72 |
|
| 73 |
void *hook_op_check_entersubforcv_remove (hook_op_check_id id) |
| 74 |
Remove a previously registered handler referred to by "id". |
| 75 |
|
| 76 |
Returns the user data that was associated with the handler. |
| 77 |
|
| 78 |
SEE ALSO |
| 79 |
B::Hooks::OP::Check |
| 80 |
|
| 81 |
AUTHOR |
| 82 |
Florian Ragwitz <[email protected]> |
| 83 |
|
| 84 |
COPYRIGHT AND LICENSE |
| 85 |
Copyright (c) 2008, 2009 Florian Ragwitz |
| 86 |
|
| 87 |
Copyright (c) 2011, 2012, 2017 Andrew Main (Zefram) |
| 88 |
|
| 89 |
This module is free software. |
| 90 |
|
| 91 |
You may distribute this code under the same terms as Perl itself. |
| 92 |
|