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

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

Issue 1834893002: Treat empty string DartPackage as no DartPackage specified (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 9 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/dart/tools/presubmit/check_mojom_dart.py ('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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 438
439 def IsImportedKind(kind): 439 def IsImportedKind(kind):
440 return hasattr(kind, 'imported_from') and kind.imported_from 440 return hasattr(kind, 'imported_from') and kind.imported_from
441 441
442 def ParseStringAttribute(attribute): 442 def ParseStringAttribute(attribute):
443 assert isinstance(attribute, basestring) 443 assert isinstance(attribute, basestring)
444 return attribute 444 return attribute
445 445
446 def GetPackage(module): 446 def GetPackage(module):
447 if module.attributes and 'DartPackage' in module.attributes: 447 if module.attributes and 'DartPackage' in module.attributes:
448 return ParseStringAttribute(module.attributes['DartPackage']) 448 package = ParseStringAttribute(module.attributes['DartPackage'])
449 package = package.strip()
450 if package != '':
451 return package
449 # Default package. 452 # Default package.
450 return 'mojom' 453 return 'mojom'
451 454
452 def GetImportUri(module): 455 def GetImportUri(module):
453 package = GetPackage(module); 456 package = GetPackage(module);
454 elements = module.namespace.split('.') 457 elements = module.namespace.split('.')
455 elements.append("%s" % module.name) 458 elements.append("%s" % module.name)
456 return os.path.join(package, *elements) 459 return os.path.join(package, *elements)
457 460
458 def RaiseHelper(msg): 461 def RaiseHelper(msg):
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 interface_to_import[name] = each_import["unique_name"] + "." + name 631 interface_to_import[name] = each_import["unique_name"] + "." + name
629 return interface_to_import 632 return interface_to_import
630 633
631 def ImportedFrom(self): 634 def ImportedFrom(self):
632 interface_to_import = {} 635 interface_to_import = {}
633 for each_import in self.module.imports: 636 for each_import in self.module.imports:
634 for each_interface in each_import["module"].interfaces: 637 for each_interface in each_import["module"].interfaces:
635 name = each_interface.name 638 name = each_interface.name
636 interface_to_import[name] = each_import["unique_name"] + "." 639 interface_to_import[name] = each_import["unique_name"] + "."
637 return interface_to_import 640 return interface_to_import
OLDNEW
« no previous file with comments | « mojo/dart/tools/presubmit/check_mojom_dart.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698