Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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. |
|
Peter Beverloo
2014/08/01 16:14:03
Are there plans to make these scripts use the actu
| |
| 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) |
| 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))) |
| OLD | NEW |