Branch: refs/heads/yves/require_hook_rebased
  Home:   https://github.com/Perl/perl5
  Commit: 2451b72bdfa2605d035cb6794838b137f31b9a19
      
https://github.com/Perl/perl5/commit/2451b72bdfa2605d035cb6794838b137f31b9a19
  Author: Yves Orton <demer...@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: cf40e62f6d4f4aed2153737e808539a59c4bd423
      
https://github.com/Perl/perl5/commit/cf40e62f6d4f4aed2153737e808539a59c4bd423
  Author: Yves Orton <demer...@gmail.com>
  Date:   2023-03-16 (Thu, 16 Mar 2023)

  Changed paths:
    M embed.fnc
    M embed.h
    M mg_names.inc
    M mg_raw.h
    M mg_vtable.h
    M pod/perlguts.pod
    M proto.h
    M regen/mg_vtable.pl
    M scope.c

  Log Message:
  -----------
  scope.c - create_sv_destruct/magic_freedestruct (XXX update commit message)

[ More/Better commit message to come ]

This is *heavily* cribberd from Leon's Variable-OnDestruct. See:

https://metacpan.org/dist/Variable-OnDestruct/source/lib/Variable/OnDestruct.xs#L6-17

I am very grateful to him for his help on this.


  Commit: 77e19265561083b711c36082e3440f637ba291e0
      
https://github.com/Perl/perl5/commit/77e19265561083b711c36082e3440f637ba291e0
  Author: Yves Orton <demer...@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/3dcd4b2a9869...77e192655610

Reply via email to