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

Side by Side Diff: Source/bindings/scripts/utilities.py

Issue 261243002: Add support for [Global] / [PrimaryGlobal] IDL extended attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove non-ASCII character in comment Created 6 years, 7 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 # 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 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build . 5 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build .
6 6
7 Design doc: http://www.chromium.org/developers/design-documents/idl-build 7 Design doc: http://www.chromium.org/developers/design-documents/idl-build
8 """ 8 """
9 9
10 import os 10 import os
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 def get_parent_interface(file_contents): 86 def get_parent_interface(file_contents):
87 match = re.search(r'interface\s+' 87 match = re.search(r'interface\s+'
88 r'\w+\s*' 88 r'\w+\s*'
89 r':\s*(\w+)\s*' 89 r':\s*(\w+)\s*'
90 r'{', 90 r'{',
91 file_contents) 91 file_contents)
92 return match and match.group(1) 92 return match and match.group(1)
93 93
94 94
95 def get_interface_extended_attributes_from_idl(file_contents): 95 def get_interface_extended_attributes_from_idl(file_contents):
96 match = re.search(r'\[(.*)\]\s*' 96 match = re.search(r'^\s*\[(.*)\]\s*'
Inactive 2014/05/04 21:40:39 Without this fix, the comments before the extended
Nils Barth (inactive) 2014/05/07 01:55:57 Hmm...could you instead try putting the # Strip co
Inactive 2014/05/07 15:45:12 Done.
97 r'((callback|partial)\s+)?' 97 r'((callback|partial)\s+)?'
98 r'(interface|exception)\s+' 98 r'(interface|exception)\s+'
99 r'\w+\s*' 99 r'\w+\s*'
100 r'(:\s*\w+\s*)?' 100 r'(:\s*\w+\s*)?'
101 r'{', 101 r'{',
102 file_contents, flags=re.DOTALL) 102 file_contents, flags=re.DOTALL | re.MULTILINE)
103 if not match: 103 if not match:
104 return {} 104 return {}
105 # Strip comments 105 # Strip comments
106 # re.compile needed b/c Python 2.6 doesn't support flags in re.sub 106 # re.compile needed b/c Python 2.6 doesn't support flags in re.sub
107 single_line_comment_re = re.compile(r'//.*$', flags=re.MULTILINE) 107 single_line_comment_re = re.compile(r'//.*$', flags=re.MULTILINE)
108 block_comment_re = re.compile(r'/\*.*?\*/', flags=re.MULTILINE | re.DOTALL) 108 block_comment_re = re.compile(r'/\*.*?\*/', flags=re.MULTILINE | re.DOTALL)
109 extended_attributes_string = re.sub(single_line_comment_re, '', match.group( 1)) 109 extended_attributes_string = re.sub(single_line_comment_re, '', match.group( 1))
110 extended_attributes_string = re.sub(block_comment_re, '', extended_attribute s_string) 110 extended_attributes_string = re.sub(block_comment_re, '', extended_attribute s_string)
111 extended_attributes = {} 111 extended_attributes = {}
112 # FIXME: this splitting is WRONG: it fails on ExtendedAttributeArgList like 112 # FIXME: this splitting is WRONG: it fails on ExtendedAttributeArgList like
(...skipping 10 matching lines...) Expand all
123 123
124 def get_put_forward_interfaces_from_idl(file_contents): 124 def get_put_forward_interfaces_from_idl(file_contents):
125 put_forwards_pattern = (r'\[[^\]]*PutForwards=[^\]]*\]\s+' 125 put_forwards_pattern = (r'\[[^\]]*PutForwards=[^\]]*\]\s+'
126 r'readonly\s+' 126 r'readonly\s+'
127 r'attribute\s+' 127 r'attribute\s+'
128 r'(\w+)') 128 r'(\w+)')
129 return sorted(set(match.group(1) 129 return sorted(set(match.group(1)
130 for match in re.finditer(put_forwards_pattern, 130 for match in re.finditer(put_forwards_pattern,
131 file_contents, 131 file_contents,
132 flags=re.DOTALL))) 132 flags=re.DOTALL)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698