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

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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 "structs": self.GetStructs() + self.GetStructsFromMethods(), 394 "structs": self.GetStructs() + self.GetStructsFromMethods(),
395 "interfaces": self.GetInterfaces(), 395 "interfaces": self.GetInterfaces(),
396 "imported_interfaces": self.GetImportedInterfaces(), 396 "imported_interfaces": self.GetImportedInterfaces(),
397 "imported_from": self.ImportedFrom(), 397 "imported_from": self.ImportedFrom(),
398 } 398 }
399 399
400 @UseJinja("dart_templates/module.lib.tmpl", filters=dart_filters) 400 @UseJinja("dart_templates/module.lib.tmpl", filters=dart_filters)
401 def GenerateLibModule(self, args): 401 def GenerateLibModule(self, args):
402 return self.GetParameters(args) 402 return self.GetParameters(args)
403 403
404
404 def GenerateFiles(self, args): 405 def GenerateFiles(self, args):
405 elements = self.module.namespace.split('.') 406 elements = self.module.namespace.split('.')
406 elements.append("%s.dart" % self.module.name) 407 elements.append("%s.dart" % self.module.name)
407 path = os.path.join("dart-gen", "mojom", *elements) 408 path = os.path.join("dart-pkg", "mojom/lib", *elements)
409 self.Write(self.GenerateLibModule(args), path)
410 path = os.path.join("dart-gen", "mojom/lib", *elements)
408 self.Write(self.GenerateLibModule(args), path) 411 self.Write(self.GenerateLibModule(args), path)
409 link = self.MatchMojomFilePath("%s.dart" % self.module.name) 412 link = self.MatchMojomFilePath("%s.dart" % self.module.name)
410 if os.path.exists(os.path.join(self.output_dir, link)): 413 if os.path.exists(os.path.join(self.output_dir, link)):
411 os.unlink(os.path.join(self.output_dir, link)) 414 os.unlink(os.path.join(self.output_dir, link))
412 try: 415 try:
413 if sys.platform == "win32": 416 if sys.platform == "win32":
414 shutil.copy(os.path.join(self.output_dir, path), 417 shutil.copy(os.path.join(self.output_dir, path),
415 os.path.join(self.output_dir, link)) 418 os.path.join(self.output_dir, link))
416 else: 419 else:
417 os.symlink(os.path.join(self.output_dir, path), 420 os.symlink(os.path.join(self.output_dir, path),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 interface_to_import[name] = each_import["unique_name"] + "." + name 454 interface_to_import[name] = each_import["unique_name"] + "." + name
452 return interface_to_import 455 return interface_to_import
453 456
454 def ImportedFrom(self): 457 def ImportedFrom(self):
455 interface_to_import = {} 458 interface_to_import = {}
456 for each_import in self.module.imports: 459 for each_import in self.module.imports:
457 for each_interface in each_import["module"].interfaces: 460 for each_interface in each_import["module"].interfaces:
458 name = each_interface.name 461 name = each_interface.name
459 interface_to_import[name] = each_import["unique_name"] + "." 462 interface_to_import[name] = each_import["unique_name"] + "."
460 return interface_to_import 463 return interface_to_import
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/dart_templates/module.lib.tmpl ('k') | mojo/public/tools/dart_analyze.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698