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

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

Issue 1517043004: [mojo] Add typemap and variant support to generators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pickle3
Patch Set: set proper upstream Created 5 years 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 self.Write(self.GenerateInterfaceSource(interface), 496 self.Write(self.GenerateInterfaceSource(interface),
497 '%s.java' % GetNameForElement(interface)) 497 '%s.java' % GetNameForElement(interface))
498 self.Write(self.GenerateInterfaceInternalSource(interface), 498 self.Write(self.GenerateInterfaceInternalSource(interface),
499 '%s_Internal.java' % GetNameForElement(interface)) 499 '%s_Internal.java' % GetNameForElement(interface))
500 500
501 if self.module.constants: 501 if self.module.constants:
502 self.Write(self.GenerateConstantsSource(self.module), 502 self.Write(self.GenerateConstantsSource(self.module),
503 '%s.java' % GetConstantsMainEntityName(self.module)) 503 '%s.java' % GetConstantsMainEntityName(self.module))
504 504
505 def GenerateFiles(self, unparsed_args): 505 def GenerateFiles(self, unparsed_args):
506 # TODO(rockot): Support variant output for Java.
507 if self.variant:
508 raise Exception("Variants not supported in Java bindings.")
509
506 parser = argparse.ArgumentParser() 510 parser = argparse.ArgumentParser()
507 parser.add_argument('--java_output_directory', dest='java_output_directory') 511 parser.add_argument('--java_output_directory', dest='java_output_directory')
508 args = parser.parse_args(unparsed_args) 512 args = parser.parse_args(unparsed_args)
509 package_path = GetPackage(self.module).replace('.', '/') 513 package_path = GetPackage(self.module).replace('.', '/')
510 514
511 # Generate the java files in a temporary directory and place a single 515 # Generate the java files in a temporary directory and place a single
512 # srcjar in the output directory. 516 # srcjar in the output directory.
513 basename = self.MatchMojomFilePath("%s.srcjar" % self.module.name) 517 basename = self.MatchMojomFilePath("%s.srcjar" % self.module.name)
514 zip_filename = os.path.join(self.output_dir, basename) 518 zip_filename = os.path.join(self.output_dir, basename)
515 with TempDir() as temp_java_root: 519 with TempDir() as temp_java_root:
(...skipping 10 matching lines...) Expand all
526 return { 530 return {
527 'lstrip_blocks': True, 531 'lstrip_blocks': True,
528 'trim_blocks': True, 532 'trim_blocks': True,
529 } 533 }
530 534
531 def GetGlobals(self): 535 def GetGlobals(self):
532 return { 536 return {
533 'namespace': self.module.namespace, 537 'namespace': self.module.namespace,
534 'module': self.module, 538 'module': self.module,
535 } 539 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698