line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moxie; |
2
|
|
|
|
|
|
|
# ABSTRACT: Not Another Moose Clone |
3
|
|
|
|
|
|
|
|
4
|
49
|
|
|
49
|
|
3738004
|
use v5.22; |
|
49
|
|
|
|
|
641
|
|
5
|
49
|
|
|
49
|
|
280
|
use warnings; |
|
49
|
|
|
|
|
99
|
|
|
49
|
|
|
|
|
1722
|
|
6
|
49
|
|
|
|
|
274
|
use experimental qw[ |
7
|
|
|
|
|
|
|
signatures |
8
|
|
|
|
|
|
|
postderef |
9
|
49
|
|
|
49
|
|
13979
|
]; |
|
49
|
|
|
|
|
142915
|
|
10
|
|
|
|
|
|
|
|
11
|
49
|
|
|
49
|
|
9042
|
use experimental (); # need this later when we load features |
|
49
|
|
|
|
|
117
|
|
|
49
|
|
|
|
|
846
|
|
12
|
49
|
|
|
49
|
|
11647
|
use Module::Runtime (); # load things so they DWIM |
|
49
|
|
|
|
|
53380
|
|
|
49
|
|
|
|
|
1083
|
|
13
|
49
|
|
|
49
|
|
14465
|
use BEGIN::Lift (); # fake some keywords |
|
49
|
|
|
|
|
195765
|
|
|
49
|
|
|
|
|
1313
|
|
14
|
49
|
|
|
49
|
|
14634
|
use Method::Traits (); # for accessor/method generators |
|
49
|
|
|
|
|
1349040
|
|
|
49
|
|
|
|
|
1431
|
|
15
|
|
|
|
|
|
|
|
16
|
49
|
|
|
49
|
|
390
|
use MOP; |
|
49
|
|
|
|
|
105
|
|
|
49
|
|
|
|
|
1355
|
|
17
|
49
|
|
|
49
|
|
255
|
use MOP::Util; |
|
49
|
|
|
|
|
98
|
|
|
49
|
|
|
|
|
1148
|
|
18
|
|
|
|
|
|
|
|
19
|
49
|
|
|
49
|
|
14203
|
use Moxie::Object; |
|
49
|
|
|
|
|
119
|
|
|
49
|
|
|
|
|
1461
|
|
20
|
49
|
|
|
49
|
|
13141
|
use Moxie::Object::Immutable; |
|
49
|
|
|
|
|
750
|
|
|
49
|
|
|
|
|
1483
|
|
21
|
49
|
|
|
49
|
|
15955
|
use Moxie::Traits::Provider; |
|
49
|
|
|
|
|
158
|
|
|
49
|
|
|
|
|
34543
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
24
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
25
|
|
|
|
|
|
|
|
26
|
138
|
|
|
138
|
|
50827
|
sub import ($class, %opts) { |
|
138
|
|
|
|
|
407
|
|
|
138
|
|
|
|
|
228
|
|
|
138
|
|
|
|
|
191
|
|
27
|
|
|
|
|
|
|
# get the caller ... |
28
|
138
|
|
|
|
|
314
|
my $caller = caller; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# make the assumption that if we are |
31
|
|
|
|
|
|
|
# loaded outside of main then we are |
32
|
|
|
|
|
|
|
# likely being loaded in a class, so |
33
|
|
|
|
|
|
|
# turn on all the features |
34
|
138
|
50
|
|
|
|
461
|
if ( $caller ne 'main' ) { |
35
|
138
|
|
|
|
|
398
|
$class->import_into( $caller, \%opts ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
138
|
|
|
138
|
0
|
209
|
sub import_into ($class, $caller, $opts) { |
|
138
|
|
|
|
|
216
|
|
|
138
|
|
|
|
|
184
|
|
|
138
|
|
|
|
|
199
|
|
|
138
|
|
|
|
|
185
|
|
40
|
|
|
|
|
|
|
# NOTE: |
41
|
|
|
|
|
|
|
# create the meta-object, we start |
42
|
|
|
|
|
|
|
# with this as a role, but it will |
43
|
|
|
|
|
|
|
# get "cast" to a class if there |
44
|
|
|
|
|
|
|
# is a need for it. |
45
|
138
|
|
|
|
|
510
|
my $meta = MOP::Role->new( name => $caller ); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# turn on strict/warnings |
48
|
138
|
|
|
|
|
9364
|
strict->import; |
49
|
138
|
|
|
|
|
1743
|
warnings->import; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# so we can have fun with attributes ... |
52
|
138
|
|
|
|
|
1834
|
warnings->unimport('reserved'); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# turn on signatures and more |
55
|
138
|
|
|
|
|
804
|
experimental->import($_) foreach qw[ |
56
|
|
|
|
|
|
|
signatures |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
postderef |
59
|
|
|
|
|
|
|
postderef_qq |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
current_sub |
62
|
|
|
|
|
|
|
lexical_subs |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
say |
65
|
|
|
|
|
|
|
state |
66
|
|
|
|
|
|
|
]; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# turn on refaliasing if we have it ... |
69
|
138
|
50
|
|
|
|
26238
|
experimental->import('refaliasing') if $] >= 5.022; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# turn on declared refs if we have it ... |
72
|
138
|
50
|
|
|
|
3827
|
experimental->import('declared_refs') if $] >= 5.026; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# import has, extend and with keyword |
75
|
|
|
|
|
|
|
|
76
|
73
|
|
|
|
|
138
|
BEGIN::Lift::install( |
77
|
73
|
|
|
73
|
|
108
|
($caller, 'has') => sub ($name, @args) { |
|
73
|
|
|
|
|
1361
|
|
|
73
|
|
|
|
|
134
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# NOTE: |
80
|
|
|
|
|
|
|
# Handle the simple case of `has $name => $code` |
81
|
|
|
|
|
|
|
# by converting it into the more complex |
82
|
|
|
|
|
|
|
# `has $name => %opts` version, just easier |
83
|
|
|
|
|
|
|
# to maintain internal consistency. |
84
|
|
|
|
|
|
|
# - SL |
85
|
|
|
|
|
|
|
|
86
|
73
|
100
|
66
|
|
|
389
|
@args = ( default => $args[0] ) |
87
|
|
|
|
|
|
|
if scalar @args == 1 |
88
|
|
|
|
|
|
|
&& ref $args[0] eq 'CODE'; |
89
|
|
|
|
|
|
|
|
90
|
73
|
|
|
|
|
320
|
my $initializer = MOP::Slot::Initializer->new( |
91
|
|
|
|
|
|
|
within_package => $meta->name, |
92
|
|
|
|
|
|
|
@args |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
73
|
|
|
|
|
13473
|
$meta->add_slot( $name, $initializer ); |
96
|
73
|
|
|
|
|
15430
|
return; |
97
|
|
|
|
|
|
|
} |
98
|
138
|
|
|
|
|
4428
|
); |
99
|
|
|
|
|
|
|
|
100
|
93
|
|
|
|
|
234
|
BEGIN::Lift::install( |
101
|
93
|
|
|
93
|
|
148
|
($caller, 'extends') => sub (@isa) { |
|
93
|
|
|
|
|
5716
|
|
102
|
93
|
|
|
|
|
375
|
Module::Runtime::use_package_optimistically( $_ ) foreach @isa; |
103
|
|
|
|
|
|
|
($meta->isa('MOP::Class') |
104
|
|
|
|
|
|
|
? $meta |
105
|
93
|
50
|
|
|
|
9717
|
: do { |
106
|
|
|
|
|
|
|
# FIXME: |
107
|
|
|
|
|
|
|
# This is gross ... - SL |
108
|
93
|
|
|
|
|
336
|
Internals::SvREADONLY( $$meta, 0 ); |
109
|
93
|
|
|
|
|
192
|
bless $meta => 'MOP::Class'; # cast into class |
110
|
93
|
|
|
|
|
456
|
Internals::SvREADONLY( $$meta, 1 ); |
111
|
93
|
|
|
|
|
478
|
$meta; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
)->set_superclasses( @isa ); |
114
|
93
|
|
|
|
|
16161
|
return; |
115
|
|
|
|
|
|
|
} |
116
|
138
|
|
|
|
|
19592
|
); |
117
|
|
|
|
|
|
|
|
118
|
41
|
|
|
|
|
84
|
BEGIN::Lift::install( |
119
|
41
|
|
|
41
|
|
60
|
($caller, 'with') => sub (@does) { |
|
41
|
|
|
|
|
1161
|
|
120
|
41
|
|
|
|
|
146
|
Module::Runtime::use_package_optimistically( $_ ) foreach @does; |
121
|
41
|
|
|
|
|
11985
|
$meta->set_roles( @does ); |
122
|
41
|
|
|
|
|
9928
|
return; |
123
|
|
|
|
|
|
|
} |
124
|
138
|
|
|
|
|
16402
|
); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# setup the base traits, and |
127
|
138
|
|
|
|
|
14723
|
my @traits = ('Moxie::Traits::Provider'); |
128
|
|
|
|
|
|
|
# and anything we were asked to load ... |
129
|
138
|
100
|
|
|
|
491
|
push @traits => $opts->{'traits'}->@* if exists $opts->{'traits'}; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# then schedule the trait collection ... |
132
|
138
|
|
|
|
|
511
|
Method::Traits->import_into( $meta->name, @traits ); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# install our class finalizer |
135
|
|
|
|
|
|
|
MOP::Util::defer_until_UNITCHECK(sub { |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# pre-populate the cache for all the slots (if it is a class) |
138
|
138
|
|
|
138
|
|
91518
|
MOP::Util::inherit_slots( $meta ); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# apply roles ... |
141
|
138
|
|
|
|
|
19016
|
MOP::Util::compose_roles( $meta ); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# TODO: |
144
|
|
|
|
|
|
|
# Consider locking the %HAS hash now, this will |
145
|
|
|
|
|
|
|
# prevent anyone from adding new fields after |
146
|
|
|
|
|
|
|
# compile time. |
147
|
|
|
|
|
|
|
# - SL |
148
|
|
|
|
|
|
|
|
149
|
138
|
|
|
|
|
39721
|
}); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__ |