| 1 | # | ||||||||||||||
| 2 | # Autogenerated by Thrift Compiler (0.22.0) | ||||||||||||||
| 3 | # | ||||||||||||||
| 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | ||||||||||||||
| 5 | # | ||||||||||||||
| 6 | 1 | ▶ | use 5.10.0; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 1 | ▶ | use Thrift::Exception; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 1 | ▶ | use Thrift::MessageType; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 1 | ▶ | use Thrift::Type; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | ▶ | use Types; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | |||||||||||||||
| 16 | # HELPER FUNCTIONS AND STRUCTURES | ||||||||||||||
| 17 | |||||||||||||||
| 18 | package BenchmarkService_fibonacci_args; | ||||||||||||||
| 19 | 1 | ▶ | use base qw(Class::Accessor); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | 1 | BenchmarkService_fibonacci_args->mk_accessors( qw( n ) ); | |||||||||||||
| 21 | |||||||||||||||
| 22 | 10 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.8
| |||||||||||||||
| 23 | 10 | my $classname = shift; | |||||||||||||
| 24 | 10 | my $self = {}; | |||||||||||||
| 25 | 10 | ▶ | my $vals = shift || {}; | ||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||
| 26 | 10 | $self->{n} = undef; | |||||||||||||
| 27 | 10 | ▶ | if (UNIVERSAL::isa($vals,'HASH')) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 28 | 10 | ▶ | if (defined $vals->{n}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 29 | 0 | $self->{n} = $vals->{n}; | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | } | ||||||||||||||
| 32 | 10 | return bless ($self, $classname); | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | |||||||||||||||
| 35 | 0 | ▶ | sub getName { | ||||||||||||
|
Subroutine
getName: not called CC=1 SCAR=6.9
| |||||||||||||||
| 36 | 0 | return 'BenchmarkService_fibonacci_args'; | |||||||||||||
| 37 | } | ||||||||||||||
| 38 | |||||||||||||||
| 39 | 5 | ▶ | sub read { | ||||||||||||
|
Subroutine
read: called CC=5 SCAR=16.3
| |||||||||||||||
| 40 | 5 | my ($self, $input) = @_; | |||||||||||||
| 41 | 5 | my $xfer = 0; | |||||||||||||
| 42 | 5 | my $fname; | |||||||||||||
| 43 | 5 | my $ftype = 0; | |||||||||||||
| 44 | 5 | my $fid = 0; | |||||||||||||
| 45 | 5 | $xfer += $input->readStructBegin(\$fname); | |||||||||||||
| 46 | 5 | while (1) | |||||||||||||
| 47 | { | ||||||||||||||
| 48 | 10 | $xfer += $input->readFieldBegin(\$fname, \$ftype, \$fid); | |||||||||||||
| 49 | 10 | ▶ | if ($ftype == Thrift::TType::STOP) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | 5 | last; | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | 5 | SWITCH: for($fid) | |||||||||||||
| 53 | { | ||||||||||||||
| 54 | 5 | ▶ | /^1$/ && do{ if ($ftype == Thrift::TType::BYTE) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 55 | 5 | $xfer += $input->readByte(\$self->{n}); | |||||||||||||
| 56 | } else { | ||||||||||||||
| 57 | 0 | $xfer += $input->skip($ftype); | |||||||||||||
| 58 | } | ||||||||||||||
| 59 | 5 | last; }; | |||||||||||||
| 60 | 0 | $xfer += $input->skip($ftype); | |||||||||||||
| 61 | } | ||||||||||||||
| 62 | 5 | $xfer += $input->readFieldEnd(); | |||||||||||||
| 63 | } | ||||||||||||||
| 64 | 5 | $xfer += $input->readStructEnd(); | |||||||||||||
| 65 | 5 | return $xfer; | |||||||||||||
| 66 | } | ||||||||||||||
| 67 | |||||||||||||||
| 68 | 5 | ▶ | sub write { | ||||||||||||
|
Subroutine
write: called CC=2 SCAR=6.9
| |||||||||||||||
| 69 | 5 | my ($self, $output) = @_; | |||||||||||||
| 70 | 5 | my $xfer = 0; | |||||||||||||
| 71 | 5 | $xfer += $output->writeStructBegin('BenchmarkService_fibonacci_args'); | |||||||||||||
| 72 | 5 | ▶ | if (defined $self->{n}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 73 | 5 | $xfer += $output->writeFieldBegin('n', Thrift::TType::BYTE, 1); | |||||||||||||
| 74 | 5 | $xfer += $output->writeByte($self->{n}); | |||||||||||||
| 75 | 5 | $xfer += $output->writeFieldEnd(); | |||||||||||||
| 76 | } | ||||||||||||||
| 77 | 5 | $xfer += $output->writeFieldStop(); | |||||||||||||
| 78 | 5 | $xfer += $output->writeStructEnd(); | |||||||||||||
| 79 | 5 | return $xfer; | |||||||||||||
| 80 | } | ||||||||||||||
| 81 | |||||||||||||||
| 82 | package BenchmarkService_fibonacci_result; | ||||||||||||||
| 83 | 1 | ▶ | use base qw(Class::Accessor); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 84 | 1 | BenchmarkService_fibonacci_result->mk_accessors( qw( success ) ); | |||||||||||||
| 85 | |||||||||||||||
| 86 | 10 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.8
| |||||||||||||||
| 87 | 10 | my $classname = shift; | |||||||||||||
| 88 | 10 | my $self = {}; | |||||||||||||
| 89 | 10 | ▶ | my $vals = shift || {}; | ||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||
| 90 | 10 | $self->{success} = undef; | |||||||||||||
| 91 | 10 | ▶ | if (UNIVERSAL::isa($vals,'HASH')) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 92 | 10 | ▶ | if (defined $vals->{success}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 93 | 0 | $self->{success} = $vals->{success}; | |||||||||||||
| 94 | } | ||||||||||||||
| 95 | } | ||||||||||||||
| 96 | 10 | return bless ($self, $classname); | |||||||||||||
| 97 | } | ||||||||||||||
| 98 | |||||||||||||||
| 99 | 0 | ▶ | sub getName { | ||||||||||||
|
Subroutine
getName: not called CC=1 SCAR=6.9
| |||||||||||||||
| 100 | 0 | return 'BenchmarkService_fibonacci_result'; | |||||||||||||
| 101 | } | ||||||||||||||
| 102 | |||||||||||||||
| 103 | 5 | ▶ | sub read { | ||||||||||||
|
Subroutine
read: called CC=5 SCAR=16.3
| |||||||||||||||
| 104 | 5 | my ($self, $input) = @_; | |||||||||||||
| 105 | 5 | my $xfer = 0; | |||||||||||||
| 106 | 5 | my $fname; | |||||||||||||
| 107 | 5 | my $ftype = 0; | |||||||||||||
| 108 | 5 | my $fid = 0; | |||||||||||||
| 109 | 5 | $xfer += $input->readStructBegin(\$fname); | |||||||||||||
| 110 | 5 | while (1) | |||||||||||||
| 111 | { | ||||||||||||||
| 112 | 10 | $xfer += $input->readFieldBegin(\$fname, \$ftype, \$fid); | |||||||||||||
| 113 | 10 | ▶ | if ($ftype == Thrift::TType::STOP) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 114 | 5 | last; | |||||||||||||
| 115 | } | ||||||||||||||
| 116 | 5 | SWITCH: for($fid) | |||||||||||||
| 117 | { | ||||||||||||||
| 118 | 5 | ▶ | /^0$/ && do{ if ($ftype == Thrift::TType::I32) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 119 | 5 | $xfer += $input->readI32(\$self->{success}); | |||||||||||||
| 120 | } else { | ||||||||||||||
| 121 | 0 | $xfer += $input->skip($ftype); | |||||||||||||
| 122 | } | ||||||||||||||
| 123 | 5 | last; }; | |||||||||||||
| 124 | 0 | $xfer += $input->skip($ftype); | |||||||||||||
| 125 | } | ||||||||||||||
| 126 | 5 | $xfer += $input->readFieldEnd(); | |||||||||||||
| 127 | } | ||||||||||||||
| 128 | 5 | $xfer += $input->readStructEnd(); | |||||||||||||
| 129 | 5 | return $xfer; | |||||||||||||
| 130 | } | ||||||||||||||
| 131 | |||||||||||||||
| 132 | 5 | ▶ | sub write { | ||||||||||||
|
Subroutine
write: called CC=2 SCAR=6.9
| |||||||||||||||
| 133 | 5 | my ($self, $output) = @_; | |||||||||||||
| 134 | 5 | my $xfer = 0; | |||||||||||||
| 135 | 5 | $xfer += $output->writeStructBegin('BenchmarkService_fibonacci_result'); | |||||||||||||
| 136 | 5 | ▶ | if (defined $self->{success}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 137 | 5 | $xfer += $output->writeFieldBegin('success', Thrift::TType::I32, 0); | |||||||||||||
| 138 | 5 | $xfer += $output->writeI32($self->{success}); | |||||||||||||
| 139 | 5 | $xfer += $output->writeFieldEnd(); | |||||||||||||
| 140 | } | ||||||||||||||
| 141 | 5 | $xfer += $output->writeFieldStop(); | |||||||||||||
| 142 | 5 | $xfer += $output->writeStructEnd(); | |||||||||||||
| 143 | 5 | return $xfer; | |||||||||||||
| 144 | } | ||||||||||||||
| 145 | |||||||||||||||
| 146 | package BenchmarkServiceIf; | ||||||||||||||
| 147 | |||||||||||||||
| 148 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 149 | |||||||||||||||
| 150 | |||||||||||||||
| 151 | 0 | ▶ | sub fibonacci{ | ||||||||||||
|
Subroutine
fibonacci: not called CC=1 SCAR=6.9
| |||||||||||||||
| 152 | 0 | my $self = shift; | |||||||||||||
| 153 | 0 | my $n = shift; | |||||||||||||
| 154 | |||||||||||||||
| 155 | 0 | die 'implement interface'; | |||||||||||||
| 156 | } | ||||||||||||||
| 157 | |||||||||||||||
| 158 | package BenchmarkServiceRest; | ||||||||||||||
| 159 | |||||||||||||||
| 160 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 161 | |||||||||||||||
| 162 | |||||||||||||||
| 163 | 0 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||
| 164 | 0 | my ($classname, $impl) = @_; | |||||||||||||
| 165 | 0 | my $self ={ impl => $impl }; | |||||||||||||
| 166 | |||||||||||||||
| 167 | 0 | return bless($self,$classname); | |||||||||||||
| 168 | } | ||||||||||||||
| 169 | |||||||||||||||
| 170 | 0 | ▶ | sub fibonacci{ | ||||||||||||
|
Subroutine
fibonacci: not called CC=2 SCAR=17.9
| |||||||||||||||
| 171 | 0 | my ($self, $request) = @_; | |||||||||||||
| 172 | |||||||||||||||
| 173 | 0 | ▶ | my $n = ($request->{'n'}) ? $request->{'n'} : undef; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 174 | 0 | return $self->{impl}->fibonacci($n); | |||||||||||||
| 175 | } | ||||||||||||||
| 176 | |||||||||||||||
| 177 | package BenchmarkServiceClient; | ||||||||||||||
| 178 | |||||||||||||||
| 179 | |||||||||||||||
| 180 | 1 | ▶ | use base qw(BenchmarkServiceIf); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 181 | 1 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
| |||||||||||||||
| 182 | 1 | my ($classname, $input, $output) = @_; | |||||||||||||
| 183 | 1 | my $self = {}; | |||||||||||||
| 184 | 1 | $self->{input} = $input; | |||||||||||||
| 185 | 1 | ▶ | $self->{output} = defined $output ? $output : $input; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 186 | 1 | $self->{seqid} = 0; | |||||||||||||
| 187 | 1 | return bless($self,$classname); | |||||||||||||
| 188 | } | ||||||||||||||
| 189 | |||||||||||||||
| 190 | 0 | ▶ | sub fibonacci{ | ||||||||||||
|
Subroutine
fibonacci: not called CC=1 SCAR=6.9
| |||||||||||||||
| 191 | 0 | my $self = shift; | |||||||||||||
| 192 | 0 | my $n = shift; | |||||||||||||
| 193 | |||||||||||||||
| 194 | 0 | $self->send_fibonacci($n); | |||||||||||||
| 195 | 0 | return $self->recv_fibonacci(); | |||||||||||||
| 196 | } | ||||||||||||||
| 197 | |||||||||||||||
| 198 | 5 | ▶ | sub send_fibonacci{ | ||||||||||||
|
Subroutine
send_fibonacci: called CC=1 SCAR=0.0
| |||||||||||||||
| 199 | 5 | my $self = shift; | |||||||||||||
| 200 | 5 | my $n = shift; | |||||||||||||
| 201 | |||||||||||||||
| 202 | 5 | $self->{output}->writeMessageBegin('fibonacci', Thrift::TMessageType::CALL, $self->{seqid}); | |||||||||||||
| 203 | 5 | my $args = BenchmarkService_fibonacci_args->new(); | |||||||||||||
| 204 | 5 | $args->{n} = $n; | |||||||||||||
| 205 | 5 | $args->write($self->{output}); | |||||||||||||
| 206 | 5 | $self->{output}->writeMessageEnd(); | |||||||||||||
| 207 | 5 | $self->{output}->getTransport()->flush(); | |||||||||||||
| 208 | } | ||||||||||||||
| 209 | |||||||||||||||
| 210 | 0 | ▶ | sub recv_fibonacci{ | ||||||||||||
|
Subroutine
recv_fibonacci: not called CC=3 SCAR=24.8
| |||||||||||||||
| 211 | 0 | my $self = shift; | |||||||||||||
| 212 | |||||||||||||||
| 213 | 0 | my $rseqid = 0; | |||||||||||||
| 214 | 0 | my $fname; | |||||||||||||
| 215 | 0 | my $mtype = 0; | |||||||||||||
| 216 | |||||||||||||||
| 217 | 0 | $self->{input}->readMessageBegin(\$fname, \$mtype, \$rseqid); | |||||||||||||
| 218 | 0 | ▶ | if ($mtype == Thrift::TMessageType::EXCEPTION) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 219 | 0 | my $x = Thrift::TApplicationException->new(); | |||||||||||||
| 220 | 0 | $x->read($self->{input}); | |||||||||||||
| 221 | 0 | $self->{input}->readMessageEnd(); | |||||||||||||
| 222 | 0 | die $x; | |||||||||||||
| 223 | } | ||||||||||||||
| 224 | 0 | my $result = BenchmarkService_fibonacci_result->new(); | |||||||||||||
| 225 | 0 | $result->read($self->{input}); | |||||||||||||
| 226 | 0 | $self->{input}->readMessageEnd(); | |||||||||||||
| 227 | |||||||||||||||
| 228 | 0 | ▶ | if (defined $result->{success} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 229 | 0 | return $result->{success}; | |||||||||||||
| 230 | } | ||||||||||||||
| 231 | 0 | die "fibonacci failed: unknown result"; | |||||||||||||
| 232 | } | ||||||||||||||
| 233 | package BenchmarkServiceProcessor; | ||||||||||||||
| 234 | |||||||||||||||
| 235 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 236 | |||||||||||||||
| 237 | |||||||||||||||
| 238 | 1 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||
| 239 | 1 | my ($classname, $handler) = @_; | |||||||||||||
| 240 | 1 | my $self = {}; | |||||||||||||
| 241 | 1 | $self->{handler} = $handler; | |||||||||||||
| 242 | 1 | return bless ($self, $classname); | |||||||||||||
| 243 | } | ||||||||||||||
| 244 | |||||||||||||||
| 245 | 5 | ▶ | sub process { | ||||||||||||
|
Subroutine
process: called CC=2 SCAR=8.9
| |||||||||||||||
| 246 | 5 | my ($self, $input, $output) = @_; | |||||||||||||
| 247 | 5 | my $rseqid = 0; | |||||||||||||
| 248 | 5 | my $fname = undef; | |||||||||||||
| 249 | 5 | my $mtype = 0; | |||||||||||||
| 250 | |||||||||||||||
| 251 | 5 | $input->readMessageBegin(\$fname, \$mtype, \$rseqid); | |||||||||||||
| 252 | 5 | my $methodname = 'process_'.$fname; | |||||||||||||
| 253 | 5 | ▶ | if (!$self->can($methodname)) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 254 | 0 | $input->skip(Thrift::TType::STRUCT); | |||||||||||||
| 255 | 0 | $input->readMessageEnd(); | |||||||||||||
| 256 | 0 | my $x = Thrift::TApplicationException->new('Function '.$fname.' not implemented.', Thrift::TApplicationException::UNKNOWN_METHOD); | |||||||||||||
| 257 | 0 | $output->writeMessageBegin($fname, Thrift::TMessageType::EXCEPTION, $rseqid); | |||||||||||||
| 258 | 0 | $x->write($output); | |||||||||||||
| 259 | 0 | $output->writeMessageEnd(); | |||||||||||||
| 260 | 0 | $output->getTransport()->flush(); | |||||||||||||
| 261 | 0 | return; | |||||||||||||
| 262 | } | ||||||||||||||
| 263 | 5 | $self->$methodname($rseqid, $input, $output); | |||||||||||||
| 264 | 5 | return 1; | |||||||||||||
| 265 | } | ||||||||||||||
| 266 | |||||||||||||||
| 267 | 5 | ▶ | sub process_fibonacci { | ||||||||||||
|
Subroutine
process_fibonacci: called CC=1 SCAR=0.0
| |||||||||||||||
| 268 | 5 | my ($self, $seqid, $input, $output) = @_; | |||||||||||||
| 269 | 5 | my $args = BenchmarkService_fibonacci_args->new(); | |||||||||||||
| 270 | 5 | $args->read($input); | |||||||||||||
| 271 | 5 | $input->readMessageEnd(); | |||||||||||||
| 272 | 5 | my $result = BenchmarkService_fibonacci_result->new(); | |||||||||||||
| 273 | 5 | $result->{success} = $self->{handler}->fibonacci($args->n); | |||||||||||||
| 274 | 5 | $output->writeMessageBegin('fibonacci', Thrift::TMessageType::REPLY, $seqid); | |||||||||||||
| 275 | 5 | $result->write($output); | |||||||||||||
| 276 | 5 | $output->writeMessageEnd(); | |||||||||||||
| 277 | 5 | $output->getTransport()->flush(); | |||||||||||||
| 278 | } | ||||||||||||||
| 279 | |||||||||||||||
| 280 | 1 | 1; | |||||||||||||