line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::MOP::Class::Immutable::Trait; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2205'; |
3
|
|
|
|
|
|
|
|
4
|
450
|
|
|
450
|
|
248603
|
use strict; |
|
450
|
|
|
|
|
1135
|
|
|
450
|
|
|
|
|
14220
|
|
5
|
450
|
|
|
450
|
|
2507
|
use warnings; |
|
450
|
|
|
|
|
1938
|
|
|
450
|
|
|
|
|
11808
|
|
6
|
|
|
|
|
|
|
|
7
|
450
|
|
|
450
|
|
3368
|
use MRO::Compat; |
|
450
|
|
|
|
|
1533
|
|
|
450
|
|
|
|
|
12151
|
|
8
|
450
|
|
|
450
|
|
2974
|
use Module::Runtime 'use_module'; |
|
450
|
|
|
|
|
1112
|
|
|
450
|
|
|
|
|
4229
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# the original class of the metaclass instance |
11
|
11078
|
|
|
11078
|
|
60495
|
sub _get_mutable_metaclass_name { $_[0]{__immutable}{original_class} } |
12
|
|
|
|
|
|
|
|
13
|
17
|
|
|
17
|
|
102
|
sub is_mutable { 0 } |
14
|
11133
|
|
|
11133
|
|
46565
|
sub is_immutable { 1 } |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
38
|
sub _immutable_metaclass { ref $_[1] } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _immutable_read_only { |
19
|
6
|
|
|
6
|
|
12
|
my $name = shift; |
20
|
6
|
|
|
|
|
22
|
__throw_exception( CallingReadOnlyMethodOnAnImmutableInstance => method_name => $name ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _immutable_cannot_call { |
24
|
33
|
|
|
33
|
|
70
|
my $name = shift; |
25
|
33
|
|
|
|
|
79
|
__throw_exception( CallingMethodOnAnImmutableInstance => method_name => $name ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
for my $name (qw/superclasses/) { |
29
|
450
|
|
|
450
|
|
103279
|
no strict 'refs'; |
|
450
|
|
|
|
|
1401
|
|
|
450
|
|
|
|
|
74980
|
|
30
|
|
|
|
|
|
|
*{__PACKAGE__."::$name"} = sub { |
31
|
1127
|
|
|
1127
|
|
2463
|
my $orig = shift; |
32
|
1127
|
|
|
|
|
1925
|
my $self = shift; |
33
|
1127
|
100
|
|
|
|
3011
|
_immutable_read_only($name) if @_; |
34
|
1121
|
|
|
|
|
2939
|
$self->$orig; |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
for my $name (qw/add_method alias_method remove_method add_attribute remove_attribute remove_package_symbol add_package_symbol/) { |
39
|
450
|
|
|
450
|
|
3586
|
no strict 'refs'; |
|
450
|
|
|
|
|
6207
|
|
|
450
|
|
|
|
|
216180
|
|
40
|
32
|
|
|
32
|
|
269
|
*{__PACKAGE__."::$name"} = sub { _immutable_cannot_call($name) }; |
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub class_precedence_list { |
44
|
2571
|
|
|
2571
|
|
4913
|
my $orig = shift; |
45
|
2571
|
|
|
|
|
4530
|
my $self = shift; |
46
|
2571
|
|
|
|
|
3950
|
@{ $self->{__immutable}{class_precedence_list} |
47
|
2571
|
|
100
|
|
|
25109
|
||= [ $self->$orig ] }; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub linearized_isa { |
51
|
27965
|
|
|
27965
|
|
45391
|
my $orig = shift; |
52
|
27965
|
|
|
|
|
41393
|
my $self = shift; |
53
|
27965
|
|
100
|
|
|
43257
|
@{ $self->{__immutable}{linearized_isa} ||= [ $self->$orig ] }; |
|
27965
|
|
|
|
|
143741
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_all_methods { |
57
|
0
|
|
|
0
|
|
0
|
my $orig = shift; |
58
|
0
|
|
|
|
|
0
|
my $self = shift; |
59
|
0
|
|
0
|
|
|
0
|
@{ $self->{__immutable}{get_all_methods} ||= [ $self->$orig ] }; |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_all_method_names { |
63
|
0
|
|
|
0
|
|
0
|
my $orig = shift; |
64
|
0
|
|
|
|
|
0
|
my $self = shift; |
65
|
0
|
|
0
|
|
|
0
|
@{ $self->{__immutable}{get_all_method_names} ||= [ $self->$orig ] }; |
|
0
|
|
|
|
|
0
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub get_all_attributes { |
69
|
19161
|
|
|
19161
|
|
32759
|
my $orig = shift; |
70
|
19161
|
|
|
|
|
30383
|
my $self = shift; |
71
|
19161
|
|
100
|
|
|
30286
|
@{ $self->{__immutable}{get_all_attributes} ||= [ $self->$orig ] }; |
|
19161
|
|
|
|
|
99036
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub get_meta_instance { |
75
|
118383
|
|
|
118383
|
|
180580
|
my $orig = shift; |
76
|
118383
|
|
|
|
|
161666
|
my $self = shift; |
77
|
118383
|
|
66
|
|
|
398613
|
$self->{__immutable}{get_meta_instance} ||= $self->$orig; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _method_map { |
81
|
77091
|
|
|
77091
|
|
119976
|
my $orig = shift; |
82
|
77091
|
|
|
|
|
111549
|
my $self = shift; |
83
|
77091
|
|
66
|
|
|
400270
|
$self->{__immutable}{_method_map} ||= $self->$orig; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# private method, for this file only - |
87
|
|
|
|
|
|
|
# if we declare a method here, it will behave differently depending on what |
88
|
|
|
|
|
|
|
# class this trait is applied to, so we won't have a reliable parameter list. |
89
|
|
|
|
|
|
|
sub __throw_exception { |
90
|
39
|
|
|
39
|
|
107
|
my ($exception_type, @args_to_exception) = @_; |
91
|
39
|
|
|
|
|
174
|
die use_module( "Moose::Exception::$exception_type" )->new( @args_to_exception ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# ABSTRACT: Implements immutability for metaclass objects |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=pod |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=encoding UTF-8 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Class::MOP::Class::Immutable::Trait - Implements immutability for metaclass objects |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 VERSION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
version 2.2205 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 DESCRIPTION |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This class provides a pseudo-trait that is applied to immutable metaclass |
115
|
|
|
|
|
|
|
objects. In reality, it is simply a parent class. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
It implements caching and read-only-ness for various metaclass methods. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHORS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over 4 |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Shawn M Moore <sartak@cpan.org> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Hans Dieter Pearcey <hdp@cpan.org> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Chris Prather <chris@prather.org> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Matt S Trout <mstrout@cpan.org> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This software is copyright (c) 2006 by Infinity Interactive, Inc. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
170
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |