line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
4
|
|
|
4
|
|
47
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
99
|
|
4
|
4
|
|
|
4
|
|
19
|
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
144
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.48'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Carp qw( confess ); |
8
|
4
|
|
|
4
|
|
18
|
use List::Util (); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
153
|
|
9
|
4
|
|
|
4
|
|
20
|
use Scalar::Util qw( blessed ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
88
|
|
10
|
4
|
|
|
4
|
|
20
|
use Specio::Helpers qw( perlstring ); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
157
|
|
11
|
4
|
|
|
4
|
|
21
|
use Specio::Library::Builtins; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
148
|
|
12
|
4
|
|
|
4
|
|
28
|
use Specio::TypeChecks qw( does_role ); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
26
|
|
13
|
4
|
|
|
4
|
|
22
|
|
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
2314
|
|
14
|
|
|
|
|
|
|
my $hashref = t('HashRef'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
0
|
24
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
18
|
|
|
|
|
|
|
$hashref->inline_check( $_[1] ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
5
|
shift; |
22
|
|
|
|
|
|
|
my $args = shift; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
for my $p ( ( $args->{slurpy} || () ), values %{ $args->{kv} } ) { |
25
|
4
|
|
|
4
|
|
36
|
my $type; |
26
|
4
|
|
|
|
|
8
|
if ( blessed($p) ) { |
27
|
|
|
|
|
|
|
$type = $p; |
28
|
4
|
|
66
|
|
|
35
|
} |
|
4
|
|
|
|
|
14
|
|
29
|
11
|
|
|
|
|
41
|
else { |
30
|
11
|
100
|
|
|
|
26
|
if ( ref $p eq 'HASH' && $p->{optional} ) { |
31
|
9
|
|
|
|
|
12
|
$type = $p->{optional}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
2
|
50
|
33
|
|
|
8
|
confess |
35
|
2
|
|
|
|
|
4
|
'Can only pass types, optional types, and slurpy types when defining a Dict'; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
0
|
|
39
|
|
|
|
|
|
|
does_role( $type, 'Specio::Constraint::Role::Interface' ) |
40
|
|
|
|
|
|
|
or confess |
41
|
|
|
|
|
|
|
'All parameters passed to ->parameterize must be objects which do the Specio::Constraint::Role::Interface role'; |
42
|
|
|
|
|
|
|
|
43
|
11
|
50
|
|
|
|
22
|
confess |
44
|
|
|
|
|
|
|
'All parameters passed to ->parameterize must be inlinable constraints' |
45
|
|
|
|
|
|
|
unless $type->can_be_inlined; |
46
|
|
|
|
|
|
|
} |
47
|
11
|
50
|
|
|
|
125
|
|
48
|
|
|
|
|
|
|
return %{$args}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $self = shift; |
52
|
4
|
|
|
|
|
20
|
my $p = shift; |
|
4
|
|
|
|
|
18
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
## no critic (Subroutines::ProtectPrivateSubs) |
55
|
|
|
|
|
|
|
my @kv; |
56
|
4
|
|
|
4
|
|
13
|
for my $k ( sort keys %{ $p->{kv} } ) { |
57
|
4
|
|
|
|
|
5
|
my $v = $p->{kv}{$k}; |
58
|
|
|
|
|
|
|
if ( blessed($v) ) { |
59
|
|
|
|
|
|
|
push @kv, "$k => " . $self->_name_or_anon($v); |
60
|
4
|
|
|
|
|
6
|
} |
61
|
4
|
|
|
|
|
7
|
elsif ( $v->{optional} ) { |
|
4
|
|
|
|
|
14
|
|
62
|
10
|
|
|
|
|
47
|
push @kv, |
63
|
10
|
100
|
|
|
|
27
|
"$k => " . $self->_name_or_anon( $v->{optional} ) . '?'; |
|
|
50
|
|
|
|
|
|
64
|
8
|
|
|
|
|
20
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
if ( $p->{slurpy} ) { |
68
|
2
|
|
|
|
|
6
|
push @kv, $self->_name_or_anon( $p->{slurpy} ) . '...'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return 'Dict{ ' . ( join ', ', @kv ) . ' }'; |
72
|
4
|
100
|
|
|
|
28
|
} |
73
|
1
|
|
|
|
|
3
|
|
74
|
|
|
|
|
|
|
shift; |
75
|
|
|
|
|
|
|
my $val = shift; |
76
|
4
|
|
|
|
|
29
|
my %args = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my @code = sprintf( '( %s )', $hashref->_inline_check($val) ); |
79
|
|
|
|
|
|
|
|
80
|
9
|
|
|
9
|
|
14
|
for my $k ( sort keys %{ $args{kv} } ) { |
81
|
9
|
|
|
|
|
15
|
my $p = $args{kv}{$k}; |
82
|
9
|
|
|
|
|
22
|
my $access = sprintf( '%s->{%s}', $val, perlstring($k) ); |
83
|
|
|
|
|
|
|
|
84
|
9
|
|
|
|
|
28
|
if ( !blessed($p) ) { |
85
|
|
|
|
|
|
|
my $type = $p->{optional}; |
86
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
44
|
|
87
|
24
|
|
|
|
|
42
|
push @code, |
88
|
24
|
|
|
|
|
75
|
sprintf( |
89
|
|
|
|
|
|
|
'( exists %s ? ( %s ) : 1 )', |
90
|
24
|
100
|
|
|
|
68
|
$access, $type->_inline_check($access) |
91
|
6
|
|
|
|
|
14
|
); |
92
|
|
|
|
|
|
|
} |
93
|
6
|
|
|
|
|
16
|
else { |
94
|
|
|
|
|
|
|
push @code, sprintf( '( %s )', $p->_inline_check($access) ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
if ( $args{slurpy} ) { |
99
|
|
|
|
|
|
|
my $check |
100
|
18
|
|
|
|
|
43
|
= '( do { my %%_____known_____ = map { $_ => 1 } ( %s ); List::Util::all { %s } grep { ! $_____known_____{$_} } sort keys %%{ %s } } )'; |
101
|
|
|
|
|
|
|
push @code, |
102
|
|
|
|
|
|
|
sprintf( |
103
|
|
|
|
|
|
|
$check, |
104
|
9
|
100
|
|
|
|
26
|
( join ', ', map { perlstring($_) } keys %{ $args{kv} } ), |
105
|
3
|
|
|
|
|
6
|
$args{slurpy}->_inline_check( sprintf( '%s->{$_}', $val ) ), |
106
|
|
|
|
|
|
|
$val, |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
9
|
|
|
|
|
31
|
return '( ' . ( join ' && ', @code ) . ' )'; |
|
3
|
|
|
|
|
8
|
|
111
|
3
|
|
|
|
|
6
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# ABSTRACT: Guts of Dict structured type |
116
|
9
|
|
|
|
|
212
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=pod |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=encoding UTF-8 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 NAME |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Specio::Library::Structured::Dict - Guts of Dict structured type |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 VERSION |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
version 0.48 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 DESCRIPTION |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
There are no user facing parts 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 |