| 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 class IDLInterface(IDLNode): | 361 class IDLInterface(IDLNode): |
| 362 """IDLInterface node contains operations, attributes, constants, | 362 """IDLInterface node contains operations, attributes, constants, |
| 363 as well as parent references.""" | 363 as well as parent references.""" |
| 364 | 364 |
| 365 def __init__(self, ast): | 365 def __init__(self, ast): |
| 366 IDLNode.__init__(self, ast) | 366 IDLNode.__init__(self, ast) |
| 367 self._convert_ext_attrs(ast) | 367 self._convert_ext_attrs(ast) |
| 368 self._convert_annotations(ast) | 368 self._convert_annotations(ast) |
| 369 self.parents = self._convert_all(ast, 'ParentInterface', | 369 self.parents = self._convert_all(ast, 'ParentInterface', |
| 370 IDLParentInterface) | 370 IDLParentInterface) |
| 371 self.operations = self._convert_all(ast, 'Operation', IDLOperation) | 371 self.javascript_binding_name = self.id |
| 372 self.attributes = self._convert_all(ast, 'Attribute', IDLAttribute) | 372 self.doc_js_name = self.id |
| 373 self.constants = self._convert_all(ast, 'Const', IDLConstant) | 373 self.operations = self._convert_all(ast, 'Operation', |
| 374 lambda ast: IDLOperation(ast, self.doc_js_name)) |
| 375 self.attributes = self._convert_all(ast, 'Attribute', |
| 376 lambda ast: IDLAttribute(ast, self.doc_js_name)) |
| 377 self.constants = self._convert_all(ast, 'Const', |
| 378 lambda ast: IDLConstant(ast, self.doc_js_name)) |
| 374 self.is_supplemental = 'Supplemental' in self.ext_attrs | 379 self.is_supplemental = 'Supplemental' in self.ext_attrs |
| 375 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs | 380 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs |
| 376 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs | 381 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs |
| 377 self.javascript_binding_name = self.id | |
| 378 | 382 |
| 379 def has_attribute(self, candidate): | 383 def has_attribute(self, candidate): |
| 380 for attribute in self.attributes: | 384 for attribute in self.attributes: |
| 381 if (attribute.id == candidate.id and | 385 if (attribute.id == candidate.id and |
| 382 attribute.is_fc_getter == candidate.is_fc_getter and | 386 attribute.is_fc_getter == candidate.is_fc_getter and |
| 383 attribute.is_fc_setter == candidate.is_fc_setter): | 387 attribute.is_fc_setter == candidate.is_fc_setter): |
| 384 return True | 388 return True |
| 385 return False | 389 return False |
| 386 | 390 |
| 387 | 391 |
| 388 class IDLParentInterface(IDLNode): | 392 class IDLParentInterface(IDLNode): |
| 389 """This IDLNode specialization is for 'Interface Child : Parent {}' | 393 """This IDLNode specialization is for 'Interface Child : Parent {}' |
| 390 declarations.""" | 394 declarations.""" |
| 391 def __init__(self, ast): | 395 def __init__(self, ast): |
| 392 IDLNode.__init__(self, ast) | 396 IDLNode.__init__(self, ast) |
| 393 self._convert_annotations(ast) | 397 self._convert_annotations(ast) |
| 394 self.type = self._convert_first(ast, 'InterfaceType', IDLType) | 398 self.type = self._convert_first(ast, 'InterfaceType', IDLType) |
| 395 | 399 |
| 396 | 400 |
| 397 class IDLMember(IDLNode): | 401 class IDLMember(IDLNode): |
| 398 """A base class for constants, attributes and operations.""" | 402 """A base class for constants, attributes and operations.""" |
| 399 | 403 |
| 400 def __init__(self, ast): | 404 def __init__(self, ast, doc_js_interface_name): |
| 401 IDLNode.__init__(self, ast) | 405 IDLNode.__init__(self, ast) |
| 402 self.type = self._convert_first(ast, 'Type', IDLType) | 406 self.type = self._convert_first(ast, 'Type', IDLType) |
| 403 self._convert_ext_attrs(ast) | 407 self._convert_ext_attrs(ast) |
| 404 self._convert_annotations(ast) | 408 self._convert_annotations(ast) |
| 409 self.doc_js_interface_name = doc_js_interface_name |
| 405 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs | 410 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs |
| 406 | 411 |
| 407 | 412 |
| 408 class IDLOperation(IDLMember): | 413 class IDLOperation(IDLMember): |
| 409 """IDLNode specialization for 'type name(args)' declarations.""" | 414 """IDLNode specialization for 'type name(args)' declarations.""" |
| 410 def __init__(self, ast): | 415 def __init__(self, ast, doc_js_interface_name): |
| 411 IDLMember.__init__(self, ast) | 416 IDLMember.__init__(self, ast, doc_js_interface_name) |
| 412 self.type = self._convert_first(ast, 'ReturnType', IDLType) | 417 self.type = self._convert_first(ast, 'ReturnType', IDLType) |
| 413 self.arguments = self._convert_all(ast, 'Argument', IDLArgument) | 418 self.arguments = self._convert_all(ast, 'Argument', IDLArgument) |
| 414 self.raises = self._convert_first(ast, 'Raises', IDLType) | 419 self.raises = self._convert_first(ast, 'Raises', IDLType) |
| 415 self.specials = self._find_all(ast, 'Special') | 420 self.specials = self._find_all(ast, 'Special') |
| 416 self.is_stringifier = self._has(ast, 'Stringifier') | 421 self.is_stringifier = self._has(ast, 'Stringifier') |
| 417 self.is_static = self._has(ast, 'Static') | 422 self.is_static = self._has(ast, 'Static') |
| 418 def _extra_repr(self): | 423 def _extra_repr(self): |
| 419 return [self.arguments] | 424 return [self.arguments] |
| 420 | 425 |
| 421 | 426 |
| 422 class IDLAttribute(IDLMember): | 427 class IDLAttribute(IDLMember): |
| 423 """IDLNode specialization for 'attribute type name' declarations.""" | 428 """IDLNode specialization for 'attribute type name' declarations.""" |
| 424 def __init__(self, ast): | 429 def __init__(self, ast, doc_js_interface_name): |
| 425 IDLMember.__init__(self, ast) | 430 IDLMember.__init__(self, ast, doc_js_interface_name) |
| 426 self.is_read_only = self._has(ast, 'ReadOnly') | 431 self.is_read_only = self._has(ast, 'ReadOnly') |
| 427 # There are various ways to define exceptions for attributes: | 432 # There are various ways to define exceptions for attributes: |
| 428 self.raises = self._convert_first(ast, 'Raises', IDLType) | 433 self.raises = self._convert_first(ast, 'Raises', IDLType) |
| 429 self.get_raises = self.raises \ | 434 self.get_raises = self.raises \ |
| 430 or self._convert_first(ast, 'GetRaises', IDLType) | 435 or self._convert_first(ast, 'GetRaises', IDLType) |
| 431 self.set_raises = self.raises \ | 436 self.set_raises = self.raises \ |
| 432 or self._convert_first(ast, 'SetRaises', IDLType) | 437 or self._convert_first(ast, 'SetRaises', IDLType) |
| 433 # FremontCut IDL syntax defines getters and setters separately: | 438 # FremontCut IDL syntax defines getters and setters separately: |
| 434 self.is_fc_getter = self._has(ast, 'AttrGetter') | 439 self.is_fc_getter = self._has(ast, 'AttrGetter') |
| 435 self.is_fc_setter = self._has(ast, 'AttrSetter') | 440 self.is_fc_setter = self._has(ast, 'AttrSetter') |
| 436 def _extra_repr(self): | 441 def _extra_repr(self): |
| 437 extra = [] | 442 extra = [] |
| 438 if self.is_fc_getter: extra.append('get') | 443 if self.is_fc_getter: extra.append('get') |
| 439 if self.is_fc_setter: extra.append('set') | 444 if self.is_fc_setter: extra.append('set') |
| 440 if self.is_read_only: extra.append('readonly') | 445 if self.is_read_only: extra.append('readonly') |
| 441 if self.raises: extra.append('raises') | 446 if self.raises: extra.append('raises') |
| 442 return extra | 447 return extra |
| 443 | 448 |
| 444 class IDLConstant(IDLMember): | 449 class IDLConstant(IDLMember): |
| 445 """IDLNode specialization for 'const type name = value' declarations.""" | 450 """IDLNode specialization for 'const type name = value' declarations.""" |
| 446 def __init__(self, ast): | 451 def __init__(self, ast, doc_js_interface_name): |
| 447 IDLMember.__init__(self, ast) | 452 IDLMember.__init__(self, ast, doc_js_interface_name) |
| 448 self.value = self._find_first(ast, 'ConstExpr') | 453 self.value = self._find_first(ast, 'ConstExpr') |
| 449 | 454 |
| 450 | 455 |
| 451 class IDLArgument(IDLNode): | 456 class IDLArgument(IDLNode): |
| 452 """IDLNode specialization for operation arguments.""" | 457 """IDLNode specialization for operation arguments.""" |
| 453 def __init__(self, ast): | 458 def __init__(self, ast): |
| 454 IDLNode.__init__(self, ast) | 459 IDLNode.__init__(self, ast) |
| 455 self.type = self._convert_first(ast, 'Type', IDLType) | 460 self.type = self._convert_first(ast, 'Type', IDLType) |
| 456 self._convert_ext_attrs(ast) | 461 self._convert_ext_attrs(ast) |
| 457 # WebKit and Web IDL differ in how Optional is declared: | 462 # WebKit and Web IDL differ in how Optional is declared: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 486 """IDLDictNode specialization for one annotation.""" | 491 """IDLDictNode specialization for one annotation.""" |
| 487 def __init__(self, ast=None): | 492 def __init__(self, ast=None): |
| 488 IDLDictNode.__init__(self, ast) | 493 IDLDictNode.__init__(self, ast) |
| 489 self.id = None | 494 self.id = None |
| 490 if not ast: | 495 if not ast: |
| 491 return | 496 return |
| 492 for arg in self._find_all(ast, 'AnnotationArg'): | 497 for arg in self._find_all(ast, 'AnnotationArg'): |
| 493 name = self._find_first(arg, 'Id') | 498 name = self._find_first(arg, 'Id') |
| 494 value = self._find_first(arg, 'AnnotationArgValue') | 499 value = self._find_first(arg, 'AnnotationArgValue') |
| 495 self[name] = value | 500 self[name] = value |
| OLD | NEW |