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 os | 10 import os |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 'HTMLKeygenElement': "Element.isTagSupported('keygen') " | 82 'HTMLKeygenElement': "Element.isTagSupported('keygen') " |
83 "&& (new Element.tag('keygen') is KeygenElement)", | 83 "&& (new Element.tag('keygen') is KeygenElement)", |
84 'HTMLMeterElement': "Element.isTagSupported('meter')", | 84 'HTMLMeterElement': "Element.isTagSupported('meter')", |
85 'HTMLObjectElement': "Element.isTagSupported('object')", | 85 'HTMLObjectElement': "Element.isTagSupported('object')", |
86 'HTMLOutputElement': "Element.isTagSupported('output')", | 86 'HTMLOutputElement': "Element.isTagSupported('output')", |
87 'HTMLProgressElement': "Element.isTagSupported('progress')", | 87 'HTMLProgressElement': "Element.isTagSupported('progress')", |
88 'HTMLShadowElement': "Element.isTagSupported('shadow')", | 88 'HTMLShadowElement': "Element.isTagSupported('shadow')", |
89 'HTMLTrackElement': "Element.isTagSupported('track')", | 89 'HTMLTrackElement': "Element.isTagSupported('track')", |
90 'NotificationCenter': "JS('bool', '!!(window.webkitNotifications)')", | 90 'NotificationCenter': "JS('bool', '!!(window.webkitNotifications)')", |
91 'Performance': "JS('bool', '!!(window.performance)')", | 91 'Performance': "JS('bool', '!!(window.performance)')", |
92 'SpeechRecognition': "JS('bool', '!!(window.SpeechRecognition || " | |
93 "window.webkitSpeechRecognition)')", | |
94 'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')", | 92 'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')", |
95 } | 93 } |
96 | 94 |
97 # Classes that offer only static methods, and therefore we should suppress | 95 # Classes that offer only static methods, and therefore we should suppress |
98 # constructor creation. | 96 # constructor creation. |
99 _static_classes = set(['Url']) | 97 _static_classes = set(['Url']) |
100 | 98 |
101 # Information for generating element constructors. | 99 # Information for generating element constructors. |
102 # | 100 # |
103 # TODO(sra): maybe remove all the argument complexity and use cascades. | 101 # TODO(sra): maybe remove all the argument complexity and use cascades. |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 return self._interface.doc_js_name in js_support_checks | 505 return self._interface.doc_js_name in js_support_checks |
508 | 506 |
509 def GetSupportCheck(self): | 507 def GetSupportCheck(self): |
510 return js_support_checks.get(self._interface.doc_js_name) | 508 return js_support_checks.get(self._interface.doc_js_name) |
511 | 509 |
512 def EmitStaticFactory(self, constructor_info): | 510 def EmitStaticFactory(self, constructor_info): |
513 WITH_CUSTOM_STATIC_FACTORY = [ | 511 WITH_CUSTOM_STATIC_FACTORY = [ |
514 'AudioContext', | 512 'AudioContext', |
515 'Blob', | 513 'Blob', |
516 'MutationObserver', | 514 'MutationObserver', |
517 'SpeechRecognition', | |
518 ] | 515 ] |
519 | 516 |
520 if self._interface.doc_js_name in WITH_CUSTOM_STATIC_FACTORY: | 517 if self._interface.doc_js_name in WITH_CUSTOM_STATIC_FACTORY: |
521 return | 518 return |
522 | 519 |
523 has_optional = any(param_info.is_optional | 520 has_optional = any(param_info.is_optional |
524 for param_info in constructor_info.param_infos) | 521 for param_info in constructor_info.param_infos) |
525 | 522 |
526 def FormatJS(index): | 523 def FormatJS(index): |
527 arguments = constructor_info.ParametersAsArgumentList(index) | 524 arguments = constructor_info.ParametersAsArgumentList(index) |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 for library_name in libraries: | 1044 for library_name in libraries: |
1048 self._libraries[library_name] = DartLibrary( | 1045 self._libraries[library_name] = DartLibrary( |
1049 library_name, template_loader, library_type, output_dir) | 1046 library_name, template_loader, library_type, output_dir) |
1050 | 1047 |
1051 def AddFile(self, basename, library_name, path): | 1048 def AddFile(self, basename, library_name, path): |
1052 self._libraries[library_name].AddFile(path) | 1049 self._libraries[library_name].AddFile(path) |
1053 | 1050 |
1054 def Emit(self, emitter, auxiliary_dir): | 1051 def Emit(self, emitter, auxiliary_dir): |
1055 for lib in self._libraries.values(): | 1052 for lib in self._libraries.values(): |
1056 lib.Emit(emitter, auxiliary_dir) | 1053 lib.Emit(emitter, auxiliary_dir) |
OLD | NEW |