Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: mojo/public/tools/bindings/generators/mojom_js_generator.py

Issue 2427323004: Mojo JS bindings: Fix codec names for nested enum definitions (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 """Generates JavaScript source files from a mojom.Module.""" 5 """Generates JavaScript source files from a mojom.Module."""
6 6
7 import mojom.generate.generator as generator 7 import mojom.generate.generator as generator
8 import mojom.generate.module as mojom 8 import mojom.generate.module as mojom
9 import mojom.generate.pack as pack 9 import mojom.generate.pack as pack
10 from mojom.generate.template_expander import UseJinja 10 from mojom.generate.template_expander import UseJinja
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if mojom.IsInterfaceKind(kind): 126 if mojom.IsInterfaceKind(kind):
127 return "codec.%s" % ("NullableInterface" if mojom.IsNullableKind(kind) 127 return "codec.%s" % ("NullableInterface" if mojom.IsNullableKind(kind)
128 else "Interface") 128 else "Interface")
129 if mojom.IsInterfaceRequestKind(kind): 129 if mojom.IsInterfaceRequestKind(kind):
130 return CodecType(mojom.MSGPIPE) 130 return CodecType(mojom.MSGPIPE)
131 if mojom.IsAssociatedInterfaceKind(kind): 131 if mojom.IsAssociatedInterfaceKind(kind):
132 return "codec.AssociatedInterfaceNotSupported" 132 return "codec.AssociatedInterfaceNotSupported"
133 if mojom.IsAssociatedInterfaceRequestKind(kind): 133 if mojom.IsAssociatedInterfaceRequestKind(kind):
134 return "codec.AssociatedInterfaceRequestNotSupported" 134 return "codec.AssociatedInterfaceRequestNotSupported"
135 if mojom.IsEnumKind(kind): 135 if mojom.IsEnumKind(kind):
136 element_type = kind.name 136 return "new codec.Enum(%s)" % JavaScriptType(kind)
137 return "new codec.Enum(%s)" % (element_type)
138 if mojom.IsMapKind(kind): 137 if mojom.IsMapKind(kind):
139 map_type = "NullableMapOf" if mojom.IsNullableKind(kind) else "MapOf" 138 map_type = "NullableMapOf" if mojom.IsNullableKind(kind) else "MapOf"
140 key_type = ElementCodecType(kind.key_kind) 139 key_type = ElementCodecType(kind.key_kind)
141 value_type = ElementCodecType(kind.value_kind) 140 value_type = ElementCodecType(kind.value_kind)
142 return "new codec.%s(%s, %s)" % (map_type, key_type, value_type) 141 return "new codec.%s(%s, %s)" % (map_type, key_type, value_type)
143 raise Exception("No codec type for %s" % kind) 142 raise Exception("No codec type for %s" % kind)
144 143
145 144
146 def ElementCodecType(kind): 145 def ElementCodecType(kind):
147 return "codec.PackedBool" if mojom.IsBoolKind(kind) else CodecType(kind) 146 return "codec.PackedBool" if mojom.IsBoolKind(kind) else CodecType(kind)
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 return self.module.imports 452 return self.module.imports
454 453
455 def GetImportedInterfaces(self): 454 def GetImportedInterfaces(self):
456 interface_to_import = {}; 455 interface_to_import = {};
457 for each_import in self.module.imports: 456 for each_import in self.module.imports:
458 for each_interface in each_import["module"].interfaces: 457 for each_interface in each_import["module"].interfaces:
459 name = each_interface.name 458 name = each_interface.name
460 interface_to_import[name] = each_import["unique_name"] + "." + name 459 interface_to_import[name] = each_import["unique_name"] + "." + name
461 return interface_to_import; 460 return interface_to_import;
462 461
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698