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