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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 value is returned, then we can save two instructions by returning the | 66 value is returned, then we can save two instructions by returning the |
67 result of the last statement. It looks funny but it helps. | 67 result of the last statement. It looks funny but it helps. |
68 * We assume that type and bounds checking has happened at a higher level. | 68 * We assume that type and bounds checking has happened at a higher level. |
69 """ | 69 """ |
70 | 70 |
71 __author__ = 'kenton@google.com (Kenton Varda)' | 71 __author__ = 'kenton@google.com (Kenton Varda)' |
72 | 72 |
73 import struct | 73 import struct |
74 import sys ##PY25 | 74 import sys ##PY25 |
75 _PY2 = sys.version_info[0] < 3 ##PY25 | 75 _PY2 = sys.version_info[0] < 3 ##PY25 |
76 from google.protobuf.internal import wire_format | 76 from protobuf26.internal import wire_format |
77 | 77 |
78 | 78 |
79 # This will overflow and thus become IEEE-754 "infinity". We would use | 79 # This will overflow and thus become IEEE-754 "infinity". We would use |
80 # "float('inf')" but it doesn't work on Windows pre-Python-2.6. | 80 # "float('inf')" but it doesn't work on Windows pre-Python-2.6. |
81 _POS_INF = 1e10000 | 81 _POS_INF = 1e10000 |
82 _NEG_INF = -_POS_INF | 82 _NEG_INF = -_POS_INF |
83 | 83 |
84 | 84 |
85 def _VarintSize(value): | 85 def _VarintSize(value): |
86 """Compute the size of a varint value.""" | 86 """Compute the size of a varint value.""" |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 end_bytes = TagBytes(1, wire_format.WIRETYPE_END_GROUP) | 779 end_bytes = TagBytes(1, wire_format.WIRETYPE_END_GROUP) |
780 local_EncodeVarint = _EncodeVarint | 780 local_EncodeVarint = _EncodeVarint |
781 | 781 |
782 def EncodeField(write, value): | 782 def EncodeField(write, value): |
783 write(start_bytes) | 783 write(start_bytes) |
784 local_EncodeVarint(write, value.ByteSize()) | 784 local_EncodeVarint(write, value.ByteSize()) |
785 value._InternalSerialize(write) | 785 value._InternalSerialize(write) |
786 return write(end_bytes) | 786 return write(end_bytes) |
787 | 787 |
788 return EncodeField | 788 return EncodeField |
OLD | NEW |