| 1 | # | ||||||||||
| 2 | # Licensed to the Apache Software Foundation (ASF) under one | ||||||||||
| 3 | # or more contributor license agreements. See the NOTICE file | ||||||||||
| 4 | # distributed with this work for additional information | ||||||||||
| 5 | # regarding copyright ownership. The ASF licenses this file | ||||||||||
| 6 | # to you under the Apache License, Version 2.0 (the | ||||||||||
| 7 | # "License"); you may not use this file except in compliance | ||||||||||
| 8 | # with the License. You may obtain a copy of the License at | ||||||||||
| 9 | # | ||||||||||
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| 11 | # | ||||||||||
| 12 | # Unless required by applicable law or agreed to in writing, | ||||||||||
| 13 | # software distributed under the License is distributed on an | ||||||||||
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||||||||
| 15 | # KIND, either express or implied. See the License for the | ||||||||||
| 16 | # specific language governing permissions and limitations | ||||||||||
| 17 | # under the License. | ||||||||||
| 18 | # | ||||||||||
| 19 | |||||||||||
| 20 | 3 | ▶ | use 5.10.0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 3 | ▶ | use Bit::Vector; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 3 | ▶ | use Encode; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 3 | ▶ | use Thrift; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 3 | ▶ | use Thrift::Exception; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 3 | ▶ | use Thrift::MessageType; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 3 | ▶ | use Thrift::Protocol; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 3 | ▶ | use Thrift::Type; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 3 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | |||||||||||
| 33 | # | ||||||||||
| 34 | # Binary implementation of the Thrift protocol. | ||||||||||
| 35 | # | ||||||||||
| 36 | package Thrift::BinaryProtocol; | ||||||||||
| 37 | 3 | ▶ | use base('Thrift::Protocol'); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 3 | ▶ | use version 0.77; our $VERSION = version->declare("$Thrift::VERSION"); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | |||||||||||
| 40 | 3 | ▶ | use constant VERSION_MASK => 0xffff0000; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | 3 | ▶ | use constant VERSION_1 => 0x80010000; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | 3 | ▶ | use constant IS_BIG_ENDIAN => unpack('h*', pack('s', 1)) =~ m/01/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | |||||||||||
| 44 | sub new | ||||||||||
| 45 | 8 | ▶ | { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 46 | 8 | my $classname = shift; | |||||||||
| 47 | 8 | my $trans = shift; | |||||||||
| 48 | 8 | my $self = $classname->SUPER::new($trans); | |||||||||
| 49 | |||||||||||
| 50 | 8 | return bless($self,$classname); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | sub writeMessageBegin | ||||||||||
| 54 | 26 | ▶ | { | ||||||||
|
Subroutine
writeMessageBegin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 55 | 26 | my $self = shift; | |||||||||
| 56 | 26 | my ($name, $type, $seqid) = @_; | |||||||||
| 57 | |||||||||||
| 58 | return | ||||||||||
| 59 | 26 | $self->writeI32(VERSION_1 | $type) + | |||||||||
| 60 | $self->writeString($name) + | ||||||||||
| 61 | $self->writeI32($seqid); | ||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | sub writeMessageEnd | ||||||||||
| 65 | 26 | ▶ | { | ||||||||
|
Subroutine
writeMessageEnd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 66 | 26 | my $self = shift; | |||||||||
| 67 | 26 | return 0; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | sub writeStructBegin | ||||||||||
| 71 | 28 | ▶ | { | ||||||||
|
Subroutine
writeStructBegin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 72 | 28 | my $self = shift; | |||||||||
| 73 | 28 | my $name = shift; | |||||||||
| 74 | 28 | return 0; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | sub writeStructEnd | ||||||||||
| 78 | 28 | ▶ | { | ||||||||
|
Subroutine
writeStructEnd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 79 | 28 | my $self = shift; | |||||||||
| 80 | 28 | return 0; | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | sub writeFieldBegin | ||||||||||
| 84 | 26 | ▶ | { | ||||||||
|
Subroutine
writeFieldBegin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 85 | 26 | my $self = shift; | |||||||||
| 86 | 26 | my ($fieldName, $fieldType, $fieldId) = @_; | |||||||||
| 87 | |||||||||||
| 88 | return | ||||||||||
| 89 | 26 | $self->writeByte($fieldType) + | |||||||||
| 90 | $self->writeI16($fieldId); | ||||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | sub writeFieldEnd | ||||||||||
| 94 | 26 | ▶ | { | ||||||||
|
Subroutine
writeFieldEnd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 95 | 26 | my $self = shift; | |||||||||
| 96 | 26 | return 0; | |||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | sub writeFieldStop | ||||||||||
| 100 | 28 | ▶ | { | ||||||||
|
Subroutine
writeFieldStop: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 101 | 28 | my $self = shift; | |||||||||
| 102 | 28 | return $self->writeByte(Thrift::TType::STOP); | |||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | sub writeMapBegin | ||||||||||
| 106 | 0 | ▶ | { | ||||||||
|
Subroutine
writeMapBegin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 107 | 0 | my $self = shift; | |||||||||
| 108 | 0 | my ($keyType, $valType, $size) = @_; | |||||||||
| 109 | |||||||||||
| 110 | return | ||||||||||
| 111 | 0 | $self->writeByte($keyType) + | |||||||||
| 112 | $self->writeByte($valType) + | ||||||||||
| 113 | $self->writeI32($size); | ||||||||||
| 114 | } | ||||||||||
| 115 | |||||||||||
| 116 | sub writeMapEnd | ||||||||||
| 117 | 0 | ▶ | { | ||||||||
|
Subroutine
writeMapEnd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 118 | 0 | my $self = shift; | |||||||||
| 119 | 0 | return 0; | |||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | sub writeListBegin | ||||||||||
| 123 | 1 | ▶ | { | ||||||||
|
Subroutine
writeListBegin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 124 | 1 | my $self = shift; | |||||||||
| 125 | 1 | my ($elemType, $size) = @_; | |||||||||
| 126 | |||||||||||
| 127 | return | ||||||||||
| 128 | 1 | $self->writeByte($elemType) + | |||||||||
| 129 | $self->writeI32($size); | ||||||||||
| 130 | } | ||||||||||
| 131 | |||||||||||
| 132 | sub writeListEnd | ||||||||||
| 133 | 1 | ▶ | { | ||||||||
|
Subroutine
writeListEnd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 134 | 1 | my $self = shift; | |||||||||
| 135 | 1 | return 0; | |||||||||
| 136 | } | ||||||||||
| 137 | |||||||||||
| 138 | sub writeSetBegin | ||||||||||
| 139 | 0 | ▶ | { | ||||||||
|
Subroutine
writeSetBegin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 140 | 0 | my $self = shift; | |||||||||
| 141 | 0 | my ($elemType, $size) = @_; | |||||||||
| 142 | |||||||||||
| 143 | return | ||||||||||
| 144 | 0 | $self->writeByte($elemType) + | |||||||||
| 145 | $self->writeI32($size); | ||||||||||
| 146 | } | ||||||||||
| 147 | |||||||||||
| 148 | sub writeSetEnd | ||||||||||
| 149 | 0 | ▶ | { | ||||||||
|
Subroutine
writeSetEnd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 150 | 0 | my $self = shift; | |||||||||
| 151 | 0 | return 0; | |||||||||
| 152 | } | ||||||||||
| 153 | |||||||||||
| 154 | sub writeBool | ||||||||||
| 155 | 0 | ▶ | { | ||||||||
|
Subroutine
writeBool: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 156 | 0 | my $self = shift; | |||||||||
| 157 | 0 | my $value = shift; | |||||||||
| 158 | |||||||||||
| 159 | 0 | ▶ | my $data = pack('c', $value ? 1 : 0); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 160 | 0 | $self->{trans}->write($data, 1); | |||||||||
| 161 | 0 | return 1; | |||||||||
| 162 | } | ||||||||||
| 163 | |||||||||||
| 164 | sub writeByte | ||||||||||
| 165 | 60 | ▶ | { | ||||||||
|
Subroutine
writeByte: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 166 | 60 | my $self = shift; | |||||||||
| 167 | 60 | my $value= shift; | |||||||||
| 168 | |||||||||||
| 169 | 60 | my $data = pack('c', $value); | |||||||||
| 170 | 60 | $self->{trans}->write($data, 1); | |||||||||
| 171 | 60 | return 1; | |||||||||
| 172 | } | ||||||||||
| 173 | |||||||||||
| 174 | sub writeI16 | ||||||||||
| 175 | 26 | ▶ | { | ||||||||
|
Subroutine
writeI16: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 176 | 26 | my $self = shift; | |||||||||
| 177 | 26 | my $value= shift; | |||||||||
| 178 | |||||||||||
| 179 | 26 | my $data = pack('n', $value); | |||||||||
| 180 | 26 | $self->{trans}->write($data, 2); | |||||||||
| 181 | 26 | return 2; | |||||||||
| 182 | } | ||||||||||
| 183 | |||||||||||
| 184 | sub writeI32 | ||||||||||
| 185 | 102 | ▶ | { | ||||||||
|
Subroutine
writeI32: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 186 | 102 | my $self = shift; | |||||||||
| 187 | 102 | my $value= shift; | |||||||||
| 188 | |||||||||||
| 189 | 102 | my $data = pack('N', $value); | |||||||||
| 190 | 102 | $self->{trans}->write($data, 4); | |||||||||
| 191 | 102 | return 4; | |||||||||
| 192 | } | ||||||||||
| 193 | |||||||||||
| 194 | sub writeI64 | ||||||||||
| 195 | 2 | ▶ | { | ||||||||
|
Subroutine
writeI64: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 196 | 2 | my $self = shift; | |||||||||
| 197 | 2 | my $value= shift; | |||||||||
| 198 | 2 | my $data; | |||||||||
| 199 | |||||||||||
| 200 | my $vec; | ||||||||||
| 201 | #stop annoying error | ||||||||||
| 202 | 2 | $vec = Bit::Vector->new_Dec(64, $value); | |||||||||
| 203 | 2 | $data = pack 'NN', $vec->Chunk_Read(32, 32), $vec->Chunk_Read(32, 0); | |||||||||
| 204 | |||||||||||
| 205 | 2 | $self->{trans}->write($data, 8); | |||||||||
| 206 | |||||||||||
| 207 | 2 | return 8; | |||||||||
| 208 | } | ||||||||||
| 209 | |||||||||||
| 210 | |||||||||||
| 211 | sub writeDouble | ||||||||||
| 212 | 0 | ▶ | { | ||||||||
|
Subroutine
writeDouble: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 213 | 0 | my $self = shift; | |||||||||
| 214 | 0 | my $value= shift; | |||||||||
| 215 | |||||||||||
| 216 | 0 | my $data = pack('d', $value); | |||||||||
| 217 | 0 | ▶ | if (IS_BIG_ENDIAN) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 218 | 0 | $self->{trans}->write($data, 8); | |||||||||
| 219 | } | ||||||||||
| 220 | else { | ||||||||||
| 221 | 0 | $self->{trans}->write(scalar reverse($data), 8); | |||||||||
| 222 | } | ||||||||||
| 223 | 0 | return 8; | |||||||||
| 224 | } | ||||||||||
| 225 | |||||||||||
| 226 | 32 | ▶ | sub writeString{ | ||||||||
|
Subroutine
writeString: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||
| 227 | 32 | my $self = shift; | |||||||||
| 228 | 32 | my $value= shift; | |||||||||
| 229 | |||||||||||
| 230 | 32 | ▶ | if( utf8::is_utf8($value) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 231 | 0 | $value = Encode::encode_utf8($value); | |||||||||
| 232 | } | ||||||||||
| 233 | |||||||||||
| 234 | 32 | my $len = length($value); | |||||||||
| 235 | |||||||||||
| 236 | 32 | my $result = $self->writeI32($len); | |||||||||
| 237 | |||||||||||
| 238 | 32 | ▶ | if ($len) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 239 | 32 | $self->{trans}->write($value,$len); | |||||||||
| 240 | } | ||||||||||
| 241 | 32 | return $result + $len; | |||||||||
| 242 | } | ||||||||||
| 243 | |||||||||||
| 244 | |||||||||||
| 245 | # | ||||||||||
| 246 | #All references | ||||||||||
| 247 | # | ||||||||||
| 248 | sub readMessageBegin | ||||||||||
| 249 | 26 | ▶ | { | ||||||||
|
Subroutine
readMessageBegin: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||
| 250 | 26 | my $self = shift; | |||||||||
| 251 | 26 | my ($name, $type, $seqid) = @_; | |||||||||
| 252 | |||||||||||
| 253 | 26 | my $version = 0; | |||||||||
| 254 | 26 | my $result = $self->readI32(\$version); | |||||||||
| 255 | 26 | ▶ | if (($version & VERSION_MASK) > 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 256 | 26 | ▶ | if (($version & VERSION_MASK) != VERSION_1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 257 | 0 | die Thrift::TProtocolException->new('Missing version identifier', | |||||||||
| 258 | Thrift::TProtocolException::BAD_VERSION); | ||||||||||
| 259 | } | ||||||||||
| 260 | 26 | $$type = $version & 0x000000ff; | |||||||||
| 261 | return | ||||||||||
| 262 | 26 | $result + | |||||||||
| 263 | $self->readString($name) + | ||||||||||
| 264 | $self->readI32($seqid); | ||||||||||
| 265 | } | ||||||||||
| 266 | else { # old client support code | ||||||||||
| 267 | return | ||||||||||
| 268 | 0 | $result + | |||||||||
| 269 | $self->readStringBody($name, $version) + # version here holds the size of the string | ||||||||||
| 270 | $self->readByte($type) + | ||||||||||
| 271 | $self->readI32($seqid); | ||||||||||
| 272 | } | ||||||||||
| 273 | } | ||||||||||
| 274 | |||||||||||
| 275 | sub readMessageEnd | ||||||||||
| 276 | 26 | ▶ | { | ||||||||
|
Subroutine
readMessageEnd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 277 | 26 | my $self = shift; | |||||||||
| 278 | 26 | return 0; | |||||||||
| 279 | } | ||||||||||
| 280 | |||||||||||
| 281 | sub readStructBegin | ||||||||||
| 282 | 28 | ▶ | { | ||||||||
|
Subroutine
readStructBegin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 283 | 28 | my $self = shift; | |||||||||
| 284 | 28 | my $name = shift; | |||||||||
| 285 | |||||||||||
| 286 | 28 | $$name = ''; | |||||||||
| 287 | |||||||||||
| 288 | 28 | return 0; | |||||||||
| 289 | } | ||||||||||
| 290 | |||||||||||
| 291 | sub readStructEnd | ||||||||||
| 292 | 28 | ▶ | { | ||||||||
|
Subroutine
readStructEnd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 293 | 28 | my $self = shift; | |||||||||
| 294 | 28 | return 0; | |||||||||
| 295 | } | ||||||||||
| 296 | |||||||||||
| 297 | sub readFieldBegin | ||||||||||
| 298 | 54 | ▶ | { | ||||||||
|
Subroutine
readFieldBegin: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 299 | 54 | my $self = shift; | |||||||||
| 300 | 54 | my ($name, $fieldType, $fieldId) = @_; | |||||||||
| 301 | |||||||||||
| 302 | 54 | my $result = $self->readByte($fieldType); | |||||||||
| 303 | |||||||||||
| 304 | 54 | ▶ | if ($$fieldType == Thrift::TType::STOP) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 305 | 28 | $$fieldId = 0; | |||||||||
| 306 | 28 | return $result; | |||||||||
| 307 | } | ||||||||||
| 308 | |||||||||||
| 309 | 26 | $result += $self->readI16($fieldId); | |||||||||
| 310 | |||||||||||
| 311 | 26 | return $result; | |||||||||
| 312 | } | ||||||||||
| 313 | |||||||||||
| 314 | 26 | ▶ | sub readFieldEnd() { | ||||||||
|
Subroutine
readFieldEnd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 315 | 26 | my $self = shift; | |||||||||
| 316 | 26 | return 0; | |||||||||
| 317 | } | ||||||||||
| 318 | |||||||||||
| 319 | sub readMapBegin | ||||||||||
| 320 | 0 | ▶ | { | ||||||||
|
Subroutine
readMapBegin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 321 | 0 | my $self = shift; | |||||||||
| 322 | 0 | my ($keyType, $valType, $size) = @_; | |||||||||
| 323 | |||||||||||
| 324 | return | ||||||||||
| 325 | 0 | $self->readByte($keyType) + | |||||||||
| 326 | $self->readByte($valType) + | ||||||||||
| 327 | $self->readI32($size); | ||||||||||
| 328 | } | ||||||||||
| 329 | |||||||||||
| 330 | sub readMapEnd() | ||||||||||
| 331 | 0 | ▶ | { | ||||||||
|
Subroutine
readMapEnd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 332 | 0 | my $self = shift; | |||||||||
| 333 | 0 | return 0; | |||||||||
| 334 | } | ||||||||||
| 335 | |||||||||||
| 336 | sub readListBegin | ||||||||||
| 337 | 1 | ▶ | { | ||||||||
|
Subroutine
readListBegin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 338 | 1 | my $self = shift; | |||||||||
| 339 | 1 | my ($elemType, $size) = @_; | |||||||||
| 340 | |||||||||||
| 341 | return | ||||||||||
| 342 | 1 | $self->readByte($elemType) + | |||||||||
| 343 | $self->readI32($size); | ||||||||||
| 344 | } | ||||||||||
| 345 | |||||||||||
| 346 | sub readListEnd | ||||||||||
| 347 | 1 | ▶ | { | ||||||||
|
Subroutine
readListEnd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 348 | 1 | my $self = shift; | |||||||||
| 349 | 1 | return 0; | |||||||||
| 350 | } | ||||||||||
| 351 | |||||||||||
| 352 | sub readSetBegin | ||||||||||
| 353 | 0 | ▶ | { | ||||||||
|
Subroutine
readSetBegin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 354 | 0 | my $self = shift; | |||||||||
| 355 | 0 | my ($elemType, $size) = @_; | |||||||||
| 356 | |||||||||||
| 357 | return | ||||||||||
| 358 | 0 | $self->readByte($elemType) + | |||||||||
| 359 | $self->readI32($size); | ||||||||||
| 360 | } | ||||||||||
| 361 | |||||||||||
| 362 | sub readSetEnd | ||||||||||
| 363 | 0 | ▶ | { | ||||||||
|
Subroutine
readSetEnd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 364 | 0 | my $self = shift; | |||||||||
| 365 | 0 | return 0; | |||||||||
| 366 | } | ||||||||||
| 367 | |||||||||||
| 368 | sub readBool | ||||||||||
| 369 | 0 | ▶ | { | ||||||||
|
Subroutine
readBool: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 370 | 0 | my $self = shift; | |||||||||
| 371 | 0 | my $value = shift; | |||||||||
| 372 | |||||||||||
| 373 | 0 | my $data = $self->{trans}->readAll(1); | |||||||||
| 374 | 0 | my @arr = unpack('c', $data); | |||||||||
| 375 | 0 | $$value = $arr[0] == 1; | |||||||||
| 376 | 0 | return 1; | |||||||||
| 377 | } | ||||||||||
| 378 | |||||||||||
| 379 | sub readByte | ||||||||||
| 380 | 61 | ▶ | { | ||||||||
|
Subroutine
readByte: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 381 | 61 | my $self = shift; | |||||||||
| 382 | 61 | my $value = shift; | |||||||||
| 383 | |||||||||||
| 384 | 61 | my $data = $self->{trans}->readAll(1); | |||||||||
| 385 | 60 | my @arr = unpack('c', $data); | |||||||||
| 386 | 60 | $$value = $arr[0]; | |||||||||
| 387 | 60 | return 1; | |||||||||
| 388 | } | ||||||||||
| 389 | |||||||||||
| 390 | sub readI16 | ||||||||||
| 391 | 26 | ▶ | { | ||||||||
|
Subroutine
readI16: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 392 | 26 | my $self = shift; | |||||||||
| 393 | 26 | my $value = shift; | |||||||||
| 394 | |||||||||||
| 395 | 26 | my $data = $self->{trans}->readAll(2); | |||||||||
| 396 | |||||||||||
| 397 | 26 | my @arr = unpack('n', $data); | |||||||||
| 398 | |||||||||||
| 399 | 26 | $$value = $arr[0]; | |||||||||
| 400 | |||||||||||
| 401 | 26 | ▶ | if ($$value > 0x7fff) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 402 | 0 | $$value = 0 - (($$value - 1) ^ 0xffff); | |||||||||
| 403 | } | ||||||||||
| 404 | |||||||||||
| 405 | 26 | return 2; | |||||||||
| 406 | } | ||||||||||
| 407 | |||||||||||
| 408 | sub readI32 | ||||||||||
| 409 | 102 | ▶ | { | ||||||||
|
Subroutine
readI32: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 410 | 102 | my $self = shift; | |||||||||
| 411 | 102 | my $value= shift; | |||||||||
| 412 | |||||||||||
| 413 | 102 | my $data = $self->{trans}->readAll(4); | |||||||||
| 414 | 102 | my @arr = unpack('N', $data); | |||||||||
| 415 | |||||||||||
| 416 | 102 | $$value = $arr[0]; | |||||||||
| 417 | 102 | ▶ | if ($$value > 0x7fffffff) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 418 | 26 | $$value = 0 - (($$value - 1) ^ 0xffffffff); | |||||||||
| 419 | } | ||||||||||
| 420 | 102 | return 4; | |||||||||
| 421 | } | ||||||||||
| 422 | |||||||||||
| 423 | sub readI64 | ||||||||||
| 424 | 2 | ▶ | { | ||||||||
|
Subroutine
readI64: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 425 | 2 | my $self = shift; | |||||||||
| 426 | 2 | my $value = shift; | |||||||||
| 427 | |||||||||||
| 428 | 2 | my $data = $self->{trans}->readAll(8); | |||||||||
| 429 | |||||||||||
| 430 | 2 | my ($hi,$lo)=unpack('NN',$data); | |||||||||
| 431 | |||||||||||
| 432 | 2 | my $vec = Bit::Vector->new(64); | |||||||||
| 433 | |||||||||||
| 434 | 2 | $vec->Chunk_Store(32,32,$hi); | |||||||||
| 435 | 2 | $vec->Chunk_Store(32,0,$lo); | |||||||||
| 436 | |||||||||||
| 437 | 2 | $$value = $vec->to_Dec(); | |||||||||
| 438 | |||||||||||
| 439 | 2 | return 8; | |||||||||
| 440 | } | ||||||||||
| 441 | |||||||||||
| 442 | sub readDouble | ||||||||||
| 443 | 0 | ▶ | { | ||||||||
|
Subroutine
readDouble: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 444 | 0 | my $self = shift; | |||||||||
| 445 | 0 | my $value = shift; | |||||||||
| 446 | |||||||||||
| 447 | 0 | my $data; | |||||||||
| 448 | 0 | ▶ | if (IS_BIG_ENDIAN) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 449 | 0 | $data = $self->{trans}->readAll(8); | |||||||||
| 450 | } | ||||||||||
| 451 | else { | ||||||||||
| 452 | 0 | $data = scalar reverse($self->{trans}->readAll(8)); | |||||||||
| 453 | } | ||||||||||
| 454 | |||||||||||
| 455 | 0 | my @arr = unpack('d', $data); | |||||||||
| 456 | |||||||||||
| 457 | 0 | $$value = $arr[0]; | |||||||||
| 458 | |||||||||||
| 459 | 0 | return 8; | |||||||||
| 460 | } | ||||||||||
| 461 | |||||||||||
| 462 | sub readString | ||||||||||
| 463 | 32 | ▶ | { | ||||||||
|
Subroutine
readString: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 464 | 32 | my $self = shift; | |||||||||
| 465 | 32 | my $value = shift; | |||||||||
| 466 | |||||||||||
| 467 | 32 | my $len; | |||||||||
| 468 | 32 | my $result = $self->readI32(\$len); | |||||||||
| 469 | |||||||||||
| 470 | 32 | ▶ | if ($len) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 471 | 32 | $$value = $self->{trans}->readAll($len); | |||||||||
| 472 | } | ||||||||||
| 473 | else { | ||||||||||
| 474 | 0 | $$value = ''; | |||||||||
| 475 | } | ||||||||||
| 476 | |||||||||||
| 477 | 32 | return $result + $len; | |||||||||
| 478 | } | ||||||||||
| 479 | |||||||||||
| 480 | sub readStringBody | ||||||||||
| 481 | 0 | ▶ | { | ||||||||
|
Subroutine
readStringBody: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 482 | 0 | my $self = shift; | |||||||||
| 483 | 0 | my $value = shift; | |||||||||
| 484 | 0 | my $len = shift; | |||||||||
| 485 | |||||||||||
| 486 | 0 | ▶ | if ($len) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 487 | 0 | $$value = $self->{trans}->readAll($len); | |||||||||
| 488 | } | ||||||||||
| 489 | else { | ||||||||||
| 490 | 0 | $$value = ''; | |||||||||
| 491 | } | ||||||||||
| 492 | |||||||||||
| 493 | 0 | return $len; | |||||||||
| 494 | } | ||||||||||
| 495 | |||||||||||
| 496 | # | ||||||||||
| 497 | # Binary Protocol Factory | ||||||||||
| 498 | # | ||||||||||
| 499 | package Thrift::BinaryProtocolFactory; | ||||||||||
| 500 | 3 | ▶ | use base('Thrift::TProtocolFactory'); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 501 | 3 | ▶ | use version 0.77; our $VERSION = version->declare("$Thrift::VERSION"); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 502 | |||||||||||
| 503 | sub new | ||||||||||
| 504 | 2 | ▶ | { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||
| 505 | 2 | my $classname = shift; | |||||||||
| 506 | 2 | my $self = $classname->SUPER::new(); | |||||||||
| 507 | |||||||||||
| 508 | 2 | return bless($self,$classname); | |||||||||
| 509 | } | ||||||||||
| 510 | |||||||||||
| 511 | 4 | ▶ | sub getProtocol{ | ||||||||
|
Subroutine
getProtocol: called CC=1 SCAR=0.0
| |||||||||||
| 512 | 4 | my $self = shift; | |||||||||
| 513 | 4 | my $trans = shift; | |||||||||
| 514 | |||||||||||
| 515 | 4 | return Thrift::BinaryProtocol->new($trans); | |||||||||
| 516 | } | ||||||||||
| 517 | |||||||||||
| 518 | 3 | 1; | |||||||||