protolib.py (12209:2c8d30e495ab) protolib.py (12210:4c6eb3ea3e1a)
1#!/usr/bin/env python2
2
3# Copyright (c) 2013 ARM Limited
4# All rights reserved
5#
6# The license below extends only to copyright in the software and shall
7# not be construed as granting a license to any other intellectual
8# property including but not limited to intellectual property relating

--- 138 unchanged lines hidden (view full) ---

147 """
148 The encoding of the Varint32 is copied from
149 google.protobuf.internal.encoder and is only repeated here to
150 avoid depending on the internal functions in the library.
151 """
152 bits = value & 0x7f
153 value >>= 7
154 while value:
1#!/usr/bin/env python2
2
3# Copyright (c) 2013 ARM Limited
4# All rights reserved
5#
6# The license below extends only to copyright in the software and shall
7# not be construed as granting a license to any other intellectual
8# property including but not limited to intellectual property relating

--- 138 unchanged lines hidden (view full) ---

147 """
148 The encoding of the Varint32 is copied from
149 google.protobuf.internal.encoder and is only repeated here to
150 avoid depending on the internal functions in the library.
151 """
152 bits = value & 0x7f
153 value >>= 7
154 while value:
155 out_file.write(struct.pack('<B', 0x80|bits))
155 out_file.write(struct.pack('<B', 0x80 | bits))
156 bits = value & 0x7f
157 value >>= 7
158 out_file.write(struct.pack('<B', bits))
159
160def encodeMessage(out_file, message):
161 """
162 Encoded a message with the length prepended as a 32-bit varint.
163 """
164 out = message.SerializeToString()
165 _EncodeVarint32(out_file, len(out))
166 out_file.write(out)
156 bits = value & 0x7f
157 value >>= 7
158 out_file.write(struct.pack('<B', bits))
159
160def encodeMessage(out_file, message):
161 """
162 Encoded a message with the length prepended as a 32-bit varint.
163 """
164 out = message.SerializeToString()
165 _EncodeVarint32(out_file, len(out))
166 out_file.write(out)