Example #1
0
def _EnumField(module, enum, parsed_field, parent_kind):
  """
  Args:
    module: {mojom.Module} Module currently being constructed.
    enum: {mojom.Enum} Enum this field belongs to.
    parsed_field: {ast.EnumValue} Parsed enum value.
    parent_kind: {mojom.Kind} The enclosing type.

  Returns:
    {mojom.EnumField} AST enum field.
  """
  field = mojom.EnumField()
  field.mojom_name = parsed_field.mojom_name
  # TODO(mpcomplete): FixupExpression should be done in the second pass,
  # so constants and enums can refer to each other.
  # TODO(mpcomplete): But then, what if constants are initialized to an enum? Or
  # vice versa?
  if parent_kind:
    field.value = _FixupExpression(
        module, parsed_field.value,
        (module.mojom_namespace, parent_kind.mojom_name), enum)
  else:
    field.value = _FixupExpression(
        module, parsed_field.value, (module.mojom_namespace, ), enum)
  field.attributes = _AttributeListToDict(parsed_field.attribute_list)
  value = mojom.EnumValue(module, enum, field)
  module.values[value.GetSpec()] = value
  return field
Example #2
0
def _EnumField(module, enum, parsed_field):
    """
  Args:
    module: {mojom.Module} Module currently being constructed.
    enum: {mojom.Enum} Enum this field belongs to.
    parsed_field: {ast.EnumValue} Parsed enum value.

  Returns:
    {mojom.EnumField} AST enum field.
  """
    field = mojom.EnumField()
    field.mojom_name = parsed_field.mojom_name
    field.value = _LookupValue(module, enum, None, parsed_field.value)
    field.attributes = _AttributeListToDict(parsed_field.attribute_list)
    value = mojom.EnumValue(module, enum, field)
    module.values[value.GetSpec()] = value
    return field