Chromium Code Reviews| 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 sys | 6 import sys |
| 7 | 7 |
| 8 | 8 |
| 9 class IDLNode(object): | 9 class IDLNode(object): |
| 10 """Base class for all IDL elements. | 10 """Base class for all IDL elements. |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 self.attributes = self._convert_all(ast, 'Attribute', | 374 self.attributes = self._convert_all(ast, 'Attribute', |
| 375 lambda ast: IDLAttribute(ast, self.doc_js_name)) | 375 lambda ast: IDLAttribute(ast, self.doc_js_name)) |
| 376 self.constants = self._convert_all(ast, 'Const', | 376 self.constants = self._convert_all(ast, 'Const', |
| 377 lambda ast: IDLConstant(ast, self.doc_js_name)) | 377 lambda ast: IDLConstant(ast, self.doc_js_name)) |
| 378 self.is_supplemental = 'Supplemental' in self.ext_attrs | 378 self.is_supplemental = 'Supplemental' in self.ext_attrs |
| 379 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs | 379 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs |
| 380 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs | 380 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs |
| 381 | 381 |
| 382 def has_attribute(self, candidate): | 382 def has_attribute(self, candidate): |
| 383 for attribute in self.attributes: | 383 for attribute in self.attributes: |
| 384 if (attribute.id == candidate.id and | 384 if (attribute.id == candidate.id and |
|
Anton Muhin
2012/07/04 15:41:25
if AOO(attribute, candidate) == 0?
And, btw, mayb
podivilov
2012/07/04 16:32:47
This is the only place where we compare nodes.
| |
| 385 attribute.is_fc_getter == candidate.is_fc_getter and | 385 attribute.is_read_only == candidate.is_read_only): |
| 386 attribute.is_fc_setter == candidate.is_fc_setter): | |
| 387 return True | 386 return True |
| 388 return False | 387 return False |
| 389 | 388 |
| 390 | 389 |
| 391 class IDLParentInterface(IDLNode): | 390 class IDLParentInterface(IDLNode): |
| 392 """This IDLNode specialization is for 'Interface Child : Parent {}' | 391 """This IDLNode specialization is for 'Interface Child : Parent {}' |
| 393 declarations.""" | 392 declarations.""" |
| 394 def __init__(self, ast): | 393 def __init__(self, ast): |
| 395 IDLNode.__init__(self, ast) | 394 IDLNode.__init__(self, ast) |
| 396 self._convert_annotations(ast) | 395 self._convert_annotations(ast) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 427 """IDLNode specialization for 'attribute type name' declarations.""" | 426 """IDLNode specialization for 'attribute type name' declarations.""" |
| 428 def __init__(self, ast, doc_js_interface_name): | 427 def __init__(self, ast, doc_js_interface_name): |
| 429 IDLMember.__init__(self, ast, doc_js_interface_name) | 428 IDLMember.__init__(self, ast, doc_js_interface_name) |
| 430 self.is_read_only = self._has(ast, 'ReadOnly') | 429 self.is_read_only = self._has(ast, 'ReadOnly') |
| 431 # There are various ways to define exceptions for attributes: | 430 # There are various ways to define exceptions for attributes: |
| 432 self.raises = self._convert_first(ast, 'Raises', IDLType) | 431 self.raises = self._convert_first(ast, 'Raises', IDLType) |
| 433 self.get_raises = self.raises \ | 432 self.get_raises = self.raises \ |
| 434 or self._convert_first(ast, 'GetRaises', IDLType) | 433 or self._convert_first(ast, 'GetRaises', IDLType) |
| 435 self.set_raises = self.raises \ | 434 self.set_raises = self.raises \ |
| 436 or self._convert_first(ast, 'SetRaises', IDLType) | 435 or self._convert_first(ast, 'SetRaises', IDLType) |
| 437 # FremontCut IDL syntax defines getters and setters separately: | |
| 438 self.is_fc_getter = self._has(ast, 'AttrGetter') | |
| 439 self.is_fc_setter = self._has(ast, 'AttrSetter') | |
| 440 def _extra_repr(self): | 436 def _extra_repr(self): |
| 441 extra = [] | 437 extra = [] |
| 442 if self.is_fc_getter: extra.append('get') | |
| 443 if self.is_fc_setter: extra.append('set') | |
| 444 if self.is_read_only: extra.append('readonly') | 438 if self.is_read_only: extra.append('readonly') |
| 445 if self.raises: extra.append('raises') | 439 if self.raises: extra.append('raises') |
| 446 return extra | 440 return extra |
| 447 | 441 |
| 448 class IDLConstant(IDLMember): | 442 class IDLConstant(IDLMember): |
| 449 """IDLNode specialization for 'const type name = value' declarations.""" | 443 """IDLNode specialization for 'const type name = value' declarations.""" |
| 450 def __init__(self, ast, doc_js_interface_name): | 444 def __init__(self, ast, doc_js_interface_name): |
| 451 IDLMember.__init__(self, ast, doc_js_interface_name) | 445 IDLMember.__init__(self, ast, doc_js_interface_name) |
| 452 self.value = self._find_first(ast, 'ConstExpr') | 446 self.value = self._find_first(ast, 'ConstExpr') |
| 453 | 447 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 """IDLDictNode specialization for one annotation.""" | 484 """IDLDictNode specialization for one annotation.""" |
| 491 def __init__(self, ast=None): | 485 def __init__(self, ast=None): |
| 492 IDLDictNode.__init__(self, ast) | 486 IDLDictNode.__init__(self, ast) |
| 493 self.id = None | 487 self.id = None |
| 494 if not ast: | 488 if not ast: |
| 495 return | 489 return |
| 496 for arg in self._find_all(ast, 'AnnotationArg'): | 490 for arg in self._find_all(ast, 'AnnotationArg'): |
| 497 name = self._find_first(arg, 'Id') | 491 name = self._find_first(arg, 'Id') |
| 498 value = self._find_first(arg, 'AnnotationArgValue') | 492 value = self._find_first(arg, 'AnnotationArgValue') |
| 499 self[name] = value | 493 self[name] = value |
| OLD | NEW |