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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 | 635 |
636 | 636 |
637 def Indent(self, data, tabs=0): | 637 def Indent(self, data, tabs=0): |
638 """Handles indentation and 80-column line wrapping.""" | 638 """Handles indentation and 80-column line wrapping.""" |
639 tab = ' ' * tabs | 639 tab = ' ' * tabs |
640 lines = [] | 640 lines = [] |
641 for line in data.split('\n'): | 641 for line in data.split('\n'): |
642 # Add indentation | 642 # Add indentation |
643 line = tab + line | 643 line = tab + line |
644 space_break = line.rfind(' ', 0, 80) | 644 space_break = line.rfind(' ', 0, 80) |
645 if len(line) <= 80 or 'http' in line: | 645 if len(line) <= 80 or 'http://' in line: |
646 # Ignore normal line and URLs permitted by the style guide. | 646 # Ignore normal line and URLs permitted by the style guide. |
647 lines.append(line.rstrip()) | 647 lines.append(line.rstrip()) |
648 elif not '(' in line and space_break >= 0: | 648 elif not '(' in line and space_break >= 0: |
649 # Break long typedefs on nearest space. | 649 # Break long typedefs on nearest space. |
650 lines.append(line[0:space_break]) | 650 lines.append(line[0:space_break]) |
651 lines.append(' ' + line[space_break + 1:]) | 651 lines.append(' ' + line[space_break + 1:]) |
652 else: | 652 else: |
653 left = line.rfind('(') + 1 | 653 left = line.rfind('(') + 1 |
654 args = line[left:].split(',') | 654 args = line[left:].split(',') |
655 orig_args = args | 655 orig_args = args |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 if f.GetProperty('ERRORS') > 0: | 778 if f.GetProperty('ERRORS') > 0: |
779 print 'Skipping %s' % f.GetName() | 779 print 'Skipping %s' % f.GetName() |
780 continue | 780 continue |
781 for node in f.GetChildren()[2:]: | 781 for node in f.GetChildren()[2:]: |
782 print cgen.Define(node, ast.releases, comment=True, prefix='tst_') | 782 print cgen.Define(node, ast.releases, comment=True, prefix='tst_') |
783 | 783 |
784 | 784 |
785 if __name__ == '__main__': | 785 if __name__ == '__main__': |
786 sys.exit(main(sys.argv[1:])) | 786 sys.exit(main(sys.argv[1:])) |
787 | 787 |
OLD | NEW |