summaryrefslogtreecommitdiff
path: root/utils/ipc/mojo/public/tools/mojom/mojom/generate/translate.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/ipc/mojo/public/tools/mojom/mojom/generate/translate.py')
-rw-r--r--utils/ipc/mojo/public/tools/mojom/mojom/generate/translate.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/utils/ipc/mojo/public/tools/mojom/mojom/generate/translate.py b/utils/ipc/mojo/public/tools/mojom/mojom/generate/translate.py
index d6df3ca6..7580b780 100644
--- a/utils/ipc/mojo/public/tools/mojom/mojom/generate/translate.py
+++ b/utils/ipc/mojo/public/tools/mojom/mojom/generate/translate.py
@@ -472,6 +472,9 @@ def _Method(module, parsed_method, interface):
"attribute. If no response parameters are needed, you "
"could use an empty response parameter list, i.e., "
"\"=> ()\".")
+ # And only methods with the [Sync] attribute can specify [NoInterrupt].
+ if not method.allow_interrupt and not method.sync:
+ raise Exception("Only [Sync] methods can be marked [NoInterrupt].")
return method
@@ -592,6 +595,16 @@ def _Enum(module, parsed_enum, parent_kind):
map(lambda field: _EnumField(module, enum, field),
parsed_enum.enum_value_list))
_ResolveNumericEnumValues(enum)
+ # TODO(https://crbug.com/731893): Require a default value to be
+ # specified.
+ for field in enum.fields:
+ if field.default:
+ if not enum.extensible:
+ raise Exception('Non-extensible enums may not specify a default')
+ if enum.default_field is not None:
+ raise Exception(
+ 'Only one enumerator value may be specified as the default')
+ enum.default_field = field
module.kinds[enum.spec] = enum
@@ -650,7 +663,9 @@ def _CollectReferencedKinds(module, all_defined_kinds):
if mojom.IsMapKind(kind):
return (extract_referenced_user_kinds(kind.key_kind) +
extract_referenced_user_kinds(kind.value_kind))
- if mojom.IsInterfaceRequestKind(kind) or mojom.IsAssociatedKind(kind):
+ if (mojom.IsInterfaceRequestKind(kind) or mojom.IsAssociatedKind(kind)
+ or mojom.IsPendingRemoteKind(kind)
+ or mojom.IsPendingReceiverKind(kind)):
return [kind.kind]
if mojom.IsStructKind(kind):
return [kind]
@@ -678,12 +693,9 @@ def _CollectReferencedKinds(module, all_defined_kinds):
for method in interface.methods:
for param in itertools.chain(method.parameters or [],
method.response_parameters or []):
- if (mojom.IsStructKind(param.kind) or mojom.IsUnionKind(param.kind)
- or mojom.IsEnumKind(param.kind)
- or mojom.IsAnyInterfaceKind(param.kind)):
- for referenced_kind in extract_referenced_user_kinds(param.kind):
- sanitized_kind = sanitize_kind(referenced_kind)
- referenced_user_kinds[sanitized_kind.spec] = sanitized_kind
+ for referenced_kind in extract_referenced_user_kinds(param.kind):
+ sanitized_kind = sanitize_kind(referenced_kind)
+ referenced_user_kinds[sanitized_kind.spec] = sanitized_kind
return referenced_user_kinds