mojo/public/tools/mojom/mojom/generate/pack.py
def GetVersionInfo(packed_struct):
  """Get version information for a struct.

  Args:
    packed_struct: A PackedStruct instance.

  Returns:
    A non-empty list of VersionInfo instances, sorted by version in increasing
    order.
    Note: The version numbers may not be consecutive.
  """
  versions = []
  last_version = 0
  last_num_fields = 0
  last_payload_size = 0

  for packed_field in packed_struct.packed_fields_in_ordinal_order:
    if packed_field.min_version != last_version:
      versions.append(
          VersionInfo(last_version, last_num_fields,
                      last_payload_size + HEADER_SIZE))
      last_version = packed_field.min_version

    last_num_fields += 1
    # The fields are iterated in ordinal order here. However, the size of a
    # version is determined by the last field of that version in pack order,
    # instead of ordinal order. Therefore, we need to calculate the max value.
    last_payload_size = max(
        GetPayloadSizeUpToField(packed_field), last_payload_size)

  assert len(versions) == 0 or last_num_fields != versions[-1].num_fields
  versions.append(
      VersionInfo(last_version, last_num_fields,
                  last_payload_size + HEADER_SIZE))
  return versions
Get version information for a struct.

  Args:
    packed_struct: A PackedStruct instance.

  Returns:
    A non-empty list of VersionInfo instances, sorted by version in increasing
    order.
    Note: The version numbers may not be consecutive.
  
Get version information for a struct.
Get version information for a struct .
def GetVersionInfo(packed_struct):
  versions = []
  last_version = 0
  last_num_fields = 0
  last_payload_size = 0
  for packed_field in packed_struct.packed_fields_in_ordinal_order:
    if packed_field.min_version != last_version:
      versions.append(
          VersionInfo(last_version, last_num_fields,
                      last_payload_size + HEADER_SIZE))
      last_version = packed_field.min_version
    last_num_fields += 1
    last_payload_size = max(
        GetPayloadSizeUpToField(packed_field), last_payload_size)
  assert len(versions) == 0 or last_num_fields != versions[-1].num_fields
  versions.append(
      VersionInfo(last_version, last_num_fields,
                  last_payload_size + HEADER_SIZE))
  return versions
def GetVersionInfo ( packed_struct ) : versions = [ ] last_version = 0 last_num_fields = 0 last_payload_size = 0 for packed_field in packed_struct . packed_fields_in_ordinal_order : if packed_field . min_version != last_version : versions . append ( VersionInfo ( last_version , last_num_fields , last_payload_size + HEADER_SIZE ) ) last_version = packed_field . min_version last_num_fields += 1 last_payload_size = max ( GetPayloadSizeUpToField ( packed_field ) , last_payload_size ) assert len ( versions ) == 0 or last_num_fields != versions [ - 1 ] . num_fields versions . append ( VersionInfo ( last_version , last_num_fields , last_payload_size + HEADER_SIZE ) ) return versions
Get version information for a struct.
Get version information for a struct .
"""Get version information for a struct.

  Args:
    packed_struct: A PackedStruct instance.

  Returns:
    A non-empty list of VersionInfo instances, sorted by version in increasing
    order.
    Note: The version numbers may not be consecutive.
  """ # The fields are iterated in ordinal order here. However, the size of a # version is determined by the last field of that version in pack order, # instead of ordinal order. Therefore, we need to calculate the max value.
A non-empty list of VersionInfo instances, sorted by version in increasing
order.
Note: The version numbers may not be consecutive.
A non - empty list of VersionInfo instances sorted by version in increasing order . Note : The version numbers may not be consecutive .
packed_struct
A PackedStruct instance.
A PackedStruct instance .