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

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

Issue 11419300: Dartifying dart:html type names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporating review feedback. Created 8 years 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 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 24 matching lines...) Expand all
35 'WheelEvent.wheelDeltaX', 35 'WheelEvent.wheelDeltaX',
36 'WheelEvent.wheelDeltaY', 36 'WheelEvent.wheelDeltaY',
37 'Window.cancelAnimationFrame', 37 'Window.cancelAnimationFrame',
38 'Window.document', 38 'Window.document',
39 'Window.indexedDB', 39 'Window.indexedDB',
40 'Window.location', 40 'Window.location',
41 'Window.open', 41 'Window.open',
42 'Window.requestAnimationFrame', 42 'Window.requestAnimationFrame',
43 'Window.webkitCancelAnimationFrame', 43 'Window.webkitCancelAnimationFrame',
44 'Window.webkitRequestAnimationFrame', 44 'Window.webkitRequestAnimationFrame',
45 'WorkerContext.indexedDB',
45 ]) 46 ])
46 47
47 48
48 # Classes that offer only static methods, and therefore we should suppress 49 # Classes that offer only static methods, and therefore we should suppress
49 # constructor creation. 50 # constructor creation.
50 _static_classes = set(['Url']) 51 _static_classes = set(['Url'])
51 52
52 # Information for generating element constructors. 53 # Information for generating element constructors.
53 # 54 #
54 # TODO(sra): maybe remove all the argument complexity and use cascades. 55 # TODO(sra): maybe remove all the argument complexity and use cascades.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 'TitleElement': 'title', 197 'TitleElement': 'title',
197 'TRefElement': 'tref', 198 'TRefElement': 'tref',
198 'TSpanElement': 'tspan', 199 'TSpanElement': 'tspan',
199 'UseElement': 'use', 200 'UseElement': 'use',
200 'ViewElement': 'view', 201 'ViewElement': 'view',
201 'VKernElement': 'vkern', 202 'VKernElement': 'vkern',
202 } 203 }
203 204
204 _element_constructors = { 205 _element_constructors = {
205 'html': _html_element_constructors, 206 'html': _html_element_constructors,
207 'indexed_db': {},
206 'svg': _svg_element_constructors, 208 'svg': _svg_element_constructors,
207 'web_audio': {}, 209 'web_audio': {},
208 } 210 }
209 211
210 _factory_ctr_strings = { 212 _factory_ctr_strings = {
211 'html': { 213 'html': {
212 'provider_name': 'document', 214 'provider_name': 'document',
213 'constructor_name': '$dom_createElement' 215 'constructor_name': '$dom_createElement'
214 }, 216 },
217 'indexed_db': {
218 'provider_name': 'document',
219 'constructor_name': '$dom_createElement'
220 },
215 'svg': { 221 'svg': {
216 'provider_name': '_SvgElementFactoryProvider', 222 'provider_name': '_SvgElementFactoryProvider',
217 'constructor_name': 'createSvgElement_tag', 223 'constructor_name': 'createSvgElement_tag',
218 }, 224 },
219 'web_audio': { 225 'web_audio': {
220 'provider_name': 'document', 226 'provider_name': 'document',
221 'constructor_name': '$dom_createElement' 227 'constructor_name': '$dom_createElement'
222 }, 228 },
223 } 229 }
224 230
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 self.GenerateInterface() 269 self.GenerateInterface()
264 270
265 def GenerateCallback(self): 271 def GenerateCallback(self):
266 """Generates a typedef for the callback interface.""" 272 """Generates a typedef for the callback interface."""
267 handlers = [operation for operation in self._interface.operations 273 handlers = [operation for operation in self._interface.operations
268 if operation.id == 'handleEvent'] 274 if operation.id == 'handleEvent']
269 info = AnalyzeOperation(self._interface, handlers) 275 info = AnalyzeOperation(self._interface, handlers)
270 code = self._library_emitter.FileEmitter(self._interface.id, 276 code = self._library_emitter.FileEmitter(self._interface.id,
271 self._library_name) 277 self._library_name)
272 code.Emit(self._template_loader.Load('callback.darttemplate')) 278 code.Emit(self._template_loader.Load('callback.darttemplate'))
279
280 typedef_name = self._renamer.RenameInterface(self._interface)
273 code.Emit('typedef void $NAME($PARAMS);\n', 281 code.Emit('typedef void $NAME($PARAMS);\n',
274 NAME=self._interface.id, 282 NAME=self._interface.id,
275 PARAMS=info.ParametersDeclaration(self._DartType)) 283 PARAMS=info.ParametersDeclaration(self._DartType))
276 self._backend.GenerateCallback(info) 284 self._backend.GenerateCallback(info)
277 285
278 def GenerateInterface(self): 286 def GenerateInterface(self):
279 interface_name = self._interface_type_info.interface_name() 287 interface_name = self._interface_type_info.interface_name()
280 288
281 factory_provider = None 289 factory_provider = None
282 if interface_name in interface_factories: 290 if interface_name in interface_factories:
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 for library_name in libraries: 990 for library_name in libraries:
983 self._libraries[library_name] = DartLibrary( 991 self._libraries[library_name] = DartLibrary(
984 library_name, template_loader, library_type, output_dir) 992 library_name, template_loader, library_type, output_dir)
985 993
986 def AddFile(self, basename, library_name, path): 994 def AddFile(self, basename, library_name, path):
987 self._libraries[library_name].AddFile(path) 995 self._libraries[library_name].AddFile(path)
988 996
989 def Emit(self, emitter, auxiliary_dir): 997 def Emit(self, emitter, auxiliary_dir):
990 for lib in self._libraries.values(): 998 for lib in self._libraries.values():
991 lib.Emit(emitter, auxiliary_dir) 999 lib.Emit(emitter, auxiliary_dir)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698