line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::MOP::Class::Immutable::Trait; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2206'; |
3
|
|
|
|
|
|
|
|
4
|
450
|
|
|
450
|
|
248690
|
use strict; |
|
450
|
|
|
|
|
1164
|
|
|
450
|
|
|
|
|
14048
|
|
5
|
450
|
|
|
450
|
|
2439
|
use warnings; |
|
450
|
|
|
|
|
1957
|
|
|
450
|
|
|
|
|
11645
|
|
6
|
|
|
|
|
|
|
|
7
|
450
|
|
|
450
|
|
3354
|
use MRO::Compat; |
|
450
|
|
|
|
|
1496
|
|
|
450
|
|
|
|
|
12697
|
|
8
|
450
|
|
|
450
|
|
2973
|
use Module::Runtime 'use_module'; |
|
450
|
|
|
|
|
1091
|
|
|
450
|
|
|
|
|
4142
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# the original class of the metaclass instance |
11
|
11078
|
|
|
11078
|
|
58812
|
sub _get_mutable_metaclass_name { $_[0]{__immutable}{original_class} } |
12
|
|
|
|
|
|
|
|
13
|
17
|
|
|
17
|
|
101
|
sub is_mutable { 0 } |
14
|
11133
|
|
|
11133
|
|
47415
|
sub is_immutable { 1 } |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
8
|
sub _immutable_metaclass { ref $_[1] } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _immutable_read_only { |
19
|
6
|
|
|
6
|
|
19
|
my $name = shift; |
20
|
6
|
|
|
|
|
20
|
__throw_exception( CallingReadOnlyMethodOnAnImmutableInstance => method_name => $name ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _immutable_cannot_call { |
24
|
33
|
|
|
33
|
|
70
|
my $name = shift; |
25
|
33
|
|
|
|
|
94
|
__throw_exception( CallingMethodOnAnImmutableInstance => method_name => $name ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
for my $name (qw/superclasses/) { |
29
|
450
|
|
|
450
|
|
102746
|
no strict 'refs'; |
|
450
|
|
|
|
|
1321
|
|
|
450
|
|
|
|
|
74866
|
|
30
|
|
|
|
|
|
|
*{__PACKAGE__."::$name"} = sub { |
31
|
1127
|
|
|
1127
|
|
2418
|
my $orig = shift; |
32
|
1127
|
|
|
|
|
1895
|
my $self = shift; |
33
|
1127
|
100
|
|
|
|
2929
|
_immutable_read_only($name) if @_; |
34
|
1121
|
|
|
|
|
2863
|
$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
|
|
3502
|
no strict 'refs'; |
|
450
|
|
|
|
|
5775
|
|
|
450
|
|
|
|
|
212021
|
|
40
|
32
|
|
|
32
|
|
282
|
*{__PACKAGE__."::$name"} = sub { _immutable_cannot_call($name) }; |
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub class_precedence_list { |
44
|
2571
|
|
|
2571
|
|
4639
|
my $orig = shift; |
45
|
2571
|
|
|
|
|
4083
|
my $self = shift; |
46
|
2571
|
|
|
|
|
3936
|
@{ $self->{__immutable}{class_precedence_list} |
47
|
2571
|
|
100
|
|
|
24472
|
||= [ $self->$orig ] }; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub linearized_isa { |
51
|
27965
|
|
|
27965
|
|
45762
|
my $orig = shift; |
52
|
27965
|
|
|
|
|
42019
|
my $self = shift; |
53
|
27965
|
|
100
|
|
|
41971
|
@{ $self->{__immutable}{linearized_isa} ||= [ $self->$orig ] }; |
|
27965
|
|
|
|
|
143734
|
|
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
|
|
33161
|
my $orig = shift; |
70
|
19161
|
|
|
|
|
29203
|
my $self = shift; |
71
|
19161
|
|
100
|
|
|
29522
|
@{ $self->{__immutable}{get_all_attributes} ||= [ $self->$orig ] }; |
|
19161
|
|
|
|
|
100252
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub get_meta_instance { |
75
|
118384
|
|
|
118384
|
|
179825
|
my $orig = shift; |
76
|
118384
|
|
|
|
|
161977
|
my $self = shift; |
77
|
118384
|
|
66
|
|
|
396723
|
$self->{__immutable}{get_meta_instance} ||= $self->$orig; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _method_map { |
81
|
77091
|
|
|
77091
|
|
118270
|
my $orig = shift; |
82
|
77091
|
|
|
|
|
110389
|
my $self = shift; |
83
|
77091
|
|
66
|
|
|
398290
|
$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
|
|
114
|
my ($exception_type, @args_to_exception) = @_; |
91
|
39
|
|
|
|
|
185
|
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.2206 |
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 |