Branch: refs/heads/yves/require_hook_rebased Home: https://github.com/Perl/perl5 Commit: 6ae8209f5a0f6661411587562e50ea2bf01abaeb https://github.com/Perl/perl5/commit/6ae8209f5a0f6661411587562e50ea2bf01abaeb Author: Yves Orton <demerphq@gmail.com> Date: 2023-03-16 (Thu, 16 Mar 2023) Changed paths: M MANIFEST R t/lib/GH_15109/Apack.pm R t/lib/GH_15109/Bpack.pm R t/lib/GH_15109/Cpack.pm R t/lib/GH_15109/Foo.pm A t/lib/caller/Apack.pm A t/lib/caller/Bpack.pm A t/lib/caller/Cpack.pm A t/lib/caller/Foo.pm M t/op/caller.t Log Message: ----------- t/lib/GH_15109 - rename to t/lib/caller I want to use these modules in other tests, so changing the name makes sense. Commit: 567a3658ec596789cbd7878ec1508a862a1df8c8 https://github.com/Perl/perl5/commit/567a3658ec596789cbd7878ec1508a862a1df8c8 Author: Yves Orton <demerphq@gmail.com> Date: 2023-03-16 (Thu, 16 Mar 2023) Changed paths: M regen/mg_vtable.pl Log Message: ----------- regen/mg_vtable.pl - rename confusing var %sig to %vtable_conf Commit: 5546ec4bb6ac6e3938f34bd4dd97940851c97aab https://github.com/Perl/perl5/commit/5546ec4bb6ac6e3938f34bd4dd97940851c97aab Author: Yves Orton <demerphq@gmail.com> Date: 2023-03-16 (Thu, 16 Mar 2023) Changed paths: M embed.fnc M embed.h M proto.h M sv.h M sv_inline.h Log Message: ----------- sv.h - add SvREFCNT_dec_set_NULL() and also SvREFCNT_dec_ret_NULL() which is used to implement SvREFCNT_dec_set_NULL(). The set_NULL() macro is intended to be used to replace code like this: if (sv) { SvREFCNT_dec_NN(sv); sv = NULL; } The function form just facilitates it, and can be used in situations where returning NULL after decrementing a refcount would be reduce code complexity. Commit: 6bc97d9862f5923b3f63b6f001e0560e51e16ce8 https://github.com/Perl/perl5/commit/6bc97d9862f5923b3f63b6f001e0560e51e16ce8 Author: Yves Orton <demerphq@gmail.com> Date: 2023-03-16 (Thu, 16 Mar 2023) Changed paths: M MANIFEST M embed.fnc M embed.h M embedvar.h M gv.c M intrpvar.h M mg.c M mg_names.inc M mg_raw.h M mg_vtable.h M perl.c M pod/perldiag.pod M pod/perlfunc.pod M pod/perlguts.pod M pod/perlvar.pod M pp_ctl.c M proto.h M regen/mg_vtable.pl M sv.c M t/harness A t/lib/caller/Bicycle.pm A t/lib/caller/Cycle.pm A t/lib/caller/Tricycle.pm M t/op/glob.t A t/op/hook/require.t Log Message: ----------- pp_ctl.c - add support for hooking require. This defines a new magic hash C<%{^HOOK}> which is intended to be used for hooking keywords. It is similar to %SIG in that the values it contains are validated on set, and it is not allowed to store something in C<%{^HOOK}> that isn't supposed to be there. Hooks are expected to be coderefs (people can use currying if they really want to put an object in there, the API is deliberately simple.) The C<%{^HOOK}> hash is documented to have keys of the form "${keyword}__${phase}" where $phase is either "before" or "after" and in this initial release two hooks are supported, "require__before" and "require__after": The C<require__before> hook is called before require is executed, including any @INC hooks that might be fired. It is called with the path of the file being required, just as would be stored in %INC. The hook may alter the filename by writing to $_[0] and it may return a coderef to be executed *after* the require has completed, otherwise the return is ignored. This coderef is also called with the path of the file which was required, and it will be called regardless as to whether the require (or its dependencies) die during execution. This mechanism makes it trivial and safe to share state between the initial hook and the coderef it returns. The C<require__after> hook is similar to the C<require__before> hook however except that it is called after the require completes (successfully or not), and its return is ignored always. Compare: https://github.com/Perl/perl5/compare/50cbd72cf96b...6bc97d9862f5