In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/3c761071e79b5600ba18495d95ab6425145f5e45?hp=5064495bb4e4885232438df9bc66e685c1e6b98b>
- Log ----------------------------------------------------------------- commit 3c761071e79b5600ba18495d95ab6425145f5e45 Author: Zefram <[email protected]> Date: Mon Jul 31 11:10:16 2017 +0100 fix example code in wrap_op_checker() doc Commit b93e7f0e1e15a1bbbcd9031bc4b66a5c60686eca added some code fragments to the documentation of this function in order to explain it, but got part of it wrong, confusing a pointer with the thing it points to. Correct that, and reformulate the fragments of code into a more coherent single example. ----------------------------------------------------------------------- Summary of changes: op.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/op.c b/op.c index 69cc69325a..ff78e95fc0 100644 --- a/op.c +++ b/op.c @@ -15375,18 +15375,6 @@ pointer to the next function in the chain will be stored. The value of C<new_pointer> is written into the L</PL_check> array, while the value previously stored there is written to C<*old_checker_p>. -The function should be defined like this: - - static OP *new_checker(pTHX_ OP *op) { ... } - -It is intended to be called in this manner: - - new_checker(aTHX_ op) - -C<old_checker_p> should be defined like this: - - static Perl_check_t old_checker_p; - L</PL_check> is global to an entire process, and a module wishing to hook op checking may find itself invoked more than once per process, typically in different threads. To handle that situation, this function @@ -15408,6 +15396,19 @@ decides not to do anything special with an op that it is given (which is the usual case for most uses of op check hooking), it must chain the check function referenced by C<*old_checker_p>. +Taken all together, XS code to hook an op checker should typically look +something like this: + + static Perl_check_t nxck_frob; + static OP *myck_frob(pTHX_ OP *op) { + ... + op = nxck_frob(aTHX_ op); + ... + return op; + } + BOOT: + wrap_op_checker(OP_FROB, myck_frob, &nxck_frob); + If you want to influence compilation of calls to a specific subroutine, then use L</cv_set_call_checker> rather than hooking checking of all C<entersub> ops. -- Perl5 Master Repository
