line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::ClassData; |
2
|
|
|
|
|
|
|
|
3
|
172
|
|
|
172
|
|
106901
|
use Moose::Role; |
|
172
|
|
|
|
|
5943
|
|
|
172
|
|
|
|
|
1888
|
|
4
|
172
|
|
|
172
|
|
988873
|
use Moose::Meta::Class (); |
|
172
|
|
|
|
|
540
|
|
|
172
|
|
|
|
|
3972
|
|
5
|
172
|
|
|
172
|
|
1092
|
use Class::MOP; |
|
172
|
|
|
|
|
540
|
|
|
172
|
|
|
|
|
4451
|
|
6
|
172
|
|
|
172
|
|
1067
|
use Moose::Util (); |
|
172
|
|
|
|
|
494
|
|
|
172
|
|
|
|
|
30506
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub mk_classdata { |
9
|
5219
|
|
|
5219
|
1
|
777183
|
my ($class, $attribute, $warn_on_instance) = @_; |
10
|
5219
|
50
|
|
|
|
13930
|
confess("mk_classdata() is a class method, not an object method") |
11
|
|
|
|
|
|
|
if blessed $class; |
12
|
|
|
|
|
|
|
|
13
|
5219
|
|
|
|
|
11007
|
my $slot = '$'.$attribute; |
14
|
|
|
|
|
|
|
my $accessor = sub { |
15
|
341878
|
|
66
|
341878
|
|
1229619
|
my $pkg = ref $_[0] || $_[0]; |
|
|
|
|
341822
|
|
|
|
|
|
|
|
341822
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341825
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341822
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341825
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
341806
|
|
|
|
|
|
|
|
302947
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
53
|
|
|
|
16
|
341878
|
|
66
|
|
|
879248
|
my $meta = Moose::Util::find_meta($pkg) |
17
|
|
|
|
|
|
|
|| Moose::Meta::Class->initialize( $pkg ); |
18
|
341878
|
100
|
|
|
|
5296112
|
if (@_ > 1) { |
19
|
11487
|
|
|
|
|
44514
|
$meta->namespace->{$attribute} = \$_[1]; |
20
|
11487
|
|
|
|
|
97917
|
return $_[1]; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# tighter version of |
24
|
|
|
|
|
|
|
# if ( $meta->has_package_symbol($slot) ) { |
25
|
|
|
|
|
|
|
# return ${ $meta->get_package_symbol($slot) }; |
26
|
|
|
|
|
|
|
# } |
27
|
172
|
|
|
172
|
|
1561
|
no strict 'refs'; |
|
172
|
|
|
|
|
544
|
|
|
172
|
|
|
|
|
61645
|
|
28
|
330391
|
|
|
|
|
488776
|
my $v = *{"${pkg}::${attribute}"}{SCALAR}; |
|
330391
|
|
|
|
|
1221830
|
|
29
|
330391
|
100
|
|
|
|
518463
|
if (defined ${$v}) { |
|
330391
|
|
|
|
|
703112
|
|
30
|
239108
|
|
|
|
|
339657
|
return ${$v}; |
|
239108
|
|
|
|
|
1147099
|
|
31
|
|
|
|
|
|
|
} else { |
32
|
91283
|
|
|
|
|
313507
|
foreach my $super ( $meta->linearized_isa ) { |
33
|
|
|
|
|
|
|
# tighter version of same after |
34
|
|
|
|
|
|
|
# my $super_meta = Moose::Meta::Class->initialize($super); |
35
|
267921
|
100
|
|
|
|
1121201
|
my $v = ${"${super}::"}{$attribute} ? *{"${super}::${attribute}"}{SCALAR} : undef; |
|
267921
|
|
|
|
|
839679
|
|
|
210674
|
|
|
|
|
535804
|
|
36
|
267921
|
100
|
|
|
|
365845
|
if (defined ${$v}) { |
|
267921
|
|
|
|
|
582904
|
|
37
|
83889
|
|
|
|
|
127493
|
return ${$v}; |
|
83889
|
|
|
|
|
351175
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
7394
|
|
|
|
|
45565
|
return; |
42
|
5219
|
|
|
|
|
31218
|
}; |
43
|
|
|
|
|
|
|
|
44
|
5219
|
50
|
|
|
|
15739
|
confess("Failed to create accessor: $@ ") |
45
|
|
|
|
|
|
|
unless ref $accessor eq 'CODE'; |
46
|
|
|
|
|
|
|
|
47
|
5219
|
|
|
|
|
17674
|
my $meta = $class->Class::MOP::Object::meta(); |
48
|
5219
|
50
|
|
|
|
100375
|
confess "${class}'s metaclass is not a Class::MOP::Class" |
49
|
|
|
|
|
|
|
unless $meta->isa('Class::MOP::Class'); |
50
|
|
|
|
|
|
|
|
51
|
5219
|
|
|
|
|
13868
|
my $was_immutable = $meta->is_immutable; |
52
|
5219
|
|
|
|
|
21192
|
my %immutable_options = $meta->immutable_options; |
53
|
|
|
|
|
|
|
|
54
|
5219
|
50
|
|
|
|
38221
|
$meta->make_mutable if $was_immutable; |
55
|
|
|
|
|
|
|
|
56
|
5219
|
|
|
|
|
11540
|
my $alias = "_${attribute}_accessor"; |
57
|
5219
|
|
|
|
|
15281
|
$meta->add_method($alias, $accessor); |
58
|
5219
|
|
|
|
|
252052
|
$meta->add_method($attribute, $accessor); |
59
|
|
|
|
|
|
|
|
60
|
5219
|
50
|
|
|
|
185588
|
$meta->make_immutable(%immutable_options) if $was_immutable; |
61
|
|
|
|
|
|
|
|
62
|
5219
|
100
|
|
|
|
12513
|
$class->$attribute($_[2]) if(@_ > 2); |
63
|
5219
|
|
|
|
|
19363
|
return $accessor; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Catalyst::ClassData - Class data accessors |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 METHODS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 mk_classdata $name, $optional_value |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
A moose-safe clone of L<Class::Data::Inheritable> that borrows some ideas from |
80
|
|
|
|
|
|
|
L<Class::Accessor::Grouped>; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=begin stopwords |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Guillermo Roditi |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=end stopwords |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 COPYRIGHT |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify it under |
93
|
|
|
|
|
|
|
the same terms as Perl itself. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |