line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graph::Attribute; |
2
|
|
|
|
|
|
|
|
3
|
82
|
|
|
82
|
|
120948
|
use strict; |
|
82
|
|
|
|
|
173
|
|
|
82
|
|
|
|
|
2441
|
|
4
|
82
|
|
|
82
|
|
657
|
use warnings; |
|
82
|
|
|
|
|
730
|
|
|
82
|
|
|
|
|
7333
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my @API = qw(get_attribute |
7
|
|
|
|
|
|
|
get_attributes |
8
|
|
|
|
|
|
|
set_attribute |
9
|
|
|
|
|
|
|
set_attributes |
10
|
|
|
|
|
|
|
has_attribute |
11
|
|
|
|
|
|
|
has_attributes |
12
|
|
|
|
|
|
|
delete_attribute |
13
|
|
|
|
|
|
|
delete_attributes |
14
|
|
|
|
|
|
|
get_attribute_names |
15
|
|
|
|
|
|
|
get_attribute_values); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
82
|
|
|
82
|
|
1608
|
my $package = shift; |
19
|
82
|
|
|
|
|
307
|
my %attr = @_; |
20
|
82
|
|
|
|
|
2901
|
my $caller = caller(0); |
21
|
82
|
100
|
|
|
|
1626
|
if (exists $attr{array}) { |
|
|
50
|
|
|
|
|
|
22
|
81
|
|
|
|
|
145
|
my $i = $attr{array}; |
23
|
82
|
|
|
82
|
|
551
|
no strict 'refs'; |
|
82
|
|
|
|
|
168
|
|
|
82
|
|
|
|
|
17555
|
|
24
|
81
|
|
|
15463
|
|
274
|
*{"${caller}::_g_get_attributes"} = sub { $_[0]->[ $i ] }; |
|
81
|
|
|
|
|
410
|
|
|
15463
|
|
|
|
|
20556
|
|
25
|
81
|
|
|
|
|
253
|
*{"${caller}::_g_set_attributes"} = |
26
|
587
|
|
100
|
587
|
|
2453
|
sub { $_[0]->[ $i ] ||= { }; |
27
|
587
|
100
|
|
|
|
1536
|
$_[0]->[ $i ] = $_[1] if @_ == 2; |
28
|
81
|
|
|
|
|
254
|
$_[0]->[ $i ] }; |
|
587
|
|
|
|
|
1109
|
|
29
|
81
|
|
|
5
|
|
195
|
*{"${caller}::_g_has_attributes"} = sub { defined $_[0]->[ $i ] }; |
|
81
|
|
|
2
|
|
243
|
|
|
5
|
|
|
|
|
104
|
|
30
|
81
|
|
|
2
|
|
224
|
*{"${caller}::_g_delete_attributes"} = sub { undef $_[0]->[ $i ]; 1 }; |
|
81
|
|
|
|
|
282
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
5
|
|
31
|
|
|
|
|
|
|
} elsif (exists $attr{hash}) { |
32
|
1
|
|
|
|
|
2
|
my $k = $attr{hash}; |
33
|
82
|
|
|
82
|
|
534
|
no strict 'refs'; |
|
82
|
|
|
|
|
154
|
|
|
82
|
|
|
|
|
24767
|
|
34
|
1
|
|
|
3
|
|
3
|
*{"${caller}::_g_get_attributes"} = sub { $_[0]->{ $k } }; |
|
1
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
15
|
|
35
|
1
|
|
|
|
|
3
|
*{"${caller}::_g_set_attributes"} = |
36
|
1
|
|
50
|
1
|
|
8
|
sub { $_[0]->{ $k } ||= { }; |
37
|
1
|
50
|
|
|
|
4
|
$_[0]->{ $k } = $_[1] if @_ == 2; |
38
|
1
|
|
|
|
|
3
|
$_[0]->{ $k } }; |
|
1
|
|
|
|
|
16
|
|
39
|
1
|
|
|
3
|
|
3
|
*{"${caller}::_g_has_attributes"} = sub { defined $_[0]->{ $k } }; |
|
1
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
103
|
|
40
|
1
|
|
|
1
|
|
3
|
*{"${caller}::_g_delete_attributes"} = sub { delete $_[0]->{ $k } }; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
41
|
|
|
|
|
|
|
} else { |
42
|
|
|
|
|
|
|
# uncoverable statement |
43
|
0
|
|
|
|
|
0
|
die "Graph::Attribute::import($package @_) caller $caller\n"; |
44
|
|
|
|
|
|
|
} |
45
|
82
|
100
|
|
|
|
1697
|
if (exists $attr{map}) { |
46
|
80
|
|
|
|
|
146
|
my $map = $attr{map}; |
47
|
80
|
|
|
|
|
1555
|
for my $api (@API) { |
48
|
800
|
|
|
|
|
2878
|
my ($first, $rest) = ($api =~ /^(\w+?)_(.+)/); |
49
|
82
|
|
|
82
|
|
540
|
no strict 'refs'; |
|
82
|
|
|
|
|
137
|
|
|
82
|
|
|
|
|
37904
|
|
50
|
800
|
|
|
|
|
1599
|
*{"${caller}::${first}_${map}_${rest}"} = \&$api; |
|
800
|
|
|
|
|
25845
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub set_attribute { |
56
|
585
|
|
|
585
|
0
|
1957
|
my $g = shift; |
57
|
585
|
|
|
|
|
860
|
my $v = pop; |
58
|
585
|
|
|
|
|
902
|
my $a = pop; |
59
|
585
|
|
|
|
|
1740
|
my $p = $g->_g_set_attributes; |
60
|
585
|
|
|
|
|
1450
|
$p->{ $a } = $v; |
61
|
585
|
|
|
|
|
1499
|
return 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub set_attributes { |
65
|
1
|
|
|
1
|
0
|
3
|
my $g = shift; |
66
|
1
|
|
|
|
|
2
|
my $a = pop; |
67
|
1
|
|
|
|
|
4
|
my $p = $g->_g_set_attributes( $a ); |
68
|
1
|
|
|
|
|
3
|
return 1; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub has_attribute { |
72
|
3
|
|
|
3
|
0
|
331
|
my $g = shift; |
73
|
3
|
|
|
|
|
5
|
my $a = pop; |
74
|
3
|
|
|
|
|
7
|
my $p = $g->_g_get_attributes; |
75
|
3
|
50
|
|
|
|
14
|
$p ? exists $p->{ $a } : 0; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub has_attributes { |
79
|
10
|
|
|
10
|
0
|
1725
|
my $g = shift; |
80
|
10
|
100
|
|
|
|
23
|
$g->_g_get_attributes ? 1 : 0; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_attribute { |
84
|
15207
|
|
|
15207
|
0
|
26214
|
my $g = shift; |
85
|
15207
|
|
|
|
|
15930
|
my $a = pop; |
86
|
15207
|
|
|
|
|
19690
|
my $p = $g->_g_get_attributes; |
87
|
15207
|
100
|
|
|
|
40998
|
$p ? $p->{ $a } : undef; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub delete_attribute { |
91
|
230
|
|
|
230
|
0
|
483
|
my $g = shift; |
92
|
230
|
|
|
|
|
410
|
my $a = pop; |
93
|
230
|
100
|
|
|
|
729
|
return 0 unless defined(my $p = $g->_g_get_attributes); |
94
|
229
|
|
|
|
|
13610
|
delete $p->{ $a }; |
95
|
229
|
|
|
|
|
1059
|
return 1; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub delete_attributes { |
99
|
2
|
|
|
2
|
0
|
6
|
my $g = shift; |
100
|
2
|
100
|
|
|
|
7
|
return 0 if !$g->_g_has_attributes; |
101
|
1
|
|
|
|
|
4
|
$g->_g_delete_attributes; |
102
|
1
|
|
|
|
|
3
|
return 1; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub get_attribute_names { |
106
|
3
|
|
|
3
|
0
|
7
|
my $g = shift; |
107
|
3
|
|
|
|
|
7
|
my $p = $g->_g_get_attributes; |
108
|
3
|
100
|
|
|
|
11
|
defined $p ? keys %{ $p } : ( ); |
|
2
|
|
|
|
|
13
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub get_attribute_values { |
112
|
3
|
|
|
3
|
0
|
6
|
my $g = shift; |
113
|
3
|
|
|
|
|
8
|
my $p = $g->_g_get_attributes; |
114
|
3
|
100
|
|
|
|
10
|
defined $p ? values %{ $p } : ( ); |
|
2
|
|
|
|
|
12
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub get_attributes { |
118
|
4
|
|
|
4
|
0
|
545
|
$_[0]->_g_get_attributes; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |