OLD | NEW |
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 monitored | 10 import monitored |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 'WheelEvent.deltaMode', | 63 'WheelEvent.deltaMode', |
64 'WheelEvent.wheelDeltaX', | 64 'WheelEvent.wheelDeltaX', |
65 'WheelEvent.wheelDeltaY', | 65 'WheelEvent.wheelDeltaY', |
66 'Window.cancelAnimationFrame', | 66 'Window.cancelAnimationFrame', |
67 'Window.console', | 67 'Window.console', |
68 'Window.document', | 68 'Window.document', |
69 'Window.indexedDB', | 69 'Window.indexedDB', |
70 'Window.location', | 70 'Window.location', |
71 'Window.open', | 71 'Window.open', |
72 'Window.requestAnimationFrame', | 72 'Window.requestAnimationFrame', |
73 'WorkerContext.indexedDB', | 73 # 'WorkerContext.indexedDB', # Workers |
74 ]) | 74 ]) |
75 | 75 |
76 _js_custom_constructors = monitored.Set('systemhtml._js_custom_constructors', [ | 76 _js_custom_constructors = monitored.Set('systemhtml._js_custom_constructors', [ |
77 'AudioContext', | 77 'AudioContext', |
78 'Blob', | 78 'Blob', |
79 'MutationObserver', | 79 'MutationObserver', |
80 'RTCIceCandidate', | 80 'RTCIceCandidate', |
81 'RTCPeerConnection', | 81 'RTCPeerConnection', |
82 'RTCSessionDescription', | 82 'RTCSessionDescription', |
83 'SpeechRecognition', | 83 'SpeechRecognition', |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 'SVGLangSpace': ('supported(SvgElement element)', | 388 'SVGLangSpace': ('supported(SvgElement element)', |
389 "JS('bool', '#.xmlspace !== undefined && #.xmllang !== undefined', " | 389 "JS('bool', '#.xmlspace !== undefined && #.xmllang !== undefined', " |
390 "element, element)"), | 390 "element, element)"), |
391 'TouchList': "JS('bool', '!!document.createTouchList')", | 391 'TouchList': "JS('bool', '!!document.createTouchList')", |
392 'XMLHttpRequestProgressEvent': | 392 'XMLHttpRequestProgressEvent': |
393 "Device.isEventTypeSupported('XMLHttpRequestProgressEvent')", | 393 "Device.isEventTypeSupported('XMLHttpRequestProgressEvent')", |
394 'WebGLRenderingContext': "JS('bool', '!!(window.WebGLRenderingContext)')", | 394 'WebGLRenderingContext': "JS('bool', '!!(window.WebGLRenderingContext)')", |
395 'WebKitCSSMatrix': "JS('bool', '!!(window.WebKitCSSMatrix)')", | 395 'WebKitCSSMatrix': "JS('bool', '!!(window.WebKitCSSMatrix)')", |
396 'WebKitPoint': "JS('bool', '!!(window.WebKitPoint)')", | 396 'WebKitPoint': "JS('bool', '!!(window.WebKitPoint)')", |
397 'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')", | 397 'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')", |
| 398 'Worker': "JS('bool', '(typeof window.Worker != \"undefined\")')", |
398 'XSLTProcessor': "JS('bool', '!!(window.XSLTProcessor)')", | 399 'XSLTProcessor': "JS('bool', '!!(window.XSLTProcessor)')", |
399 }.items() + | 400 }.items() + |
400 dict((key, | 401 dict((key, |
401 SvgSupportStr(_svg_element_constructors[key]) if key.startswith('SVG') | 402 SvgSupportStr(_svg_element_constructors[key]) if key.startswith('SVG') |
402 else ElemSupportStr(_html_element_constructors[key])) for key in | 403 else ElemSupportStr(_html_element_constructors[key])) for key in |
403 _js_support_checks_basic_element_with_constructors + | 404 _js_support_checks_basic_element_with_constructors + |
404 _js_support_checks_additional_element).items()) | 405 _js_support_checks_additional_element).items()) |
405 # ------------------------------------------------------------------------------ | 406 # ------------------------------------------------------------------------------ |
406 | 407 |
407 class HtmlDartInterfaceGenerator(object): | 408 class HtmlDartInterfaceGenerator(object): |
(...skipping 14 matching lines...) Expand all Loading... |
422 self._library_name = self._renamer.GetLibraryName(self._interface) | 423 self._library_name = self._renamer.GetLibraryName(self._interface) |
423 | 424 |
424 def Generate(self): | 425 def Generate(self): |
425 if 'Callback' in self._interface.ext_attrs: | 426 if 'Callback' in self._interface.ext_attrs: |
426 self.GenerateCallback() | 427 self.GenerateCallback() |
427 else: | 428 else: |
428 self.GenerateInterface() | 429 self.GenerateInterface() |
429 | 430 |
430 def GenerateCallback(self): | 431 def GenerateCallback(self): |
431 """Generates a typedef for the callback interface.""" | 432 """Generates a typedef for the callback interface.""" |
| 433 typedef_name = self._renamer.RenameInterface(self._interface) |
| 434 if not typedef_name: |
| 435 return |
| 436 |
432 info = GetCallbackInfo(self._interface) | 437 info = GetCallbackInfo(self._interface) |
433 code = self._library_emitter.FileEmitter(self._interface.id, | 438 code = self._library_emitter.FileEmitter(self._interface.id, |
434 self._library_name) | 439 self._library_name) |
435 code.Emit(self._template_loader.Load('callback.darttemplate')) | 440 code.Emit(self._template_loader.Load('callback.darttemplate')) |
436 | 441 |
437 typedef_name = self._renamer.RenameInterface(self._interface) | |
438 code.Emit('typedef void $NAME($PARAMS);\n', | 442 code.Emit('typedef void $NAME($PARAMS);\n', |
439 LIBRARYNAME='dart.dom.%s' % self._library_name, | 443 LIBRARYNAME='dart.dom.%s' % self._library_name, |
440 NAME=typedef_name, | 444 NAME=typedef_name, |
441 PARAMS=info.ParametersDeclaration(self._DartType)) | 445 PARAMS=info.ParametersDeclaration(self._DartType)) |
442 self._backend.GenerateCallback(info) | 446 self._backend.GenerateCallback(info) |
443 | 447 |
444 def GenerateInterface(self): | 448 def GenerateInterface(self): |
445 interface_name = self._interface_type_info.interface_name() | 449 interface_name = self._interface_type_info.interface_name() |
446 | 450 |
447 factory_provider = None | 451 factory_provider = None |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 for library_name in libraries: | 1147 for library_name in libraries: |
1144 self._libraries[library_name] = DartLibrary( | 1148 self._libraries[library_name] = DartLibrary( |
1145 library_name, template_loader, library_type, output_dir) | 1149 library_name, template_loader, library_type, output_dir) |
1146 | 1150 |
1147 def AddFile(self, basename, library_name, path): | 1151 def AddFile(self, basename, library_name, path): |
1148 self._libraries[library_name].AddFile(path) | 1152 self._libraries[library_name].AddFile(path) |
1149 | 1153 |
1150 def Emit(self, emitter, auxiliary_dir): | 1154 def Emit(self, emitter, auxiliary_dir): |
1151 for lib in self._libraries.values(): | 1155 for lib in self._libraries.values(): |
1152 lib.Emit(emitter, auxiliary_dir) | 1156 lib.Emit(emitter, auxiliary_dir) |
OLD | NEW |