| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 'Window.document', | 63 'Window.document', |
| 64 'Window.indexedDB', | 64 'Window.indexedDB', |
| 65 'Window.location', | 65 'Window.location', |
| 66 'Window.open', | 66 'Window.open', |
| 67 'Window.requestAnimationFrame', | 67 'Window.requestAnimationFrame', |
| 68 'Window.webkitCancelAnimationFrame', | 68 'Window.webkitCancelAnimationFrame', |
| 69 'Window.webkitRequestAnimationFrame', | 69 'Window.webkitRequestAnimationFrame', |
| 70 'WorkerContext.indexedDB', | 70 'WorkerContext.indexedDB', |
| 71 ]) | 71 ]) |
| 72 | 72 |
| 73 _js_custom_constructors = set([ |
| 74 'AudioContext', |
| 75 'Blob', |
| 76 'MutationObserver', |
| 77 'Notification', |
| 78 'RTCIceCandidate', |
| 79 'RTCPeerConnection', |
| 80 'RTCSessionDescription', |
| 81 'SpeechRecognition', |
| 82 ]) |
| 83 |
| 73 # Classes that offer only static methods, and therefore we should suppress | 84 # Classes that offer only static methods, and therefore we should suppress |
| 74 # constructor creation. | 85 # constructor creation. |
| 75 _static_classes = set(['Url']) | 86 _static_classes = set(['Url']) |
| 76 | 87 |
| 77 # Information for generating element constructors. | 88 # Information for generating element constructors. |
| 78 # | 89 # |
| 79 # TODO(sra): maybe remove all the argument complexity and use cascades. | 90 # TODO(sra): maybe remove all the argument complexity and use cascades. |
| 80 # | 91 # |
| 81 # var c = new CanvasElement(width: 100, height: 70); | 92 # var c = new CanvasElement(width: 100, height: 70); |
| 82 # var c = new CanvasElement()..width = 100..height = 70; | 93 # var c = new CanvasElement()..width = 100..height = 70; |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 lib_prefix = '' | 615 lib_prefix = '' |
| 605 constructors = _html_element_constructors | 616 constructors = _html_element_constructors |
| 606 return (js_support_checks.get(self._interface.doc_js_name) + | 617 return (js_support_checks.get(self._interface.doc_js_name) + |
| 607 " && (new %sElement.tag('%s') is %s)" % (lib_prefix, | 618 " && (new %sElement.tag('%s') is %s)" % (lib_prefix, |
| 608 constructors[self._interface.doc_js_name], | 619 constructors[self._interface.doc_js_name], |
| 609 self._renamer.RenameInterface(self._interface))) | 620 self._renamer.RenameInterface(self._interface))) |
| 610 return js_support_checks.get(self._interface.doc_js_name) | 621 return js_support_checks.get(self._interface.doc_js_name) |
| 611 | 622 |
| 612 def GenerateCustomFactory(self, constructor_info): | 623 def GenerateCustomFactory(self, constructor_info): |
| 613 # Custom factory will be taken from the template. | 624 # Custom factory will be taken from the template. |
| 614 return self._interface.doc_js_name in [ | 625 return self._interface.doc_js_name in _js_custom_constructors |
| 615 'AudioContext', | |
| 616 'Blob', | |
| 617 'MutationObserver', | |
| 618 'SpeechRecognition', | |
| 619 ] | |
| 620 | 626 |
| 621 def IsConstructorArgumentOptional(self, argument): | 627 def IsConstructorArgumentOptional(self, argument): |
| 622 return 'Optional' in argument.ext_attrs | 628 return 'Optional' in argument.ext_attrs |
| 623 | 629 |
| 624 def EmitStaticFactoryOverload(self, constructor_info, name, arguments): | 630 def EmitStaticFactoryOverload(self, constructor_info, name, arguments): |
| 625 index = len(arguments) | 631 index = len(arguments) |
| 626 arguments = constructor_info.ParametersAsArgumentList(index) | 632 arguments = constructor_info.ParametersAsArgumentList(index) |
| 627 if arguments: | 633 if arguments: |
| 628 arguments = ', ' + arguments | 634 arguments = ', ' + arguments |
| 629 self._members_emitter.Emit( | 635 self._members_emitter.Emit( |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 for library_name in libraries: | 1113 for library_name in libraries: |
| 1108 self._libraries[library_name] = DartLibrary( | 1114 self._libraries[library_name] = DartLibrary( |
| 1109 library_name, template_loader, library_type, output_dir) | 1115 library_name, template_loader, library_type, output_dir) |
| 1110 | 1116 |
| 1111 def AddFile(self, basename, library_name, path): | 1117 def AddFile(self, basename, library_name, path): |
| 1112 self._libraries[library_name].AddFile(path) | 1118 self._libraries[library_name].AddFile(path) |
| 1113 | 1119 |
| 1114 def Emit(self, emitter, auxiliary_dir): | 1120 def Emit(self, emitter, auxiliary_dir): |
| 1115 for lib in self._libraries.values(): | 1121 for lib in self._libraries.values(): |
| 1116 lib.Emit(emitter, auxiliary_dir) | 1122 lib.Emit(emitter, auxiliary_dir) |
| OLD | NEW |