OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ Generator for C style prototypes and definitions """ | 6 """ Generator for C style prototypes and definitions """ |
7 | 7 |
8 import glob | 8 import glob |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 __pychecker__ = 'unusednames=comment,prefix' | 561 __pychecker__ = 'unusednames=comment,prefix' |
562 self.LogEnter('DefineStruct %s' % node) | 562 self.LogEnter('DefineStruct %s' % node) |
563 out = '' | 563 out = '' |
564 build_list = node.GetUniqueReleases(releases) | 564 build_list = node.GetUniqueReleases(releases) |
565 | 565 |
566 # TODO(noelallen) : Bug 157017 finish multiversion support | 566 # TODO(noelallen) : Bug 157017 finish multiversion support |
567 if node.IsA('Struct'): | 567 if node.IsA('Struct'): |
568 if len(build_list) != 1: | 568 if len(build_list) != 1: |
569 node.Error('Can not support multiple versions of node.') | 569 node.Error('Can not support multiple versions of node.') |
570 assert len(build_list) == 1 | 570 assert len(build_list) == 1 |
571 | 571 out = self.DefineStructInternals(node, build_list[-1], |
| 572 include_version=False, comment=True) |
572 | 573 |
573 if node.IsA('Interface'): | 574 if node.IsA('Interface'): |
574 # Build the most recent one versioned, with comments | 575 # Build the most recent one versioned, with comments |
575 out = self.DefineStructInternals(node, build_list[-1], | 576 out = self.DefineStructInternals(node, build_list[-1], |
576 include_version=True, comment=True) | 577 include_version=True, comment=True) |
577 | |
578 # Define an unversioned typedef for the most recent version | 578 # Define an unversioned typedef for the most recent version |
579 out += '\ntypedef struct %s %s;\n' % ( | 579 out += '\ntypedef struct %s %s;\n' % ( |
580 self.GetStructName(node, build_list[-1], include_version=True), | 580 self.GetStructName(node, build_list[-1], include_version=True), |
581 self.GetStructName(node, build_list[-1], include_version=False)) | 581 self.GetStructName(node, build_list[-1], include_version=False)) |
582 else: | 582 # Build the rest without comments and with the version number appended |
583 # Build the most recent one versioned, with comments | 583 for rel in build_list[0:-1]: |
584 out = self.DefineStructInternals(node, build_list[-1], | 584 out += '\n' + self.DefineStructInternals(node, rel, |
585 include_version=False, comment=True) | 585 include_version=True, |
586 | 586 comment=False) |
587 | |
588 # Build the rest without comments and with the version number appended | |
589 for rel in build_list[0:-1]: | |
590 out += '\n' + self.DefineStructInternals(node, rel, | |
591 include_version=True, | |
592 comment=False) | |
593 | 587 |
594 self.LogExit('Exit DefineStruct') | 588 self.LogExit('Exit DefineStruct') |
595 return out | 589 return out |
596 | 590 |
597 | 591 |
598 # | 592 # |
599 # Copyright and Comment | 593 # Copyright and Comment |
600 # | 594 # |
601 # Generate a comment or copyright block | 595 # Generate a comment or copyright block |
602 # | 596 # |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 filenames = ParseOptions(args) | 739 filenames = ParseOptions(args) |
746 if GetOption('test'): | 740 if GetOption('test'): |
747 return TestFiles(filenames) | 741 return TestFiles(filenames) |
748 ast = ParseFiles(filenames) | 742 ast = ParseFiles(filenames) |
749 cgen = CGen() | 743 cgen = CGen() |
750 for f in ast.GetListOf('File'): | 744 for f in ast.GetListOf('File'): |
751 if f.GetProperty('ERRORS') > 0: | 745 if f.GetProperty('ERRORS') > 0: |
752 print 'Skipping %s' % f.GetName() | 746 print 'Skipping %s' % f.GetName() |
753 continue | 747 continue |
754 for node in f.GetChildren()[2:]: | 748 for node in f.GetChildren()[2:]: |
755 print cgen.Define(node, comment=True, prefix='tst_') | 749 print cgen.Define(node, ast.releases, comment=True, prefix='tst_') |
756 | 750 |
757 | 751 |
758 if __name__ == '__main__': | 752 if __name__ == '__main__': |
759 sys.exit(main(sys.argv[1:])) | 753 sys.exit(main(sys.argv[1:])) |
760 | 754 |
OLD | NEW |