line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graph::Attribute; |
2
|
|
|
|
|
|
|
|
3
|
82
|
|
|
82
|
|
138019
|
use strict; |
|
82
|
|
|
|
|
186
|
|
|
82
|
|
|
|
|
2444
|
|
4
|
82
|
|
|
82
|
|
710
|
use warnings; |
|
82
|
|
|
|
|
693
|
|
|
82
|
|
|
|
|
7886
|
|
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
|
|
228
|
my $package = shift; |
19
|
82
|
|
|
|
|
3953
|
my %attr = @_; |
20
|
82
|
|
|
|
|
2072
|
my $caller = caller(0); |
21
|
82
|
100
|
|
|
|
303
|
if (exists $attr{array}) { |
|
|
50
|
|
|
|
|
|
22
|
81
|
|
|
|
|
1911
|
my $i = $attr{array}; |
23
|
82
|
|
|
82
|
|
663
|
no strict 'refs'; |
|
82
|
|
|
|
|
176
|
|
|
82
|
|
|
|
|
19219
|
|
24
|
81
|
|
|
15430
|
|
334
|
*{"${caller}::_g_get_attributes"} = sub { $_[0]->[ $i ] }; |
|
81
|
|
|
|
|
475
|
|
|
15430
|
|
|
|
|
22354
|
|
25
|
81
|
|
|
|
|
303
|
*{"${caller}::_g_set_attributes"} = |
26
|
587
|
|
100
|
587
|
|
2283
|
sub { $_[0]->[ $i ] ||= { }; |
27
|
587
|
100
|
|
|
|
1341
|
$_[0]->[ $i ] = $_[1] if @_ == 2; |
28
|
81
|
|
|
|
|
331
|
$_[0]->[ $i ] }; |
|
587
|
|
|
|
|
1031
|
|
29
|
81
|
|
|
5
|
|
220
|
*{"${caller}::_g_has_attributes"} = sub { defined $_[0]->[ $i ] }; |
|
81
|
|
|
2
|
|
287
|
|
|
5
|
|
|
|
|
139
|
|
30
|
81
|
|
|
2
|
|
273
|
*{"${caller}::_g_delete_attributes"} = sub { undef $_[0]->[ $i ]; 1 }; |
|
81
|
|
|
|
|
328
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
6
|
|
31
|
|
|
|
|
|
|
} elsif (exists $attr{hash}) { |
32
|
1
|
|
|
|
|
2
|
my $k = $attr{hash}; |
33
|
82
|
|
|
82
|
|
619
|
no strict 'refs'; |
|
82
|
|
|
|
|
164
|
|
|
82
|
|
|
|
|
28095
|
|
34
|
1
|
|
|
3
|
|
3
|
*{"${caller}::_g_get_attributes"} = sub { $_[0]->{ $k } }; |
|
1
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
19
|
|
35
|
1
|
|
|
|
|
4
|
*{"${caller}::_g_set_attributes"} = |
36
|
1
|
|
50
|
1
|
|
12
|
sub { $_[0]->{ $k } ||= { }; |
37
|
1
|
50
|
|
|
|
6
|
$_[0]->{ $k } = $_[1] if @_ == 2; |
38
|
1
|
|
|
|
|
3
|
$_[0]->{ $k } }; |
|
1
|
|
|
|
|
18
|
|
39
|
1
|
|
|
3
|
|
3
|
*{"${caller}::_g_has_attributes"} = sub { defined $_[0]->{ $k } }; |
|
1
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
105
|
|
40
|
1
|
|
|
1
|
|
3
|
*{"${caller}::_g_delete_attributes"} = sub { delete $_[0]->{ $k } }; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
5
|
|
41
|
|
|
|
|
|
|
} else { |
42
|
|
|
|
|
|
|
# uncoverable statement |
43
|
0
|
|
|
|
|
0
|
die "Graph::Attribute::import($package @_) caller $caller\n"; |
44
|
|
|
|
|
|
|
} |
45
|
82
|
100
|
|
|
|
2005
|
if (exists $attr{map}) { |
46
|
80
|
|
|
|
|
170
|
my $map = $attr{map}; |
47
|
80
|
|
|
|
|
2053
|
for my $api (@API) { |
48
|
800
|
|
|
|
|
3627
|
my ($first, $rest) = ($api =~ /^(\w+?)_(.+)/); |
49
|
82
|
|
|
82
|
|
694
|
no strict 'refs'; |
|
82
|
|
|
|
|
178
|
|
|
82
|
|
|
|
|
43296
|
|
50
|
800
|
|
|
|
|
1659
|
*{"${caller}::${first}_${map}_${rest}"} = \&$api; |
|
800
|
|
|
|
|
29884
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub set_attribute { |
56
|
585
|
|
|
585
|
0
|
2099
|
my $g = shift; |
57
|
585
|
|
|
|
|
914
|
my $v = pop; |
58
|
585
|
|
|
|
|
913
|
my $a = pop; |
59
|
585
|
|
|
|
|
1384
|
my $p = $g->_g_set_attributes; |
60
|
585
|
|
|
|
|
1324
|
$p->{ $a } = $v; |
61
|
585
|
|
|
|
|
1562
|
return 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub set_attributes { |
65
|
1
|
|
|
1
|
0
|
4
|
my $g = shift; |
66
|
1
|
|
|
|
|
2
|
my $a = pop; |
67
|
1
|
|
|
|
|
5
|
my $p = $g->_g_set_attributes( $a ); |
68
|
1
|
|
|
|
|
4
|
return 1; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub has_attribute { |
72
|
3
|
|
|
3
|
0
|
449
|
my $g = shift; |
73
|
3
|
|
|
|
|
7
|
my $a = pop; |
74
|
3
|
|
|
|
|
9
|
my $p = $g->_g_get_attributes; |
75
|
3
|
50
|
|
|
|
17
|
$p ? exists $p->{ $a } : 0; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub has_attributes { |
79
|
10
|
|
|
10
|
0
|
1946
|
my $g = shift; |
80
|
10
|
100
|
|
|
|
23
|
$g->_g_get_attributes ? 1 : 0; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_attribute { |
84
|
15174
|
|
|
15174
|
0
|
28089
|
my $g = shift; |
85
|
15174
|
|
|
|
|
18522
|
my $a = pop; |
86
|
15174
|
|
|
|
|
22685
|
my $p = $g->_g_get_attributes; |
87
|
15174
|
100
|
|
|
|
44770
|
$p ? $p->{ $a } : undef; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub delete_attribute { |
91
|
230
|
|
|
230
|
0
|
460
|
my $g = shift; |
92
|
230
|
|
|
|
|
354
|
my $a = pop; |
93
|
230
|
100
|
|
|
|
456
|
return 0 unless defined(my $p = $g->_g_get_attributes); |
94
|
229
|
|
|
|
|
13041
|
delete $p->{ $a }; |
95
|
229
|
|
|
|
|
1084
|
return 1; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub delete_attributes { |
99
|
2
|
|
|
2
|
0
|
5
|
my $g = shift; |
100
|
2
|
100
|
|
|
|
6
|
return 0 if !$g->_g_has_attributes; |
101
|
1
|
|
|
|
|
6
|
$g->_g_delete_attributes; |
102
|
1
|
|
|
|
|
5
|
return 1; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub get_attribute_names { |
106
|
3
|
|
|
3
|
0
|
9
|
my $g = shift; |
107
|
3
|
|
|
|
|
7
|
my $p = $g->_g_get_attributes; |
108
|
3
|
100
|
|
|
|
13
|
defined $p ? keys %{ $p } : ( ); |
|
2
|
|
|
|
|
19
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub get_attribute_values { |
112
|
3
|
|
|
3
|
0
|
9
|
my $g = shift; |
113
|
3
|
|
|
|
|
9
|
my $p = $g->_g_get_attributes; |
114
|
3
|
100
|
|
|
|
13
|
defined $p ? values %{ $p } : ( ); |
|
2
|
|
|
|
|
14
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub get_attributes { |
118
|
4
|
|
|
4
|
0
|
619
|
$_[0]->_g_get_attributes; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |