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

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

Issue 1998433002: Dart: Adds Interface and InterfaceRequest interfaces. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge Created 4 years, 7 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 | « mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 dart source files from a mojom.Module.""" 5 """Generates dart source files from a mojom.Module."""
6 6
7 import errno 7 import errno
8 import os 8 import os
9 import re 9 import re
10 import shutil 10 import shutil
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return GetDartType(kind) 236 return GetDartType(kind)
237 if mojom.IsUnionKind(kind): 237 if mojom.IsUnionKind(kind):
238 return GetDartType(kind) 238 return GetDartType(kind)
239 if mojom.IsArrayKind(kind): 239 if mojom.IsArrayKind(kind):
240 array_type = DartDeclType(kind.kind) 240 array_type = DartDeclType(kind.kind)
241 return "List<" + array_type + ">" 241 return "List<" + array_type + ">"
242 if mojom.IsMapKind(kind): 242 if mojom.IsMapKind(kind):
243 key_type = DartDeclType(kind.key_kind) 243 key_type = DartDeclType(kind.key_kind)
244 value_type = DartDeclType(kind.value_kind) 244 value_type = DartDeclType(kind.value_kind)
245 return "Map<"+ key_type + ", " + value_type + ">" 245 return "Map<"+ key_type + ", " + value_type + ">"
246 if mojom.IsInterfaceKind(kind) or \ 246 if mojom.IsInterfaceKind(kind):
247 mojom.IsInterfaceRequestKind(kind): 247 return ("%sInterface" % GetDartType(kind))
248 return "Object" 248 if mojom.IsInterfaceRequestKind(kind):
249 return ("%sInterfaceRequest" % GetDartType(kind.kind))
249 if mojom.IsEnumKind(kind): 250 if mojom.IsEnumKind(kind):
250 return GetDartType(kind) 251 return GetDartType(kind)
251 252
252 def NameToComponent(name): 253 def NameToComponent(name):
253 # insert '_' between anything and a Title name (e.g, HTTPEntry2FooBar -> 254 # insert '_' between anything and a Title name (e.g, HTTPEntry2FooBar ->
254 # HTTP_Entry2_FooBar). Numbers terminate a string of lower-case characters. 255 # HTTP_Entry2_FooBar). Numbers terminate a string of lower-case characters.
255 name = re.sub('([^_])([A-Z][^A-Z1-9_]+)', r'\1_\2', name) 256 name = re.sub('([^_])([A-Z][^A-Z1-9_]+)', r'\1_\2', name)
256 # insert '_' between non upper and start of upper blocks (e.g., 257 # insert '_' between non upper and start of upper blocks (e.g.,
257 # HTTP_Entry2_FooBar -> HTTP_Entry2_Foo_Bar). 258 # HTTP_Entry2_FooBar -> HTTP_Entry2_Foo_Bar).
258 name = re.sub('([^A-Z_])([A-Z])', r'\1_\2', name) 259 name = re.sub('([^A-Z_])([A-Z])', r'\1_\2', name)
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 interface_to_import[name] = each_import["unique_name"] + "." + name 647 interface_to_import[name] = each_import["unique_name"] + "." + name
647 return interface_to_import 648 return interface_to_import
648 649
649 def ImportedFrom(self): 650 def ImportedFrom(self):
650 interface_to_import = {} 651 interface_to_import = {}
651 for each_import in self.module.imports: 652 for each_import in self.module.imports:
652 for each_interface in each_import["module"].interfaces: 653 for each_interface in each_import["module"].interfaces:
653 name = each_interface.name 654 name = each_interface.name
654 interface_to_import[name] = each_import["unique_name"] + "." 655 interface_to_import[name] = each_import["unique_name"] + "."
655 return interface_to_import 656 return interface_to_import
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698