File Coverage

blib/lib/Google/ProtocolBuffers/Constants.pm
Criterion Covered Total %
statement 28 28 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod n/a
total 37 37 100.0


line stmt bran cond sub pod time code
1             package Google::ProtocolBuffers::Constants;
2 13     13   66 use strict;
  13         22  
  13         851  
3 13     13   63 use warnings;
  13         112  
  13         1890  
4            
5             my ($types, $wiretypes, $labels, $complex_types);
6             BEGIN
7             {
8             ## from src/google/protobuf/descriptor.h
9 13     13   233 $types = {
10             TYPE_DOUBLE => 1, ## double, exactly eight bytes on the wire.
11             TYPE_FLOAT => 2, ## float, exactly four bytes on the wire.
12             TYPE_INT64 => 3, ## int64, varint on the wire. Negative numbers
13             ## take 10 bytes. Use TYPE_SINT64 if negative
14             ## values are likely.
15             TYPE_UINT64 => 4, ## uint64, varint on the wire.
16             TYPE_INT32 => 5, ## int32, varint on the wire. Negative numbers
17             ## take 10 bytes. Use TYPE_SINT32 if negative
18             ## values are likely.
19             TYPE_FIXED64 => 6, ## uint64, exactly eight bytes on the wire.
20             TYPE_FIXED32 => 7, ## uint32, exactly four bytes on the wire.
21             TYPE_BOOL => 8, ## bool, varint on the wire.
22             TYPE_STRING => 9, ## UTF-8 text.
23             TYPE_GROUP => 10, ## Tag-delimited message. Deprecated.
24             TYPE_MESSAGE => 11, ## Length-delimited message.
25             TYPE_BYTES => 12, ## Arbitrary byte array.
26             TYPE_UINT32 => 13, ## uint32, varint on the wire
27             TYPE_ENUM => 14, ## Enum, varint on the wire
28             TYPE_SFIXED32 => 15, ## int32, exactly four bytes on the wire
29             TYPE_SFIXED64 => 16, ## int64, exactly eight bytes on the wire
30             TYPE_SINT32 => 17, ## int32, ZigZag-encoded varint on the wire
31             TYPE_SINT64 => 18, ## int64, ZigZag-encoded varint on the wire
32             };
33            
34             ## from src/google/protobuf/descriptor.h
35 13         49 $labels = {
36             LABEL_OPTIONAL => 1,
37             LABEL_REQUIRED => 2,
38             LABEL_REPEATED => 3,
39             };
40            
41            
42             ## from src/google/protobuf/wire_format.h
43 13         92 $wiretypes = {
44             WIRETYPE_VARINT => 0,
45             WIRETYPE_FIXED64 => 1,
46             WIRETYPE_LENGTH_DELIMITED => 2,
47             WIRETYPE_START_GROUP => 3,
48             WIRETYPE_END_GROUP => 4,
49             WIRETYPE_FIXED32 => 5,
50             };
51            
52            
53             ## Complex types - this is not a part of Google specificaion
54 13         276 $complex_types = {
55             MESSAGE => 1,
56             GROUP => 2,
57             ENUM => 3,
58             };
59             }
60            
61 13     13   71 use base 'Exporter';
  13         25  
  13         1526  
62 13     13   67 use vars qw/@EXPORT_OK %EXPORT_TAGS/;
  13         16  
  13         1017  
63            
64 13     13   96 use constant $types;
  13         226  
  13         3525  
65             $EXPORT_TAGS{'types'} = [keys %$types];
66             push @{$EXPORT_TAGS{'all'}}, keys %$types;
67             push @EXPORT_OK, keys %$types;
68            
69 13     13   70 use constant $wiretypes;
  13         20  
  13         1662  
70             $EXPORT_TAGS{'wiretypes'} = [keys %$wiretypes];
71             push @{$EXPORT_TAGS{'all'}}, keys %$wiretypes;
72             push @EXPORT_OK, keys %$wiretypes;
73            
74 13     13   63 use constant $labels;
  13         24  
  13         1477  
75             $EXPORT_TAGS{'labels'} = [keys %$labels];
76             push @{$EXPORT_TAGS{'all'}}, keys %$labels;
77             push @EXPORT_OK, keys %$labels;
78            
79 13     13   73 use constant $complex_types;
  13         27  
  13         1394  
80             $EXPORT_TAGS{'complex_types'} = [keys %$complex_types];
81             push @{$EXPORT_TAGS{'all'}}, keys %$complex_types;
82             push @EXPORT_OK, keys %$complex_types;
83            
84             1;
85