line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Thrift::Parser::Type::bool; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Thrift::Parser::Type::bool - bool type |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
32
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
178
|
|
10
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
170
|
|
11
|
6
|
|
|
6
|
|
28
|
use base qw(Thrift::Parser::Type); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
448
|
|
12
|
6
|
|
|
6
|
|
43
|
use Scalar::Util qw(blessed); |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
377
|
|
13
|
6
|
|
|
6
|
|
6605
|
use JSON::XS; |
|
6
|
|
|
|
|
32633
|
|
|
6
|
|
|
|
|
610
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 USAGE |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Stringification is overloaded to the values 'true' or 'false'. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
When composing, the value doesn't matter; it will be evaluated in boolean context to determine the value here. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
6
|
50
|
|
6
|
|
50
|
use overload '""' => sub { $_[0]->value ? 'true' : 'false' }; |
|
6
|
|
|
1
|
|
12
|
|
|
6
|
|
|
|
|
60
|
|
|
1
|
|
|
|
|
8
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub values_equal { |
26
|
0
|
|
|
0
|
1
|
0
|
my ($class, $value_a, $value_b) = @_; |
27
|
0
|
|
0
|
|
|
0
|
return $value_a && $value_b; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub compose { |
31
|
3
|
|
|
3
|
1
|
1617
|
my ($class, $value) = @_; |
32
|
|
|
|
|
|
|
|
33
|
3
|
50
|
66
|
|
|
48
|
if (ref $value && blessed($value) && $value->isa('JSON::XS::Boolean')) { |
|
|
|
66
|
|
|
|
|
34
|
2
|
100
|
|
|
|
7
|
$value = $value == JSON::XS::true ? 1 : 0; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
151
|
return $class->SUPER::compose($value); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 is_true |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Returns 1 if is true, 0 otherwise. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
3
|
100
|
|
3
|
1
|
577
|
sub is_true { return $_[0]->value ? 1 : 0 } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 is_false |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Returns 1 if is false, 0 otherwise. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
3
|
100
|
|
3
|
1
|
11
|
sub is_false { return $_[0]->value ? 0 : 1 } |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub value_plain { |
57
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
58
|
1
|
50
|
|
|
|
5
|
return $self->value ? 1 : 0; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 COPYRIGHT |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The full text of the license can be found in the LICENSE file included with this module. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Eric Waters |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |