line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Closure; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
218126
|
use strict; |
|
18
|
|
|
|
|
51
|
|
|
18
|
|
|
|
|
935
|
|
4
|
18
|
|
|
18
|
|
102
|
use warnings; |
|
18
|
|
|
|
|
49
|
|
|
18
|
|
|
|
|
469
|
|
5
|
18
|
|
|
18
|
|
357
|
use 5.008004; |
|
18
|
|
|
|
|
65
|
|
6
|
18
|
|
|
18
|
|
851
|
use FFI::Platypus; |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
649
|
|
7
|
18
|
|
|
18
|
|
113
|
use Scalar::Util qw( refaddr); |
|
18
|
|
|
|
|
38
|
|
|
18
|
|
|
|
|
1175
|
|
8
|
18
|
|
|
18
|
|
138
|
use Carp qw( croak ); |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
2248
|
|
9
|
|
|
|
|
|
|
use overload '&{}' => sub { |
10
|
4
|
|
|
4
|
|
1849
|
my $self = shift; |
11
|
4
|
|
|
4
|
|
19
|
sub { $self->{code}->(@_) }; |
|
4
|
|
|
|
|
14
|
|
12
|
18
|
|
|
18
|
|
158
|
}, bool => sub { 1 }, fallback => 1; |
|
18
|
|
|
0
|
|
38
|
|
|
18
|
|
|
|
|
289
|
|
|
0
|
|
|
|
|
0
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Platypus closure object |
15
|
|
|
|
|
|
|
our $VERSION = '2.06_01'; # TRIAL VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new |
19
|
|
|
|
|
|
|
{ |
20
|
87
|
|
|
87
|
1
|
5511
|
my($class, $coderef) = @_; |
21
|
87
|
50
|
|
|
|
269
|
croak "not a coderef" unless ref($coderef) eq 'CODE'; |
22
|
87
|
|
|
|
|
323
|
my $self = bless { code => $coderef, cbdata => {}, sticky => 0 }, $class; |
23
|
87
|
|
|
|
|
577
|
$self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub add_data |
27
|
|
|
|
|
|
|
{ |
28
|
89
|
|
|
89
|
0
|
284
|
my($self, $payload, $type) = @_; |
29
|
89
|
|
|
|
|
779
|
$self->{cbdata}{$type} = bless \$payload, 'FFI::Platypus::ClosureData'; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_data |
33
|
|
|
|
|
|
|
{ |
34
|
90
|
|
|
90
|
0
|
720
|
my($self, $type) = @_; |
35
|
|
|
|
|
|
|
|
36
|
90
|
100
|
|
|
|
816
|
if (exists $self->{cbdata}->{$type}) { |
37
|
1
|
|
|
|
|
2
|
return ${$self->{cbdata}->{$type}}; |
|
1
|
|
|
|
|
13
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
89
|
|
|
|
|
5258
|
return 0; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub call |
45
|
|
|
|
|
|
|
{ |
46
|
2
|
|
|
2
|
1
|
749
|
my $self = shift; |
47
|
2
|
|
|
|
|
7
|
$self->{code}->(@_) |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub sticky |
52
|
|
|
|
|
|
|
{ |
53
|
2
|
|
|
2
|
1
|
1641
|
my($self) = @_; |
54
|
2
|
100
|
|
|
|
11
|
return if $self->{sticky}; |
55
|
1
|
|
|
|
|
3
|
$self->{sticky} = 1; |
56
|
1
|
|
|
|
|
5
|
$self->_sticky; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub unstick |
61
|
|
|
|
|
|
|
{ |
62
|
1
|
|
|
1
|
1
|
750
|
my($self) = @_; |
63
|
1
|
50
|
|
|
|
5
|
return unless $self->{sticky}; |
64
|
1
|
|
|
|
|
3
|
$self->{sticky} = 0; |
65
|
1
|
|
|
|
|
6
|
$self->_unstick; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
package FFI::Platypus::ClosureData; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
our $VERSION = '2.06_01'; # TRIAL VERSION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |