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

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

Issue 1132063007: Rationalize Dart mojo and sky package structure (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
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 os 7 import os
8 import re 8 import re
9 import shutil 9 import shutil
10 import sys 10 import sys
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 "structs": self.GetStructs() + self.GetStructsFromMethods(), 391 "structs": self.GetStructs() + self.GetStructsFromMethods(),
392 "interfaces": self.GetInterfaces(), 392 "interfaces": self.GetInterfaces(),
393 "imported_interfaces": self.GetImportedInterfaces(), 393 "imported_interfaces": self.GetImportedInterfaces(),
394 "imported_from": self.ImportedFrom(), 394 "imported_from": self.ImportedFrom(),
395 } 395 }
396 396
397 @UseJinja("dart_templates/module.lib.tmpl", filters=dart_filters) 397 @UseJinja("dart_templates/module.lib.tmpl", filters=dart_filters)
398 def GenerateLibModule(self, args): 398 def GenerateLibModule(self, args):
399 return self.GetParameters(args) 399 return self.GetParameters(args)
400 400
401
401 def GenerateFiles(self, args): 402 def GenerateFiles(self, args):
402 elements = self.module.namespace.split('.') 403 elements = self.module.namespace.split('.')
403 elements.append("%s.dart" % self.module.name) 404 elements.append("%s.dart" % self.module.name)
404 path = os.path.join("dart-gen", "mojom", *elements) 405 path = os.path.join("dart-pkg", "mojom/lib", *elements)
406 self.Write(self.GenerateLibModule(args), path)
407 path = os.path.join("dart-gen", "mojom/lib", *elements)
405 self.Write(self.GenerateLibModule(args), path) 408 self.Write(self.GenerateLibModule(args), path)
406 link = self.MatchMojomFilePath("%s.dart" % self.module.name) 409 link = self.MatchMojomFilePath("%s.dart" % self.module.name)
407 if os.path.exists(os.path.join(self.output_dir, link)): 410 if os.path.exists(os.path.join(self.output_dir, link)):
408 os.unlink(os.path.join(self.output_dir, link)) 411 os.unlink(os.path.join(self.output_dir, link))
409 try: 412 try:
410 if sys.platform == "win32": 413 if sys.platform == "win32":
411 shutil.copy(os.path.join(self.output_dir, path), 414 shutil.copy(os.path.join(self.output_dir, path),
412 os.path.join(self.output_dir, link)) 415 os.path.join(self.output_dir, link))
413 else: 416 else:
414 os.symlink(os.path.join(self.output_dir, path), 417 os.symlink(os.path.join(self.output_dir, path),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 interface_to_import[name] = each_import["unique_name"] + "." + name 451 interface_to_import[name] = each_import["unique_name"] + "." + name
449 return interface_to_import 452 return interface_to_import
450 453
451 def ImportedFrom(self): 454 def ImportedFrom(self):
452 interface_to_import = {} 455 interface_to_import = {}
453 for each_import in self.module.imports: 456 for each_import in self.module.imports:
454 for each_interface in each_import["module"].interfaces: 457 for each_interface in each_import["module"].interfaces:
455 name = each_interface.name 458 name = each_interface.name
456 interface_to_import[name] = each_import["unique_name"] + "." 459 interface_to_import[name] = each_import["unique_name"] + "."
457 return interface_to_import 460 return interface_to_import
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698