line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::TransformerParameter::Behavior::StringList; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
14
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Perl::ToPerl6::Utils qw{ :characters &words_from_string &hashify }; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
219
|
use base qw{ Perl::ToPerl6::TransformerParameter::Behavior }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
314
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub initialize_parameter { |
14
|
0
|
|
|
0
|
1
|
|
my ($self, $parameter, $specification) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Unfortunately, this has to be kept as a reference, rather than a regular |
17
|
|
|
|
|
|
|
# array, due to a problem in Devel::Cycle |
18
|
|
|
|
|
|
|
# (http://rt.cpan.org/Ticket/Display.html?id=25360) which causes |
19
|
|
|
|
|
|
|
# t/92_memory_leaks.t to fall over. |
20
|
0
|
|
|
|
|
|
my $always_present_values = $specification->{list_always_present_values}; |
21
|
|
|
|
|
|
|
$parameter->_get_behavior_values()->{always_present_values} = |
22
|
0
|
|
|
|
|
|
$always_present_values; |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
if ( not $always_present_values ) { |
25
|
0
|
|
|
|
|
|
$always_present_values = []; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$parameter->_set_parser( |
29
|
|
|
|
|
|
|
sub { |
30
|
|
|
|
|
|
|
# Normally bad thing, obscuring a variable in a outer scope |
31
|
|
|
|
|
|
|
# with a variable with the same name is being done here in |
32
|
|
|
|
|
|
|
# order to remain consistent with the parser function interface. |
33
|
0
|
|
|
0
|
|
|
my ($transformer, $parameter, $config_string) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my @values = @{$always_present_values}; |
|
0
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $value_string = $parameter->get_default_string(); |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if (defined $config_string) { |
39
|
0
|
|
|
|
|
|
$value_string = $config_string; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if ( defined $value_string ) { |
43
|
0
|
|
|
|
|
|
push @values, words_from_string($value_string); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my %values = hashify(@values); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$transformer->__set_parameter_value($parameter, \%values); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub generate_parameter_description { |
60
|
0
|
|
|
0
|
1
|
|
my ($self, $parameter) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $always_present_values = |
63
|
0
|
|
|
|
|
|
$parameter->_get_behavior_values()->{always_present_values}; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $description = $parameter->_get_description_with_trailing_period(); |
66
|
0
|
0
|
0
|
|
|
|
if ( $description and $always_present_values ) { |
67
|
0
|
|
|
|
|
|
$description .= qq{\n}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if ( $always_present_values ) { |
71
|
0
|
|
|
|
|
|
$description .= 'Values that are always included: '; |
72
|
0
|
|
|
|
|
|
$description .= join ', ', sort @{ $always_present_values }; |
|
0
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$description .= $PERIOD; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $description; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=pod |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=for stopwords |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Perl::ToPerl6::TransformerParameter::Behavior::StringList - Actions appropriate for a parameter that is a list of strings. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Provides a standard set of functionality for a string list |
97
|
|
|
|
|
|
|
L<Perl::ToPerl6::TransformerParameter|Perl::ToPerl6::TransformerParameter> so that |
98
|
|
|
|
|
|
|
the developer of a transformer does not have to provide it her/himself. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
NOTE: Do not instantiate this class. Use the singleton instance held |
101
|
|
|
|
|
|
|
onto by |
102
|
|
|
|
|
|
|
L<Perl::ToPerl6::TransformerParameter|Perl::ToPerl6::TransformerParameter>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 INTERFACE SUPPORT |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is considered to be a non-public class. Its interface is subject |
108
|
|
|
|
|
|
|
to change without notice. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 METHODS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=over |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item C<initialize_parameter( $parameter, $specification )> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Plug in the functionality this behavior provides into the parameter, |
118
|
|
|
|
|
|
|
based upon the configuration provided by the specification. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This behavior looks for one configuration item: |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item always_present_values |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Optional. Values that should always be included, regardless of what |
127
|
|
|
|
|
|
|
the configuration of the parameter specifies, as an array reference. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item C<generate_parameter_description( $parameter )> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Create a description of the parameter, based upon the description on |
134
|
|
|
|
|
|
|
the parameter itself, but enhancing it with information from this |
135
|
|
|
|
|
|
|
behavior. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
In this specific case, the always present values are added at the end. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Elliot Shank <perl@galumph.com> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 COPYRIGHT |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Copyright (c) 2006-2011 Elliot Shank. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
151
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
152
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# Local Variables: |
157
|
|
|
|
|
|
|
# mode: cperl |
158
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
159
|
|
|
|
|
|
|
# fill-column: 78 |
160
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
161
|
|
|
|
|
|
|
# c-indentation-style: bsd |
162
|
|
|
|
|
|
|
# End: |
163
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |