| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 | 9 |
| 10 class IDLNode(object): | 10 class IDLNode(object): |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 def __contains__(self, key): | 210 def __contains__(self, key): |
| 211 return key in self.__map | 211 return key in self.__map |
| 212 | 212 |
| 213 def __iter__(self): | 213 def __iter__(self): |
| 214 return self.__map.__iter__() | 214 return self.__map.__iter__() |
| 215 | 215 |
| 216 def get(self, key, default=None): | 216 def get(self, key, default=None): |
| 217 return self.__map.get(key, default) | 217 return self.__map.get(key, default) |
| 218 | 218 |
| 219 def setdefault(self, key, value=None): |
| 220 return self.__map.setdefault(key, value) |
| 221 |
| 219 def items(self): | 222 def items(self): |
| 220 return self.__map.items() | 223 return self.__map.items() |
| 221 | 224 |
| 222 def keys(self): | 225 def keys(self): |
| 223 return self.__map.keys() | 226 return self.__map.keys() |
| 224 | 227 |
| 225 def values(self): | 228 def values(self): |
| 226 return self.__map.values() | 229 return self.__map.values() |
| 227 | 230 |
| 228 def clear(self): | 231 def clear(self): |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 IDLDictNode.__init__(self, None) | 283 IDLDictNode.__init__(self, None) |
| 281 if not ast: | 284 if not ast: |
| 282 return | 285 return |
| 283 ext_attrs_ast = self._find_first(ast, 'ExtAttrs') | 286 ext_attrs_ast = self._find_first(ast, 'ExtAttrs') |
| 284 if not ext_attrs_ast: | 287 if not ext_attrs_ast: |
| 285 return | 288 return |
| 286 for ext_attr in self._find_all(ext_attrs_ast, 'ExtAttr'): | 289 for ext_attr in self._find_all(ext_attrs_ast, 'ExtAttr'): |
| 287 name = self._find_first(ext_attr, 'Id') | 290 name = self._find_first(ext_attr, 'Id') |
| 288 value = self._find_first(ext_attr, 'ExtAttrValue') | 291 value = self._find_first(ext_attr, 'ExtAttrValue') |
| 289 | 292 |
| 293 if name == 'Constructor': |
| 294 # There might be multiple constructor attributes, collect them |
| 295 # as a list. Represent plain Constructor attribute |
| 296 # (without any signature) as None. |
| 297 assert value is None |
| 298 func_value = None |
| 299 ctor_args = self._find_first(ext_attr, 'ExtAttrArgList') |
| 300 if ctor_args: |
| 301 func_value = IDLExtAttrFunctionValue(None, ctor_args) |
| 302 self.setdefault('Constructor', []).append(func_value) |
| 303 continue |
| 304 |
| 290 func_value = self._find_first(value, 'ExtAttrFunctionValue') | 305 func_value = self._find_first(value, 'ExtAttrFunctionValue') |
| 291 if func_value: | 306 if func_value: |
| 292 # E.g. NamedConstructor=Audio(in [Optional] DOMString src) | 307 # E.g. NamedConstructor=Audio(in [Optional] DOMString src) |
| 293 self[name] = IDLExtAttrFunctionValue( | 308 self[name] = IDLExtAttrFunctionValue( |
| 294 func_value, | 309 func_value, |
| 295 self._find_first(func_value, 'ExtAttrArgList')) | 310 self._find_first(func_value, 'ExtAttrArgList')) |
| 296 continue | 311 continue |
| 297 | 312 |
| 298 ctor_args = not value and self._find_first(ext_attr, 'ExtAttrArgList') | |
| 299 if ctor_args: | |
| 300 # E.g. Constructor(Element host) | |
| 301 self[name] = IDLExtAttrFunctionValue(None, ctor_args) | |
| 302 continue | |
| 303 | |
| 304 self[name] = value | 313 self[name] = value |
| 305 | 314 |
| 306 def _all_subnodes(self): | 315 def _all_subnodes(self): |
| 307 # Extended attributes may contain IDLNodes, e.g. IDLExtAttrFunctionValue | 316 # Extended attributes may contain IDLNodes, e.g. IDLExtAttrFunctionValue |
| 308 return self.values() | 317 return self.values() |
| 309 | 318 |
| 310 | 319 |
| 311 class IDLExtAttrFunctionValue(IDLNode): | 320 class IDLExtAttrFunctionValue(IDLNode): |
| 312 """IDLExtAttrFunctionValue.""" | 321 """IDLExtAttrFunctionValue.""" |
| 313 def __init__(self, func_value_ast, arg_list_ast): | 322 def __init__(self, func_value_ast, arg_list_ast): |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 """IDLDictNode specialization for one annotation.""" | 524 """IDLDictNode specialization for one annotation.""" |
| 516 def __init__(self, ast=None): | 525 def __init__(self, ast=None): |
| 517 IDLDictNode.__init__(self, ast) | 526 IDLDictNode.__init__(self, ast) |
| 518 self.id = None | 527 self.id = None |
| 519 if not ast: | 528 if not ast: |
| 520 return | 529 return |
| 521 for arg in self._find_all(ast, 'AnnotationArg'): | 530 for arg in self._find_all(ast, 'AnnotationArg'): |
| 522 name = self._find_first(arg, 'Id') | 531 name = self._find_first(arg, 'Id') |
| 523 value = self._find_first(arg, 'AnnotationArgValue') | 532 value = self._find_first(arg, 'AnnotationArgValue') |
| 524 self[name] = value | 533 self[name] = value |
| OLD | NEW |