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

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

Issue 11040059: Add interface_name and implementation_name to IDLTypeInfo class and use them instead of dart_type. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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) 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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 608
609 def idl_type(self): 609 def idl_type(self):
610 return self._idl_type 610 return self._idl_type
611 611
612 def dart_type(self): 612 def dart_type(self):
613 return self._data.dart_type or self._idl_type 613 return self._data.dart_type or self._idl_type
614 614
615 def narrow_dart_type(self): 615 def narrow_dart_type(self):
616 return self.dart_type() 616 return self.dart_type()
617 617
618 def interface_name(self):
619 raise NotImplementedError()
620
621 def implementation_name(self):
622 raise NotImplementedError()
623
618 def native_type(self): 624 def native_type(self):
619 return self._data.native_type or self._idl_type 625 return self._data.native_type or self._idl_type
620 626
621 def bindings_class(self): 627 def bindings_class(self):
622 return 'Dart%s' % self.idl_type() 628 return 'Dart%s' % self.idl_type()
623 629
624 def vector_to_dart_template_parameter(self): 630 def vector_to_dart_template_parameter(self):
625 return self.bindings_class() 631 return self.bindings_class()
626 632
627 def requires_v8_scope(self): 633 def requires_v8_scope(self):
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 def narrow_dart_type(self): 712 def narrow_dart_type(self):
707 # TODO(podivilov): introduce ListLikeIDLTypeInfo and remove this hack. 713 # TODO(podivilov): introduce ListLikeIDLTypeInfo and remove this hack.
708 if self._data.suppress_public_interface: 714 if self._data.suppress_public_interface:
709 return ImplementationClassName(self.idl_type()) 715 return ImplementationClassName(self.idl_type())
710 # TODO(podivilov): only primitive and collection types should override 716 # TODO(podivilov): only primitive and collection types should override
711 # dart_type. 717 # dart_type.
712 if self._data.dart_type != None: 718 if self._data.dart_type != None:
713 return self.dart_type() 719 return self.dart_type()
714 if IsPureInterface(self.idl_type()): 720 if IsPureInterface(self.idl_type()):
715 return self.idl_type() 721 return self.idl_type()
716 return ImplementationClassName(self._dart_interface_name) 722 return ImplementationClassName(self._dart_interface_name)
Anton Muhin 2012/10/05 15:15:31 why not implementation_name here? And overall, it
podivilov 2012/10/05 16:02:51 Done.
Anton Muhin 2012/10/05 16:04:16 I do understand that, but presence of both is real
podivilov1 2012/10/05 17:31:43 Renamed
717 723
724 def interface_name(self):
725 return self._dart_interface_name
726
727 def implementation_name(self):
728 # TODO(podivilov): introduce ListLikeIDLTypeInfo and remove this hack.
729 if self._data.suppress_public_interface:
730 return ImplementationClassName(self.idl_type())
731 return ImplementationClassName(self._dart_interface_name)
732
718 733
719 class CallbackIDLTypeInfo(IDLTypeInfo): 734 class CallbackIDLTypeInfo(IDLTypeInfo):
720 def __init__(self, idl_type, data): 735 def __init__(self, idl_type, data):
721 super(CallbackIDLTypeInfo, self).__init__(idl_type, data) 736 super(CallbackIDLTypeInfo, self).__init__(idl_type, data)
722 737
723 738
724 class SequenceIDLTypeInfo(IDLTypeInfo): 739 class SequenceIDLTypeInfo(IDLTypeInfo):
725 def __init__(self, idl_type, data, item_info): 740 def __init__(self, idl_type, data, item_info):
726 super(SequenceIDLTypeInfo, self).__init__(idl_type, data) 741 super(SequenceIDLTypeInfo, self).__init__(idl_type, data)
727 self._item_info = item_info 742 self._item_info = item_info
728 743
729 def dart_type(self): 744 def dart_type(self):
730 return 'List<%s>' % self._item_info.dart_type() 745 return 'List<%s>' % self._item_info.dart_type()
731 746
747 def interface_name(self):
748 return self.dart_type()
749
750 def implementation_name(self):
751 return self.dart_type()
752
732 def vector_to_dart_template_parameter(self): 753 def vector_to_dart_template_parameter(self):
733 raise Exception('sequences of sequences are not supported yet') 754 raise Exception('sequences of sequences are not supported yet')
734 755
735 def to_native_info(self, idl_node, interface_name): 756 def to_native_info(self, idl_node, interface_name):
736 item_native_type = self._item_info.vector_to_dart_template_parameter() 757 item_native_type = self._item_info.vector_to_dart_template_parameter()
737 return '%s', 'Vector<%s>' % item_native_type, 'DartUtilities', 'toNativeVect or<%s>' % item_native_type 758 return '%s', 'Vector<%s>' % item_native_type, 'DartUtilities', 'toNativeVect or<%s>' % item_native_type
738 759
739 def pass_native_by_ref(self): return True 760 def pass_native_by_ref(self): return True
740 761
741 def to_dart_conversion(self, value, interface_name=None, attributes=None): 762 def to_dart_conversion(self, value, interface_name=None, attributes=None):
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 if type_data.clazz == 'Interface': 1050 if type_data.clazz == 'Interface':
1030 if self._database.HasInterface(type_name): 1051 if self._database.HasInterface(type_name):
1031 dart_interface_name = self._renamer.RenameInterface( 1052 dart_interface_name = self._renamer.RenameInterface(
1032 self._database.GetInterface(type_name)) 1053 self._database.GetInterface(type_name))
1033 else: 1054 else:
1034 dart_interface_name = type_name 1055 dart_interface_name = type_name
1035 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name) 1056 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name)
1036 1057
1037 class_name = '%sIDLTypeInfo' % type_data.clazz 1058 class_name = '%sIDLTypeInfo' % type_data.clazz
1038 return globals()[class_name](type_name, type_data) 1059 return globals()[class_name](type_name, type_data)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698