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

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

Issue 11027033: Move Dart type narrowing to TypeRegistry. (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
« no previous file with comments | « lib/html/scripts/generator.py ('k') | no next file » | no next file with comments »
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 the system to generate 6 """This module provides shared functionality for the system to generate
7 Dart:html APIs from the IDL database.""" 7 Dart:html APIs from the IDL database."""
8 8
9 import emitter 9 import emitter
10 import os 10 import os
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 def CustomJSMembers(self): 1020 def CustomJSMembers(self):
1021 return _js_custom_members 1021 return _js_custom_members
1022 1022
1023 def _HasJavaScriptIndexingBehaviour(self): 1023 def _HasJavaScriptIndexingBehaviour(self):
1024 """Returns True if the native object has an indexer and length property.""" 1024 """Returns True if the native object has an indexer and length property."""
1025 (element_type, requires_indexer) = ListImplementationInfo( 1025 (element_type, requires_indexer) = ListImplementationInfo(
1026 self._interface, self._database) 1026 self._interface, self._database)
1027 if element_type and requires_indexer: return True 1027 if element_type and requires_indexer: return True
1028 return False 1028 return False
1029 1029
1030 def _ShouldNarrowToImplementationType(self, type_name):
1031 # TODO(sra): Move into the 'system' and cache the result.
1032 do_not_narrow = ['DOMStringList', 'DOMStringMap', 'EventListener',
1033 'IDBAny', 'IDBKey', 'MediaQueryListListener', 'List<Node>',
1034 'NodeList']
1035 if type_name in do_not_narrow:
1036 return False
1037 if self._database.HasInterface(type_name):
1038 interface = self._database.GetInterface(type_name)
1039 # Callbacks are typedef functions so don't have a class.
1040 return 'Callback' not in interface.ext_attrs
1041 return False
1042
1043 def _NarrowToImplementationType(self, type_name): 1030 def _NarrowToImplementationType(self, type_name):
1044 if type_name == 'Dynamic': 1031 if type_name == 'Dynamic':
1045 return type_name 1032 return type_name
1046 if self._ShouldNarrowToImplementationType(type_name): 1033 return self._type_registry.TypeInfo(type_name).narrow_dart_type()
1047 return self._ImplClassName(self._DartType(type_name))
1048 return self._DartType(type_name)
1049 1034
1050 def _NarrowInputType(self, type_name): 1035 def _NarrowInputType(self, type_name):
1051 return self._NarrowToImplementationType(type_name) 1036 return self._NarrowToImplementationType(type_name)
1052 1037
1053 def _NarrowOutputType(self, type_name): 1038 def _NarrowOutputType(self, type_name):
1054 return self._NarrowToImplementationType(type_name) 1039 return self._NarrowToImplementationType(type_name)
1055 1040
1056 def _FindShadowedAttribute(self, attr, merged_interfaces={}): 1041 def _FindShadowedAttribute(self, attr, merged_interfaces={}):
1057 """Returns (attribute, superinterface) or (None, None).""" 1042 """Returns (attribute, superinterface) or (None, None)."""
1058 def FindInParent(interface): 1043 def FindInParent(interface):
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 1104
1120 library_emitter = self._multiemitter.FileEmitter(library_file_path) 1105 library_emitter = self._multiemitter.FileEmitter(library_file_path)
1121 library_file_dir = os.path.dirname(library_file_path) 1106 library_file_dir = os.path.dirname(library_file_path)
1122 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) 1107 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir)
1123 imports_emitter = library_emitter.Emit( 1108 imports_emitter = library_emitter.Emit(
1124 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) 1109 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir))
1125 for path in sorted(self._path_to_emitter.keys()): 1110 for path in sorted(self._path_to_emitter.keys()):
1126 relpath = os.path.relpath(path, library_file_dir) 1111 relpath = os.path.relpath(path, library_file_dir)
1127 imports_emitter.Emit( 1112 imports_emitter.Emit(
1128 "#source('$PATH');\n", PATH=massage_path(relpath)) 1113 "#source('$PATH');\n", PATH=massage_path(relpath))
OLDNEW
« no previous file with comments | « lib/html/scripts/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698