| OLD | NEW |
| 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 Loading... |
| 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 = self.MatchMojomFilePath("%s.srcjar" % self.module.name) |
| 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: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 } |
| OLD | NEW |