Commit a18d8217 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Format mojom_js_generator.py

In preparation for upcoming changes, this applies the repo's python
auto-formatting to the entire mojom_js_generator.py file to avoid extra
noise alongside more meaningful changes.

Bug: 1004256
Change-Id: I227d689b4eff4ee2a5f51bba068490f282151cba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450585
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Auto-Submit: Ken Rockot <rockot@google.com>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813972}
parent 8e3b29e6
# Copyright 2013 The Chromium Authors. All rights reserved. # Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
"""Generates JavaScript source files from a mojom.Module.""" """Generates JavaScript source files from a mojom.Module."""
import mojom.generate.generator as generator import mojom.generate.generator as generator
...@@ -17,115 +16,115 @@ else: ...@@ -17,115 +16,115 @@ else:
import urllib.request as urllib_request import urllib.request as urllib_request
_kind_to_javascript_default_value = { _kind_to_javascript_default_value = {
mojom.BOOL: "false", mojom.BOOL: "false",
mojom.INT8: "0", mojom.INT8: "0",
mojom.UINT8: "0", mojom.UINT8: "0",
mojom.INT16: "0", mojom.INT16: "0",
mojom.UINT16: "0", mojom.UINT16: "0",
mojom.INT32: "0", mojom.INT32: "0",
mojom.UINT32: "0", mojom.UINT32: "0",
mojom.FLOAT: "0", mojom.FLOAT: "0",
mojom.HANDLE: "null", mojom.HANDLE: "null",
mojom.DCPIPE: "null", mojom.DCPIPE: "null",
mojom.DPPIPE: "null", mojom.DPPIPE: "null",
mojom.MSGPIPE: "null", mojom.MSGPIPE: "null",
mojom.SHAREDBUFFER: "null", mojom.SHAREDBUFFER: "null",
mojom.PLATFORMHANDLE: "null", mojom.PLATFORMHANDLE: "null",
mojom.NULLABLE_HANDLE: "null", mojom.NULLABLE_HANDLE: "null",
mojom.NULLABLE_DCPIPE: "null", mojom.NULLABLE_DCPIPE: "null",
mojom.NULLABLE_DPPIPE: "null", mojom.NULLABLE_DPPIPE: "null",
mojom.NULLABLE_MSGPIPE: "null", mojom.NULLABLE_MSGPIPE: "null",
mojom.NULLABLE_SHAREDBUFFER: "null", mojom.NULLABLE_SHAREDBUFFER: "null",
mojom.NULLABLE_PLATFORMHANDLE: "null", mojom.NULLABLE_PLATFORMHANDLE: "null",
mojom.INT64: "0", mojom.INT64: "0",
mojom.UINT64: "0", mojom.UINT64: "0",
mojom.DOUBLE: "0", mojom.DOUBLE: "0",
mojom.STRING: "null", mojom.STRING: "null",
mojom.NULLABLE_STRING: "null" mojom.NULLABLE_STRING: "null"
} }
_kind_to_codec_type = { _kind_to_codec_type = {
mojom.BOOL: "codec.Uint8", mojom.BOOL: "codec.Uint8",
mojom.INT8: "codec.Int8", mojom.INT8: "codec.Int8",
mojom.UINT8: "codec.Uint8", mojom.UINT8: "codec.Uint8",
mojom.INT16: "codec.Int16", mojom.INT16: "codec.Int16",
mojom.UINT16: "codec.Uint16", mojom.UINT16: "codec.Uint16",
mojom.INT32: "codec.Int32", mojom.INT32: "codec.Int32",
mojom.UINT32: "codec.Uint32", mojom.UINT32: "codec.Uint32",
mojom.FLOAT: "codec.Float", mojom.FLOAT: "codec.Float",
mojom.HANDLE: "codec.Handle", mojom.HANDLE: "codec.Handle",
mojom.DCPIPE: "codec.Handle", mojom.DCPIPE: "codec.Handle",
mojom.DPPIPE: "codec.Handle", mojom.DPPIPE: "codec.Handle",
mojom.MSGPIPE: "codec.Handle", mojom.MSGPIPE: "codec.Handle",
mojom.SHAREDBUFFER: "codec.Handle", mojom.SHAREDBUFFER: "codec.Handle",
mojom.PLATFORMHANDLE: "codec.Handle", mojom.PLATFORMHANDLE: "codec.Handle",
mojom.NULLABLE_HANDLE: "codec.NullableHandle", mojom.NULLABLE_HANDLE: "codec.NullableHandle",
mojom.NULLABLE_DCPIPE: "codec.NullableHandle", mojom.NULLABLE_DCPIPE: "codec.NullableHandle",
mojom.NULLABLE_DPPIPE: "codec.NullableHandle", mojom.NULLABLE_DPPIPE: "codec.NullableHandle",
mojom.NULLABLE_MSGPIPE: "codec.NullableHandle", mojom.NULLABLE_MSGPIPE: "codec.NullableHandle",
mojom.NULLABLE_SHAREDBUFFER: "codec.NullableHandle", mojom.NULLABLE_SHAREDBUFFER: "codec.NullableHandle",
mojom.NULLABLE_PLATFORMHANDLE: "codec.NullableHandle", mojom.NULLABLE_PLATFORMHANDLE: "codec.NullableHandle",
mojom.INT64: "codec.Int64", mojom.INT64: "codec.Int64",
mojom.UINT64: "codec.Uint64", mojom.UINT64: "codec.Uint64",
mojom.DOUBLE: "codec.Double", mojom.DOUBLE: "codec.Double",
mojom.STRING: "codec.String", mojom.STRING: "codec.String",
mojom.NULLABLE_STRING: "codec.NullableString", mojom.NULLABLE_STRING: "codec.NullableString",
} }
_kind_to_closure_type = { _kind_to_closure_type = {
mojom.BOOL: "boolean", mojom.BOOL: "boolean",
mojom.INT8: "number", mojom.INT8: "number",
mojom.UINT8: "number", mojom.UINT8: "number",
mojom.INT16: "number", mojom.INT16: "number",
mojom.UINT16: "number", mojom.UINT16: "number",
mojom.INT32: "number", mojom.INT32: "number",
mojom.UINT32: "number", mojom.UINT32: "number",
mojom.FLOAT: "number", mojom.FLOAT: "number",
mojom.INT64: "number", mojom.INT64: "number",
mojom.UINT64: "number", mojom.UINT64: "number",
mojom.DOUBLE: "number", mojom.DOUBLE: "number",
mojom.STRING: "string", mojom.STRING: "string",
mojom.NULLABLE_STRING: "string", mojom.NULLABLE_STRING: "string",
mojom.HANDLE: "MojoHandle", mojom.HANDLE: "MojoHandle",
mojom.DCPIPE: "MojoHandle", mojom.DCPIPE: "MojoHandle",
mojom.DPPIPE: "MojoHandle", mojom.DPPIPE: "MojoHandle",
mojom.MSGPIPE: "MojoHandle", mojom.MSGPIPE: "MojoHandle",
mojom.SHAREDBUFFER: "MojoHandle", mojom.SHAREDBUFFER: "MojoHandle",
mojom.PLATFORMHANDLE: "MojoHandle", mojom.PLATFORMHANDLE: "MojoHandle",
mojom.NULLABLE_HANDLE: "MojoHandle", mojom.NULLABLE_HANDLE: "MojoHandle",
mojom.NULLABLE_DCPIPE: "MojoHandle", mojom.NULLABLE_DCPIPE: "MojoHandle",
mojom.NULLABLE_DPPIPE: "MojoHandle", mojom.NULLABLE_DPPIPE: "MojoHandle",
mojom.NULLABLE_MSGPIPE: "MojoHandle", mojom.NULLABLE_MSGPIPE: "MojoHandle",
mojom.NULLABLE_SHAREDBUFFER: "MojoHandle", mojom.NULLABLE_SHAREDBUFFER: "MojoHandle",
mojom.NULLABLE_PLATFORMHANDLE: "MojoHandle", mojom.NULLABLE_PLATFORMHANDLE: "MojoHandle",
} }
_kind_to_lite_js_type = { _kind_to_lite_js_type = {
mojom.BOOL: "mojo.internal.Bool", mojom.BOOL: "mojo.internal.Bool",
mojom.INT8: "mojo.internal.Int8", mojom.INT8: "mojo.internal.Int8",
mojom.UINT8: "mojo.internal.Uint8", mojom.UINT8: "mojo.internal.Uint8",
mojom.INT16: "mojo.internal.Int16", mojom.INT16: "mojo.internal.Int16",
mojom.UINT16: "mojo.internal.Uint16", mojom.UINT16: "mojo.internal.Uint16",
mojom.INT32: "mojo.internal.Int32", mojom.INT32: "mojo.internal.Int32",
mojom.UINT32: "mojo.internal.Uint32", mojom.UINT32: "mojo.internal.Uint32",
mojom.FLOAT: "mojo.internal.Float", mojom.FLOAT: "mojo.internal.Float",
mojom.HANDLE: "mojo.internal.Handle", mojom.HANDLE: "mojo.internal.Handle",
mojom.DCPIPE: "mojo.internal.Handle", mojom.DCPIPE: "mojo.internal.Handle",
mojom.DPPIPE: "mojo.internal.Handle", mojom.DPPIPE: "mojo.internal.Handle",
mojom.MSGPIPE: "mojo.internal.Handle", mojom.MSGPIPE: "mojo.internal.Handle",
mojom.SHAREDBUFFER: "mojo.internal.Handle", mojom.SHAREDBUFFER: "mojo.internal.Handle",
mojom.PLATFORMHANDLE: "mojo.internal.Handle", mojom.PLATFORMHANDLE: "mojo.internal.Handle",
mojom.NULLABLE_HANDLE: "mojo.internal.Handle", mojom.NULLABLE_HANDLE: "mojo.internal.Handle",
mojom.NULLABLE_DCPIPE: "mojo.internal.Handle", mojom.NULLABLE_DCPIPE: "mojo.internal.Handle",
mojom.NULLABLE_DPPIPE: "mojo.internal.Handle", mojom.NULLABLE_DPPIPE: "mojo.internal.Handle",
mojom.NULLABLE_MSGPIPE: "mojo.internal.Handle", mojom.NULLABLE_MSGPIPE: "mojo.internal.Handle",
mojom.NULLABLE_SHAREDBUFFER: "mojo.internal.Handle", mojom.NULLABLE_SHAREDBUFFER: "mojo.internal.Handle",
mojom.NULLABLE_PLATFORMHANDLE: "mojo.internal.Handle", mojom.NULLABLE_PLATFORMHANDLE: "mojo.internal.Handle",
mojom.INT64: "mojo.internal.Int64", mojom.INT64: "mojo.internal.Int64",
mojom.UINT64: "mojo.internal.Uint64", mojom.UINT64: "mojo.internal.Uint64",
mojom.DOUBLE: "mojo.internal.Double", mojom.DOUBLE: "mojo.internal.Double",
mojom.STRING: "mojo.internal.String", mojom.STRING: "mojo.internal.String",
mojom.NULLABLE_STRING: "mojo.internal.String", mojom.NULLABLE_STRING: "mojo.internal.String",
} }
_js_reserved_keywords = [ _js_reserved_keywords = [
...@@ -176,31 +175,31 @@ _js_reserved_keywords = [ ...@@ -176,31 +175,31 @@ _js_reserved_keywords = [
] ]
_primitive_kind_to_fuzz_type = { _primitive_kind_to_fuzz_type = {
mojom.BOOL: "Bool", mojom.BOOL: "Bool",
mojom.INT8: "Int8", mojom.INT8: "Int8",
mojom.UINT8: "Uint8", mojom.UINT8: "Uint8",
mojom.INT16: "Int16", mojom.INT16: "Int16",
mojom.UINT16: "Uint16", mojom.UINT16: "Uint16",
mojom.INT32: "Int32", mojom.INT32: "Int32",
mojom.UINT32: "Uint32", mojom.UINT32: "Uint32",
mojom.FLOAT: "Float", mojom.FLOAT: "Float",
mojom.INT64: "Int64", mojom.INT64: "Int64",
mojom.UINT64: "Uint64", mojom.UINT64: "Uint64",
mojom.DOUBLE: "Double", mojom.DOUBLE: "Double",
mojom.STRING: "String", mojom.STRING: "String",
mojom.NULLABLE_STRING: "String", mojom.NULLABLE_STRING: "String",
mojom.HANDLE: "Handle", mojom.HANDLE: "Handle",
mojom.DCPIPE: "DataPipeConsumer", mojom.DCPIPE: "DataPipeConsumer",
mojom.DPPIPE: "DataPipeProducer", mojom.DPPIPE: "DataPipeProducer",
mojom.MSGPIPE: "MessagePipe", mojom.MSGPIPE: "MessagePipe",
mojom.SHAREDBUFFER: "SharedBuffer", mojom.SHAREDBUFFER: "SharedBuffer",
mojom.PLATFORMHANDLE: "PlatformHandle", mojom.PLATFORMHANDLE: "PlatformHandle",
mojom.NULLABLE_HANDLE: "Handle", mojom.NULLABLE_HANDLE: "Handle",
mojom.NULLABLE_DCPIPE: "DataPipeConsumer", mojom.NULLABLE_DCPIPE: "DataPipeConsumer",
mojom.NULLABLE_DPPIPE: "DataPipeProducer", mojom.NULLABLE_DPPIPE: "DataPipeProducer",
mojom.NULLABLE_MSGPIPE: "MessagePipe", mojom.NULLABLE_MSGPIPE: "MessagePipe",
mojom.NULLABLE_SHAREDBUFFER: "SharedBuffer", mojom.NULLABLE_SHAREDBUFFER: "SharedBuffer",
mojom.NULLABLE_PLATFORMHANDLE: "PlatformHandle", mojom.NULLABLE_PLATFORMHANDLE: "PlatformHandle",
} }
...@@ -260,26 +259,27 @@ class JavaScriptStylizer(generator.Stylizer): ...@@ -260,26 +259,27 @@ class JavaScriptStylizer(generator.Stylizer):
return mojom_name return mojom_name
def StylizeModule(self, mojom_namespace): def StylizeModule(self, mojom_namespace):
return '.'.join(generator.ToCamel(word, lower_initial=True) return '.'.join(
for word in mojom_namespace.split('.')) generator.ToCamel(word, lower_initial=True)
for word in mojom_namespace.split('.'))
class Generator(generator.Generator): class Generator(generator.Generator):
def _GetParameters(self, for_compile=False): def _GetParameters(self, for_compile=False):
return { return {
"enums": self.module.enums, "enums": self.module.enums,
"html_imports": self._GenerateHtmlImports(), "html_imports": self._GenerateHtmlImports(),
"imports": self.module.imports, "imports": self.module.imports,
"interfaces": self.module.interfaces, "interfaces": self.module.interfaces,
"kinds": self.module.kinds, "kinds": self.module.kinds,
"module": self.module, "module": self.module,
"mojom_filename": os.path.basename(self.module.path), "mojom_filename": os.path.basename(self.module.path),
"mojom_namespace": self.module.mojom_namespace, "mojom_namespace": self.module.mojom_namespace,
"structs": self.module.structs + self._GetStructsFromMethods(), "structs": self.module.structs + self._GetStructsFromMethods(),
"unions": self.module.unions, "unions": self.module.unions,
"generate_fuzzing": self.generate_fuzzing, "generate_fuzzing": self.generate_fuzzing,
"generate_closure_exports": for_compile, "generate_closure_exports": for_compile,
"generate_struct_deserializers": self.js_generate_struct_deserializers, "generate_struct_deserializers": self.js_generate_struct_deserializers,
} }
@staticmethod @staticmethod
...@@ -288,65 +288,66 @@ class Generator(generator.Generator): ...@@ -288,65 +288,66 @@ class Generator(generator.Generator):
def GetFilters(self): def GetFilters(self):
js_filters = { js_filters = {
"closure_type": self._ClosureType, "closure_type": self._ClosureType,
"decode_snippet": self._JavaScriptDecodeSnippet, "decode_snippet": self._JavaScriptDecodeSnippet,
"default_value": self._JavaScriptDefaultValue, "default_value": self._JavaScriptDefaultValue,
"encode_snippet": self._JavaScriptEncodeSnippet, "encode_snippet": self._JavaScriptEncodeSnippet,
"expression_to_text": self._ExpressionToText, "expression_to_text": self._ExpressionToText,
"expression_to_text_lite": self._ExpressionToTextLite, "expression_to_text_lite": self._ExpressionToTextLite,
"field_offset": JavaScriptFieldOffset, "field_offset": JavaScriptFieldOffset,
"get_relative_url": GetRelativeUrl, "get_relative_url": GetRelativeUrl,
"has_callbacks": mojom.HasCallbacks, "has_callbacks": mojom.HasCallbacks,
"is_any_handle_or_interface_kind": mojom.IsAnyHandleOrInterfaceKind, "is_any_handle_or_interface_kind": mojom.IsAnyHandleOrInterfaceKind,
"is_array_kind": mojom.IsArrayKind, "is_array_kind": mojom.IsArrayKind,
"is_associated_interface_kind": mojom.IsAssociatedInterfaceKind, "is_associated_interface_kind": mojom.IsAssociatedInterfaceKind,
"is_pending_associated_remote_kind": mojom.IsPendingAssociatedRemoteKind, "is_pending_associated_remote_kind":
"is_associated_interface_request_kind": mojom.IsPendingAssociatedRemoteKind,
mojom.IsAssociatedInterfaceRequestKind, "is_associated_interface_request_kind":
"is_pending_associated_receiver_kind": mojom.IsAssociatedInterfaceRequestKind,
mojom.IsPendingAssociatedReceiverKind, "is_pending_associated_receiver_kind":
"is_bool_kind": mojom.IsBoolKind, mojom.IsPendingAssociatedReceiverKind,
"is_enum_kind": mojom.IsEnumKind, "is_bool_kind": mojom.IsBoolKind,
"is_any_handle_kind": mojom.IsAnyHandleKind, "is_enum_kind": mojom.IsEnumKind,
"is_any_interface_kind": mojom.IsAnyInterfaceKind, "is_any_handle_kind": mojom.IsAnyHandleKind,
"is_interface_kind": mojom.IsInterfaceKind, "is_any_interface_kind": mojom.IsAnyInterfaceKind,
"is_pending_remote_kind": mojom.IsPendingRemoteKind, "is_interface_kind": mojom.IsInterfaceKind,
"is_interface_request_kind": mojom.IsInterfaceRequestKind, "is_pending_remote_kind": mojom.IsPendingRemoteKind,
"is_pending_receiver_kind": mojom.IsPendingReceiverKind, "is_interface_request_kind": mojom.IsInterfaceRequestKind,
"is_map_kind": mojom.IsMapKind, "is_pending_receiver_kind": mojom.IsPendingReceiverKind,
"is_object_kind": mojom.IsObjectKind, "is_map_kind": mojom.IsMapKind,
"is_reference_kind": mojom.IsReferenceKind, "is_object_kind": mojom.IsObjectKind,
"is_string_kind": mojom.IsStringKind, "is_reference_kind": mojom.IsReferenceKind,
"is_struct_kind": mojom.IsStructKind, "is_string_kind": mojom.IsStringKind,
"is_union_kind": mojom.IsUnionKind, "is_struct_kind": mojom.IsStructKind,
"js_type": self._JavaScriptType, "is_union_kind": mojom.IsUnionKind,
"lite_default_value": self._LiteJavaScriptDefaultValue, "js_type": self._JavaScriptType,
"lite_js_type": self._LiteJavaScriptType, "lite_default_value": self._LiteJavaScriptDefaultValue,
"lite_js_import_name": self._LiteJavaScriptImportName, "lite_js_type": self._LiteJavaScriptType,
"method_passes_associated_kinds": mojom.MethodPassesAssociatedKinds, "lite_js_import_name": self._LiteJavaScriptImportName,
"namespace_declarations": self._NamespaceDeclarations, "method_passes_associated_kinds": mojom.MethodPassesAssociatedKinds,
"closure_type_with_nullability": self._ClosureTypeWithNullability, "namespace_declarations": self._NamespaceDeclarations,
"lite_closure_param_type": self._LiteClosureParamType, "closure_type_with_nullability": self._ClosureTypeWithNullability,
"lite_closure_type": self._LiteClosureType, "lite_closure_param_type": self._LiteClosureParamType,
"lite_closure_type_with_nullability": "lite_closure_type": self._LiteClosureType,
self._LiteClosureTypeWithNullability, "lite_closure_type_with_nullability":
"lite_closure_field_type": self._LiteClosureFieldType, self._LiteClosureTypeWithNullability,
"payload_size": JavaScriptPayloadSize, "lite_closure_field_type": self._LiteClosureFieldType,
"to_camel": generator.ToCamel, "payload_size": JavaScriptPayloadSize,
"union_decode_snippet": self._JavaScriptUnionDecodeSnippet, "to_camel": generator.ToCamel,
"union_encode_snippet": self._JavaScriptUnionEncodeSnippet, "union_decode_snippet": self._JavaScriptUnionDecodeSnippet,
"validate_array_params": self._JavaScriptValidateArrayParams, "union_encode_snippet": self._JavaScriptUnionEncodeSnippet,
"validate_enum_params": self._JavaScriptValidateEnumParams, "validate_array_params": self._JavaScriptValidateArrayParams,
"validate_map_params": self._JavaScriptValidateMapParams, "validate_enum_params": self._JavaScriptValidateEnumParams,
"validate_nullable_params": self._JavaScriptNullableParam, "validate_map_params": self._JavaScriptValidateMapParams,
"validate_struct_params": self._JavaScriptValidateStructParams, "validate_nullable_params": self._JavaScriptNullableParam,
"validate_union_params": self._JavaScriptValidateUnionParams, "validate_struct_params": self._JavaScriptValidateStructParams,
"sanitize_identifier": self._JavaScriptSanitizeIdentifier, "validate_union_params": self._JavaScriptValidateUnionParams,
"contains_handles_or_interfaces": mojom.ContainsHandlesOrInterfaces, "sanitize_identifier": self._JavaScriptSanitizeIdentifier,
"fuzz_handle_name": self._FuzzHandleName, "contains_handles_or_interfaces": mojom.ContainsHandlesOrInterfaces,
"is_primitive_kind": self._IsPrimitiveKind, "fuzz_handle_name": self._FuzzHandleName,
"primitive_to_fuzz_type": self._PrimitiveToFuzzType, "is_primitive_kind": self._IsPrimitiveKind,
"to_js_boolean": self._ToJsBoolean, "primitive_to_fuzz_type": self._PrimitiveToFuzzType,
"to_js_boolean": self._ToJsBoolean,
} }
return js_filters return js_filters
...@@ -416,8 +417,7 @@ class Generator(generator.Generator): ...@@ -416,8 +417,7 @@ class Generator(generator.Generator):
return kind.module.namespace + "." + kind.name + "Ptr" return kind.module.namespace + "." + kind.name + "Ptr"
if mojom.IsPendingRemoteKind(kind): if mojom.IsPendingRemoteKind(kind):
return kind.kind.module.namespace + "." + kind.kind.name + "Ptr" return kind.kind.module.namespace + "." + kind.kind.name + "Ptr"
if (mojom.IsStructKind(kind) or if (mojom.IsStructKind(kind) or mojom.IsEnumKind(kind)):
mojom.IsEnumKind(kind)):
return kind.module.namespace + "." + kind.name return kind.module.namespace + "." + kind.name
# TODO(calamity): Support unions properly. # TODO(calamity): Support unions properly.
if mojom.IsUnionKind(kind): if mojom.IsUnionKind(kind):
...@@ -425,17 +425,17 @@ class Generator(generator.Generator): ...@@ -425,17 +425,17 @@ class Generator(generator.Generator):
if mojom.IsArrayKind(kind): if mojom.IsArrayKind(kind):
return "Array<%s>" % self._ClosureType(kind.kind) return "Array<%s>" % self._ClosureType(kind.kind)
if mojom.IsMapKind(kind): if mojom.IsMapKind(kind):
return "Map<%s, %s>" % ( return "Map<%s, %s>" % (self._ClosureType(
self._ClosureType(kind.key_kind), self._ClosureType(kind.value_kind)) kind.key_kind), self._ClosureType(kind.value_kind))
if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind): if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind):
return "mojo.InterfaceRequest" return "mojo.InterfaceRequest"
# TODO(calamity): Support associated interfaces properly. # TODO(calamity): Support associated interfaces properly.
if (mojom.IsAssociatedInterfaceKind(kind) or if (mojom.IsAssociatedInterfaceKind(kind)
mojom.IsPendingAssociatedRemoteKind(kind)): or mojom.IsPendingAssociatedRemoteKind(kind)):
return "mojo.AssociatedInterfacePtrInfo" return "mojo.AssociatedInterfacePtrInfo"
# TODO(calamity): Support associated interface requests properly. # TODO(calamity): Support associated interface requests properly.
if (mojom.IsAssociatedInterfaceRequestKind(kind) or if (mojom.IsAssociatedInterfaceRequestKind(kind)
mojom.IsPendingAssociatedReceiverKind(kind)): or mojom.IsPendingAssociatedReceiverKind(kind)):
return "mojo.AssociatedInterfaceRequest" return "mojo.AssociatedInterfaceRequest"
# TODO(calamity): Support enums properly. # TODO(calamity): Support enums properly.
...@@ -445,9 +445,9 @@ class Generator(generator.Generator): ...@@ -445,9 +445,9 @@ class Generator(generator.Generator):
# Indicates whether a kind of suitable to stringify and use as an Object # Indicates whether a kind of suitable to stringify and use as an Object
# property name. This is checked for map key types to allow most kinds of # property name. This is checked for map key types to allow most kinds of
# mojom maps to be represented as either a Map or an Object. # mojom maps to be represented as either a Map or an Object.
return (mojom.IsIntegralKind(kind) or mojom.IsFloatKind(kind) or return (mojom.IsIntegralKind(kind) or mojom.IsFloatKind(kind)
mojom.IsDoubleKind(kind) or mojom.IsStringKind(kind) or or mojom.IsDoubleKind(kind) or mojom.IsStringKind(kind)
mojom.IsEnumKind(kind)) or mojom.IsEnumKind(kind))
def _LiteClosureType(self, kind): def _LiteClosureType(self, kind):
if kind in mojom.PRIMITIVES: if kind in mojom.PRIMITIVES:
...@@ -455,18 +455,16 @@ class Generator(generator.Generator): ...@@ -455,18 +455,16 @@ class Generator(generator.Generator):
if mojom.IsArrayKind(kind): if mojom.IsArrayKind(kind):
return "Array<%s>" % self._LiteClosureTypeWithNullability(kind.kind) return "Array<%s>" % self._LiteClosureTypeWithNullability(kind.kind)
if mojom.IsMapKind(kind) and self._IsStringableKind(kind.key_kind): if mojom.IsMapKind(kind) and self._IsStringableKind(kind.key_kind):
return "Object<%s, %s>" % ( return "Object<%s, %s>" % (self._LiteClosureTypeWithNullability(
self._LiteClosureTypeWithNullability(kind.key_kind), kind.key_kind), self._LiteClosureTypeWithNullability(kind.value_kind))
self._LiteClosureTypeWithNullability(kind.value_kind))
if mojom.IsMapKind(kind): if mojom.IsMapKind(kind):
return "Map<%s, %s>" % ( return "Map<%s, %s>" % (self._LiteClosureTypeWithNullability(
self._LiteClosureTypeWithNullability(kind.key_kind), kind.key_kind), self._LiteClosureTypeWithNullability(kind.value_kind))
self._LiteClosureTypeWithNullability(kind.value_kind))
if (mojom.IsAssociatedKind(kind) or mojom.IsInterfaceRequestKind(kind)
if (mojom.IsAssociatedKind(kind) or mojom.IsInterfaceRequestKind(kind) or or mojom.IsPendingRemoteKind(kind) or mojom.IsPendingReceiverKind(kind)
mojom.IsPendingRemoteKind(kind) or mojom.IsPendingReceiverKind(kind) or or mojom.IsPendingAssociatedRemoteKind(kind)
mojom.IsPendingAssociatedRemoteKind(kind) or or mojom.IsPendingAssociatedReceiverKind(kind)):
mojom.IsPendingAssociatedReceiverKind(kind)):
named_kind = kind.kind named_kind = kind.kind
else: else:
named_kind = kind named_kind = kind
...@@ -484,20 +482,20 @@ class Generator(generator.Generator): ...@@ -484,20 +482,20 @@ class Generator(generator.Generator):
name.append("" + named_kind.name) name.append("" + named_kind.name)
name = ".".join(name) name = ".".join(name)
if (mojom.IsStructKind(kind) or mojom.IsUnionKind(kind) or if (mojom.IsStructKind(kind) or mojom.IsUnionKind(kind)
mojom.IsEnumKind(kind)): or mojom.IsEnumKind(kind)):
return name return name
if mojom.IsInterfaceKind(kind) or mojom.IsPendingRemoteKind(kind): if mojom.IsInterfaceKind(kind) or mojom.IsPendingRemoteKind(kind):
return name + "Remote" return name + "Remote"
if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind): if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind):
return name + "PendingReceiver" return name + "PendingReceiver"
# TODO(calamity): Support associated interfaces properly. # TODO(calamity): Support associated interfaces properly.
if (mojom.IsAssociatedInterfaceKind(kind) or if (mojom.IsAssociatedInterfaceKind(kind)
mojom.IsPendingAssociatedRemoteKind(kind)): or mojom.IsPendingAssociatedRemoteKind(kind)):
return "Object" return "Object"
# TODO(calamity): Support associated interface requests properly. # TODO(calamity): Support associated interface requests properly.
if (mojom.IsAssociatedInterfaceRequestKind(kind) or if (mojom.IsAssociatedInterfaceRequestKind(kind)
mojom.IsPendingAssociatedReceiverKind(kind)): or mojom.IsPendingAssociatedReceiverKind(kind)):
return "Object" return "Object"
raise Exception("No valid closure type: %s" % kind) raise Exception("No valid closure type: %s" % kind)
...@@ -512,20 +510,19 @@ class Generator(generator.Generator): ...@@ -512,20 +510,19 @@ class Generator(generator.Generator):
if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind): if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
return prefix + "Object" return prefix + "Object"
if mojom.IsArrayKind(kind): if mojom.IsArrayKind(kind):
return prefix + ("Array<%s>" % return prefix + ("Array<%s>" % self._LiteClosureParamType(kind.kind))
self._LiteClosureParamType(kind.kind))
if mojom.IsMapKind(kind): if mojom.IsMapKind(kind):
return "%sMap<%s, %s>|%sObject<%s, %s>" % ( return "%sMap<%s, %s>|%sObject<%s, %s>" % (
prefix, self._LiteClosureParamType(kind.key_kind), prefix, self._LiteClosureParamType(kind.key_kind),
self._LiteClosureParamType(kind.value_kind), self._LiteClosureParamType(
prefix, self._LiteClosureParamType(kind.key_kind), kind.value_kind), prefix, self._LiteClosureParamType(
self._LiteClosureParamType(kind.value_kind)) kind.key_kind), self._LiteClosureParamType(kind.value_kind))
return prefix + self._LiteClosureType(kind) return prefix + self._LiteClosureType(kind)
def _LiteClosureTypeWithNullability(self, kind): def _LiteClosureTypeWithNullability(self, kind):
return (("?" if mojom.IsNullableKind(kind) else "!") + return (("?" if mojom.IsNullableKind(kind) else "!") +
self._LiteClosureType(kind)) self._LiteClosureType(kind))
def _LiteClosureFieldType(self, kind): def _LiteClosureFieldType(self, kind):
if mojom.IsNullableKind(kind): if mojom.IsNullableKind(kind):
...@@ -555,19 +552,18 @@ class Generator(generator.Generator): ...@@ -555,19 +552,18 @@ class Generator(generator.Generator):
if self._IsPrimitiveKind(kind): if self._IsPrimitiveKind(kind):
return _kind_to_lite_js_type[kind] return _kind_to_lite_js_type[kind]
if mojom.IsArrayKind(kind): if mojom.IsArrayKind(kind):
return "mojo.internal.Array(%s, %s)" % ( return "mojo.internal.Array(%s, %s)" % (self._LiteJavaScriptType(
self._LiteJavaScriptType(kind.kind), kind.kind), "true" if mojom.IsNullableKind(kind.kind) else "false")
"true" if mojom.IsNullableKind(kind.kind) else "false")
if mojom.IsMapKind(kind): if mojom.IsMapKind(kind):
return "mojo.internal.Map(%s, %s, %s)" % ( return "mojo.internal.Map(%s, %s, %s)" % (self._LiteJavaScriptType(
self._LiteJavaScriptType(kind.key_kind), kind.key_kind), self._LiteJavaScriptType(
self._LiteJavaScriptType(kind.value_kind), kind.value_kind), "true" if mojom.IsNullableKind(kind.value_kind)
"true" if mojom.IsNullableKind(kind.value_kind) else "false") else "false")
if (mojom.IsAssociatedKind(kind) or mojom.IsInterfaceRequestKind(kind) or if (mojom.IsAssociatedKind(kind) or mojom.IsInterfaceRequestKind(kind)
mojom.IsPendingRemoteKind(kind) or mojom.IsPendingReceiverKind(kind) or or mojom.IsPendingRemoteKind(kind) or mojom.IsPendingReceiverKind(kind)
mojom.IsPendingAssociatedRemoteKind(kind) or or mojom.IsPendingAssociatedRemoteKind(kind)
mojom.IsPendingAssociatedReceiverKind(kind)): or mojom.IsPendingAssociatedReceiverKind(kind)):
named_kind = kind.kind named_kind = kind.kind
else: else:
named_kind = kind named_kind = kind
...@@ -583,21 +579,21 @@ class Generator(generator.Generator): ...@@ -583,21 +579,21 @@ class Generator(generator.Generator):
name.append(named_kind.name) name.append(named_kind.name)
name = ".".join(name) name = ".".join(name)
if (mojom.IsStructKind(kind) or mojom.IsUnionKind(kind) or if (mojom.IsStructKind(kind) or mojom.IsUnionKind(kind)
mojom.IsEnumKind(kind)): or mojom.IsEnumKind(kind)):
return "%sSpec.$" % name return "%sSpec.$" % name
if mojom.IsInterfaceKind(kind) or mojom.IsPendingRemoteKind(kind): if mojom.IsInterfaceKind(kind) or mojom.IsPendingRemoteKind(kind):
return "mojo.internal.InterfaceProxy(%sRemote)" % name return "mojo.internal.InterfaceProxy(%sRemote)" % name
if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind): if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind):
return "mojo.internal.InterfaceRequest(%sPendingReceiver)" % name return "mojo.internal.InterfaceRequest(%sPendingReceiver)" % name
if (mojom.IsAssociatedInterfaceKind(kind) or if (mojom.IsAssociatedInterfaceKind(kind)
mojom.IsPendingAssociatedRemoteKind(kind)): or mojom.IsPendingAssociatedRemoteKind(kind)):
# TODO(rockot): Implement associated interfaces. # TODO(rockot): Implement associated interfaces.
return "mojo.internal.AssociatedInterfaceProxy(%sRemote)" % (name) return "mojo.internal.AssociatedInterfaceProxy(%sRemote)" % (name)
if (mojom.IsAssociatedInterfaceRequestKind(kind) or if (mojom.IsAssociatedInterfaceRequestKind(kind)
mojom.IsPendingAssociatedReceiverKind(kind)): or mojom.IsPendingAssociatedReceiverKind(kind)):
return "mojo.internal.AssociatedInterfaceRequest(%sPendingReceiver)" % ( return "mojo.internal.AssociatedInterfaceRequest(%sPendingReceiver)" % (
name) name)
return name return name
...@@ -630,14 +626,14 @@ class Generator(generator.Generator): ...@@ -630,14 +626,14 @@ class Generator(generator.Generator):
return "new %sPtr()" % self._JavaScriptType(field.kind) return "new %sPtr()" % self._JavaScriptType(field.kind)
if mojom.IsPendingRemoteKind(field.kind): if mojom.IsPendingRemoteKind(field.kind):
return "new %sPtr()" % self._JavaScriptType(field.kind.kind) return "new %sPtr()" % self._JavaScriptType(field.kind.kind)
if (mojom.IsInterfaceRequestKind(field.kind) or if (mojom.IsInterfaceRequestKind(field.kind)
mojom.IsPendingReceiverKind(field.kind)): or mojom.IsPendingReceiverKind(field.kind)):
return "new bindings.InterfaceRequest()" return "new bindings.InterfaceRequest()"
if (mojom.IsAssociatedInterfaceKind(field.kind) or if (mojom.IsAssociatedInterfaceKind(field.kind)
mojom.IsPendingAssociatedRemoteKind(field.kind)): or mojom.IsPendingAssociatedRemoteKind(field.kind)):
return "new associatedBindings.AssociatedInterfacePtrInfo()" return "new associatedBindings.AssociatedInterfacePtrInfo()"
if (mojom.IsAssociatedInterfaceRequestKind(field.kind) or if (mojom.IsAssociatedInterfaceRequestKind(field.kind)
mojom.IsPendingAssociatedReceiverKind(field.kind)): or mojom.IsPendingAssociatedReceiverKind(field.kind)):
return "new associatedBindings.AssociatedInterfaceRequest()" return "new associatedBindings.AssociatedInterfaceRequest()"
if mojom.IsEnumKind(field.kind): if mojom.IsEnumKind(field.kind):
return "0" return "0"
...@@ -647,7 +643,7 @@ class Generator(generator.Generator): ...@@ -647,7 +643,7 @@ class Generator(generator.Generator):
if field.default: if field.default:
if mojom.IsStructKind(field.kind): if mojom.IsStructKind(field.kind):
assert field.default == "default" assert field.default == "default"
return "null"; return "null"
return self._ExpressionToTextLite(field.default) return self._ExpressionToTextLite(field.default)
if field.kind in mojom.PRIMITIVES: if field.kind in mojom.PRIMITIVES:
return _kind_to_javascript_default_value[field.kind] return _kind_to_javascript_default_value[field.kind]
...@@ -665,8 +661,8 @@ class Generator(generator.Generator): ...@@ -665,8 +661,8 @@ class Generator(generator.Generator):
if mojom.IsUnionKind(kind): if mojom.IsUnionKind(kind):
return self._JavaScriptType(kind) return self._JavaScriptType(kind)
if mojom.IsArrayKind(kind): if mojom.IsArrayKind(kind):
array_type = ("NullableArrayOf" if mojom.IsNullableKind(kind) array_type = ("NullableArrayOf"
else "ArrayOf") if mojom.IsNullableKind(kind) else "ArrayOf")
array_length = "" if kind.length is None else ", %d" % kind.length array_length = "" if kind.length is None else ", %d" % kind.length
element_type = self._ElementCodecType(kind.kind) element_type = self._ElementCodecType(kind.kind)
return "new codec.%s(%s%s)" % (array_type, element_type, array_length) return "new codec.%s(%s%s)" % (array_type, element_type, array_length)
...@@ -679,17 +675,18 @@ class Generator(generator.Generator): ...@@ -679,17 +675,18 @@ class Generator(generator.Generator):
"NullableInterface" if mojom.IsNullableKind(kind) else "Interface", "NullableInterface" if mojom.IsNullableKind(kind) else "Interface",
self._JavaScriptType(kind.kind)) self._JavaScriptType(kind.kind))
if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind): if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind):
return "codec.%s" % ( return "codec.%s" % ("NullableInterfaceRequest" if
"NullableInterfaceRequest" if mojom.IsNullableKind(kind) mojom.IsNullableKind(kind) else "InterfaceRequest")
else "InterfaceRequest") if (mojom.IsAssociatedInterfaceKind(kind)
if (mojom.IsAssociatedInterfaceKind(kind) or or mojom.IsPendingAssociatedRemoteKind(kind)):
mojom.IsPendingAssociatedRemoteKind(kind)):
return "codec.%s" % ("NullableAssociatedInterfacePtrInfo" return "codec.%s" % ("NullableAssociatedInterfacePtrInfo"
if mojom.IsNullableKind(kind) else "AssociatedInterfacePtrInfo") if mojom.IsNullableKind(kind) else
if (mojom.IsAssociatedInterfaceRequestKind(kind) or "AssociatedInterfacePtrInfo")
mojom.IsPendingAssociatedReceiverKind(kind)): if (mojom.IsAssociatedInterfaceRequestKind(kind)
or mojom.IsPendingAssociatedReceiverKind(kind)):
return "codec.%s" % ("NullableAssociatedInterfaceRequest" return "codec.%s" % ("NullableAssociatedInterfaceRequest"
if mojom.IsNullableKind(kind) else "AssociatedInterfaceRequest") if mojom.IsNullableKind(kind) else
"AssociatedInterfaceRequest")
if mojom.IsEnumKind(kind): if mojom.IsEnumKind(kind):
return "new codec.Enum(%s)" % self._JavaScriptType(kind) return "new codec.Enum(%s)" % self._JavaScriptType(kind)
if mojom.IsMapKind(kind): if mojom.IsMapKind(kind):
...@@ -700,19 +697,18 @@ class Generator(generator.Generator): ...@@ -700,19 +697,18 @@ class Generator(generator.Generator):
raise Exception("No codec type for %s" % kind) raise Exception("No codec type for %s" % kind)
def _ElementCodecType(self, kind): def _ElementCodecType(self, kind):
return ("codec.PackedBool" if mojom.IsBoolKind(kind) return ("codec.PackedBool"
else self._CodecType(kind)) if mojom.IsBoolKind(kind) else self._CodecType(kind))
def _JavaScriptDecodeSnippet(self, kind): def _JavaScriptDecodeSnippet(self, kind):
if (kind in mojom.PRIMITIVES or mojom.IsUnionKind(kind) or if (kind in mojom.PRIMITIVES or mojom.IsUnionKind(kind)
mojom.IsAnyInterfaceKind(kind)): or mojom.IsAnyInterfaceKind(kind)):
return "decodeStruct(%s)" % self._CodecType(kind) return "decodeStruct(%s)" % self._CodecType(kind)
if mojom.IsStructKind(kind): if mojom.IsStructKind(kind):
return "decodeStructPointer(%s)" % self._JavaScriptType(kind) return "decodeStructPointer(%s)" % self._JavaScriptType(kind)
if mojom.IsMapKind(kind): if mojom.IsMapKind(kind):
return "decodeMapPointer(%s, %s)" % ( return "decodeMapPointer(%s, %s)" % (self._ElementCodecType(
self._ElementCodecType(kind.key_kind), kind.key_kind), self._ElementCodecType(kind.value_kind))
self._ElementCodecType(kind.value_kind))
if mojom.IsArrayKind(kind) and mojom.IsBoolKind(kind.kind): if mojom.IsArrayKind(kind) and mojom.IsBoolKind(kind.kind):
return "decodeArrayPointer(codec.PackedBool)" return "decodeArrayPointer(codec.PackedBool)"
if mojom.IsArrayKind(kind): if mojom.IsArrayKind(kind):
...@@ -724,19 +720,18 @@ class Generator(generator.Generator): ...@@ -724,19 +720,18 @@ class Generator(generator.Generator):
raise Exception("No decode snippet for %s" % kind) raise Exception("No decode snippet for %s" % kind)
def _JavaScriptEncodeSnippet(self, kind): def _JavaScriptEncodeSnippet(self, kind):
if (kind in mojom.PRIMITIVES or mojom.IsUnionKind(kind) or if (kind in mojom.PRIMITIVES or mojom.IsUnionKind(kind)
mojom.IsAnyInterfaceKind(kind)): or mojom.IsAnyInterfaceKind(kind)):
return "encodeStruct(%s, " % self._CodecType(kind) return "encodeStruct(%s, " % self._CodecType(kind)
if mojom.IsUnionKind(kind): if mojom.IsUnionKind(kind):
return "encodeStruct(%s, " % self._JavaScriptType(kind) return "encodeStruct(%s, " % self._JavaScriptType(kind)
if mojom.IsStructKind(kind): if mojom.IsStructKind(kind):
return "encodeStructPointer(%s, " % self._JavaScriptType(kind) return "encodeStructPointer(%s, " % self._JavaScriptType(kind)
if mojom.IsMapKind(kind): if mojom.IsMapKind(kind):
return "encodeMapPointer(%s, %s, " % ( return "encodeMapPointer(%s, %s, " % (self._ElementCodecType(
self._ElementCodecType(kind.key_kind), kind.key_kind), self._ElementCodecType(kind.value_kind))
self._ElementCodecType(kind.value_kind))
if mojom.IsArrayKind(kind) and mojom.IsBoolKind(kind.kind): if mojom.IsArrayKind(kind) and mojom.IsBoolKind(kind.kind):
return "encodeArrayPointer(codec.PackedBool, "; return "encodeArrayPointer(codec.PackedBool, "
if mojom.IsArrayKind(kind): if mojom.IsArrayKind(kind):
return "encodeArrayPointer(%s, " % self._CodecType(kind.kind) return "encodeArrayPointer(%s, " % self._CodecType(kind.kind)
if mojom.IsEnumKind(kind): if mojom.IsEnumKind(kind):
...@@ -760,8 +755,7 @@ class Generator(generator.Generator): ...@@ -760,8 +755,7 @@ class Generator(generator.Generator):
nullable = self._JavaScriptNullableParam(field) nullable = self._JavaScriptNullableParam(field)
element_kind = field.kind.kind element_kind = field.kind.kind
element_size = pack.PackedField.GetSizeForKind(element_kind) element_size = pack.PackedField.GetSizeForKind(element_kind)
expected_dimension_sizes = GetArrayExpectedDimensionSizes( expected_dimension_sizes = GetArrayExpectedDimensionSizes(field.kind)
field.kind)
element_type = self._ElementCodecType(element_kind) element_type = self._ElementCodecType(element_kind)
return "%s, %s, %s, %s, 0" % \ return "%s, %s, %s, %s, 0" % \
(element_size, element_type, nullable, (element_size, element_type, nullable,
...@@ -783,7 +777,7 @@ class Generator(generator.Generator): ...@@ -783,7 +777,7 @@ class Generator(generator.Generator):
def _JavaScriptValidateMapParams(self, field): def _JavaScriptValidateMapParams(self, field):
nullable = self._JavaScriptNullableParam(field) nullable = self._JavaScriptNullableParam(field)
keys_type = self._ElementCodecType(field.kind.key_kind) keys_type = self._ElementCodecType(field.kind.key_kind)
values_kind = field.kind.value_kind; values_kind = field.kind.value_kind
values_type = self._ElementCodecType(values_kind) values_type = self._ElementCodecType(values_kind)
values_nullable = "true" if mojom.IsNullableKind(values_kind) else "false" values_nullable = "true" if mojom.IsNullableKind(values_kind) else "false"
return "%s, %s, %s, %s" % \ return "%s, %s, %s, %s" % \
...@@ -811,12 +805,12 @@ class Generator(generator.Generator): ...@@ -811,12 +805,12 @@ class Generator(generator.Generator):
if isinstance(token, mojom.BuiltinValue): if isinstance(token, mojom.BuiltinValue):
if token.value == "double.INFINITY" or token.value == "float.INFINITY": if token.value == "double.INFINITY" or token.value == "float.INFINITY":
return "Infinity"; return "Infinity"
if token.value == "double.NEGATIVE_INFINITY" or \ if token.value == "double.NEGATIVE_INFINITY" or \
token.value == "float.NEGATIVE_INFINITY": token.value == "float.NEGATIVE_INFINITY":
return "-Infinity"; return "-Infinity"
if token.value == "double.NAN" or token.value == "float.NAN": if token.value == "double.NAN" or token.value == "float.NAN":
return "NaN"; return "NaN"
return token return token
...@@ -848,8 +842,8 @@ class Generator(generator.Generator): ...@@ -848,8 +842,8 @@ class Generator(generator.Generator):
def _GenerateHtmlImports(self): def _GenerateHtmlImports(self):
result = [] result = []
for full_import in self.module.imports: for full_import in self.module.imports:
result.append(os.path.relpath(full_import.path, result.append(
os.path.dirname(self.module.path))) os.path.relpath(full_import.path, os.path.dirname(self.module.path)))
return result return result
def _GetStructsFromMethods(self): def _GetStructsFromMethods(self):
...@@ -863,20 +857,17 @@ class Generator(generator.Generator): ...@@ -863,20 +857,17 @@ class Generator(generator.Generator):
def _FuzzHandleName(self, kind): def _FuzzHandleName(self, kind):
if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind): if mojom.IsInterfaceRequestKind(kind) or mojom.IsPendingReceiverKind(kind):
return '{0}.{1}Request'.format(kind.kind.module.namespace, return '{0}.{1}Request'.format(kind.kind.module.namespace, kind.kind.name)
kind.kind.name)
elif mojom.IsInterfaceKind(kind): elif mojom.IsInterfaceKind(kind):
return '{0}.{1}Ptr'.format(kind.module.namespace, return '{0}.{1}Ptr'.format(kind.module.namespace, kind.name)
kind.name)
elif mojom.IsPendingRemoteKind(kind): elif mojom.IsPendingRemoteKind(kind):
return '{0}.{1}Ptr'.format(kind.kind.module.namespace, return '{0}.{1}Ptr'.format(kind.kind.module.namespace, kind.kind.name)
kind.kind.name) elif (mojom.IsAssociatedInterfaceRequestKind(kind)
elif (mojom.IsAssociatedInterfaceRequestKind(kind) or or mojom.IsPendingAssociatedReceiverKind(kind)):
mojom.IsPendingAssociatedReceiverKind(kind)):
return '{0}.{1}AssociatedRequest'.format(kind.kind.module.namespace, return '{0}.{1}AssociatedRequest'.format(kind.kind.module.namespace,
kind.kind.name) kind.kind.name)
elif (mojom.IsAssociatedInterfaceKind(kind) or elif (mojom.IsAssociatedInterfaceKind(kind)
mojom.IsPendingAssociatedRemoteKind(kind)): or mojom.IsPendingAssociatedRemoteKind(kind)):
return '{0}.{1}AssociatedPtr'.format(kind.kind.module.namespace, return '{0}.{1}AssociatedPtr'.format(kind.kind.module.namespace,
kind.kind.name) kind.kind.name)
elif mojom.IsSharedBufferKind(kind): elif mojom.IsSharedBufferKind(kind):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment