| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Class::MakeMethods::Template::Array; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
32106
|
use Class::MakeMethods::Template::Generic '-isasubclass'; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
51
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$VERSION = 1.008; |
|
6
|
3
|
|
|
3
|
|
2608
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
150
|
|
|
7
|
|
|
|
|
|
|
require 5.00; |
|
8
|
3
|
|
|
3
|
|
15
|
use Carp; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
253
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Class::MakeMethods::Template::Array - Methods for manipulating positional values in arrays |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
19
|
use vars qw( %ClassInfo ); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
1064
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub generic { |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
|
|
|
|
|
|
'params' => { |
|
26
|
|
|
|
|
|
|
'array_index' => undef, |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
'code_expr' => { |
|
29
|
|
|
|
|
|
|
_VALUE_ => '_SELF_->[_STATIC_ATTR_{array_index}]', |
|
30
|
|
|
|
|
|
|
'-import' => { 'Template::Generic:generic' => '*' }, |
|
31
|
|
|
|
|
|
|
_EMPTY_NEW_INSTANCE_ => 'bless [], _SELF_CLASS_', |
|
32
|
|
|
|
|
|
|
_SET_VALUES_FROM_HASH_ => 'while ( scalar @_ ) { local $_ = shift(); $self->[ _BFP_FROM_NAME_{ $_ } ] = shift() }' |
|
33
|
|
|
|
|
|
|
}, |
|
34
|
|
|
|
|
|
|
'behavior' => { |
|
35
|
|
|
|
|
|
|
'-init' => sub { |
|
36
|
15
|
|
|
15
|
|
27
|
my $m_info = $_[0]; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# If we're the first one, |
|
39
|
15
|
100
|
|
|
|
44
|
if ( ! $ClassInfo{$m_info->{target_class}} ) { |
|
40
|
|
|
|
|
|
|
# traverse inheritance hierarchy, looking for fields to inherit |
|
41
|
3
|
|
|
|
|
5
|
my @results; |
|
42
|
3
|
|
|
3
|
|
20
|
no strict 'refs'; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
1771
|
|
|
43
|
3
|
|
|
|
|
5
|
my @sources = @{"$m_info->{target_class}\::ISA"}; |
|
|
3
|
|
|
|
|
24
|
|
|
44
|
3
|
|
|
|
|
13
|
while ( my $class = shift @sources ) { |
|
45
|
0
|
0
|
|
|
|
0
|
next unless exists $ClassInfo{ $class }; |
|
46
|
0
|
|
|
|
|
0
|
push @sources, @{"$class\::ISA"}; |
|
|
0
|
|
|
|
|
0
|
|
|
47
|
0
|
0
|
|
|
|
0
|
if ( scalar @results ) { |
|
48
|
0
|
|
|
|
|
0
|
Carp::croak "Too many inheritances of fields"; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
|
|
|
|
0
|
push @results, @{$ClassInfo{$class}}; |
|
|
0
|
|
|
|
|
0
|
|
|
51
|
|
|
|
|
|
|
} |
|
52
|
3
|
|
|
|
|
12
|
$ClassInfo{$m_info->{target_class}} = \@sources; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
15
|
|
|
|
|
32
|
my $class_info = $ClassInfo{$m_info->{target_class}}; |
|
56
|
15
|
50
|
|
|
|
45
|
if ( ! defined $m_info->{array_index} ) { |
|
57
|
15
|
|
|
|
|
40
|
foreach ( 0..$#$class_info ) { |
|
58
|
33
|
50
|
|
|
|
92
|
if ( $class_info->[$_] eq $m_info->{'name'} ) { |
|
59
|
0
|
|
|
|
|
0
|
$m_info->{array_index} = $_; last } |
|
|
0
|
|
|
|
|
0
|
|
|
60
|
|
|
|
|
|
|
} |
|
61
|
15
|
50
|
|
|
|
54
|
if ( ! defined $m_info->{array_index} ) { |
|
62
|
15
|
|
|
|
|
221
|
push @ $class_info, $m_info->{'name'}; |
|
63
|
15
|
|
|
|
|
32
|
$m_info->{array_index} = $#$class_info; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
15
|
|
|
|
|
53
|
return; |
|
68
|
|
|
|
|
|
|
}, |
|
69
|
|
|
|
|
|
|
}, |
|
70
|
|
|
|
|
|
|
} |
|
71
|
3
|
|
|
3
|
0
|
90
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
######################################################################## |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 Standard Methods |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The following methods from Generic should be supported: |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
scalar |
|
80
|
|
|
|
|
|
|
string |
|
81
|
|
|
|
|
|
|
number |
|
82
|
|
|
|
|
|
|
boolean |
|
83
|
|
|
|
|
|
|
bits (?) |
|
84
|
|
|
|
|
|
|
array |
|
85
|
|
|
|
|
|
|
hash |
|
86
|
|
|
|
|
|
|
tiedhash (?) |
|
87
|
|
|
|
|
|
|
hash_of_arrays (?) |
|
88
|
|
|
|
|
|
|
object |
|
89
|
|
|
|
|
|
|
instance |
|
90
|
|
|
|
|
|
|
array_of_objects (?) |
|
91
|
|
|
|
|
|
|
code |
|
92
|
|
|
|
|
|
|
code_or_scalar (?) |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
See L for the interfaces and behaviors of these method types. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The items marked with a ? above have not been tested sufficiently; please inform the author if they do not function as you would expect. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
######################################################################## |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |