OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import module as mojom | 5 import module as mojom |
6 | 6 |
7 # This module provides a mechanism for determining the packed order and offsets | 7 # This module provides a mechanism for determining the packed order and offsets |
8 # of a mojom.Struct. | 8 # of a mojom.Struct. |
9 # | 9 # |
10 # ps = pack.PackedStruct(struct) | 10 # ps = pack.PackedStruct(struct) |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 # The fields are iterated in ordinal order here. However, the size of a | 241 # The fields are iterated in ordinal order here. However, the size of a |
242 # version is determined by the last field of that version in pack order, | 242 # version is determined by the last field of that version in pack order, |
243 # instead of ordinal order. Therefore, we need to calculate the max value. | 243 # instead of ordinal order. Therefore, we need to calculate the max value. |
244 last_payload_size = max(GetPayloadSizeUpToField(packed_field), | 244 last_payload_size = max(GetPayloadSizeUpToField(packed_field), |
245 last_payload_size) | 245 last_payload_size) |
246 | 246 |
247 assert len(versions) == 0 or last_num_fields != versions[-1].num_fields | 247 assert len(versions) == 0 or last_num_fields != versions[-1].num_fields |
248 versions.append(VersionInfo(last_version, last_num_fields, | 248 versions.append(VersionInfo(last_version, last_num_fields, |
249 last_payload_size + HEADER_SIZE)) | 249 last_payload_size + HEADER_SIZE)) |
250 return versions | 250 return versions |
OLD | NEW |