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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 self.Write(self.GenerateInterfaceSource(interface), | 497 self.Write(self.GenerateInterfaceSource(interface), |
498 '%s.java' % GetNameForElement(interface)) | 498 '%s.java' % GetNameForElement(interface)) |
499 self.Write(self.GenerateInterfaceInternalSource(interface), | 499 self.Write(self.GenerateInterfaceInternalSource(interface), |
500 '%s_Internal.java' % GetNameForElement(interface)) | 500 '%s_Internal.java' % GetNameForElement(interface)) |
501 | 501 |
502 if self.module.constants: | 502 if self.module.constants: |
503 self.Write(self.GenerateConstantsSource(self.module), | 503 self.Write(self.GenerateConstantsSource(self.module), |
504 '%s.java' % GetConstantsMainEntityName(self.module)) | 504 '%s.java' % GetConstantsMainEntityName(self.module)) |
505 | 505 |
506 def GenerateFiles(self, unparsed_args): | 506 def GenerateFiles(self, unparsed_args): |
507 # TODO(rockot): Support variant output for Java. | |
508 if self.variant: | |
509 return | |
yzshen1
2015/12/15 00:09:10
Please output some message or assert, so it is eas
| |
510 | |
507 parser = argparse.ArgumentParser() | 511 parser = argparse.ArgumentParser() |
508 parser.add_argument('--java_output_directory', dest='java_output_directory') | 512 parser.add_argument('--java_output_directory', dest='java_output_directory') |
509 args = parser.parse_args(unparsed_args) | 513 args = parser.parse_args(unparsed_args) |
510 package_path = GetPackage(self.module).replace('.', '/') | 514 package_path = GetPackage(self.module).replace('.', '/') |
511 | 515 |
512 # Generate the java files in a temporary directory and place a single | 516 # Generate the java files in a temporary directory and place a single |
513 # srcjar in the output directory. | 517 # srcjar in the output directory. |
514 basename = self.MatchMojomFilePath("%s.srcjar" % self.module.name) | 518 basename = self.MatchMojomFilePath("%s.srcjar" % self.module.name) |
515 zip_filename = os.path.join(self.output_dir, basename) | 519 zip_filename = os.path.join(self.output_dir, basename) |
516 with TempDir() as temp_java_root: | 520 with TempDir() as temp_java_root: |
(...skipping 10 matching lines...) Expand all Loading... | |
527 return { | 531 return { |
528 'lstrip_blocks': True, | 532 'lstrip_blocks': True, |
529 'trim_blocks': True, | 533 'trim_blocks': True, |
530 } | 534 } |
531 | 535 |
532 def GetGlobals(self): | 536 def GetGlobals(self): |
533 return { | 537 return { |
534 'namespace': self.module.namespace, | 538 'namespace': self.module.namespace, |
535 'module': self.module, | 539 'module': self.module, |
536 } | 540 } |
OLD | NEW |