OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Utility classes for serialization""" | 5 """Utility classes for serialization""" |
6 | 6 |
7 import struct | 7 import struct |
8 | 8 |
9 | 9 |
10 # Format of a header for a struct or an array. | 10 # Format of a header for a struct or an array. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 needed_padding = NeededPaddingForAlignment(index, size) | 184 needed_padding = NeededPaddingForAlignment(index, size) |
185 if needed_padding: | 185 if needed_padding: |
186 codes.append('x' * needed_padding) | 186 codes.append('x' * needed_padding) |
187 index = index + needed_padding | 187 index = index + needed_padding |
188 codes.append(code) | 188 codes.append(code) |
189 index = index + size | 189 index = index + size |
190 alignment_needed = NeededPaddingForAlignment(index) | 190 alignment_needed = NeededPaddingForAlignment(index) |
191 if alignment_needed: | 191 if alignment_needed: |
192 codes.append('x' * alignment_needed) | 192 codes.append('x' * alignment_needed) |
193 return struct.Struct(''.join(codes)) | 193 return struct.Struct(''.join(codes)) |
OLD | NEW |