develooper Front page | perl.perl5.changes | Postings from March 2023

[Perl/perl5] 77efb3: t/lib/GH_15109 - rename to t/lib/caller

From:
Yves Orton via perl5-changes
Date:
March 17, 2023 14:54
Subject:
[Perl/perl5] 77efb3: t/lib/GH_15109 - rename to t/lib/caller
Message ID:
Perl/perl5/push/refs/heads/yves/require_hook_rebased/d84844-d0b1ad@github.com
  Branch: refs/heads/yves/require_hook_rebased
  Home:   https://github.com/Perl/perl5
  Commit: 77efb39417475f92f5120285ddb950d63cd5a321
      https://github.com/Perl/perl5/commit/77efb39417475f92f5120285ddb950d63cd5a321
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2023-03-17 (Fri, 17 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: 283e506e6cb4a3efae7adfa3ba89b4999ffe8aa8
      https://github.com/Perl/perl5/commit/283e506e6cb4a3efae7adfa3ba89b4999ffe8aa8
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2023-03-17 (Fri, 17 Mar 2023)

  Changed paths:
    M regen/mg_vtable.pl

  Log Message:
  -----------
  regen/mg_vtable.pl - rename confusing var %sig to %vtable_conf


  Commit: 41bfa2b82ff47c0ad8609cc2a8ac80d5fab0fd07
      https://github.com/Perl/perl5/commit/41bfa2b82ff47c0ad8609cc2a8ac80d5fab0fd07
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2023-03-17 (Fri, 17 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: de26a03cecf994eba922a3c27287969437cdd0cc
      https://github.com/Perl/perl5/commit/de26a03cecf994eba922a3c27287969437cdd0cc
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2023-03-17 (Fri, 17 Mar 2023)

  Changed paths:
    M pod/perldiag.pod

  Log Message:
  -----------
  pod/perldiag.pod - provide full path to issues tracker

https://github.com/Perl/perl5/issues shows the list of open issues,
whereas https://github.com/Perl/perl5/issues/new/choose is where someone
can create a new ticket.


  Commit: 7dceac41b1118feeab9d98550898ccc1938f3e0c
      https://github.com/Perl/perl5/commit/7dceac41b1118feeab9d98550898ccc1938f3e0c
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2023-03-17 (Fri, 17 Mar 2023)

  Changed paths:
    M dist/threads-shared/lib/threads/shared.pm
    M dist/threads-shared/shared.xs

  Log Message:
  -----------
  threads-shared - fixup typo in comment


  Commit: 9961aaca30f44e833d29e1fc613850a42f82d040
      https://github.com/Perl/perl5/commit/9961aaca30f44e833d29e1fc613850a42f82d040
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2023-03-17 (Fri, 17 Mar 2023)

  Changed paths:
    M MANIFEST
    M embed.fnc
    M embed.h
    M ext/XS-APItest/APItest.pm
    M ext/XS-APItest/APItest.xs
    A ext/XS-APItest/t/mortal_destructor.t
    M mg_names.inc
    M mg_raw.h
    M mg_vtable.h
    M pod/perldiag.pod
    M pod/perlguts.pod
    M proto.h
    M regen/mg_vtable.pl
    M scope.c
    M scope.h

  Log Message:
  -----------
  scope.c - add mortal_destructor_sv() and mortal_svfunc_x()

The function SAVEDESTRUCTOR_X() (save_destructor_x) can be used to
execute a C function at the end of the current psuedo-block. Prior to
this patch there was no "mortal" equivalent that would execute at the
end of the current statement. We offer a collection of functions which
are intended to free SV's at either point in time, but only support
callbacks at the end of the current pseudo-block.

This patch adds two such functions, "mortal_destructor_sv" which can be
used to trigger a perl code reference to execute at the end of the
current statement, and "mortal_svfunc_x" which can be used to trigger an
SVFUNC_t C function at the end of the current statement.

Both functions differ from save_destructor_x() in that instead of
supporting a void pointer argument they both require their argument to
be some sort of SV pointer. The Perl callback function triggered by
"mortal_destructor_sv" may be provided no arguments, a single argument
or a list of arguments, depending on the type of argument provided to
mortal_destructor_sv(): when the argument is a raw AV (with no SV ref
wrapping it), then the contents of the AV are passed in as a list of
arguments. When the argument is anything else but NULL, the argument is
provided as a single argument, and when it is NULL the perl function is
called with no arguments.

Both functions are implemented on top of a mortal SV (unseen by the
user) which has PERL_MAGIC_destruct magic associated with it, which
triggers the destructor behavior when the SV is freed.

Both functions are provided with macros to match the normal SAVExx()
API, with MORTALDESTRUCTOR_SV() wrapping mortal_destructor_sv() and
MORTALSVFUNC_X() wrapping mortal_svfunc_x().

The heart of this logic cribbed from Leon Timmermans' Variable-OnDestruct.
See the code at:

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

I am very grateful to him for his help on this. Any errors or omissions
in this code are my fault, not his.


  Commit: d0b1ad153b8a809bf01f7580357a9574c0965ce6
      https://github.com/Perl/perl5/commit/d0b1ad153b8a809bf01f7580357a9574c0965ce6
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2023-03-17 (Fri, 17 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/d84844075753...d0b1ad153b8a



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About