line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::ClosedHash::Meta::Instance; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
BEGIN { |
4
|
1
|
|
|
1
|
|
2
|
$MooseX::ClosedHash::Meta::Instance::AUTHORITY = 'cpan:TOBYINK'; |
5
|
1
|
|
|
|
|
20
|
$MooseX::ClosedHash::Meta::Instance::VERSION = '0.002'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1380
|
use Moose::Role; |
|
1
|
|
|
|
|
5189
|
|
|
1
|
|
|
|
|
7
|
|
9
|
1
|
|
|
1
|
|
6457
|
use Scalar::Util qw( isweak weaken ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1359
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub get_fallback_closure |
12
|
|
|
|
|
|
|
{ |
13
|
0
|
|
|
0
|
0
|
0
|
return sub { die "unrecognized call to closure: $_[0]" }; |
|
4
|
|
|
4
|
|
25
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub get_fresh_closure |
17
|
|
|
|
|
|
|
{ |
18
|
4
|
|
|
4
|
0
|
3704
|
my $meta = shift; |
19
|
4
|
|
|
|
|
11
|
my %store = @_; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
18
|
my $fallback = $meta->get_fallback_closure; |
22
|
|
|
|
|
|
|
return sub { |
23
|
22
|
|
|
22
|
|
4043
|
my ($action, $slot, $value) = @_; |
24
|
22
|
50
|
|
|
|
42
|
for (grep { defined and not ref } $action) |
|
22
|
|
|
|
|
154
|
|
25
|
|
|
|
|
|
|
{ |
26
|
22
|
100
|
|
|
|
82
|
if (/fetch/) { return $store{$slot} } |
|
12
|
|
|
|
|
74
|
|
27
|
10
|
50
|
|
|
|
35
|
if (/store/) { return $store{$slot} = $value } |
|
10
|
|
|
|
|
239
|
|
28
|
0
|
0
|
|
|
|
|
if (/delete/) { return delete $store{$slot} } |
|
0
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if (/exists/) { return exists $store{$slot} } |
|
0
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
if (/clone/) { return %store } |
|
0
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
if (/clear/) { return %store = () } |
|
0
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if (/weaken/) { return weaken($store{$slot}) } |
|
0
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if (/isweak/) { return isweak($store{$slot}) } |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
$fallback->(@_); |
36
|
4
|
|
|
|
|
97
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
override create_instance => sub { |
40
|
|
|
|
|
|
|
my $meta = shift; |
41
|
|
|
|
|
|
|
my $class = $meta->associated_metaclass; |
42
|
|
|
|
|
|
|
bless($meta->get_fresh_closure => $class->name); |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
override clone_instance => sub { |
46
|
|
|
|
|
|
|
my ($meta, $instance) = @_; |
47
|
|
|
|
|
|
|
my $class = $meta->associated_metaclass; |
48
|
|
|
|
|
|
|
bless $meta->get_fresh_closure($instance->(clone => ())) => $class->name; |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
override get_slot_value => sub { |
52
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
53
|
|
|
|
|
|
|
$instance->(fetch => $slot_name); |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
override set_slot_value => sub { |
57
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name, $value) = @_; |
58
|
|
|
|
|
|
|
$instance->(store => $slot_name, $value); |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
override initialize_slot => sub { 1 }; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
override deinitialize_slot => sub { |
64
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
65
|
|
|
|
|
|
|
$instance->(delete => $slot_name); |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
override deinitialize_all_slots => sub { |
69
|
|
|
|
|
|
|
my ($meta, $instance) = @_; |
70
|
|
|
|
|
|
|
$instance->(clear => ()); |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
override is_slot_initialized => sub { |
74
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
75
|
|
|
|
|
|
|
$instance->(exists => $slot_name); |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
override weaken_slot_value => sub { |
79
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
80
|
|
|
|
|
|
|
$instance->(weaken => $slot_name); |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
override slot_value_is_weak => sub { |
84
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
85
|
|
|
|
|
|
|
$instance->(isweak => $slot_name); |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
override inline_create_instance => sub { |
89
|
|
|
|
|
|
|
my ($meta, $klass) = @_; |
90
|
|
|
|
|
|
|
qq{ bless(\$meta->get_meta_instance->get_fresh_closure => $klass) } |
91
|
|
|
|
|
|
|
}; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
override inline_slot_access => sub { |
94
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
95
|
|
|
|
|
|
|
qq{ $instance->(fetch => "$slot_name") } |
96
|
|
|
|
|
|
|
}; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
override inline_get_is_lvalue => sub { |
99
|
|
|
|
|
|
|
0 |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
override inline_get_slot_value => sub { |
103
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
104
|
|
|
|
|
|
|
qq{ $instance->(fetch => "$slot_name") } |
105
|
|
|
|
|
|
|
}; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
override inline_set_slot_value => sub { |
108
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name, $value) = @_; |
109
|
|
|
|
|
|
|
qq{ $instance->(store => "$slot_name", $value) } |
110
|
|
|
|
|
|
|
}; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
override inline_initialize_slot => sub { |
113
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
114
|
|
|
|
|
|
|
qq{} |
115
|
|
|
|
|
|
|
}; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
override inline_deinitialize_slot => sub { |
118
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
119
|
|
|
|
|
|
|
qq{ $instance->(delete => "$slot_name") } |
120
|
|
|
|
|
|
|
}; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
override inline_is_slot_initialized => sub { |
123
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name) = @_; |
124
|
|
|
|
|
|
|
qq{ $instance->(exists => "$slot_name") } |
125
|
|
|
|
|
|
|
}; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
override inline_weaken_slot_value => sub { |
128
|
|
|
|
|
|
|
my ($meta, $instance, $slot_name, $value) = @_; |
129
|
|
|
|
|
|
|
qq{ $instance->(weaken => "$slot_name", $value) } |
130
|
|
|
|
|
|
|
}; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |