Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: tools/dom/scripts/idlnode.py

Issue 551713003: Fix handling default parameters (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 import idl_definitions 9 import idl_definitions
10 from idl_types import IdlType, IdlUnionType 10 from idl_types import IdlType, IdlUnionType
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 IDLParentInterface) 612 IDLParentInterface)
613 613
614 javascript_interface_name = self.ext_attrs.get('InterfaceName', self.id) 614 javascript_interface_name = self.ext_attrs.get('InterfaceName', self.id)
615 self.javascript_binding_name = javascript_interface_name 615 self.javascript_binding_name = javascript_interface_name
616 self.doc_js_name = javascript_interface_name 616 self.doc_js_name = javascript_interface_name
617 617
618 if not (self._find_first(ast, 'Callback') is None): 618 if not (self._find_first(ast, 'Callback') is None):
619 self.ext_attrs['Callback'] = None 619 self.ext_attrs['Callback'] = None
620 if not (self._find_first(ast, 'Partial') is None): 620 if not (self._find_first(ast, 'Partial') is None):
621 self.is_supplemental = True 621 self.is_supplemental = True
622 self.ext_attrs['Supplemental'] = None 622 self.ext_attrs['DartSupplemental'] = None
623 623
624 self.operations = self._convert_all(ast, 'Operation', 624 self.operations = self._convert_all(ast, 'Operation',
625 lambda ast: IDLOperation(ast, self.doc_js_name)) 625 lambda ast: IDLOperation(ast, self.doc_js_name))
626 self.attributes = self._convert_all(ast, 'Attribute', 626 self.attributes = self._convert_all(ast, 'Attribute',
627 lambda ast: IDLAttribute(ast, self.doc_js_name)) 627 lambda ast: IDLAttribute(ast, self.doc_js_name))
628 self.constants = self._convert_all(ast, 'Const', 628 self.constants = self._convert_all(ast, 'Const',
629 lambda ast: IDLConstant(ast, self.doc_js_name)) 629 lambda ast: IDLConstant(ast, self.doc_js_name))
630 self.is_supplemental = 'Supplemental' in self.ext_attrs 630 self.is_supplemental = 'DartSupplemental' in self.ext_attrs
631 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs 631 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs
632 # TODO(terry): Can eliminate Suppressed when we're only using blink parser. 632 # TODO(terry): Can eliminate Suppressed when we're only using blink parser.
633 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs or \ 633 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs or \
634 'DartSuppress' in self.ext_attrs 634 'DartSuppress' in self.ext_attrs
635 635
636 636
637 def reset_id(self, new_id): 637 def reset_id(self, new_id):
638 """Reset the id of the Interface and corresponding the JS names.""" 638 """Reset the id of the Interface and corresponding the JS names."""
639 if self.id != new_id: 639 if self.id != new_id:
640 self.id = new_id 640 self.id = new_id
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 self.type = self._convert_first(ast, 'ReturnType', IDLType) 688 self.type = self._convert_first(ast, 'ReturnType', IDLType)
689 self.arguments = self._convert_all(ast, 'Argument', IDLArgument) 689 self.arguments = self._convert_all(ast, 'Argument', IDLArgument)
690 self.specials = self._find_all(ast, 'Special') 690 self.specials = self._find_all(ast, 'Special')
691 # Special case: there are getters of the form 691 # Special case: there are getters of the form
692 # getter <ReturnType>(args). For now force the name to be __getter__, 692 # getter <ReturnType>(args). For now force the name to be __getter__,
693 # but it should be operator[] later. 693 # but it should be operator[] later.
694 if self.id is None: 694 if self.id is None:
695 if self.specials == ['getter']: 695 if self.specials == ['getter']:
696 if self.ext_attrs.get('Custom') == 'PropertyQuery': 696 if self.ext_attrs.get('Custom') == 'PropertyQuery':
697 # Handling __propertyQuery__ the extended attribute is: 697 # Handling __propertyQuery__ the extended attribute is:
698 # [Custom=PropertyQuery] legacycaller boolean (DOMString name); 698 # [Custom=PropertyQuery] getter boolean (DOMString name);
699 self.id = '__propertyQuery__' 699 self.id = '__propertyQuery__'
700 else: 700 else:
701 self.id = '__getter__' 701 self.id = '__getter__'
702 elif self.specials == ['setter']: 702 elif self.specials == ['setter']:
703 self.id = '__setter__' 703 self.id = '__setter__'
704 # Special case: if it's a setter, ignore 'declared' return type 704 # Special case: if it's a setter, ignore 'declared' return type
705 self.type = IDLType([('VoidType', None)]) 705 self.type = IDLType([('VoidType', None)])
706 elif self.specials == ['deleter']: 706 elif self.specials == ['deleter']:
707 self.id = '__delete__' 707 self.id = '__delete__'
708 else: 708 else:
(...skipping 29 matching lines...) Expand all
738 """IDLNode specialization for 'const type name = value' declarations.""" 738 """IDLNode specialization for 'const type name = value' declarations."""
739 def __init__(self, ast, doc_js_interface_name): 739 def __init__(self, ast, doc_js_interface_name):
740 IDLMember.__init__(self, ast, doc_js_interface_name) 740 IDLMember.__init__(self, ast, doc_js_interface_name)
741 self.value = self._find_first(ast, 'ConstExpr') 741 self.value = self._find_first(ast, 'ConstExpr')
742 742
743 743
744 class IDLArgument(IDLNode): 744 class IDLArgument(IDLNode):
745 """IDLNode specialization for operation arguments.""" 745 """IDLNode specialization for operation arguments."""
746 def __init__(self, ast): 746 def __init__(self, ast):
747 IDLNode.__init__(self, ast) 747 IDLNode.__init__(self, ast)
748
749 self.default_value = None
750 self.default_value_is_null = False
751 # Handle the 'argType arg = default'. IDL syntax changed from
752 # [default=NullString].
753 if not isinstance(ast, list):
754 if isinstance(ast.default_value, idl_definitions.IdlLiteral) and ast.defau lt_value:
755 self.default_value = ast.default_value.value
756 self.default_value_is_null = ast.default_value.is_null
757 elif 'Default' in ast.extended_attributes:
758 # Work around [Default=Undefined] for arguments - only look in the model 's
759 # default_value
760 self.default_value = ast.extended_attributes.get('Default')
761 self.default_value_is_null = False
762
748 self.type = self._convert_first(ast, 'Type', IDLType) 763 self.type = self._convert_first(ast, 'Type', IDLType)
749 self.optional = self._has(ast, 'Optional') 764 self.optional = self._has(ast, 'Optional')
750 self._convert_ext_attrs(ast) 765 self._convert_ext_attrs(ast)
751 # TODO(vsm): Recover this from the type instead. 766 # TODO(vsm): Recover this from the type instead.
752 if 'Callback' in self.type.id: 767 if 'Callback' in self.type.id:
753 self.ext_attrs['Callback'] = None 768 self.ext_attrs['Callback'] = None
754 769
755 def __repr__(self): 770 def __repr__(self):
756 return '<IDLArgument(type = %s, id = %s)>' % (self.type, self.id) 771 return '<IDLArgument(type = %s, id = %s)>' % (self.type, self.id)
757 772
(...skipping 24 matching lines...) Expand all
782 """IDLDictNode specialization for one annotation.""" 797 """IDLDictNode specialization for one annotation."""
783 def __init__(self, ast=None): 798 def __init__(self, ast=None):
784 IDLDictNode.__init__(self, ast) 799 IDLDictNode.__init__(self, ast)
785 self.id = None 800 self.id = None
786 if not ast: 801 if not ast:
787 return 802 return
788 for arg in self._find_all(ast, 'AnnotationArg'): 803 for arg in self._find_all(ast, 'AnnotationArg'):
789 name = self._find_first(arg, 'Id') 804 name = self._find_first(arg, 'Id')
790 value = self._find_first(arg, 'AnnotationArgValue') 805 value = self._find_first(arg, 'AnnotationArgValue')
791 self[name] = value 806 self[name] = value
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698