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

Side by Side Diff: sdk/lib/html/scripts/generator.py

Issue 11364186: Dartifying SVG library class names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporating review feedback. Created 8 years, 1 month 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
« no previous file with comments | « no previous file | sdk/lib/html/scripts/htmlrenamer.py » ('j') | sdk/lib/html/scripts/htmlrenamer.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return self.idl_type() 678 return self.idl_type()
679 # TODO(podivilov): only primitive and collection types should override 679 # TODO(podivilov): only primitive and collection types should override
680 # dart_type. 680 # dart_type.
681 if self._data.dart_type != None: 681 if self._data.dart_type != None:
682 return self.dart_type() 682 return self.dart_type()
683 if IsPureInterface(self.idl_type()): 683 if IsPureInterface(self.idl_type()):
684 return self.idl_type() 684 return self.idl_type()
685 return self.interface_name() 685 return self.interface_name()
686 686
687 def interface_name(self): 687 def interface_name(self):
688 if self.list_item_type() and not self.has_generated_interface():
689 return self.dart_type()
690 return self._dart_interface_name 688 return self._dart_interface_name
691 689
692 def implementation_name(self): 690 def implementation_name(self):
693 if self.list_item_type(): 691 implementation_name = self._dart_interface_name
694 implementation_name = self.idl_type()
695 else:
696 implementation_name = self.interface_name()
697 if self.merged_into(): 692 if self.merged_into():
698 implementation_name = '_%s_Merged' % implementation_name 693 implementation_name = '_%s_Merged' % implementation_name
699 694
700 if not self.has_generated_interface(): 695 if not self.has_generated_interface():
701 implementation_name = '_%s' % implementation_name 696 implementation_name = '_%s' % implementation_name
702 697
703 return implementation_name 698 return implementation_name
704 699
705 def has_generated_interface(self): 700 def has_generated_interface(self):
706 return not self._data.suppress_interface 701 return not self._data.suppress_interface
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 return self._data.webcore_getter_name 810 return self._data.webcore_getter_name
816 811
817 def webcore_setter_name(self): 812 def webcore_setter_name(self):
818 return self._data.webcore_setter_name 813 return self._data.webcore_setter_name
819 814
820 def _capitalized_native_type(self): 815 def _capitalized_native_type(self):
821 return re.sub(r'(^| )([a-z])', lambda x: x.group(2).upper(), self.native_typ e()) 816 return re.sub(r'(^| )([a-z])', lambda x: x.group(2).upper(), self.native_typ e())
822 817
823 818
824 class SVGTearOffIDLTypeInfo(InterfaceIDLTypeInfo): 819 class SVGTearOffIDLTypeInfo(InterfaceIDLTypeInfo):
825 def __init__(self, idl_type, data, type_registry): 820 def __init__(self, idl_type, data, interface_name, type_registry):
826 super(SVGTearOffIDLTypeInfo, self).__init__( 821 super(SVGTearOffIDLTypeInfo, self).__init__(
827 idl_type, data, idl_type, type_registry) 822 idl_type, data, interface_name, type_registry)
828 823
829 def native_type(self): 824 def native_type(self):
830 if self._data.native_type: 825 if self._data.native_type:
831 return self._data.native_type 826 return self._data.native_type
832 tear_off_type = 'SVGPropertyTearOff' 827 tear_off_type = 'SVGPropertyTearOff'
833 if self._idl_type.endswith('List'): 828 if self._idl_type.endswith('List'):
834 tear_off_type = 'SVGListPropertyTearOff' 829 tear_off_type = 'SVGListPropertyTearOff'
835 return '%s<%s>' % (tear_off_type, self._idl_type) 830 return '%s<%s>' % (tear_off_type, self._idl_type)
836 831
837 def receiver(self): 832 def receiver(self):
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 self._renamer.RenameInterface(interface), 1070 self._renamer.RenameInterface(interface),
1076 self) 1071 self)
1077 1072
1078 type_data = _idl_type_registry.get(type_name) 1073 type_data = _idl_type_registry.get(type_name)
1079 1074
1080 if type_data.clazz == 'Interface': 1075 if type_data.clazz == 'Interface':
1081 if self._database.HasInterface(type_name): 1076 if self._database.HasInterface(type_name):
1082 dart_interface_name = self._renamer.RenameInterface( 1077 dart_interface_name = self._renamer.RenameInterface(
1083 self._database.GetInterface(type_name)) 1078 self._database.GetInterface(type_name))
1084 else: 1079 else:
1085 dart_interface_name = type_name 1080 dart_interface_name = self._renamer.RenameIDLName(type_name)
1086 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name, 1081 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name,
1087 self) 1082 self)
1088 1083
1089 if type_data.clazz == 'SVGTearOff': 1084 if type_data.clazz == 'SVGTearOff':
1090 return SVGTearOffIDLTypeInfo(type_name, type_data, self) 1085 dart_interface_name = self._renamer.RenameInterface(
1086 self._database.GetInterface(type_name))
1087 return SVGTearOffIDLTypeInfo(
1088 type_name, type_data, dart_interface_name, self)
1091 1089
1092 class_name = '%sIDLTypeInfo' % type_data.clazz 1090 class_name = '%sIDLTypeInfo' % type_data.clazz
1093 return globals()[class_name](type_name, type_data) 1091 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/scripts/htmlrenamer.py » ('j') | sdk/lib/html/scripts/htmlrenamer.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698