| 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 _operation_suffix_map = { |
| 11 '__getter__': "Getter", |
| 12 '__setter__': "Setter", |
| 13 '__delete__': "Deleter", |
| 14 } |
| 15 |
| 10 class IDLNode(object): | 16 class IDLNode(object): |
| 11 """Base class for all IDL elements. | 17 """Base class for all IDL elements. |
| 12 IDLNode may contain various child nodes, and have properties. Examples | 18 IDLNode may contain various child nodes, and have properties. Examples |
| 13 of IDLNode are interfaces, interface members, function arguments, | 19 of IDLNode are interfaces, interface members, function arguments, |
| 14 etc. | 20 etc. |
| 15 """ | 21 """ |
| 16 | 22 |
| 17 def __init__(self, ast): | 23 def __init__(self, ast): |
| 18 """Initializes an IDLNode from a PegParser AST output.""" | 24 """Initializes an IDLNode from a PegParser AST output.""" |
| 19 self.id = self._find_first(ast, 'Id') if ast is not None else None | 25 self.id = self._find_first(ast, 'Id') if ast is not None else None |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 self.id = '__getter__' | 492 self.id = '__getter__' |
| 487 elif self.specials == ['setter']: | 493 elif self.specials == ['setter']: |
| 488 self.id = '__setter__' | 494 self.id = '__setter__' |
| 489 # Special case: if it's a setter, ignore 'declared' return type | 495 # Special case: if it's a setter, ignore 'declared' return type |
| 490 self.type = IDLType([('VoidType', None)]) | 496 self.type = IDLType([('VoidType', None)]) |
| 491 elif self.specials == ['deleter']: | 497 elif self.specials == ['deleter']: |
| 492 self.id = '__delete__' | 498 self.id = '__delete__' |
| 493 else: | 499 else: |
| 494 raise Exception('Cannot handle %s: operation has no id' % ast) | 500 raise Exception('Cannot handle %s: operation has no id' % ast) |
| 495 | 501 |
| 502 if len(self.arguments) >= 1 and (self.id in _operation_suffix_map) and not
self.ext_attrs.get('ImplementedAs'): |
| 503 arg = self.arguments[0] |
| 504 operation_category = 'Named' if arg.type.id == 'DOMString' else 'Indexed
' |
| 505 self.ext_attrs.setdefault('ImplementedAs', 'anonymous%s%s' % (operation_
category, _operation_suffix_map[self.id])) |
| 506 |
| 496 def _extra_repr(self): | 507 def _extra_repr(self): |
| 497 return [self.arguments] | 508 return [self.arguments] |
| 498 | 509 |
| 499 def SameSignatureAs(self, operation): | 510 def SameSignatureAs(self, operation): |
| 500 if self.type != operation.type: | 511 if self.type != operation.type: |
| 501 return False | 512 return False |
| 502 return [a.type for a in self.arguments] == [a.type for a in operation.argume
nts] | 513 return [a.type for a in self.arguments] == [a.type for a in operation.argume
nts] |
| 503 | 514 |
| 504 class IDLAttribute(IDLMember): | 515 class IDLAttribute(IDLMember): |
| 505 """IDLNode specialization for 'attribute type name' declarations.""" | 516 """IDLNode specialization for 'attribute type name' declarations.""" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 """IDLDictNode specialization for one annotation.""" | 572 """IDLDictNode specialization for one annotation.""" |
| 562 def __init__(self, ast=None): | 573 def __init__(self, ast=None): |
| 563 IDLDictNode.__init__(self, ast) | 574 IDLDictNode.__init__(self, ast) |
| 564 self.id = None | 575 self.id = None |
| 565 if not ast: | 576 if not ast: |
| 566 return | 577 return |
| 567 for arg in self._find_all(ast, 'AnnotationArg'): | 578 for arg in self._find_all(ast, 'AnnotationArg'): |
| 568 name = self._find_first(arg, 'Id') | 579 name = self._find_first(arg, 'Id') |
| 569 value = self._find_first(arg, 'AnnotationArgValue') | 580 value = self._find_first(arg, 'AnnotationArgValue') |
| 570 self[name] = value | 581 self[name] = value |
| OLD | NEW |