| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
544
|
|
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
push(@::bean_desc, { |
|
4
|
|
|
|
|
|
|
bean_opt => { |
|
5
|
|
|
|
|
|
|
abstract => 'Abstract PerlBean attribute information', |
|
6
|
|
|
|
|
|
|
base => [ qw( PerlBean::Method::Factory ) ], |
|
7
|
|
|
|
|
|
|
package => 'PerlBean::Attribute', |
|
8
|
|
|
|
|
|
|
use_perl_version => 5.005, |
|
9
|
|
|
|
|
|
|
description => <
|
|
10
|
|
|
|
|
|
|
C abstract class for bean attribute information. Attribute access methods are implemented and code and documentation generation interface methods are defined. |
|
11
|
|
|
|
|
|
|
EOF |
|
12
|
|
|
|
|
|
|
short_description => 'contains bean attribute information', |
|
13
|
|
|
|
|
|
|
synopsis => "None. This is an abstract class.\n", |
|
14
|
|
|
|
|
|
|
}, |
|
15
|
|
|
|
|
|
|
attr_opt => [ |
|
16
|
|
|
|
|
|
|
# { |
|
17
|
|
|
|
|
|
|
# method_factory_name => 'method_factory_name', |
|
18
|
|
|
|
|
|
|
# type => 'SINGLE', |
|
19
|
|
|
|
|
|
|
# mandatory => 1, |
|
20
|
|
|
|
|
|
|
# allow_empty => 0, |
|
21
|
|
|
|
|
|
|
# allow_rx => [qw(^\w+$)], |
|
22
|
|
|
|
|
|
|
# short_description => 'attribute\'s name', |
|
23
|
|
|
|
|
|
|
# }, |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
|
|
|
|
|
|
method_factory_name => 'default_value', |
|
26
|
|
|
|
|
|
|
type => 'SINGLE', |
|
27
|
|
|
|
|
|
|
short_description => 'attribute default value', |
|
28
|
|
|
|
|
|
|
}, |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
|
|
|
|
|
|
method_factory_name => 'documented', |
|
31
|
|
|
|
|
|
|
type => 'BOOLEAN', |
|
32
|
|
|
|
|
|
|
default_value => 1, |
|
33
|
|
|
|
|
|
|
short_description => 'the attribute is documented', |
|
34
|
|
|
|
|
|
|
}, |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
|
|
|
|
|
|
method_factory_name => 'exception_class', |
|
37
|
|
|
|
|
|
|
type => 'SINGLE', |
|
38
|
|
|
|
|
|
|
allow_empty => 0, |
|
39
|
|
|
|
|
|
|
default_value => 'Error::Simple', |
|
40
|
|
|
|
|
|
|
short_description => 'the class to throw when an exception occurs', |
|
41
|
|
|
|
|
|
|
}, |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
|
|
|
|
|
|
method_factory_name => 'mandatory', |
|
44
|
|
|
|
|
|
|
type => 'BOOLEAN', |
|
45
|
|
|
|
|
|
|
default_value => 0, |
|
46
|
|
|
|
|
|
|
short_description => 'the attribute is mandatory for construction', |
|
47
|
|
|
|
|
|
|
}, |
|
48
|
|
|
|
|
|
|
{ |
|
49
|
|
|
|
|
|
|
method_factory_name => 'method_base', |
|
50
|
|
|
|
|
|
|
type => 'SINGLE', |
|
51
|
|
|
|
|
|
|
short_description => 'the method base name', |
|
52
|
|
|
|
|
|
|
}, |
|
53
|
|
|
|
|
|
|
# { |
|
54
|
|
|
|
|
|
|
# method_factory_name => 'perl_bean', |
|
55
|
|
|
|
|
|
|
# type => 'SINGLE', |
|
56
|
|
|
|
|
|
|
# allow_isa => [qw(PerlBean)], |
|
57
|
|
|
|
|
|
|
# short_description => 'the PerlBean to which this attribute belongs', |
|
58
|
|
|
|
|
|
|
# }, |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
|
|
|
|
|
|
method_factory_name => 'short_description', |
|
61
|
|
|
|
|
|
|
type => 'SINGLE', |
|
62
|
|
|
|
|
|
|
short_description => 'the attribute description', |
|
63
|
|
|
|
|
|
|
}, |
|
64
|
|
|
|
|
|
|
], |
|
65
|
|
|
|
|
|
|
meth_opt => [ |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
|
|
|
|
|
|
method_name => 'get_package', |
|
68
|
|
|
|
|
|
|
description => <
|
|
69
|
|
|
|
|
|
|
Returns the package name. The package name is obtained from the C to which the C belongs. Or, if the C does not belong to a C, C is returned. |
|
70
|
|
|
|
|
|
|
EOF |
|
71
|
|
|
|
|
|
|
body => <<'EOF', |
|
72
|
|
|
|
|
|
|
my $self = shift; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
defined( $self->get_perl_bean() ) || return('main'); |
|
75
|
|
|
|
|
|
|
return( $self->get_perl_bean()->get_package() ); |
|
76
|
|
|
|
|
|
|
EOF |
|
77
|
|
|
|
|
|
|
}, |
|
78
|
|
|
|
|
|
|
{ |
|
79
|
|
|
|
|
|
|
method_name => 'get_package_us', |
|
80
|
|
|
|
|
|
|
description => <
|
|
81
|
|
|
|
|
|
|
Calls C and replaces C<:+> with C <_>. |
|
82
|
|
|
|
|
|
|
EOF |
|
83
|
|
|
|
|
|
|
body => <<'EOF', |
|
84
|
|
|
|
|
|
|
my $self = shift; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $pkg = $self->get_package(); |
|
87
|
|
|
|
|
|
|
$pkg =~ s/:+/_/g; |
|
88
|
|
|
|
|
|
|
return($pkg); |
|
89
|
|
|
|
|
|
|
EOF |
|
90
|
|
|
|
|
|
|
}, |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
|
|
|
|
|
|
method_name => 'create_methods', |
|
93
|
|
|
|
|
|
|
# description => <
|
|
94
|
|
|
|
|
|
|
#Returns a list containing the access methods for the attribute. |
|
95
|
|
|
|
|
|
|
#EOF |
|
96
|
|
|
|
|
|
|
interface => 1, |
|
97
|
|
|
|
|
|
|
}, |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
|
|
|
|
|
|
method_name => 'write_allow_isa', |
|
100
|
|
|
|
|
|
|
documented => 0, |
|
101
|
|
|
|
|
|
|
interface => 1, |
|
102
|
|
|
|
|
|
|
description => <
|
|
103
|
|
|
|
|
|
|
Returns a C<\%ALLOW_ISA> line string for the attribute. |
|
104
|
|
|
|
|
|
|
EOF |
|
105
|
|
|
|
|
|
|
}, |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
|
|
|
|
|
|
method_name => 'write_allow_ref', |
|
108
|
|
|
|
|
|
|
documented => 0, |
|
109
|
|
|
|
|
|
|
interface => 1, |
|
110
|
|
|
|
|
|
|
description => <
|
|
111
|
|
|
|
|
|
|
Returns a C<\%ALLOW_REF> line string for the attribute. |
|
112
|
|
|
|
|
|
|
EOF |
|
113
|
|
|
|
|
|
|
}, |
|
114
|
|
|
|
|
|
|
{ |
|
115
|
|
|
|
|
|
|
method_name => 'write_allow_rx', |
|
116
|
|
|
|
|
|
|
documented => 0, |
|
117
|
|
|
|
|
|
|
interface => 1, |
|
118
|
|
|
|
|
|
|
description => <
|
|
119
|
|
|
|
|
|
|
Returns a C<\%ALLOW_RX> line string for the attribute. |
|
120
|
|
|
|
|
|
|
EOF |
|
121
|
|
|
|
|
|
|
}, |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
|
|
|
|
|
|
method_name => 'write_allow_value', |
|
124
|
|
|
|
|
|
|
documented => 0, |
|
125
|
|
|
|
|
|
|
interface => 1, |
|
126
|
|
|
|
|
|
|
description => <
|
|
127
|
|
|
|
|
|
|
Returns a C<\%ALLOW_VALUE> line string for the attribute. |
|
128
|
|
|
|
|
|
|
EOF |
|
129
|
|
|
|
|
|
|
}, |
|
130
|
|
|
|
|
|
|
{ |
|
131
|
|
|
|
|
|
|
method_name => 'write_default_value', |
|
132
|
|
|
|
|
|
|
description => <<'EOF', |
|
133
|
|
|
|
|
|
|
Returns a C<%DEFAULT_VALUE> line string for the attribute. |
|
134
|
|
|
|
|
|
|
EOF |
|
135
|
|
|
|
|
|
|
interface => 1, |
|
136
|
|
|
|
|
|
|
}, |
|
137
|
|
|
|
|
|
|
{ |
|
138
|
|
|
|
|
|
|
method_name => 'write_constructor_option_code', |
|
139
|
|
|
|
|
|
|
description => <
|
|
140
|
|
|
|
|
|
|
Writes constructor code for the attribute option. |
|
141
|
|
|
|
|
|
|
EOF |
|
142
|
|
|
|
|
|
|
interface => 1, |
|
143
|
|
|
|
|
|
|
}, |
|
144
|
|
|
|
|
|
|
{ |
|
145
|
|
|
|
|
|
|
method_name => 'write_constructor_option_doc', |
|
146
|
|
|
|
|
|
|
description => <
|
|
147
|
|
|
|
|
|
|
Writes constructor documentation for the attribute option. |
|
148
|
|
|
|
|
|
|
EOF |
|
149
|
|
|
|
|
|
|
interface => 1, |
|
150
|
|
|
|
|
|
|
}, |
|
151
|
|
|
|
|
|
|
{ |
|
152
|
|
|
|
|
|
|
method_name => '_esc_apos', |
|
153
|
|
|
|
|
|
|
documented => 0, |
|
154
|
|
|
|
|
|
|
description => <
|
|
155
|
|
|
|
|
|
|
Escapes apostrophes in string |
|
156
|
|
|
|
|
|
|
EOF |
|
157
|
|
|
|
|
|
|
body => <<'EOF', |
|
158
|
|
|
|
|
|
|
my $self = shift; |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
my @in = @_; |
|
161
|
|
|
|
|
|
|
my @el = (); |
|
162
|
|
|
|
|
|
|
foreach my $el (@in) { |
|
163
|
|
|
|
|
|
|
if ( $el =~ /^[+-]?\d+$/ ) { |
|
164
|
|
|
|
|
|
|
$el = ( int($el) ); |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
else { |
|
167
|
|
|
|
|
|
|
$el =~ s/'/\\'/g; |
|
168
|
|
|
|
|
|
|
$el = '\'' . $el . '\''; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
push( @el, $el ); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
if (wantarray) { |
|
173
|
|
|
|
|
|
|
return(@el); |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
else { |
|
176
|
|
|
|
|
|
|
return( join( ', ', @el ) ); |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
EOF |
|
179
|
|
|
|
|
|
|
}, |
|
180
|
|
|
|
|
|
|
{ |
|
181
|
|
|
|
|
|
|
method_name => '_esc_aq', |
|
182
|
|
|
|
|
|
|
documented => 0, |
|
183
|
|
|
|
|
|
|
description => <
|
|
184
|
|
|
|
|
|
|
Escapes apostrophes and quotes in string |
|
185
|
|
|
|
|
|
|
EOF |
|
186
|
|
|
|
|
|
|
body => <<'EOF', |
|
187
|
|
|
|
|
|
|
my $self = shift; |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
my $do_quote = 0; |
|
190
|
|
|
|
|
|
|
foreach my $el (@_) { |
|
191
|
|
|
|
|
|
|
if ($el =~ /[\n\r\t\f\a\e]/) { |
|
192
|
|
|
|
|
|
|
$do_quote = 1; |
|
193
|
|
|
|
|
|
|
last; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
if (wantarray) { |
|
198
|
|
|
|
|
|
|
return ( |
|
199
|
|
|
|
|
|
|
$do_quote ? |
|
200
|
|
|
|
|
|
|
( $self->_esc_quote(@_) ) : |
|
201
|
|
|
|
|
|
|
( $self->_esc_apos(@_) ) |
|
202
|
|
|
|
|
|
|
); |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
else { |
|
205
|
|
|
|
|
|
|
return ( |
|
206
|
|
|
|
|
|
|
$do_quote ? |
|
207
|
|
|
|
|
|
|
scalar( $self->_esc_quote(@_) ) : |
|
208
|
|
|
|
|
|
|
scalar( $self->_esc_apos(@_) ) |
|
209
|
|
|
|
|
|
|
); |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
EOF |
|
212
|
|
|
|
|
|
|
}, |
|
213
|
|
|
|
|
|
|
{ |
|
214
|
|
|
|
|
|
|
method_name => '_esc_quote', |
|
215
|
|
|
|
|
|
|
documented => 0, |
|
216
|
|
|
|
|
|
|
description => <
|
|
217
|
|
|
|
|
|
|
Escapes quotes in string |
|
218
|
|
|
|
|
|
|
EOF |
|
219
|
|
|
|
|
|
|
body => <<'EOF', |
|
220
|
|
|
|
|
|
|
my $self = shift; |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
my @in = @_; |
|
223
|
|
|
|
|
|
|
my @el = (); |
|
224
|
|
|
|
|
|
|
foreach my $el (@in) { |
|
225
|
|
|
|
|
|
|
if ( $el =~ /^[+-]?\d+$/ ) { |
|
226
|
|
|
|
|
|
|
$el = ( int($el) ); |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
else { |
|
229
|
|
|
|
|
|
|
$el =~ s/\\/\\\\/g; |
|
230
|
|
|
|
|
|
|
$el =~ s/\n/\\n/g; |
|
231
|
|
|
|
|
|
|
$el =~ s/\r/\\r/g; |
|
232
|
|
|
|
|
|
|
$el =~ s/\t/\\t/g; |
|
233
|
|
|
|
|
|
|
$el =~ s/\f/\\f/g; |
|
234
|
|
|
|
|
|
|
$el =~ s/\a/\\a/g; |
|
235
|
|
|
|
|
|
|
$el =~ s/\e/\\e/g; |
|
236
|
|
|
|
|
|
|
$el =~ s/([\$\@\%"])/\\$1/g; |
|
237
|
|
|
|
|
|
|
$el = '"' . $el . '"'; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
push( @el, $el ); |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
if (wantarray) { |
|
242
|
|
|
|
|
|
|
return(@el); |
|
243
|
|
|
|
|
|
|
} |
|
244
|
|
|
|
|
|
|
else { |
|
245
|
|
|
|
|
|
|
return( join( ', ', @el ) ); |
|
246
|
|
|
|
|
|
|
} |
|
247
|
|
|
|
|
|
|
EOF |
|
248
|
|
|
|
|
|
|
}, |
|
249
|
|
|
|
|
|
|
{ |
|
250
|
|
|
|
|
|
|
method_name => '_get_overloaded_attribute', |
|
251
|
|
|
|
|
|
|
documented => 0, |
|
252
|
|
|
|
|
|
|
description => <
|
|
253
|
|
|
|
|
|
|
Searches superclass packages for an identically named C. If found it is returned otherwise C is returned. |
|
254
|
|
|
|
|
|
|
EOF |
|
255
|
|
|
|
|
|
|
body => <<'EOF', |
|
256
|
|
|
|
|
|
|
my $self = shift; |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# No attribute found if no collection defined |
|
259
|
|
|
|
|
|
|
defined( $self->get_perl_bean() ) || return(undef); |
|
260
|
|
|
|
|
|
|
defined( $self->get_perl_bean()->get_collection() ) || return(undef); |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
# Look for the attribute in super classes |
|
263
|
|
|
|
|
|
|
foreach my $super_pkg ( $self->get_perl_bean()->get_base() ) { |
|
264
|
|
|
|
|
|
|
# Get the super class bean |
|
265
|
|
|
|
|
|
|
my $super_bean = ( $self->get_perl_bean()->get_collection()-> |
|
266
|
|
|
|
|
|
|
values_perl_bean($super_pkg) )[0]; |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
# If the super class bean has no bean in the collection then no |
|
269
|
|
|
|
|
|
|
# attribute is found |
|
270
|
|
|
|
|
|
|
defined($super_bean) || return(undef); |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
# See if the super class bean has an attribute |
|
273
|
|
|
|
|
|
|
my $attr_over = $super_bean->_get_overloaded_attribute( $self, { |
|
274
|
|
|
|
|
|
|
$self->get_perl_bean()->get_package() => 1, |
|
275
|
|
|
|
|
|
|
} ); |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
# Return the overloaded bean if found |
|
278
|
|
|
|
|
|
|
defined($attr_over) && return($attr_over); |
|
279
|
|
|
|
|
|
|
} |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
# Nothing found |
|
282
|
|
|
|
|
|
|
return(undef); |
|
283
|
|
|
|
|
|
|
EOF |
|
284
|
|
|
|
|
|
|
}, |
|
285
|
|
|
|
|
|
|
{ |
|
286
|
|
|
|
|
|
|
method_name => 'type', |
|
287
|
|
|
|
|
|
|
description => <
|
|
288
|
|
|
|
|
|
|
Determines and returns the type of the attribute. The type is either C, C or C. |
|
289
|
|
|
|
|
|
|
EOF |
|
290
|
|
|
|
|
|
|
body => <<'EOF', |
|
291
|
|
|
|
|
|
|
my $self = shift; |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
$self->isa('PerlBean::Attribute::Boolean') && return('BOOLEAN'); |
|
294
|
|
|
|
|
|
|
$self->isa('PerlBean::Attribute::Multi') && return('MULTI'); |
|
295
|
|
|
|
|
|
|
$self->isa('PerlBean::Attribute::Single') && return('SINGLE'); |
|
296
|
|
|
|
|
|
|
EOF |
|
297
|
|
|
|
|
|
|
}, |
|
298
|
|
|
|
|
|
|
{ |
|
299
|
|
|
|
|
|
|
method_name => 'mk_doc_clauses', |
|
300
|
|
|
|
|
|
|
description => <
|
|
301
|
|
|
|
|
|
|
Returns a string containing the documentation for the clauses to which the contents the contents of the attribute must adhere. |
|
302
|
|
|
|
|
|
|
EOF |
|
303
|
|
|
|
|
|
|
body => <<'THE_EOF', |
|
304
|
|
|
|
|
|
|
my $self = shift; |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
return('') if ( ! scalar( $self->values_allow_isa() ) && |
|
307
|
|
|
|
|
|
|
! scalar( $self->values_allow_ref() ) && |
|
308
|
|
|
|
|
|
|
! scalar( $self->values_allow_rx() ) && |
|
309
|
|
|
|
|
|
|
! scalar( $self->values_allow_value() ) |
|
310
|
|
|
|
|
|
|
); |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
# Make the clauses for documentation |
|
313
|
|
|
|
|
|
|
my $doc = <
|
|
314
|
|
|
|
|
|
|
\=over |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
EOF |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
$doc .= $self->mk_doc_clauses_allow_isa(@_); |
|
319
|
|
|
|
|
|
|
$doc .= $self->mk_doc_clauses_allow_ref(@_); |
|
320
|
|
|
|
|
|
|
$doc .= $self->mk_doc_clauses_allow_rx(@_); |
|
321
|
|
|
|
|
|
|
$doc .= $self->mk_doc_clauses_allow_value(@_); |
|
322
|
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
$doc .= <
|
|
324
|
|
|
|
|
|
|
\=back |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
EOF |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
# Return the clauses for documentation |
|
329
|
|
|
|
|
|
|
return($doc); |
|
330
|
|
|
|
|
|
|
THE_EOF |
|
331
|
|
|
|
|
|
|
}, |
|
332
|
|
|
|
|
|
|
], |
|
333
|
|
|
|
|
|
|
sym_opt => [ |
|
334
|
|
|
|
|
|
|
{ |
|
335
|
|
|
|
|
|
|
symbol_name => '$LEGACY_COUNT', |
|
336
|
|
|
|
|
|
|
comment => <
|
|
337
|
|
|
|
|
|
|
# Legacy count variable |
|
338
|
|
|
|
|
|
|
EOF |
|
339
|
|
|
|
|
|
|
assignment => "0;\n", |
|
340
|
|
|
|
|
|
|
}, |
|
341
|
|
|
|
|
|
|
], |
|
342
|
|
|
|
|
|
|
use_opt => [ |
|
343
|
|
|
|
|
|
|
{ |
|
344
|
|
|
|
|
|
|
dependency_name => 'PerlBean::Style', |
|
345
|
|
|
|
|
|
|
import_list => [ 'qw(:codegen)' ], |
|
346
|
|
|
|
|
|
|
}, |
|
347
|
|
|
|
|
|
|
], |
|
348
|
|
|
|
|
|
|
} ); |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
1; |