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

Side by Side Diff: ppapi/generators/idl_c_proto.py

Issue 23569005: Add PPAPI interfaces for platform verification. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 7 years, 3 months 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 | Annotate | Revision Log
OLDNEW
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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 return CommentLines(lines) 599 return CommentLines(lines)
600 600
601 601
602 def Indent(self, data, tabs=0): 602 def Indent(self, data, tabs=0):
603 """Handles indentation and 80-column line wrapping.""" 603 """Handles indentation and 80-column line wrapping."""
604 tab = ' ' * tabs 604 tab = ' ' * tabs
605 lines = [] 605 lines = []
606 for line in data.split('\n'): 606 for line in data.split('\n'):
607 # Add indentation 607 # Add indentation
608 line = tab + line 608 line = tab + line
609 if len(line) <= 80: 609 space_break = line.rfind(' ', 0, 80)
610 if len(line) <= 80 or 'http' in line:
611 # Ignore normal line and URLs permitted by the style guide.
610 lines.append(line.rstrip()) 612 lines.append(line.rstrip())
613 elif not '(' in line and space_break >= 0:
614 # Break long typedefs on nearest space.
615 lines.append(line[0:space_break])
616 lines.append(' ' + line[space_break + 1:])
611 else: 617 else:
612 left = line.rfind('(') + 1 618 left = line.rfind('(') + 1
613 args = line[left:].split(',') 619 args = line[left:].split(',')
614 orig_args = args 620 orig_args = args
615 orig_left = left 621 orig_left = left
616 # Try to split on '(arg1)' or '(arg1, arg2)', not '()' 622 # Try to split on '(arg1)' or '(arg1, arg2)', not '()'
617 while args[0][0] == ')': 623 while args[0][0] == ')':
618 left = line.rfind('(', 0, left - 1) + 1 624 left = line.rfind('(', 0, left - 1) + 1
619 if left == 0: # No more parens, take the original option 625 if left == 0: # No more parens, take the original option
620 args = orig_args 626 args = orig_args
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 if f.GetProperty('ERRORS') > 0: 743 if f.GetProperty('ERRORS') > 0:
738 print 'Skipping %s' % f.GetName() 744 print 'Skipping %s' % f.GetName()
739 continue 745 continue
740 for node in f.GetChildren()[2:]: 746 for node in f.GetChildren()[2:]:
741 print cgen.Define(node, comment=True, prefix='tst_') 747 print cgen.Define(node, comment=True, prefix='tst_')
742 748
743 749
744 if __name__ == '__main__': 750 if __name__ == '__main__':
745 sys.exit(main(sys.argv[1:])) 751 sys.exit(main(sys.argv[1:]))
746 752
OLDNEW
« no previous file with comments | « ppapi/c/private/ppb_platform_verification_private.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698