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

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

Issue 601213002: Fix mojom Java generator running on its own. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Ben's (off-cl) comments. Created 6 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 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 java source files from a mojom.Module.""" 5 """Generates java source files from a mojom.Module."""
6 6
7 import argparse 7 import argparse
8 import ast 8 import ast
9 import os 9 import os
10 import re 10 import re
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 if self.output_dir and args.java_output_directory: 424 if self.output_dir and args.java_output_directory:
425 self.output_dir = os.path.join(args.java_output_directory, 425 self.output_dir = os.path.join(args.java_output_directory,
426 GetPackage(self.module).replace('.', '/')) 426 GetPackage(self.module).replace('.', '/'))
427 if not os.path.exists(self.output_dir): 427 if not os.path.exists(self.output_dir):
428 try: 428 try:
429 os.makedirs(self.output_dir) 429 os.makedirs(self.output_dir)
430 except: 430 except:
431 # Ignore errors on directory creation. 431 # Ignore errors on directory creation.
432 pass 432 pass
433 433
434 # Keep this above the others as .GetStructs() changes the state of the
435 # module, annotating structs with required information.
436 for struct in self.GetStructs():
437 self.Write(self.GenerateStructSource(struct),
438 '%s.java' % GetNameForElement(struct))
439
434 for enum in self.module.enums: 440 for enum in self.module.enums:
435 self.Write(self.GenerateEnumSource(enum), 441 self.Write(self.GenerateEnumSource(enum),
436 '%s.java' % GetNameForElement(enum)) 442 '%s.java' % GetNameForElement(enum))
437 443
438 for struct in self.module.structs:
439 self.Write(self.GenerateStructSource(struct),
440 '%s.java' % GetNameForElement(struct))
441
442 for interface in self.module.interfaces: 444 for interface in self.module.interfaces:
443 self.Write(self.GenerateInterfaceSource(interface), 445 self.Write(self.GenerateInterfaceSource(interface),
444 '%s.java' % GetNameForElement(interface)) 446 '%s.java' % GetNameForElement(interface))
445 self.Write(self.GenerateInterfaceInternalSource(interface), 447 self.Write(self.GenerateInterfaceInternalSource(interface),
446 '%s_Internal.java' % GetNameForElement(interface)) 448 '%s_Internal.java' % GetNameForElement(interface))
447 449
448 if self.module.constants: 450 if self.module.constants:
449 self.Write(self.GenerateConstantsSource(self.module), 451 self.Write(self.GenerateConstantsSource(self.module),
450 '%s.java' % GetConstantsMainEntityName(self.module)) 452 '%s.java' % GetConstantsMainEntityName(self.module))
451 453
452 def GetJinjaParameters(self): 454 def GetJinjaParameters(self):
453 return { 455 return {
454 'lstrip_blocks': True, 456 'lstrip_blocks': True,
455 'trim_blocks': True, 457 'trim_blocks': True,
456 } 458 }
457 459
458 def GetGlobals(self): 460 def GetGlobals(self):
459 return { 461 return {
460 'namespace': self.module.namespace, 462 'namespace': self.module.namespace,
461 'module': self.module, 463 'module': self.module,
462 } 464 }
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