line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package mop::object; |
2
|
|
|
|
|
|
|
|
3
|
143
|
|
|
143
|
|
1921
|
use v5.16; |
|
143
|
|
|
|
|
489
|
|
|
143
|
|
|
|
|
5882
|
|
4
|
143
|
|
|
143
|
|
786
|
use warnings; |
|
143
|
|
|
|
|
273
|
|
|
143
|
|
|
|
|
3809
|
|
5
|
|
|
|
|
|
|
|
6
|
143
|
|
|
143
|
|
86590
|
use mop::internals::util; |
|
143
|
|
|
|
|
400
|
|
|
143
|
|
|
|
|
129241
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
151
|
|
|
151
|
|
157
|
my $class = shift; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# NOTE: |
15
|
|
|
|
|
|
|
# prior to the bootstrapping being |
16
|
|
|
|
|
|
|
# finished, we need to not try to |
17
|
|
|
|
|
|
|
# build classes, it will all be done |
18
|
|
|
|
|
|
|
# manually in the mop:: classes. |
19
|
|
|
|
|
|
|
# this method will be replaced once |
20
|
|
|
|
|
|
|
# bootstrapping is done. |
21
|
|
|
|
|
|
|
# - SL |
22
|
151
|
|
|
|
|
310
|
my $self = bless \(my $x) => $class; |
23
|
|
|
|
|
|
|
|
24
|
151
|
|
|
|
|
357
|
mop::internals::util::register_object( $self ); |
25
|
|
|
|
|
|
|
|
26
|
151
|
|
|
|
|
347
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub clone { |
30
|
117
|
|
|
117
|
1
|
331
|
my ($self, %args) = @_; |
31
|
117
|
|
|
|
|
316
|
return mop::meta($self)->clone_instance($self, %args); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub does { |
35
|
54
|
|
|
54
|
1
|
4717
|
my ($self, $role) = @_; |
36
|
54
|
|
66
|
|
|
79
|
scalar grep { mop::meta($_)->does_role($role) } @{ mro::get_linear_isa(ref($self) || $self) } |
|
123
|
|
|
|
|
331
|
|
|
54
|
|
|
|
|
371
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub DOES { |
40
|
24
|
|
|
24
|
1
|
6363
|
my ($self, $role) = @_; |
41
|
24
|
100
|
|
|
|
78
|
$self->does($role) or $self->UNIVERSAL::DOES($role); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub DESTROY { |
45
|
302
|
|
|
302
|
|
147841
|
my $self = shift; |
46
|
302
|
|
|
|
|
548
|
foreach my $class (@{ mro::get_linear_isa(ref $self) }) { |
|
302
|
|
|
|
|
1697
|
|
47
|
687
|
50
|
|
|
|
1911
|
if (my $m = mop::meta($class)) { |
48
|
687
|
100
|
|
|
|
2194
|
$m->get_method('DEMOLISH')->execute($self, []) |
49
|
|
|
|
|
|
|
if $m->has_method('DEMOLISH'); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub __INIT_METACLASS__ { |
55
|
143
|
|
|
143
|
|
2816
|
my $METACLASS = mop::class->new( |
56
|
|
|
|
|
|
|
name => 'mop::object', |
57
|
|
|
|
|
|
|
version => $VERSION, |
58
|
|
|
|
|
|
|
authority => $AUTHORITY, |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$METACLASS->add_method( |
62
|
|
|
|
|
|
|
mop::method->new( |
63
|
|
|
|
|
|
|
name => 'new', |
64
|
|
|
|
|
|
|
body => sub { |
65
|
1457
|
|
|
1457
|
|
50554
|
my $class = shift; |
66
|
1457
|
100
|
66
|
|
|
12733
|
my (%args) = @_ == 1 && ref $_[0] eq 'HASH' ? %{$_[0]} : @_; |
|
1
|
|
|
|
|
4
|
|
67
|
1457
|
|
|
|
|
5057
|
mop::internals::util::find_or_inflate_meta($class)->new_instance(%args); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
) |
70
|
143
|
|
|
|
|
4929
|
); |
71
|
|
|
|
|
|
|
|
72
|
143
|
|
|
|
|
861
|
$METACLASS->add_method( mop::method->new( name => 'clone', body => \&clone ) ); |
73
|
|
|
|
|
|
|
|
74
|
143
|
|
|
|
|
960
|
$METACLASS->add_method( mop::method->new( name => 'does', body => \&does ) ); |
75
|
143
|
|
|
|
|
2176
|
$METACLASS->add_method( mop::method->new( name => 'DOES', body => \&DOES ) ); |
76
|
|
|
|
|
|
|
|
77
|
143
|
|
|
|
|
3379
|
$METACLASS->add_method( mop::method->new( name => 'DESTROY', body => \&DESTROY ) ); |
78
|
|
|
|
|
|
|
|
79
|
143
|
|
|
|
|
5076
|
$METACLASS; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |