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

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

Issue 11365019: Merging dart:html interfaces and implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding generated files. 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
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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 return '\n' 439 return '\n'
440 return ''.join(FormatLine(line) for line in text.split('\n')) 440 return ''.join(FormatLine(line) for line in text.split('\n'))
441 441
442 # Given a sorted sequence of type identifiers, return an appropriate type 442 # Given a sorted sequence of type identifiers, return an appropriate type
443 # name 443 # name
444 def TypeName(type_ids, interface): 444 def TypeName(type_ids, interface):
445 # Dynamically type this field for now. 445 # Dynamically type this field for now.
446 return 'dynamic' 446 return 'dynamic'
447 447
448 def ImplementationClassNameForInterfaceName(interface_name): 448 def ImplementationClassNameForInterfaceName(interface_name):
449 return '_%sImpl' % interface_name 449 return interface_name
450 450
451 # ------------------------------------------------------------------------------ 451 # ------------------------------------------------------------------------------
452 452
453 class Conversion(object): 453 class Conversion(object):
454 """Represents a way of converting between types.""" 454 """Represents a way of converting between types."""
455 def __init__(self, name, input_type, output_type): 455 def __init__(self, name, input_type, output_type):
456 # input_type is the type of the API input (and the argument type of the 456 # input_type is the type of the API input (and the argument type of the
457 # conversion function) 457 # conversion function)
458 # output_type is the type of the API output (and the result type of the 458 # output_type is the type of the API output (and the result type of the
459 # conversion function) 459 # conversion function)
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 return self.dart_type() 693 return self.dart_type()
694 if IsPureInterface(self.idl_type()): 694 if IsPureInterface(self.idl_type()):
695 return self.idl_type() 695 return self.idl_type()
696 return ImplementationClassNameForInterfaceName(self.interface_name()) 696 return ImplementationClassNameForInterfaceName(self.interface_name())
697 697
698 def interface_name(self): 698 def interface_name(self):
699 if self.list_item_type() and not self.has_generated_interface(): 699 if self.list_item_type() and not self.has_generated_interface():
700 return self.dart_type() 700 return self.dart_type()
701 return self._dart_interface_name 701 return self._dart_interface_name
702 702
703 def implementation_name(self): 703 def implementation_name(self):
Anton Muhin 2012/11/02 12:55:47 implementation_name looks rather like an interface
blois 2012/11/02 19:25:28 This is still the implementation name, assuming th
704 if self.list_item_type(): 704 if self.list_item_type():
705 return ImplementationClassNameForInterfaceName(self.idl_type()) 705 implementation_name = ImplementationClassNameForInterfaceName(
706 implementation_name = ImplementationClassNameForInterfaceName( 706 self.idl_type())
707 self.interface_name()) 707 else:
708 implementation_name = ImplementationClassNameForInterfaceName(
709 self.interface_name())
708 if self.merged_into(): 710 if self.merged_into():
709 implementation_name = '%s_Merged' % implementation_name 711 implementation_name = '%s_Merged' % implementation_name
712
713 if not self.has_generated_interface():
714 implementation_name = '_%s' % implementation_name
715
710 return implementation_name 716 return implementation_name
711 717
712 def has_generated_interface(self): 718 def has_generated_interface(self):
713 return not self._data.suppress_interface 719 return not self._data.suppress_interface
714 720
715 def list_item_type(self): 721 def list_item_type(self):
716 return self._data.item_type 722 return self._data.item_type
717 723
718 def is_typed_array(self): 724 def is_typed_array(self):
719 return self._data.is_typed_array 725 return self._data.is_typed_array
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 else: 1097 else:
1092 dart_interface_name = type_name 1098 dart_interface_name = type_name
1093 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name, 1099 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name,
1094 self) 1100 self)
1095 1101
1096 if type_data.clazz == 'SVGTearOff': 1102 if type_data.clazz == 'SVGTearOff':
1097 return SVGTearOffIDLTypeInfo(type_name, type_data, self) 1103 return SVGTearOffIDLTypeInfo(type_name, type_data, self)
1098 1104
1099 class_name = '%sIDLTypeInfo' % type_data.clazz 1105 class_name = '%sIDLTypeInfo' % type_data.clazz
1100 return globals()[class_name](type_name, type_data) 1106 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « no previous file | lib/html/scripts/htmldartgenerator.py » ('j') | lib/html/scripts/htmldartgenerator.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698