protolib.py (11828:36b064696175) | protolib.py (12208:621c3f3f80f2) |
---|---|
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 --- 109 unchanged lines hidden (view full) --- 118 result |= ((b & 0x7f) << shift) 119 pos += 1 120 if not (b & 0x80): 121 if result > 0x7fffffffffffffff: 122 result -= (1 << 64) 123 result |= ~mask 124 else: 125 result &= mask | 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 --- 109 unchanged lines hidden (view full) --- 118 result |= ((b & 0x7f) << shift) 119 pos += 1 120 if not (b & 0x80): 121 if result > 0x7fffffffffffffff: 122 result -= (1 << 64) 123 result |= ~mask 124 else: 125 result &= mask |
126 return (result, pos) 127 shift += 7 128 if shift >= 64: 129 raise IOError('Too many bytes when decoding varint.') | 126 return (result, pos) 127 shift += 7 128 if shift >= 64: 129 raise IOError('Too many bytes when decoding varint.') |
130 131def decodeMessage(in_file, message): 132 """ 133 Attempt to read a message from the file and decode it. Return 134 False if no message could be read. 135 """ 136 try: 137 size, pos = DecodeVarint(in_file) --- 29 unchanged lines hidden --- | 130 131def decodeMessage(in_file, message): 132 """ 133 Attempt to read a message from the file and decode it. Return 134 False if no message could be read. 135 """ 136 try: 137 size, pos = DecodeVarint(in_file) --- 29 unchanged lines hidden --- |