1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
.\"
.\" 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 3perl"
.TH autodie::Util 3perl "2023-11-25" "perl v5.36.0" "Perl Programmers Reference Guide"
.\" 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.
|