line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
30
|
|
|
30
|
|
161
|
use warnings; |
|
30
|
|
|
|
|
48
|
|
|
30
|
|
|
|
|
712
|
|
4
|
30
|
|
|
30
|
|
120
|
|
|
30
|
|
|
|
|
41
|
|
|
30
|
|
|
|
|
696
|
|
5
|
|
|
|
|
|
|
use Carp qw( croak ); |
6
|
30
|
|
|
30
|
|
142
|
use Exporter 'import'; |
|
30
|
|
|
|
|
51
|
|
|
30
|
|
|
|
|
1275
|
|
7
|
30
|
|
|
30
|
|
153
|
use overload (); |
|
30
|
|
|
|
|
72
|
|
|
30
|
|
|
|
|
716
|
|
8
|
30
|
|
|
30
|
|
26645
|
|
|
30
|
|
|
|
|
23094
|
|
|
30
|
|
|
|
|
1015
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.48'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Scalar::Util qw( blessed ); |
12
|
30
|
|
|
30
|
|
175
|
|
|
30
|
|
|
|
|
50
|
|
|
30
|
|
|
|
|
2491
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( install_t_sub is_class_loaded perlstring _STRINGLIKE ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Specio::DeclaredAt use Specio::OO, which in turn uses |
17
|
|
|
|
|
|
|
# Specio::Helpers. If we load this with "use" we get a cirular require and |
18
|
|
|
|
|
|
|
# a big mess. |
19
|
|
|
|
|
|
|
require Specio::DeclaredAt; |
20
|
|
|
|
|
|
|
|
21
|
261
|
|
|
261
|
0
|
1480
|
my $caller = shift; |
22
|
|
|
|
|
|
|
my $types = shift; |
23
|
261
|
|
|
|
|
449
|
|
24
|
261
|
|
|
|
|
348
|
# XXX - check to see if their t() is something else entirely? |
25
|
|
|
|
|
|
|
{ |
26
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
27
|
|
|
|
|
|
|
no strict 'refs'; |
28
|
|
|
|
|
|
|
|
29
|
30
|
|
|
30
|
|
172
|
# We used to check ->can('t') but that was wrong, since it would |
|
30
|
|
|
|
|
55
|
|
|
30
|
|
|
|
|
4737
|
|
|
261
|
|
|
|
|
336
|
|
30
|
|
|
|
|
|
|
# return if a parent class had a t() sub. |
31
|
|
|
|
|
|
|
return if *{ $caller . '::t' }{CODE}; |
32
|
|
|
|
|
|
|
} |
33
|
261
|
100
|
|
|
|
336
|
|
|
261
|
|
|
|
|
1716
|
|
34
|
|
|
|
|
|
|
my $t = sub { |
35
|
|
|
|
|
|
|
my $name = shift; |
36
|
|
|
|
|
|
|
|
37
|
1061
|
|
|
1061
|
|
86898
|
croak 'The t subroutine requires a single non-empty string argument' |
38
|
|
|
|
|
|
|
unless _STRINGLIKE($name); |
39
|
1061
|
50
|
|
|
|
1865
|
|
40
|
|
|
|
|
|
|
croak "There is no type named $name available for the $caller package" |
41
|
|
|
|
|
|
|
unless exists $types->{$name}; |
42
|
|
|
|
|
|
|
|
43
|
1061
|
50
|
|
|
|
2245
|
my $found = $types->{$name}; |
44
|
|
|
|
|
|
|
|
45
|
1061
|
|
|
|
|
1405
|
return $found unless @_; |
46
|
|
|
|
|
|
|
|
47
|
1061
|
100
|
|
|
|
6249
|
my %p = @_; |
48
|
|
|
|
|
|
|
|
49
|
25
|
|
|
|
|
73
|
croak 'Cannot parameterize a non-parameterizable type' |
50
|
|
|
|
|
|
|
unless $found->can('parameterize'); |
51
|
25
|
50
|
|
|
|
120
|
|
52
|
|
|
|
|
|
|
return $found->parameterize( |
53
|
|
|
|
|
|
|
declared_at => Specio::DeclaredAt->new_from_caller(1), |
54
|
25
|
|
|
|
|
122
|
%p, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
159
|
|
|
|
|
917
|
{ |
59
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
60
|
|
|
|
|
|
|
no strict 'refs'; |
61
|
|
|
|
|
|
|
no warnings 'redefine'; |
62
|
30
|
|
|
30
|
|
180
|
*{ $caller . '::t' } = $t; |
|
30
|
|
|
|
|
65
|
|
|
30
|
|
|
|
|
930
|
|
|
159
|
|
|
|
|
254
|
|
63
|
30
|
|
|
30
|
|
150
|
} |
|
30
|
|
|
|
|
52
|
|
|
30
|
|
|
|
|
6946
|
|
64
|
159
|
|
|
|
|
212
|
|
|
159
|
|
|
|
|
498
|
|
65
|
|
|
|
|
|
|
return; |
66
|
|
|
|
|
|
|
} |
67
|
159
|
|
|
|
|
349
|
|
68
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitSubroutinePrototypes, Subroutines::ProhibitExplicitReturnUndef) |
69
|
|
|
|
|
|
|
return $_[0] if _STRING( $_[0] ); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return $_[0] |
72
|
1905
|
50
|
|
1905
|
|
2944
|
if blessed $_[0] |
73
|
|
|
|
|
|
|
&& overload::Method( $_[0], q{""} ) |
74
|
0
|
0
|
0
|
|
|
0
|
&& length "$_[0]"; |
|
|
|
0
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
return undef; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
# Borrowed from Params::Util |
80
|
|
|
|
|
|
|
return defined $_[0] && !ref $_[0] && length( $_[0] ) ? $_[0] : undef; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
BEGIN { |
84
|
1905
|
50
|
33
|
1905
|
|
9824
|
if ( $] >= 5.010 && eval { require XString; 1 } ) { |
85
|
|
|
|
|
|
|
*perlstring = \&XString::perlstring; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
30
|
50
|
33
|
30
|
|
232
|
require B; |
|
30
|
|
|
|
|
10619
|
|
|
30
|
|
|
|
|
9839
|
|
89
|
30
|
|
|
|
|
931
|
*perlstring = \&B::perlstring; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
0
|
|
93
|
0
|
|
|
|
|
0
|
# Borrowed from Types::Standard |
94
|
|
|
|
|
|
|
my $stash = do { |
95
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
96
|
|
|
|
|
|
|
no strict 'refs'; |
97
|
|
|
|
|
|
|
\%{ $_[0] . '::' }; |
98
|
|
|
|
|
|
|
}; |
99
|
78
|
|
|
78
|
0
|
7635
|
|
100
|
|
|
|
|
|
|
return 1 if exists $stash->{ISA}; |
101
|
30
|
|
|
30
|
|
166
|
return 1 if exists $stash->{VERSION}; |
|
30
|
|
|
|
|
48
|
|
|
30
|
|
|
|
|
3136
|
|
102
|
78
|
|
|
|
|
98
|
|
|
78
|
|
|
|
|
271
|
|
103
|
|
|
|
|
|
|
foreach my $globref ( values %{$stash} ) { |
104
|
|
|
|
|
|
|
return 1 |
105
|
78
|
50
|
|
|
|
221
|
if ref \$globref eq 'GLOB' |
106
|
78
|
100
|
|
|
|
152
|
? *{$globref}{CODE} |
107
|
|
|
|
|
|
|
: ref $globref; # const or sub ref |
108
|
76
|
|
|
|
|
91
|
} |
|
76
|
|
|
|
|
166
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
return 0; |
111
|
30
|
|
|
|
|
203
|
} |
112
|
30
|
50
|
|
|
|
72
|
|
|
|
100
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
55
|
|
|
|
|
287
|
# ABSTRACT: Helper subs for the Specio distro |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=pod |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=encoding UTF-8 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 NAME |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Specio::Helpers - Helper subs for the Specio distro |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 VERSION |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
version 0.48 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 DESCRIPTION |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
There's nothing public here. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=for Pod::Coverage .* |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 SUPPORT |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SOURCE |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This software is Copyright (c) 2012 - 2022 by Dave Rolsky. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This is free software, licensed under: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
The full text of the license can be found in the |
157
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |