line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MsgPack::Decoder::Generator; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
$MsgPack::Decoder::Generator::VERSION = '2.0.2'; |
4
|
4
|
|
|
4
|
|
2353
|
use 5.10.0; |
|
4
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
83
|
|
7
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
106
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
21
|
use List::Util qw/ reduce /; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
307
|
|
10
|
4
|
|
|
4
|
|
30
|
use Module::Runtime qw/ use_module /; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
33
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
2002
|
use Log::Any; |
|
4
|
|
|
|
|
32426
|
|
|
4
|
|
|
|
|
20
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
176
|
use Moose; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
30
|
|
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
28090
|
use MooseX::MungeHas 'is_ro'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
35
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
4361
|
use experimental 'signatures', 'postderef'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
29
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has log => sub { |
21
|
312
|
|
|
312
|
|
4548
|
my $class = ref shift; |
22
|
312
|
|
|
|
|
1114
|
$class =~ s/MsgPack::Decoder::Generator:://; |
23
|
312
|
|
|
|
|
1294
|
Log::Any->get_logger->clone( prefix => "[$class] "); |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has bytes => ( |
27
|
|
|
|
|
|
|
required => 1, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has buffer => ( |
31
|
|
|
|
|
|
|
traits => [ 'String' ], |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
default => '', |
34
|
|
|
|
|
|
|
handles => { |
35
|
|
|
|
|
|
|
append_buffer => 'append', |
36
|
|
|
|
|
|
|
buffer_size => 'length', |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
trigger => sub { |
39
|
|
|
|
|
|
|
my ( $self, $buffer ) = @_; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return unless $self->can( 'gen_value' ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return if length($buffer) < $self->bytes; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->push_decoded->( $self->gen_value ); |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has next => ( |
50
|
|
|
|
|
|
|
is => 'ro', |
51
|
|
|
|
|
|
|
lazy => 1, |
52
|
|
|
|
|
|
|
builder => \&build_next, |
53
|
|
|
|
|
|
|
traits => [ 'Array' ], |
54
|
|
|
|
|
|
|
handles => { |
55
|
|
|
|
|
|
|
next_args => 'shift', |
56
|
|
|
|
|
|
|
push_next => 'push', |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
134
|
|
|
134
|
|
6178
|
sub build_next { [] } |
61
|
|
|
|
|
|
|
|
62
|
312
|
|
|
312
|
0
|
433910
|
sub BUILD { $_[0]->log->trace('generator created') } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub buffer_as_int { |
65
|
216
|
|
|
216
|
0
|
755
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
216
|
|
|
35
|
|
6139
|
return reduce { ( $a << 8 ) + $b } map { ord } split '', $self->buffer; |
|
35
|
|
|
|
|
589
|
|
|
251
|
|
|
|
|
4730
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has post_next => ( |
71
|
|
|
|
|
|
|
is => 'ro', |
72
|
|
|
|
|
|
|
lazy => 1, |
73
|
|
|
|
|
|
|
default => sub { [] }, |
74
|
|
|
|
|
|
|
traits => [ 'Array' ], |
75
|
|
|
|
|
|
|
handles => { |
76
|
|
|
|
|
|
|
next_post_next => 'shift', |
77
|
|
|
|
|
|
|
}, |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
has push_decoded => sub { |
81
|
0
|
|
|
0
|
|
0
|
return sub { }; |
|
|
|
|
0
|
|
|
|
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
|
84
|
309
|
|
|
309
|
0
|
448
|
sub next_read($self) { |
|
309
|
|
|
|
|
526
|
|
|
309
|
|
|
|
|
416
|
|
85
|
309
|
|
100
|
|
|
9994
|
my $arg = $self->next_args || $self->next_post_next || [ 'Any' ]; |
86
|
|
|
|
|
|
|
|
87
|
309
|
|
|
|
|
16817
|
my( $class, @args ) = @$arg; |
88
|
|
|
|
|
|
|
|
89
|
309
|
|
|
|
|
875
|
$class = 'MsgPack::Decoder::Generator::' . $class; |
90
|
309
|
|
|
|
|
1074
|
use_module($class)->new( |
91
|
|
|
|
|
|
|
push_decoded => $self->push_decoded, |
92
|
|
|
|
|
|
|
post_next => [ $self->next->@*, $self->post_next->@* ], |
93
|
|
|
|
|
|
|
@args |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
4
|
|
|
4
|
|
3041
|
use experimental 'current_sub'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
18
|
|
98
|
|
|
|
|
|
|
|
99
|
373
|
|
|
373
|
0
|
23258
|
sub read ( $self, $data ) { |
|
373
|
|
|
|
|
682
|
|
|
373
|
|
|
|
|
641
|
|
|
373
|
|
|
|
|
577
|
|
100
|
|
|
|
|
|
|
|
101
|
373
|
|
|
|
|
10557
|
my $left_to_read = $self->bytes - $self->buffer_size; |
102
|
|
|
|
|
|
|
|
103
|
373
|
100
|
|
|
|
18154
|
if ( $left_to_read > 0 ) { |
104
|
260
|
|
|
|
|
752
|
my $mine = substr $data, 0, $left_to_read, ''; |
105
|
260
|
|
|
|
|
6288
|
$self->log->trace( 'reading: ' . join ' ', map { sprintf "%#x", ord } split '', $mine ); |
|
564
|
|
|
|
|
3916
|
|
106
|
260
|
|
|
|
|
10123
|
$self->append_buffer($mine); |
107
|
260
|
|
|
|
|
3514
|
$left_to_read -= length $mine; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
373
|
100
|
|
|
|
875
|
unless ( $left_to_read ) { |
112
|
309
|
|
|
|
|
839
|
@_ = ( $self->next_read, $data ); |
113
|
309
|
|
|
|
|
51016
|
goto __SUB__; |
114
|
|
|
|
|
|
|
#return $self->next_read->read($data); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
64
|
|
|
|
|
1796
|
return $self; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=pod |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=encoding UTF-8 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 NAME |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
MsgPack::Decoder::Generator |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 VERSION |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
version 2.0.2 |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 AUTHOR |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This software is copyright (c) 2019, 2017, 2016, 2015 by Yanick Champoux. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
147
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |