line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::TxnBuffer::PP; |
2
|
3
|
|
|
3
|
|
1760
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
101
|
|
3
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
91
|
|
4
|
3
|
|
|
3
|
|
16
|
use parent 'Data::TxnBuffer::Base'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
180
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
245
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# pp interface |
9
|
3
|
|
|
3
|
|
15
|
use constant LITTLE_ENDIAN => !(unpack('S', pack('C2', 0, 1)) == 1); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
4128
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
11
|
|
|
11
|
1
|
8283
|
my ($class, $data) = @_; |
13
|
|
|
|
|
|
|
|
14
|
11
|
100
|
|
|
|
62
|
bless { |
15
|
|
|
|
|
|
|
cursor => 0, |
16
|
|
|
|
|
|
|
data => defined $data ? $data : '', |
17
|
|
|
|
|
|
|
}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub data { |
21
|
40
|
|
|
40
|
1
|
1393
|
my ($self) = @_; |
22
|
40
|
|
|
|
|
102
|
$self->{data}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub length { |
26
|
32
|
|
|
32
|
1
|
33
|
my ($self) = @_; |
27
|
32
|
|
|
|
|
94
|
CORE::length($self->{data}); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub cursor { |
31
|
69
|
|
|
69
|
1
|
67
|
my ($self) = @_; |
32
|
69
|
|
|
|
|
159
|
$self->{cursor}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub spin { |
36
|
4
|
|
|
4
|
1
|
7
|
my ($self) = @_; |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
10
|
my $read = substr $self->{data}, 0, $self->cursor; |
39
|
4
|
|
|
|
|
7
|
substr($self->{data}, 0, $self->cursor) = ''; |
40
|
4
|
|
|
|
|
8
|
$self->reset; |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
11
|
$read; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub reset { |
46
|
17
|
|
|
17
|
1
|
20
|
my ($self) = @_; |
47
|
17
|
|
|
|
|
21
|
$self->{cursor} = 0; |
48
|
17
|
|
|
|
|
25
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub clear { |
52
|
8
|
|
|
8
|
1
|
13
|
my ($self) = @_; |
53
|
8
|
|
|
|
|
12
|
$self->reset; |
54
|
8
|
|
|
|
|
13
|
$self->{data} = ''; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub write { |
58
|
26
|
|
|
26
|
1
|
1420
|
my ($self, $data) = @_; |
59
|
26
|
|
|
|
|
67
|
$self->{data} .= $data; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub read { |
63
|
30
|
|
|
30
|
1
|
46
|
my ($self, $len) = @_; |
64
|
|
|
|
|
|
|
|
65
|
30
|
50
|
|
|
|
76
|
if ($len <= 0) { |
66
|
0
|
|
|
|
|
0
|
croak sprintf 'Positive value is required for read len. got: %d', $len; |
67
|
|
|
|
|
|
|
} |
68
|
30
|
100
|
|
|
|
58
|
if ($self->cursor + $len > $self->length) { |
69
|
2
|
|
|
|
|
376
|
croak 'No enough data in buffer'; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
28
|
|
|
|
|
51
|
my $data = substr $self->data, $self->cursor, $len; |
73
|
28
|
|
|
|
|
38
|
$self->{cursor} += $len; |
74
|
|
|
|
|
|
|
|
75
|
28
|
|
|
|
|
107
|
$data; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub write_u32 { |
79
|
2
|
|
|
2
|
1
|
10
|
my ($self, $n) = @_; |
80
|
2
|
|
|
|
|
8
|
$self->write(pack 'L', $n); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub write_i32 { |
84
|
2
|
|
|
2
|
1
|
3
|
my ($self, $n) = @_; |
85
|
2
|
|
|
|
|
8
|
$self->write(pack 'l', $n); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub read_u32 { |
89
|
1
|
|
|
1
|
1
|
8
|
my ($self) = @_; |
90
|
1
|
|
|
|
|
2
|
unpack 'L', $self->read(4); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub read_i32 { |
94
|
2
|
|
|
2
|
1
|
3
|
my ($self) = @_; |
95
|
2
|
|
|
|
|
5
|
unpack 'l', $self->read(4); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub write_u24 { |
99
|
2
|
|
|
2
|
1
|
10
|
my ($self, $n) = @_; |
100
|
2
|
|
|
|
|
5
|
my $data = pack 'L', $n; |
101
|
|
|
|
|
|
|
|
102
|
2
|
|
|
|
|
2
|
if (LITTLE_ENDIAN) { |
103
|
2
|
|
|
|
|
7
|
$self->{data} .= substr $data, 0, 3; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
else { |
106
|
|
|
|
|
|
|
$self->{data} .= substr $data, 1, 3; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub write_i24 { |
111
|
2
|
|
|
2
|
1
|
4
|
my ($self, $n) = @_; |
112
|
2
|
|
|
|
|
4
|
my $data = pack 'l', $n; |
113
|
|
|
|
|
|
|
|
114
|
2
|
|
|
|
|
3
|
if (LITTLE_ENDIAN) { |
115
|
2
|
|
|
|
|
5
|
$self->{data} .= substr $data, 0, 3; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
else { |
118
|
|
|
|
|
|
|
$self->{data} .= substr $data, 1, 3; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub read_u24 { |
123
|
3
|
|
|
3
|
1
|
10
|
my ($self) = @_; |
124
|
|
|
|
|
|
|
|
125
|
3
|
|
|
|
|
5
|
my $data = $self->read(3); |
126
|
3
|
|
|
|
|
3
|
if (LITTLE_ENDIAN) { |
127
|
3
|
|
|
|
|
13
|
$data .= pack 'C', 0; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
else { |
130
|
|
|
|
|
|
|
$data = pack('C', 0) . $data; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
3
|
|
|
|
|
8
|
unpack 'L', $data; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub read_i24 { |
137
|
2
|
|
|
2
|
1
|
4
|
my ($self) = @_; |
138
|
|
|
|
|
|
|
|
139
|
2
|
|
|
|
|
3
|
my $n = $self->read_u24; |
140
|
2
|
100
|
|
|
|
7
|
$n |= 0xff000000 if ($n & 0x800000); |
141
|
|
|
|
|
|
|
|
142
|
2
|
|
|
|
|
8
|
unpack 'l', pack 'l', $n; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub write_u16 { |
146
|
2
|
|
|
2
|
1
|
9
|
my ($self, $n) = @_; |
147
|
2
|
|
|
|
|
7
|
$self->write(pack 'S', $n); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub write_i16 { |
151
|
2
|
|
|
2
|
1
|
4
|
my ($self, $n) = @_; |
152
|
2
|
|
|
|
|
7
|
$self->write(pack 's', $n); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub read_u16 { |
156
|
1
|
|
|
1
|
1
|
9
|
my ($self) = @_; |
157
|
1
|
|
|
|
|
3
|
unpack 'S', $self->read(2); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub read_i16 { |
161
|
2
|
|
|
2
|
1
|
4
|
my ($self) = @_; |
162
|
2
|
|
|
|
|
4
|
unpack 's', $self->read(2); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub write_u8 { |
166
|
1
|
|
|
1
|
1
|
8
|
my ($self, $n) = @_; |
167
|
1
|
|
|
|
|
5
|
$self->write(pack 'C', $n); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub write_i8 { |
171
|
1
|
|
|
1
|
1
|
3
|
my ($self, $n) = @_; |
172
|
1
|
|
|
|
|
6
|
$self->write(pack 'c', $n); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub read_u8 { |
176
|
1
|
|
|
1
|
1
|
8
|
my ($self) = @_; |
177
|
1
|
|
|
|
|
2
|
unpack 'C', $self->read(1); |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub read_i8 { |
181
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
182
|
1
|
|
|
|
|
3
|
unpack 'c', $self->read(1); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub write_n32 { |
186
|
3
|
|
|
3
|
1
|
12
|
my ($self, $n) = @_; |
187
|
3
|
|
|
|
|
13
|
$self->write(pack 'N', $n); |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub read_n32 { |
191
|
2
|
|
|
2
|
1
|
12
|
my ($self) = @_; |
192
|
2
|
|
|
|
|
9
|
unpack 'N', $self->read(4); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub write_n24 { |
196
|
3
|
|
|
3
|
1
|
14
|
my ($self, $n) = @_; |
197
|
3
|
|
|
|
|
10
|
$self->write(substr pack('N', $n), 1, 3); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub read_n24 { |
201
|
2
|
|
|
2
|
1
|
10
|
my ($self) = @_; |
202
|
2
|
|
|
|
|
4
|
unpack 'N', pack('C', 0) . $self->read(3); |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub write_n16 { |
206
|
3
|
|
|
3
|
1
|
12
|
my ($self, $n) = @_; |
207
|
3
|
|
|
|
|
11
|
$self->write(pack 'n', $n); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub read_n16 { |
211
|
2
|
|
|
2
|
1
|
40
|
my ($self) = @_; |
212
|
2
|
|
|
|
|
4
|
unpack 'n', $self->read(2); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub write_float { |
216
|
1
|
|
|
1
|
1
|
11
|
my ($self, $n) = @_; |
217
|
1
|
|
|
|
|
4
|
$self->write(pack 'f', $n); |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub read_float { |
221
|
1
|
|
|
1
|
1
|
8
|
my ($self) = @_; |
222
|
1
|
|
|
|
|
3
|
unpack 'f', $self->read(4); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub write_double { |
226
|
1
|
|
|
1
|
1
|
4
|
my ($self, $n) = @_; |
227
|
1
|
|
|
|
|
5
|
$self->write(pack 'd', $n); |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub read_double { |
231
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
232
|
1
|
|
|
|
|
3
|
unpack 'd', $self->read(8); |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
1; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
__END__ |