In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/a3e07c8779a37a0cc0a4e5ceac72eec0b30c0c0c?hp=4e86d35098d1785c36619cff949bf432fcc6022a>
- Log ----------------------------------------------------------------- commit a3e07c8779a37a0cc0a4e5ceac72eec0b30c0c0c Author: Ben Morrow <[email protected]> Date: Tue Jul 13 22:20:21 2010 +0100 Macros to en/disable blockhook entries. This allows the individual callbacks to be switched on and off as necessary, without removing the entry from PL_blockhooks. M op.h M pod/perlguts.pod commit 53c0f7b3da3c1d6006f40558f6011132074df828 Author: Ben Morrow <[email protected]> Date: Tue Jul 13 21:06:19 2010 +0100 Update MANIFEST. Properly, this time. M MANIFEST commit 72a21adedd766a965f0f4129023b8e664137f298 Author: Ben Morrow <[email protected]> Date: Tue Jul 13 21:02:29 2010 +0100 Remove diagnostics from XS-APItest/t/blockhooks. They were causing problems with 'make test'. M ext/XS-APItest/t/blockhooks.t ----------------------------------------------------------------------- Summary of changes: MANIFEST | 4 ++++ ext/XS-APItest/t/blockhooks.t | 3 --- op.h | 24 +++++++++++++++++++++++- pod/perlguts.pod | 10 ++++++---- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/MANIFEST b/MANIFEST index 81c5754..cea013e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3250,13 +3250,17 @@ ext/XS-APItest/Makefile.PL XS::APItest extension ext/XS-APItest/MANIFEST XS::APItest extension ext/XS-APItest/notcore.c Test API functions when PERL_CORE is not defined ext/XS-APItest/README XS::APItest extension +ext/XS-APItest/t/BHK.pm Helper for ./blockhooks.t ext/XS-APItest/t/blockhooks-csc.t XS::APItest: more tests for PL_blockhooks ext/XS-APItest/t/blockhooks.t XS::APItest: tests for PL_blockhooks +ext/XS-APItest/t/Block.pm Helper for ./blockhooks.t ext/XS-APItest/t/call.t XS::APItest extension ext/XS-APItest/t/exception.t XS::APItest extension ext/XS-APItest/t/hash.t XS::APItest: tests for hash related APIs +ext/XS-APItest/t/Markers.pm Helper for ./blockhooks.t ext/XS-APItest/t/my_cxt.t XS::APItest: test MY_CXT interface ext/XS-APItest/t/my_exit.t XS::APItest: test my_exit +ext/XS-APItest/t/Null.pm Helper for ./blockhooks.t ext/XS-APItest/t/op.t XS::APItest: tests for OP related APIs ext/XS-APItest/t/pmflag.t Test removal of Perl_pmflag() ext/XS-APItest/t/printf.t XS::APItest extension diff --git a/ext/XS-APItest/t/blockhooks.t b/ext/XS-APItest/t/blockhooks.t index a39c3f5..37590bc 100644 --- a/ext/XS-APItest/t/blockhooks.t +++ b/ext/XS-APItest/t/blockhooks.t @@ -13,9 +13,6 @@ BEGIN { package XS::APItest; *main::bhkav = \...@xs::APItest::bhkav } # 'no t::BHK' switches recording off again. # 'use t::BHK push => "foo"' pushes onto @bhkav -BEGIN { diag "## COMPILE TIME ##" } -diag "## RUN TIME ##"; - use t::BHK; 1; no t::BHK; diff --git a/op.h b/op.h index 30a41c8..2ea1dce 100644 --- a/op.h +++ b/op.h @@ -670,6 +670,17 @@ Set an entry in the BHK structure, and set the flags to indicate it is valid. I<which> is a preprocessing token indicating which entry to set. The type of I<ptr> depends on the entry. +=for apidoc Am|void|BhkDISABLE|BHK *hk|which +Temporarily disable an entry in this BHK structure, by clearing the +appropriate flag. I<which> is a preprocessor token indicating which +entry to disable. + +=for apidoc Am|void|BhkENABLE|BHK *hk|which +Re-enable an entry in this BHK structure, by setting the appropriate +flag. I<which> is a preprocessor token indicating which entry to enable. +This will assert (under -DDEBUGGING) if the entry doesn't contain a valid +pointer. + =for apidoc m|void|CALL_BLOCK_HOOKS|which|arg Call all the registered block hooks for type I<which>. I<which> is a preprocessing token; the type of I<arg> depends on I<which>. @@ -687,10 +698,21 @@ preprocessing token; the type of I<arg> depends on I<which>. #define BhkENTRY(hk, which) \ ((BhkFLAGS(hk) & BHKf_ ## which) ? ((hk)->bhk_ ## which) : NULL) +#define BhkENABLE(hk, which) \ + STMT_START { \ + BhkFLAGS(hk) |= BHKf_ ## which; \ + assert(BhkENTRY(hk, which)); \ + } STMT_END + +#define BhkDISABLE(hk, which) \ + STMT_START { \ + BhkFLAGS(hk) &= ~(BHKf_ ## which); \ + } STMT_END + #define BhkENTRY_set(hk, which, ptr) \ STMT_START { \ (hk)->bhk_ ## which = ptr; \ - (hk)->bhk_flags |= BHKf_ ## which; \ + BhkENABLE(hk, which); \ } STMT_END #define CALL_BLOCK_HOOKS(which, arg) \ diff --git a/pod/perlguts.pod b/pod/perlguts.pod index d0178e7..62e99bd 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -1905,10 +1905,12 @@ start. Once registered, there is no mechanism to switch these hooks off, so if that is necessary you will need to do this yourself. An entry in C<%^H> -is probably the best way, so the effect is lexically scoped. You should -also be aware that generally speaking at least one scope will have -opened before your extension is loaded, so you will see some -C<pre/post_end> pairs that didn't have a matching C<start>. +is probably the best way, so the effect is lexically scoped; however it +is also possible to use the C<BhkDISABLE> and C<BhkENABLE> macros to +temporarily switch entries on and off. You should also be aware that +generally speaking at least one scope will have opened before your +extension is loaded, so you will see some C<pre/post_end> pairs that +didn't have a matching C<start>. =head1 Examining internal data structures with the C<dump> functions -- Perl5 Master Repository
