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

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

Issue 1515423002: [mojo] Add mojom parser support for native-only structs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pickle2
Patch Set: 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 exports = self.GetJinjaExports() 473 exports = self.GetJinjaExports()
474 exports.update({'main_entity': GetConstantsMainEntityName(module), 474 exports.update({'main_entity': GetConstantsMainEntityName(module),
475 'constants': module.constants}) 475 'constants': module.constants})
476 return exports 476 return exports
477 477
478 def DoGenerateFiles(self): 478 def DoGenerateFiles(self):
479 fileutil.EnsureDirectoryExists(self.output_dir) 479 fileutil.EnsureDirectoryExists(self.output_dir)
480 480
481 # Keep this above the others as .GetStructs() changes the state of the 481 # Keep this above the others as .GetStructs() changes the state of the
482 # module, annotating structs with required information. 482 # module, annotating structs with required information.
483 for struct in self.GetStructs(): 483 for struct in filter(lambda struct: not struct.native_only,
484 self.GetStructs()):
484 self.Write(self.GenerateStructSource(struct), 485 self.Write(self.GenerateStructSource(struct),
485 '%s.java' % GetNameForElement(struct)) 486 '%s.java' % GetNameForElement(struct))
486 487
487 for union in self.module.unions: 488 for union in self.module.unions:
488 self.Write(self.GenerateUnionSource(union), 489 self.Write(self.GenerateUnionSource(union),
489 '%s.java' % GetNameForElement(union)) 490 '%s.java' % GetNameForElement(union))
490 491
491 for enum in self.module.enums: 492 for enum in self.module.enums:
492 self.Write(self.GenerateEnumSource(enum), 493 self.Write(self.GenerateEnumSource(enum),
493 '%s.java' % GetNameForElement(enum)) 494 '%s.java' % GetNameForElement(enum))
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return { 527 return {
527 'lstrip_blocks': True, 528 'lstrip_blocks': True,
528 'trim_blocks': True, 529 'trim_blocks': True,
529 } 530 }
530 531
531 def GetGlobals(self): 532 def GetGlobals(self):
532 return { 533 return {
533 'namespace': self.module.namespace, 534 'namespace': self.module.namespace,
534 'module': self.module, 535 'module': self.module,
535 } 536 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698