OLD | NEW |
1 # Protocol Buffers - Google's data interchange format | 1 # Protocol Buffers - Google's data interchange format |
2 # Copyright 2008 Google Inc. All rights reserved. | 2 # Copyright 2008 Google Inc. All rights reserved. |
3 # http://code.google.com/p/protobuf/ | 3 # http://code.google.com/p/protobuf/ |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 15 matching lines...) Expand all Loading... |
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
31 """Constants and static functions to support protocol buffer wire format.""" | 31 """Constants and static functions to support protocol buffer wire format.""" |
32 | 32 |
33 __author__ = 'robinson@google.com (Will Robinson)' | 33 __author__ = 'robinson@google.com (Will Robinson)' |
34 | 34 |
35 import struct | 35 import struct |
36 from google.protobuf import descriptor | 36 from protobuf26 import descriptor |
37 from google.protobuf import message | 37 from protobuf26 import message |
38 | 38 |
39 | 39 |
40 TAG_TYPE_BITS = 3 # Number of bits used to hold type info in a proto tag. | 40 TAG_TYPE_BITS = 3 # Number of bits used to hold type info in a proto tag. |
41 TAG_TYPE_MASK = (1 << TAG_TYPE_BITS) - 1 # 0x7 | 41 TAG_TYPE_MASK = (1 << TAG_TYPE_BITS) - 1 # 0x7 |
42 | 42 |
43 # These numbers identify the wire type of a protocol buffer value. | 43 # These numbers identify the wire type of a protocol buffer value. |
44 # We use the least-significant TAG_TYPE_BITS bits of the varint-encoded | 44 # We use the least-significant TAG_TYPE_BITS bits of the varint-encoded |
45 # tag-and-type to store one of these WIRETYPE_* constants. | 45 # tag-and-type to store one of these WIRETYPE_* constants. |
46 # These values must match WireType enum in google/protobuf/wire_format.h. | 46 # These values must match WireType enum in google/protobuf/wire_format.h. |
47 WIRETYPE_VARINT = 0 | 47 WIRETYPE_VARINT = 0 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 def IsTypePackable(field_type): | 259 def IsTypePackable(field_type): |
260 """Return true iff packable = true is valid for fields of this type. | 260 """Return true iff packable = true is valid for fields of this type. |
261 | 261 |
262 Args: | 262 Args: |
263 field_type: a FieldDescriptor::Type value. | 263 field_type: a FieldDescriptor::Type value. |
264 | 264 |
265 Returns: | 265 Returns: |
266 True iff fields of this type are packable. | 266 True iff fields of this type are packable. |
267 """ | 267 """ |
268 return field_type not in NON_PACKABLE_TYPES | 268 return field_type not in NON_PACKABLE_TYPES |
OLD | NEW |