| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, 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 """This module provides shared functionality for systems to generate | 6 """This module provides shared functionality for systems to generate |
| 7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
| 8 | 8 |
| 9 import copy | 9 import copy |
| 10 import json | 10 import json |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 'Int32Array', | 619 'Int32Array', |
| 620 'Uint8Array', | 620 'Uint8Array', |
| 621 'Uint8ClampedArray', | 621 'Uint8ClampedArray', |
| 622 'Uint16Array', | 622 'Uint16Array', |
| 623 'Uint32Array', | 623 'Uint32Array', |
| 624 ] | 624 ] |
| 625 | 625 |
| 626 if self._idl_type in WTF_INCLUDES: | 626 if self._idl_type in WTF_INCLUDES: |
| 627 return ['<wtf/%s.h>' % self.native_type()] | 627 return ['<wtf/%s.h>' % self.native_type()] |
| 628 | 628 |
| 629 # TODO(vsm): Why does this need special casing? |
| 630 if self._idl_type == 'AnalyserNode': |
| 631 return ['"AnalyserNode.h"', '<wtf/Uint8Array.h>'] |
| 632 |
| 629 if not self._idl_type.startswith('SVG'): | 633 if not self._idl_type.startswith('SVG'): |
| 630 return ['"%s.h"' % self.native_type()] | 634 return ['"%s.h"' % self.native_type()] |
| 631 | 635 |
| 632 if self._idl_type in ['SVGNumber', 'SVGPoint']: | 636 if self._idl_type in ['SVGNumber', 'SVGPoint']: |
| 633 return ['"SVGPropertyTearOff.h"'] | 637 return ['"SVGPropertyTearOff.h"'] |
| 634 if self._idl_type.startswith('SVGPathSeg'): | 638 if self._idl_type.startswith('SVGPathSeg'): |
| 635 include = self._idl_type.replace('Abs', '').replace('Rel', '') | 639 include = self._idl_type.replace('Abs', '').replace('Rel', '') |
| 636 else: | 640 else: |
| 637 include = self._idl_type | 641 include = self._idl_type |
| 638 return ['"%s.h"' % include] + _svg_supplemental_includes | 642 return ['"%s.h"' % include] + _svg_supplemental_includes |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 def implementation_name(self): | 685 def implementation_name(self): |
| 682 implementation_name = self._dart_interface_name | 686 implementation_name = self._dart_interface_name |
| 683 if self.merged_into(): | 687 if self.merged_into(): |
| 684 implementation_name = '_%s_Merged' % implementation_name | 688 implementation_name = '_%s_Merged' % implementation_name |
| 685 | 689 |
| 686 if not self.has_generated_interface(): | 690 if not self.has_generated_interface(): |
| 687 implementation_name = '_%s' % implementation_name | 691 implementation_name = '_%s' % implementation_name |
| 688 | 692 |
| 689 return implementation_name | 693 return implementation_name |
| 690 | 694 |
| 695 def native_type(self): |
| 696 database = self._type_registry._database |
| 697 if database.HasInterface(self.idl_type()): |
| 698 interface = database.GetInterface(self.idl_type()) |
| 699 if 'ImplementedAs' in interface.ext_attrs: |
| 700 return interface.ext_attrs['ImplementedAs'] |
| 701 return super(InterfaceIDLTypeInfo, self).native_type() |
| 702 |
| 691 def has_generated_interface(self): | 703 def has_generated_interface(self): |
| 692 return not self._data.suppress_interface | 704 return not self._data.suppress_interface |
| 693 | 705 |
| 694 def list_item_type(self): | 706 def list_item_type(self): |
| 695 return self._data.item_type | 707 return self._data.item_type |
| 696 | 708 |
| 697 def merged_interface(self): | 709 def merged_interface(self): |
| 698 # All constants, attributes, and operations of merged interface should be | 710 # All constants, attributes, and operations of merged interface should be |
| 699 # added to this interface. Merged idl interface does not have corresponding | 711 # added to this interface. Merged idl interface does not have corresponding |
| 700 # Dart generated interface, and all references to merged idl interface | 712 # Dart generated interface, and all references to merged idl interface |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 native_type='MutationRecordArray', dart_type='List<MutationRecord>'), | 984 native_type='MutationRecordArray', dart_type='List<MutationRecord>'), |
| 973 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee
t']), | 985 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee
t']), |
| 974 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True), | 986 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True), |
| 975 | 987 |
| 976 'ClientRectList': TypeData(clazz='Interface', | 988 'ClientRectList': TypeData(clazz='Interface', |
| 977 item_type='ClientRect', dart_type='List<Rect>', suppress_interface=True)
, | 989 item_type='ClientRect', dart_type='List<Rect>', suppress_interface=True)
, |
| 978 'CSSRuleList': TypeData(clazz='Interface', | 990 'CSSRuleList': TypeData(clazz='Interface', |
| 979 item_type='CSSRule', suppress_interface=True), | 991 item_type='CSSRule', suppress_interface=True), |
| 980 'CSSValueList': TypeData(clazz='Interface', | 992 'CSSValueList': TypeData(clazz='Interface', |
| 981 item_type='CSSValue', suppress_interface=True), | 993 item_type='CSSValue', suppress_interface=True), |
| 982 'DOMMimeTypeArray': TypeData(clazz='Interface', item_type='DOMMimeType'), | 994 'MimeTypeArray': TypeData(clazz='Interface', item_type='MimeType'), |
| 983 'DOMPluginArray': TypeData(clazz='Interface', item_type='DOMPlugin'), | 995 'PluginArray': TypeData(clazz='Interface', item_type='Plugin'), |
| 984 'DOMStringList': TypeData(clazz='Interface', item_type='DOMString', | 996 'DOMStringList': TypeData(clazz='Interface', item_type='DOMString', |
| 985 dart_type='List<String>', custom_to_native=True), | 997 dart_type='List<String>', custom_to_native=True), |
| 986 'EntryArray': TypeData(clazz='Interface', item_type='Entry', | 998 'EntryArray': TypeData(clazz='Interface', item_type='Entry', |
| 987 suppress_interface=True), | 999 suppress_interface=True), |
| 988 'EntryArraySync': TypeData(clazz='Interface', item_type='EntrySync', | 1000 'EntryArraySync': TypeData(clazz='Interface', item_type='EntrySync', |
| 989 suppress_interface=True), | 1001 suppress_interface=True), |
| 990 'FileList': TypeData(clazz='Interface', item_type='File', | 1002 'FileList': TypeData(clazz='Interface', item_type='File', |
| 991 dart_type='List<File>'), | 1003 dart_type='List<File>'), |
| 992 'Future': TypeData(clazz='Interface', dart_type='Future'), | 1004 'Future': TypeData(clazz='Interface', dart_type='Future'), |
| 993 'GamepadList': TypeData(clazz='Interface', item_type='Gamepad', | 1005 'GamepadList': TypeData(clazz='Interface', item_type='Gamepad', |
| 994 suppress_interface=True), | 1006 suppress_interface=True), |
| 995 'HTMLAllCollection': TypeData(clazz='Interface', item_type='Node'), | 1007 'HTMLAllCollection': TypeData(clazz='Interface', item_type='Node'), |
| 996 'HTMLCollection': TypeData(clazz='Interface', item_type='Node'), | 1008 'HTMLCollection': TypeData(clazz='Interface', item_type='Node'), |
| 997 'NamedNodeMap': TypeData(clazz='Interface', item_type='Node'), | 1009 'NamedNodeMap': TypeData(clazz='Interface', item_type='Node'), |
| 998 'NodeList': TypeData(clazz='Interface', item_type='Node', | 1010 'NodeList': TypeData(clazz='Interface', item_type='Node', |
| 999 suppress_interface=False, dart_type='List<Node>'), | 1011 suppress_interface=False, dart_type='List<Node>'), |
| 1000 'SVGElementInstanceList': TypeData(clazz='Interface', | 1012 'SVGElementInstanceList': TypeData(clazz='Interface', |
| 1001 item_type='SVGElementInstance', suppress_interface=True), | 1013 item_type='SVGElementInstance', suppress_interface=True), |
| 1002 'SourceBufferList': TypeData(clazz='Interface', item_type='SourceBuffer'), | 1014 'WebKitSourceBufferList': TypeData(clazz='Interface', item_type='WebKitSourc
eBuffer'), |
| 1003 'SpeechGrammarList': TypeData(clazz='Interface', item_type='SpeechGrammar'), | 1015 'SpeechGrammarList': TypeData(clazz='Interface', item_type='SpeechGrammar'), |
| 1004 'SpeechInputResultList': TypeData(clazz='Interface', | 1016 'SpeechInputResultList': TypeData(clazz='Interface', |
| 1005 item_type='SpeechInputResult', suppress_interface=True), | 1017 item_type='SpeechInputResult', suppress_interface=True), |
| 1006 'SpeechRecognitionResultList': TypeData(clazz='Interface', | 1018 'SpeechRecognitionResultList': TypeData(clazz='Interface', |
| 1007 item_type='SpeechRecognitionResult', suppress_interface=True), | 1019 item_type='SpeechRecognitionResult', suppress_interface=True), |
| 1008 'SQLResultSetRowList': TypeData(clazz='Interface', item_type='Dictionary'), | 1020 'SQLResultSetRowList': TypeData(clazz='Interface', item_type='Dictionary'), |
| 1009 'StyleSheetList': TypeData(clazz='Interface', | 1021 'StyleSheetList': TypeData(clazz='Interface', |
| 1010 item_type='StyleSheet', suppress_interface=True), | 1022 item_type='StyleSheet', suppress_interface=True), |
| 1011 'TextTrackCueList': TypeData(clazz='Interface', item_type='TextTrackCue'), | 1023 'TextTrackCueList': TypeData(clazz='Interface', item_type='TextTrackCue'), |
| 1012 'TextTrackList': TypeData(clazz='Interface', item_type='TextTrack'), | 1024 'TextTrackList': TypeData(clazz='Interface', item_type='TextTrack'), |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 type_name, type_data, dart_interface_name, self) | 1127 type_name, type_data, dart_interface_name, self) |
| 1116 | 1128 |
| 1117 if type_data.clazz == 'BasicTypedList': | 1129 if type_data.clazz == 'BasicTypedList': |
| 1118 dart_interface_name = self._renamer.RenameInterface( | 1130 dart_interface_name = self._renamer.RenameInterface( |
| 1119 self._database.GetInterface(type_name)) | 1131 self._database.GetInterface(type_name)) |
| 1120 return BasicTypedListIDLTypeInfo( | 1132 return BasicTypedListIDLTypeInfo( |
| 1121 type_name, type_data, dart_interface_name, self) | 1133 type_name, type_data, dart_interface_name, self) |
| 1122 | 1134 |
| 1123 class_name = '%sIDLTypeInfo' % type_data.clazz | 1135 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1124 return globals()[class_name](type_name, type_data) | 1136 return globals()[class_name](type_name, type_data) |
| OLD | NEW |