| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 402 |
| 403 def __init__(self, ast): | 403 def __init__(self, ast): |
| 404 IDLNode.__init__(self, ast) | 404 IDLNode.__init__(self, ast) |
| 405 self._convert_ext_attrs(ast) | 405 self._convert_ext_attrs(ast) |
| 406 self._convert_annotations(ast) | 406 self._convert_annotations(ast) |
| 407 self.parents = self._convert_all(ast, 'ParentInterface', | 407 self.parents = self._convert_all(ast, 'ParentInterface', |
| 408 IDLParentInterface) | 408 IDLParentInterface) |
| 409 javascript_interface_name = self.ext_attrs.get('InterfaceName', self.id) | 409 javascript_interface_name = self.ext_attrs.get('InterfaceName', self.id) |
| 410 self.javascript_binding_name = javascript_interface_name | 410 self.javascript_binding_name = javascript_interface_name |
| 411 self.doc_js_name = javascript_interface_name | 411 self.doc_js_name = javascript_interface_name |
| 412 |
| 413 if not (self._find_first(ast, 'Callback') is None): |
| 414 self.ext_attrs['Callback'] = None |
| 415 if not (self._find_first(ast, 'Partial') is None): |
| 416 self.is_supplemental = True |
| 417 self.ext_attrs['Supplemental'] = None |
| 418 |
| 412 self.operations = self._convert_all(ast, 'Operation', | 419 self.operations = self._convert_all(ast, 'Operation', |
| 413 lambda ast: IDLOperation(ast, self.doc_js_name)) | 420 lambda ast: IDLOperation(ast, self.doc_js_name)) |
| 414 self.attributes = self._convert_all(ast, 'Attribute', | 421 self.attributes = self._convert_all(ast, 'Attribute', |
| 415 lambda ast: IDLAttribute(ast, self.doc_js_name)) | 422 lambda ast: IDLAttribute(ast, self.doc_js_name)) |
| 416 self.constants = self._convert_all(ast, 'Const', | 423 self.constants = self._convert_all(ast, 'Const', |
| 417 lambda ast: IDLConstant(ast, self.doc_js_name)) | 424 lambda ast: IDLConstant(ast, self.doc_js_name)) |
| 418 self.is_supplemental = 'Supplemental' in self.ext_attrs | 425 self.is_supplemental = 'Supplemental' in self.ext_attrs |
| 419 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs | 426 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs |
| 420 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs | 427 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs |
| 421 | 428 |
| 429 |
| 422 def reset_id(self, new_id): | 430 def reset_id(self, new_id): |
| 423 """Reset the id of the Interface and corresponding the JS names.""" | 431 """Reset the id of the Interface and corresponding the JS names.""" |
| 424 if self.id != new_id: | 432 if self.id != new_id: |
| 425 self.id = new_id | 433 self.id = new_id |
| 426 self.doc_js_name = new_id | 434 self.doc_js_name = new_id |
| 427 self.javascript_binding_name = new_id | 435 self.javascript_binding_name = new_id |
| 428 for member in self.operations: | 436 for member in self.operations: |
| 429 member.doc_js_interface_name = new_id | 437 member.doc_js_interface_name = new_id |
| 430 for member in self.attributes: | 438 for member in self.attributes: |
| 431 member.doc_js_interface_name = new_id | 439 member.doc_js_interface_name = new_id |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 self.value = self._find_first(ast, 'ConstExpr') | 500 self.value = self._find_first(ast, 'ConstExpr') |
| 493 | 501 |
| 494 | 502 |
| 495 class IDLArgument(IDLNode): | 503 class IDLArgument(IDLNode): |
| 496 """IDLNode specialization for operation arguments.""" | 504 """IDLNode specialization for operation arguments.""" |
| 497 def __init__(self, ast): | 505 def __init__(self, ast): |
| 498 IDLNode.__init__(self, ast) | 506 IDLNode.__init__(self, ast) |
| 499 self.type = self._convert_first(ast, 'Type', IDLType) | 507 self.type = self._convert_first(ast, 'Type', IDLType) |
| 500 self.optional = self._has(ast, 'Optional') | 508 self.optional = self._has(ast, 'Optional') |
| 501 self._convert_ext_attrs(ast) | 509 self._convert_ext_attrs(ast) |
| 510 # TODO(vsm): Recover this from the type instead. |
| 511 if 'Callback' in self.type.id: |
| 512 self.ext_attrs['Callback'] = None |
| 502 | 513 |
| 503 def __repr__(self): | 514 def __repr__(self): |
| 504 return '<IDLArgument(type = %s, id = %s)>' % (self.type, self.id) | 515 return '<IDLArgument(type = %s, id = %s)>' % (self.type, self.id) |
| 505 | 516 |
| 506 | 517 |
| 507 class IDLImplementsStatement(IDLNode): | 518 class IDLImplementsStatement(IDLNode): |
| 508 """IDLNode specialization for 'X implements Y' declarations.""" | 519 """IDLNode specialization for 'X implements Y' declarations.""" |
| 509 def __init__(self, ast): | 520 def __init__(self, ast): |
| 510 IDLNode.__init__(self, ast) | 521 IDLNode.__init__(self, ast) |
| 511 self.implementor = self._convert_first(ast, 'ImplStmtImplementor', | 522 self.implementor = self._convert_first(ast, 'ImplStmtImplementor', |
| (...skipping 19 matching lines...) Expand all Loading... |
| 531 """IDLDictNode specialization for one annotation.""" | 542 """IDLDictNode specialization for one annotation.""" |
| 532 def __init__(self, ast=None): | 543 def __init__(self, ast=None): |
| 533 IDLDictNode.__init__(self, ast) | 544 IDLDictNode.__init__(self, ast) |
| 534 self.id = None | 545 self.id = None |
| 535 if not ast: | 546 if not ast: |
| 536 return | 547 return |
| 537 for arg in self._find_all(ast, 'AnnotationArg'): | 548 for arg in self._find_all(ast, 'AnnotationArg'): |
| 538 name = self._find_first(arg, 'Id') | 549 name = self._find_first(arg, 'Id') |
| 539 value = self._find_first(arg, 'AnnotationArgValue') | 550 value = self._find_first(arg, 'AnnotationArgValue') |
| 540 self[name] = value | 551 self[name] = value |
| OLD | NEW |