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

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

Issue 2888503002: Mojo bindings generator: introduce Stylizer to specify naming rules. (Closed)
Patch Set: Created 3 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 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 contextlib 9 import contextlib
10 import os 10 import os
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 if self.module.constants: 507 if self.module.constants:
508 self.Write(self._GenerateConstantsSource(self.module), 508 self.Write(self._GenerateConstantsSource(self.module),
509 '%s.java' % GetConstantsMainEntityName(self.module)) 509 '%s.java' % GetConstantsMainEntityName(self.module))
510 510
511 def GenerateFiles(self, unparsed_args): 511 def GenerateFiles(self, unparsed_args):
512 # TODO(rockot): Support variant output for Java. 512 # TODO(rockot): Support variant output for Java.
513 if self.variant: 513 if self.variant:
514 raise Exception("Variants not supported in Java bindings.") 514 raise Exception("Variants not supported in Java bindings.")
515 515
516 self.module.Stylize(generator.Stylizer())
517
516 parser = argparse.ArgumentParser() 518 parser = argparse.ArgumentParser()
517 parser.add_argument('--java_output_directory', dest='java_output_directory') 519 parser.add_argument('--java_output_directory', dest='java_output_directory')
518 args = parser.parse_args(unparsed_args) 520 args = parser.parse_args(unparsed_args)
519 package_path = GetPackage(self.module).replace('.', '/') 521 package_path = GetPackage(self.module).replace('.', '/')
520 522
521 # Generate the java files in a temporary directory and place a single 523 # Generate the java files in a temporary directory and place a single
522 # srcjar in the output directory. 524 # srcjar in the output directory.
523 basename = self.MatchMojomFilePath("%s.srcjar" % self.module.name) 525 basename = "%s.srcjar" % self.module.path
524 zip_filename = os.path.join(self.output_dir, basename) 526 zip_filename = os.path.join(self.output_dir, basename)
525 with TempDir() as temp_java_root: 527 with TempDir() as temp_java_root:
526 self.output_dir = os.path.join(temp_java_root, package_path) 528 self.output_dir = os.path.join(temp_java_root, package_path)
527 self._DoGenerateFiles(); 529 self._DoGenerateFiles();
528 build_utils.ZipDir(zip_filename, temp_java_root) 530 build_utils.ZipDir(zip_filename, temp_java_root)
529 531
530 if args.java_output_directory: 532 if args.java_output_directory:
531 # If requested, generate the java files directly into indicated directory. 533 # If requested, generate the java files directly into indicated directory.
532 self.output_dir = os.path.join(args.java_output_directory, package_path) 534 self.output_dir = os.path.join(args.java_output_directory, package_path)
533 self._DoGenerateFiles(); 535 self._DoGenerateFiles();
534 536
535 def GetJinjaParameters(self): 537 def GetJinjaParameters(self):
536 return { 538 return {
537 'lstrip_blocks': True, 539 'lstrip_blocks': True,
538 'trim_blocks': True, 540 'trim_blocks': True,
539 } 541 }
540 542
541 def GetGlobals(self): 543 def GetGlobals(self):
542 return { 544 return {
543 'namespace': self.module.namespace, 545 'namespace': self.module.namespace,
544 'module': self.module, 546 'module': self.module,
545 } 547 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698