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

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

Issue 434133002: Support WebIDL's ExtendedAttributeIdentList in the Blink parser (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: moved parsing to chrome Created 6 years, 4 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
« no previous file with comments | « Source/bindings/scripts/idl_validator.py ('k') | Source/bindings/scripts/v8_utilities.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 r'(interface|exception)\s+' 146 r'(interface|exception)\s+'
147 r'\w+\s*' 147 r'\w+\s*'
148 r'(:\s*\w+\s*)?' 148 r'(:\s*\w+\s*)?'
149 r'{', 149 r'{',
150 file_contents, flags=re.DOTALL) 150 file_contents, flags=re.DOTALL)
151 if not match: 151 if not match:
152 return {} 152 return {}
153 153
154 extended_attributes_string = match.group(1) 154 extended_attributes_string = match.group(1)
155 extended_attributes = {} 155 extended_attributes = {}
156 # FIXME: this splitting is WRONG: it fails on ExtendedAttributeArgList like 156 # FIXME: this splitting is WRONG: it fails on extended attributes where list s of
157 # 'NamedConstructor=Foo(a, b)' 157 # multiple values are used, which are seperated by a comma and a space.
158 parts = [extended_attribute.strip() 158 parts = [extended_attribute.strip()
159 for extended_attribute in extended_attributes_string.split(',') 159 for extended_attribute in re.split(',\s+', extended_attributes_stri ng)
haraken 2014/08/06 01:08:48 I wonder if this should be re.split(',\s*', ...)
Peter Beverloo 2014/08/07 13:32:37 This regular expression essentially is mimicing th
haraken 2014/08/07 14:16:34 Makes sense. Since we don't care about performance
160 # Discard empty parts, which may exist due to trailing comma 160 # Discard empty parts, which may exist due to trailing comma
161 if extended_attribute.strip()] 161 if extended_attribute.strip()]
162 for part in parts: 162 for part in parts:
163 name, _, value = map(string.strip, part.partition('=')) 163 name, _, value = map(string.strip, part.partition('='))
164 extended_attributes[name] = value 164 extended_attributes[name] = value
165 return extended_attributes 165 return extended_attributes
166 166
167 167
168 def get_put_forward_interfaces_from_idl(file_contents): 168 def get_put_forward_interfaces_from_idl(file_contents):
169 put_forwards_pattern = (r'\[[^\]]*PutForwards=[^\]]*\]\s+' 169 put_forwards_pattern = (r'\[[^\]]*PutForwards=[^\]]*\]\s+'
170 r'readonly\s+' 170 r'readonly\s+'
171 r'attribute\s+' 171 r'attribute\s+'
172 r'(\w+)') 172 r'(\w+)')
173 return sorted(set(match.group(1) 173 return sorted(set(match.group(1)
174 for match in re.finditer(put_forwards_pattern, 174 for match in re.finditer(put_forwards_pattern,
175 file_contents, 175 file_contents,
176 flags=re.DOTALL))) 176 flags=re.DOTALL)))
OLDNEW
« no previous file with comments | « Source/bindings/scripts/idl_validator.py ('k') | Source/bindings/scripts/v8_utilities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698