| 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 re | 10 import re |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 if self._data.dart_type != None: | 717 if self._data.dart_type != None: |
| 718 return self.dart_type() | 718 return self.dart_type() |
| 719 if IsPureInterface(self.idl_type()): | 719 if IsPureInterface(self.idl_type()): |
| 720 return self.idl_type() | 720 return self.idl_type() |
| 721 return self.interface_name() | 721 return self.interface_name() |
| 722 | 722 |
| 723 def interface_name(self): | 723 def interface_name(self): |
| 724 return self._dart_interface_name | 724 return self._dart_interface_name |
| 725 | 725 |
| 726 def implementation_name(self): | 726 def implementation_name(self): |
| 727 if self.list_item_type(): | 727 implementation_name = self._dart_interface_name |
| 728 implementation_name = self.idl_type() | |
| 729 else: | |
| 730 implementation_name = self.interface_name() | |
| 731 if self.merged_into(): | 728 if self.merged_into(): |
| 732 implementation_name = '_%s_Merged' % implementation_name | 729 implementation_name = '_%s_Merged' % implementation_name |
| 733 | 730 |
| 734 if not self.has_generated_interface(): | 731 if not self.has_generated_interface(): |
| 735 implementation_name = '_%s' % implementation_name | 732 implementation_name = '_%s' % implementation_name |
| 736 | 733 |
| 737 return implementation_name | 734 return implementation_name |
| 738 | 735 |
| 739 def has_generated_interface(self): | 736 def has_generated_interface(self): |
| 740 return not self._data.suppress_interface | 737 return not self._data.suppress_interface |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 return self._data.webcore_getter_name | 846 return self._data.webcore_getter_name |
| 850 | 847 |
| 851 def webcore_setter_name(self): | 848 def webcore_setter_name(self): |
| 852 return self._data.webcore_setter_name | 849 return self._data.webcore_setter_name |
| 853 | 850 |
| 854 def _capitalized_native_type(self): | 851 def _capitalized_native_type(self): |
| 855 return re.sub(r'(^| )([a-z])', lambda x: x.group(2).upper(), self.native_typ
e()) | 852 return re.sub(r'(^| )([a-z])', lambda x: x.group(2).upper(), self.native_typ
e()) |
| 856 | 853 |
| 857 | 854 |
| 858 class SVGTearOffIDLTypeInfo(InterfaceIDLTypeInfo): | 855 class SVGTearOffIDLTypeInfo(InterfaceIDLTypeInfo): |
| 859 def __init__(self, idl_type, data, type_registry): | 856 def __init__(self, idl_type, data, interface_name, type_registry): |
| 860 super(SVGTearOffIDLTypeInfo, self).__init__( | 857 super(SVGTearOffIDLTypeInfo, self).__init__( |
| 861 idl_type, data, idl_type, type_registry) | 858 idl_type, data, interface_name, type_registry) |
| 862 | 859 |
| 863 def native_type(self): | 860 def native_type(self): |
| 864 if self._data.native_type: | 861 if self._data.native_type: |
| 865 return self._data.native_type | 862 return self._data.native_type |
| 866 tear_off_type = 'SVGPropertyTearOff' | 863 tear_off_type = 'SVGPropertyTearOff' |
| 867 if self._idl_type.endswith('List'): | 864 if self._idl_type.endswith('List'): |
| 868 tear_off_type = 'SVGListPropertyTearOff' | 865 tear_off_type = 'SVGListPropertyTearOff' |
| 869 return '%s<%s>' % (tear_off_type, self._idl_type) | 866 return '%s<%s>' % (tear_off_type, self._idl_type) |
| 870 | 867 |
| 871 def receiver(self): | 868 def receiver(self): |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 self._renamer.RenameInterface(interface), | 1105 self._renamer.RenameInterface(interface), |
| 1109 self) | 1106 self) |
| 1110 | 1107 |
| 1111 type_data = _idl_type_registry.get(type_name) | 1108 type_data = _idl_type_registry.get(type_name) |
| 1112 | 1109 |
| 1113 if type_data.clazz == 'Interface': | 1110 if type_data.clazz == 'Interface': |
| 1114 if self._database.HasInterface(type_name): | 1111 if self._database.HasInterface(type_name): |
| 1115 dart_interface_name = self._renamer.RenameInterface( | 1112 dart_interface_name = self._renamer.RenameInterface( |
| 1116 self._database.GetInterface(type_name)) | 1113 self._database.GetInterface(type_name)) |
| 1117 else: | 1114 else: |
| 1118 dart_interface_name = type_name | 1115 dart_interface_name = self._renamer.DartifyTypeName(type_name) |
| 1119 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name, | 1116 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name, |
| 1120 self) | 1117 self) |
| 1121 | 1118 |
| 1122 if type_data.clazz == 'SVGTearOff': | 1119 if type_data.clazz == 'SVGTearOff': |
| 1123 return SVGTearOffIDLTypeInfo(type_name, type_data, self) | 1120 dart_interface_name = self._renamer.RenameInterface( |
| 1121 self._database.GetInterface(type_name)) |
| 1122 return SVGTearOffIDLTypeInfo( |
| 1123 type_name, type_data, dart_interface_name, self) |
| 1124 | 1124 |
| 1125 class_name = '%sIDLTypeInfo' % type_data.clazz | 1125 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1126 return globals()[class_name](type_name, type_data) | 1126 return globals()[class_name](type_name, type_data) |
| OLD | NEW |