line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Harness::Util::HashBase; |
2
|
7
|
|
|
7
|
|
121667
|
use strict; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
168
|
|
3
|
7
|
|
|
7
|
|
30
|
use warnings; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
173
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
################################################################# |
6
|
|
|
|
|
|
|
# # |
7
|
|
|
|
|
|
|
# This is a generated file! Do not modify this file directly! # |
8
|
|
|
|
|
|
|
# Use hashbase_inc.pl script to regenerate this file. # |
9
|
|
|
|
|
|
|
# The script is part of the Object::HashBase distribution. # |
10
|
|
|
|
|
|
|
# # |
11
|
|
|
|
|
|
|
################################################################# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
7
|
|
|
7
|
|
29
|
no warnings 'once'; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
560
|
|
15
|
|
|
|
|
|
|
$Test2::Harness::Util::HashBase::VERSION = '0.005'; |
16
|
|
|
|
|
|
|
*Test2::Harness::Util::HashBase::ATTR_SUBS = \%Object::HashBase::ATTR_SUBS; |
17
|
|
|
|
|
|
|
*Test2::Harness::Util::HashBase::ATTR_LIST = \%Object::HashBase::ATTR_LIST; |
18
|
|
|
|
|
|
|
*Test2::Harness::Util::HashBase::VERSION = \%Object::HashBase::VERSION; |
19
|
|
|
|
|
|
|
*Test2::Harness::Util::HashBase::CAN_CACHE = \%Object::HashBase::CAN_CACHE; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
require Carp; |
24
|
|
|
|
|
|
|
{ |
25
|
7
|
|
|
7
|
|
41
|
no warnings 'once'; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
405
|
|
26
|
|
|
|
|
|
|
$Carp::Internal{+__PACKAGE__} = 1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
BEGIN { |
30
|
|
|
|
|
|
|
# these are not strictly equivalent, but for out use we don't care |
31
|
|
|
|
|
|
|
# about order |
32
|
|
|
|
|
|
|
*_isa = ($] >= 5.010 && require mro) ? \&mro::get_linear_isa : sub { |
33
|
7
|
|
|
7
|
|
35
|
no strict 'refs'; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
601
|
|
34
|
0
|
|
|
|
|
0
|
my @packages = ($_[0]); |
35
|
0
|
|
|
|
|
0
|
my %seen; |
36
|
0
|
|
|
|
|
0
|
for my $package (@packages) { |
37
|
0
|
|
|
|
|
0
|
push @packages, grep !$seen{$_}++, @{"$package\::ISA"}; |
|
0
|
|
|
|
|
0
|
|
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
0
|
return \@packages; |
40
|
|
|
|
|
|
|
} |
41
|
7
|
50
|
33
|
7
|
|
2141
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my %STRIP = ( |
44
|
|
|
|
|
|
|
'^' => 1, |
45
|
|
|
|
|
|
|
'-' => 1, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub import { |
49
|
28
|
|
|
28
|
|
11902
|
my $class = shift; |
50
|
28
|
|
|
|
|
55
|
my $into = caller; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Make sure we list the OLDEST version used to create this class. |
53
|
|
|
|
|
|
|
$Test2::Harness::Util::HashBase::VERSION{$into} = $Test2::Harness::Util::HashBase::VERSION |
54
|
|
|
|
|
|
|
if !$Test2::Harness::Util::HashBase::VERSION{$into} |
55
|
28
|
50
|
33
|
|
|
128
|
|| $Test2::Harness::Util::HashBase::VERSION{$into} > $Test2::Harness::Util::HashBase::VERSION; |
56
|
|
|
|
|
|
|
|
57
|
28
|
|
|
|
|
113
|
my $isa = _isa($into); |
58
|
28
|
|
50
|
|
|
132
|
my $attr_list = $Test2::Harness::Util::HashBase::ATTR_LIST{$into} ||= []; |
59
|
28
|
|
50
|
|
|
94
|
my $attr_subs = $Test2::Harness::Util::HashBase::ATTR_SUBS{$into} ||= {}; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my %subs = ( |
62
|
|
|
|
|
|
|
($into->can('new') ? () : (new => \&_new)), |
63
|
10
|
50
|
|
|
|
54
|
(map %{$Test2::Harness::Util::HashBase::ATTR_SUBS{$_} || {}}, @{$isa}[1 .. $#$isa]), |
|
28
|
|
|
|
|
70
|
|
64
|
|
|
|
|
|
|
( |
65
|
|
|
|
|
|
|
map { |
66
|
28
|
100
|
|
|
|
228
|
my $p = substr($_, 0, 1); |
|
66
|
|
|
|
|
133
|
|
67
|
66
|
|
|
|
|
87
|
my $x = $_; |
68
|
66
|
100
|
|
|
|
139
|
substr($x, 0, 1) = '' if $STRIP{$p}; |
69
|
66
|
|
|
|
|
112
|
push @$attr_list => $x; |
70
|
66
|
|
|
|
|
126
|
my ($sub, $attr) = (uc $x, $x); |
71
|
0
|
|
|
0
|
|
0
|
$sub => ($attr_subs->{$sub} = sub() { $attr }), |
72
|
35
|
|
|
35
|
|
180
|
$attr => sub { $_[0]->{$attr} }, |
73
|
2
|
|
|
2
|
|
242
|
$p eq '-' ? ("set_$attr" => sub { Carp::croak("'$attr' is read-only") }) |
74
|
2
|
|
|
2
|
|
1174
|
: $p eq '^' ? ("set_$attr" => sub { Carp::carp("set_$attr() is deprecated"); $_[0]->{$attr} = $_[1] }) |
|
2
|
|
|
|
|
76
|
|
75
|
66
|
100
|
|
18
|
|
758
|
: ("set_$attr" => sub { $_[0]->{$attr} = $_[1] }), |
|
18
|
100
|
|
|
|
89
|
|
76
|
|
|
|
|
|
|
} @_ |
77
|
|
|
|
|
|
|
), |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
7
|
|
|
7
|
|
45
|
no strict 'refs'; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
2363
|
|
81
|
28
|
|
|
|
|
121
|
*{"$into\::$_"} = $subs{$_} for keys %subs; |
|
251
|
|
|
|
|
5011
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub attr_list { |
85
|
6
|
|
|
6
|
1
|
1773
|
my $class = shift; |
86
|
|
|
|
|
|
|
|
87
|
6
|
|
|
|
|
21
|
my $isa = _isa($class); |
88
|
|
|
|
|
|
|
|
89
|
6
|
|
|
|
|
8
|
my %seen; |
90
|
30
|
|
|
|
|
61
|
my @list = grep { !$seen{$_}++ } map { |
91
|
6
|
|
|
|
|
14
|
my @out; |
|
12
|
|
|
|
|
15
|
|
92
|
|
|
|
|
|
|
|
93
|
12
|
50
|
50
|
|
|
37
|
if (0.004 > ($Test2::Harness::Util::HashBase::VERSION{$_} || 0)) { |
94
|
0
|
|
|
|
|
0
|
Carp::carp("$_ uses an inlined version of Test2::Harness::Util::HashBase too old to support attr_list()"); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
else { |
97
|
12
|
|
|
|
|
18
|
my $list = $Test2::Harness::Util::HashBase::ATTR_LIST{$_}; |
98
|
12
|
50
|
|
|
|
28
|
@out = $list ? @$list : () |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
12
|
|
|
|
|
30
|
@out; |
102
|
|
|
|
|
|
|
} reverse @$isa; |
103
|
|
|
|
|
|
|
|
104
|
6
|
|
|
|
|
26
|
return @list; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _new { |
108
|
30
|
|
|
30
|
|
9685
|
my $class = shift; |
109
|
|
|
|
|
|
|
|
110
|
30
|
|
|
|
|
46
|
my $self; |
111
|
|
|
|
|
|
|
|
112
|
30
|
100
|
|
|
|
76
|
if (@_ == 1) { |
113
|
6
|
|
|
|
|
11
|
my $arg = shift; |
114
|
6
|
|
|
|
|
10
|
my $type = ref($arg); |
115
|
|
|
|
|
|
|
|
116
|
6
|
100
|
|
|
|
17
|
if ($type eq 'HASH') { |
117
|
2
|
|
|
|
|
8
|
$self = bless({%$arg}, $class) |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
else { |
120
|
4
|
50
|
|
|
|
12
|
Carp::croak("Not sure what to do with '$type' in $class constructor") |
121
|
|
|
|
|
|
|
unless $type eq 'ARRAY'; |
122
|
|
|
|
|
|
|
|
123
|
4
|
|
|
|
|
6
|
my %proto; |
124
|
4
|
|
|
|
|
10
|
my @attributes = attr_list($class); |
125
|
4
|
|
|
|
|
11
|
while (@$arg) { |
126
|
18
|
|
|
|
|
23
|
my $val = shift @$arg; |
127
|
18
|
100
|
|
|
|
189
|
my $key = shift @attributes or Carp::croak("Too many arguments for $class constructor"); |
128
|
16
|
|
|
|
|
33
|
$proto{$key} = $val; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
2
|
|
|
|
|
5
|
$self = bless(\%proto, $class); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
else { |
135
|
24
|
|
|
|
|
67
|
$self = bless({@_}, $class); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
$Test2::Harness::Util::HashBase::CAN_CACHE{$class} = $self->can('init') |
139
|
28
|
100
|
|
|
|
132
|
unless exists $Test2::Harness::Util::HashBase::CAN_CACHE{$class}; |
140
|
|
|
|
|
|
|
|
141
|
28
|
100
|
|
|
|
125
|
$self->init if $Test2::Harness::Util::HashBase::CAN_CACHE{$class}; |
142
|
|
|
|
|
|
|
|
143
|
27
|
|
|
|
|
89
|
$self; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
__END__ |