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.3'; |
4
|
4
|
|
|
4
|
|
1986
|
use 5.10.0; |
|
4
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
72
|
|
7
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
95
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
18
|
use List::Util qw/ reduce /; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
241
|
|
10
|
4
|
|
|
4
|
|
25
|
use Module::Runtime qw/ use_module /; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
26
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
1795
|
use Log::Any; |
|
4
|
|
|
|
|
28341
|
|
|
4
|
|
|
|
|
19
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
167
|
use Moose; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
24
|
|
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
24061
|
use MooseX::MungeHas 'is_ro'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
26
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
3715
|
use experimental 'signatures', 'postderef'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
22
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has log => sub { |
21
|
312
|
|
|
312
|
|
4065
|
my $class = ref shift; |
22
|
312
|
|
|
|
|
1015
|
$class =~ s/MsgPack::Decoder::Generator:://; |
23
|
312
|
|
|
|
|
1327
|
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
|
|
5537
|
sub build_next { [] } |
61
|
|
|
|
|
|
|
|
62
|
312
|
|
|
312
|
0
|
376083
|
sub BUILD { $_[0]->log->trace('generator created') } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub buffer_as_int { |
65
|
216
|
|
|
216
|
0
|
705
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
216
|
|
|
35
|
|
5402
|
return reduce { ( $a << 8 ) + $b } map { ord } split '', $self->buffer; |
|
35
|
|
|
|
|
485
|
|
|
251
|
|
|
|
|
4260
|
|
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
|
|
|
|
|
443
|
|
|
309
|
|
|
|
|
362
|
|
85
|
309
|
|
100
|
|
|
8897
|
my $arg = $self->next_args || $self->next_post_next || [ 'Any' ]; |
86
|
|
|
|
|
|
|
|
87
|
309
|
|
|
|
|
14780
|
my( $class, @args ) = @$arg; |
88
|
|
|
|
|
|
|
|
89
|
309
|
|
|
|
|
785
|
$class = 'MsgPack::Decoder::Generator::' . $class; |
90
|
309
|
|
|
|
|
977
|
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
|
|
2655
|
use experimental 'current_sub'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
15
|
|
98
|
|
|
|
|
|
|
|
99
|
373
|
|
|
373
|
0
|
21322
|
sub read ( $self, $data ) { |
|
373
|
|
|
|
|
590
|
|
|
373
|
|
|
|
|
522
|
|
|
373
|
|
|
|
|
553
|
|
100
|
|
|
|
|
|
|
|
101
|
373
|
|
|
|
|
9282
|
my $left_to_read = $self->bytes - $self->buffer_size; |
102
|
|
|
|
|
|
|
|
103
|
373
|
100
|
|
|
|
15475
|
if ( $left_to_read > 0 ) { |
104
|
260
|
|
|
|
|
632
|
my $mine = substr $data, 0, $left_to_read, ''; |
105
|
260
|
|
|
|
|
5345
|
$self->log->trace( 'reading: ' . join ' ', map { sprintf "%#x", ord } split '', $mine ); |
|
564
|
|
|
|
|
3571
|
|
106
|
260
|
|
|
|
|
8823
|
$self->append_buffer($mine); |
107
|
260
|
|
|
|
|
3128
|
$left_to_read -= length $mine; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
373
|
100
|
|
|
|
888
|
unless ( $left_to_read ) { |
112
|
309
|
|
|
|
|
711
|
@_ = ( $self->next_read, $data ); |
113
|
309
|
|
|
|
|
46059
|
goto __SUB__; |
114
|
|
|
|
|
|
|
#return $self->next_read->read($data); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
64
|
|
|
|
|
1719
|
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.3 |
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 |