line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::MOP::Class::Immutable::Trait; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2203'; |
3
|
|
|
|
|
|
|
|
4
|
462
|
|
|
462
|
|
214483
|
use strict; |
|
462
|
|
|
|
|
919
|
|
|
462
|
|
|
|
|
12670
|
|
5
|
462
|
|
|
462
|
|
2118
|
use warnings; |
|
462
|
|
|
|
|
2634
|
|
|
462
|
|
|
|
|
12233
|
|
6
|
|
|
|
|
|
|
|
7
|
462
|
|
|
462
|
|
2836
|
use MRO::Compat; |
|
462
|
|
|
|
|
1170
|
|
|
462
|
|
|
|
|
11224
|
|
8
|
462
|
|
|
462
|
|
2644
|
use Module::Runtime 'use_module'; |
|
462
|
|
|
|
|
843
|
|
|
462
|
|
|
|
|
3209
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# the original class of the metaclass instance |
11
|
11349
|
|
|
11349
|
|
46152
|
sub _get_mutable_metaclass_name { $_[0]{__immutable}{original_class} } |
12
|
|
|
|
|
|
|
|
13
|
19
|
|
|
19
|
|
81
|
sub is_mutable { 0 } |
14
|
11404
|
|
|
11404
|
|
41944
|
sub is_immutable { 1 } |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
5
|
sub _immutable_metaclass { ref $_[1] } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _immutable_read_only { |
19
|
6
|
|
|
6
|
|
52
|
my $name = shift; |
20
|
6
|
|
|
|
|
17
|
__throw_exception( CallingReadOnlyMethodOnAnImmutableInstance => method_name => $name ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _immutable_cannot_call { |
24
|
33
|
|
|
33
|
|
51
|
my $name = shift; |
25
|
33
|
|
|
|
|
71
|
__throw_exception( CallingMethodOnAnImmutableInstance => method_name => $name ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
for my $name (qw/superclasses/) { |
29
|
462
|
|
|
462
|
|
91988
|
no strict 'refs'; |
|
462
|
|
|
|
|
1014
|
|
|
462
|
|
|
|
|
64503
|
|
30
|
|
|
|
|
|
|
*{__PACKAGE__."::$name"} = sub { |
31
|
1143
|
|
|
1143
|
|
2084
|
my $orig = shift; |
32
|
1143
|
|
|
|
|
1563
|
my $self = shift; |
33
|
1143
|
100
|
|
|
|
2653
|
_immutable_read_only($name) if @_; |
34
|
1137
|
|
|
|
|
2568
|
$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
|
462
|
|
|
462
|
|
3144
|
no strict 'refs'; |
|
462
|
|
|
|
|
4747
|
|
|
462
|
|
|
|
|
187762
|
|
40
|
32
|
|
|
32
|
|
215
|
*{__PACKAGE__."::$name"} = sub { _immutable_cannot_call($name) }; |
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
32
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub class_precedence_list { |
44
|
2595
|
|
|
2595
|
|
4364
|
my $orig = shift; |
45
|
2595
|
|
|
|
|
3486
|
my $self = shift; |
46
|
2595
|
|
|
|
|
3466
|
@{ $self->{__immutable}{class_precedence_list} |
47
|
2595
|
|
100
|
|
|
20452
|
||= [ $self->$orig ] }; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub linearized_isa { |
51
|
28739
|
|
|
28739
|
|
40568
|
my $orig = shift; |
52
|
28739
|
|
|
|
|
36725
|
my $self = shift; |
53
|
28739
|
|
100
|
|
|
36090
|
@{ $self->{__immutable}{linearized_isa} ||= [ $self->$orig ] }; |
|
28739
|
|
|
|
|
125038
|
|
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
|
19600
|
|
|
19600
|
|
28882
|
my $orig = shift; |
70
|
19600
|
|
|
|
|
25889
|
my $self = shift; |
71
|
19600
|
|
100
|
|
|
25653
|
@{ $self->{__immutable}{get_all_attributes} ||= [ $self->$orig ] }; |
|
19600
|
|
|
|
|
85203
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub get_meta_instance { |
75
|
121658
|
|
|
121658
|
|
160343
|
my $orig = shift; |
76
|
121658
|
|
|
|
|
145268
|
my $self = shift; |
77
|
121658
|
|
66
|
|
|
346228
|
$self->{__immutable}{get_meta_instance} ||= $self->$orig; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _method_map { |
81
|
79066
|
|
|
79066
|
|
105288
|
my $orig = shift; |
82
|
79066
|
|
|
|
|
98387
|
my $self = shift; |
83
|
79066
|
|
66
|
|
|
336727
|
$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
|
|
85
|
my ($exception_type, @args_to_exception) = @_; |
91
|
39
|
|
|
|
|
149
|
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.2203 |
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 |