.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "autodie::Util 3"
.TH autodie::Util 3 "2015-07-09" "perl v5.26.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
autodie::Util \- Internal Utility subroutines for autodie and Fatal
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\&    # INTERNAL API for autodie and Fatal only!
\&
\&    use autodie::Util qw(on_end_of_compile_scope);
\&    on_end_of_compile_scope(sub { print "Hallo world\en"; });
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Interal Utilities for autodie and Fatal!  This module is not a part of
autodie's public \s-1API.\s0
.PP
This module contains utility subroutines for abstracting away the
underlying magic of autodie and (ab)uses of \f(CW\*(C`%^H\*(C'\fR to call subs at the
end of a (compile-time) scopes.
.PP
Note that due to how \f(CW\*(C`%^H\*(C'\fR works, some of these utilities are only
useful during the compilation phase of a perl module and relies on the
internals of how perl handles references in \f(CW\*(C`%^H\*(C'\fR.
.SS "Methods"
.IX Subsection "Methods"
\fIon_end_of_compile_scope\fR
.IX Subsection "on_end_of_compile_scope"
.PP
.Vb 1
\&  on_end_of_compile_scope(sub { print "Hallo world\en"; });
.Ve
.PP
Will invoke a sub at the end of a (compile-time) scope.  The sub is
called once with no arguments.  Can be called multiple times (even in
the same \*(L"compile-time\*(R" scope) to install multiple subs.  Subs are
called in a \*(L"first\-in\-last\-out\*(R"\-order (\s-1FILO\s0 or \*(L"stack\*(R"\-order).
.PP
\fIfill_protos\fR
.IX Subsection "fill_protos"
.PP
.Vb 1
\&  fill_protos(\*(Aq*$$;$@\*(Aq)
.Ve
.PP
Given a Perl subroutine prototype, return a list of invocation
specifications.  Each specification is a listref, where the first
member is the (minimum) number of arguments for this invocation
specification.  The remaining arguments are a string representation of
how to pass the arguments correctly to a sub with the given prototype,
when called with the given number of arguments.
.PP
The specifications are returned in increasing order of arguments
starting at 0 (e.g.  ';$') or 1 (e.g.  '$@').  Note that if the
prototype is \*(L"slurpy\*(R" (e.g. ends with a \*(L"@\*(R"), the number of arguments
for the last specification is a \*(L"minimum\*(R" number rather than an exact
number.  This can be detected by the last member of the last
specification matching m/[@#]_/.
.PP
\fImake_core_trampoline\fR
.IX Subsection "make_core_trampoline"
.PP
.Vb 1
\&  make_core_trampoline(\*(AqCORE::open\*(Aq, \*(Aqmain\*(Aq, prototype(\*(AqCORE::open\*(Aq))
.Ve
.PP
Creates a trampoline for calling a core sub.  Essentially, a tiny sub
that figures out how we should be calling our core sub, puts in the
arguments in the right way, and bounces our control over to it.
.PP
If we could reliably use `goto &` on core builtins, we wouldn't need
this subroutine.
.PP
\fIinstall_subs\fR
.IX Subsection "install_subs"
.PP
.Vb 1
\&  install_subs(\*(AqMy::Module\*(Aq, { \*(Aqread\*(Aq => sub { die("Hallo\en"), ... }})
.Ve
.PP
Given a package name and a hashref mapping names to a subroutine
reference (or \f(CW\*(C`undef\*(C'\fR), this subroutine will install said subroutines
on their given name in that module.  If a name mapes to \f(CW\*(C`undef\*(C'\fR, any
subroutine with that name in the target module will be remove
(possibly \*(L"unshadowing\*(R" a \s-1CORE\s0 sub of same name).
.SH "AUTHOR"
.IX Header "AUTHOR"
Copyright 2013\-2014, Niels Thykier <niels@thykier.net>
.SH "LICENSE"
.IX Header "LICENSE"
This module is free software.  You may distribute it under the
same terms as Perl itself.
