line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DCI::Cast; |
2
|
23
|
|
|
23
|
|
4621429
|
use strict; |
|
23
|
|
|
|
|
42
|
|
|
23
|
|
|
|
|
1516
|
|
3
|
23
|
|
|
23
|
|
132
|
use warnings; |
|
23
|
|
|
|
|
37
|
|
|
23
|
|
|
|
|
669
|
|
4
|
|
|
|
|
|
|
|
5
|
23
|
|
|
23
|
|
111
|
use Carp(); |
|
23
|
|
|
|
|
94
|
|
|
23
|
|
|
|
|
354
|
|
6
|
23
|
|
|
23
|
|
124
|
use Scalar::Util(); |
|
23
|
|
|
|
|
26
|
|
|
23
|
|
|
|
|
25746
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub dci_new { |
9
|
59
|
|
|
59
|
1
|
11755499
|
my $class = shift; |
10
|
59
|
|
|
|
|
571
|
my ( $direct_core, $context, %state ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
59
|
50
|
|
|
|
450
|
Carp::croak( "You must provide a core object" ) |
13
|
|
|
|
|
|
|
unless $direct_core; |
14
|
|
|
|
|
|
|
|
15
|
59
|
50
|
|
|
|
488
|
Carp::croak( "You must provide a context" ) |
16
|
|
|
|
|
|
|
unless $context; |
17
|
|
|
|
|
|
|
|
18
|
59
|
|
66
|
|
|
560
|
my $direct_core_type = Scalar::Util::blessed( $direct_core ) |
19
|
|
|
|
|
|
|
|| Scalar::Util::reftype( $direct_core ); |
20
|
|
|
|
|
|
|
|
21
|
59
|
|
|
|
|
772
|
my @allowed_cores = $class->dci_meta->allowed_cores; |
22
|
59
|
100
|
100
|
|
|
732
|
if ( @allowed_cores && !(grep { $direct_core->isa( $_ ) } @allowed_cores )) { |
|
63
|
|
|
|
|
1022
|
|
23
|
1
|
|
|
|
|
112
|
Carp::croak "Invalid core '$direct_core_type' is not one of: " |
24
|
|
|
|
|
|
|
. join( ', ', @allowed_cores ) |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
58
|
|
|
|
|
174
|
my $true_core = $direct_core; |
28
|
58
|
100
|
100
|
|
|
4552
|
$true_core = $true_core->dci_core |
29
|
|
|
|
|
|
|
if Scalar::Util::blessed($true_core) |
30
|
|
|
|
|
|
|
&& $true_core->isa( __PACKAGE__ ); |
31
|
|
|
|
|
|
|
|
32
|
58
|
|
66
|
|
|
339
|
my $true_core_type = Scalar::Util::blessed( $true_core ) |
33
|
|
|
|
|
|
|
|| Scalar::Util::reftype( $true_core ); |
34
|
|
|
|
|
|
|
|
35
|
58
|
|
66
|
|
|
1478
|
return bless { |
36
|
|
|
|
|
|
|
'state' => \%state, |
37
|
|
|
|
|
|
|
true_core => $true_core, |
38
|
|
|
|
|
|
|
direct_core => $direct_core, |
39
|
|
|
|
|
|
|
context => $context, |
40
|
|
|
|
|
|
|
true_core_type => $true_core_type, |
41
|
|
|
|
|
|
|
direct_core_type => $direct_core_type, |
42
|
|
|
|
|
|
|
context_type => Scalar::Util::blessed( $context ) |
43
|
|
|
|
|
|
|
|| Scalar::Util::reftype( $context ), |
44
|
|
|
|
|
|
|
}, $class; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub dci_meta { |
48
|
1
|
|
|
1
|
1
|
32595
|
my $self_or_class = shift; |
49
|
1
|
|
33
|
|
|
199
|
my $class = Scalar::Util::blessed( $self_or_class ) |
50
|
|
|
|
|
|
|
|| $self_or_class; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
597
|
require DCI::Meta::Cast; |
53
|
1
|
|
|
|
|
202
|
DCI::Meta::Cast->new( $class ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
9
|
|
|
9
|
1
|
176
|
sub dci_state { shift->{'state'} } |
57
|
|
|
|
|
|
|
|
58
|
21
|
|
|
21
|
1
|
259
|
sub dci_context { shift->{context} } |
59
|
0
|
|
|
0
|
1
|
0
|
sub dci_context_type { shift->{context_type} } |
60
|
|
|
|
|
|
|
|
61
|
152
|
|
|
152
|
1
|
536
|
sub dci_core { shift->dci_true_core } |
62
|
16
|
|
|
16
|
1
|
494
|
sub dci_core_type { shift->dci_true_core_type } |
63
|
|
|
|
|
|
|
|
64
|
163
|
|
|
163
|
1
|
621
|
sub dci_true_core { shift->{true_core} } |
65
|
16
|
|
|
16
|
1
|
57
|
sub dci_true_core_type { shift->{true_core_type} } |
66
|
|
|
|
|
|
|
|
67
|
21
|
|
|
21
|
1
|
181
|
sub dci_direct_core { shift->{direct_core} } |
68
|
18
|
|
|
18
|
1
|
44
|
sub dci_direct_core_type { shift->{direct_core_type} } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub dci_debug { |
71
|
9
|
|
|
9
|
1
|
28
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
9
|
|
|
|
|
17
|
my $out_start = ""; |
74
|
9
|
|
|
|
|
16
|
my $out_end = ""; |
75
|
9
|
|
|
|
|
15
|
my ( $type, $core_type, $core ); |
76
|
9
|
|
100
|
|
|
64
|
do { |
77
|
18
|
|
66
|
|
|
83
|
my $one = $core || $self; |
78
|
18
|
|
|
|
|
59
|
$type = Scalar::Util::blessed($one); |
79
|
18
|
|
|
|
|
62
|
$core = $one->dci_direct_core; |
80
|
18
|
|
|
|
|
90
|
$core_type = $one->dci_direct_core_type; |
81
|
|
|
|
|
|
|
|
82
|
18
|
|
|
|
|
44
|
$out_start = "$out_start$type( "; |
83
|
18
|
|
|
|
|
1104
|
$out_end = ")$out_end"; |
84
|
|
|
|
|
|
|
} while $core_type && $core_type->isa( __PACKAGE__ ); |
85
|
|
|
|
|
|
|
|
86
|
9
|
|
|
|
|
1338
|
return "$out_start$core $out_end"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub isa { |
90
|
123
|
|
|
123
|
1
|
16725
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
123
|
100
|
|
|
|
1299
|
return $self->SUPER::isa( @_ ) |
93
|
|
|
|
|
|
|
unless Scalar::Util::blessed( $self ); |
94
|
|
|
|
|
|
|
|
95
|
71
|
|
|
|
|
265
|
my $core = $self->dci_core; |
96
|
71
|
|
100
|
|
|
978
|
return $self->SUPER::isa( @_ ) || $core->isa( @_ ); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |