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 14     14   44 use strict;
  14         14  
  14         299  
3 14     14   37 use warnings;
  14         66  
  14         1108  
4            
5             my ($types, $wiretypes, $labels, $complex_types);
6             BEGIN
7             {
8             ## from src/google/protobuf/descriptor.h
9 14     14   159 $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 14         33 $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 14         331 $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 14         224 $complex_types = {
55             MESSAGE => 1,
56             GROUP => 2,
57             ENUM => 3,
58             ONEOF => 4,
59             };
60             }
61            
62 14     14   48 use base 'Exporter';
  14         19  
  14         1097  
63 14     14   48 use vars qw/@EXPORT_OK %EXPORT_TAGS/;
  14         16  
  14         691  
64            
65 14     14   53 use constant $types;
  14         16  
  14         2667  
66             $EXPORT_TAGS{'types'} = [keys %$types];
67             push @{$EXPORT_TAGS{'all'}}, keys %$types;
68             push @EXPORT_OK, keys %$types;
69            
70 14     14   48 use constant $wiretypes;
  14         14  
  14         1378  
71             $EXPORT_TAGS{'wiretypes'} = [keys %$wiretypes];
72             push @{$EXPORT_TAGS{'all'}}, keys %$wiretypes;
73             push @EXPORT_OK, keys %$wiretypes;
74            
75 14     14   44 use constant $labels;
  14         15  
  14         1136  
76             $EXPORT_TAGS{'labels'} = [keys %$labels];
77             push @{$EXPORT_TAGS{'all'}}, keys %$labels;
78             push @EXPORT_OK, keys %$labels;
79            
80 14     14   43 use constant $complex_types;
  14         15  
  14         1250  
81             $EXPORT_TAGS{'complex_types'} = [keys %$complex_types];
82             push @{$EXPORT_TAGS{'all'}}, keys %$complex_types;
83             push @EXPORT_OK, keys %$complex_types;
84            
85             1;
86