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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 def FinishInterface(self): | 490 def FinishInterface(self): |
491 pass | 491 pass |
492 | 492 |
493 def HasSupportCheck(self): | 493 def HasSupportCheck(self): |
494 return self._interface.doc_js_name in js_support_checks | 494 return self._interface.doc_js_name in js_support_checks |
495 | 495 |
496 def GetSupportCheck(self): | 496 def GetSupportCheck(self): |
497 return js_support_checks.get(self._interface.doc_js_name) | 497 return js_support_checks.get(self._interface.doc_js_name) |
498 | 498 |
499 def EmitStaticFactory(self, constructor_info): | 499 def EmitStaticFactory(self, constructor_info): |
| 500 WITH_CUSTOM_STATIC_FACTORY = [ |
| 501 'AudioContext', |
| 502 'Blob', |
| 503 'MutationObserver', |
| 504 ] |
| 505 |
| 506 if self._interface.doc_js_name in WITH_CUSTOM_STATIC_FACTORY: |
| 507 return |
| 508 |
500 has_optional = any(param_info.is_optional | 509 has_optional = any(param_info.is_optional |
501 for param_info in constructor_info.param_infos) | 510 for param_info in constructor_info.param_infos) |
502 | 511 |
503 def FormatJS(index): | 512 def FormatJS(index): |
504 arguments = constructor_info.ParametersAsArgumentList(index) | 513 arguments = constructor_info.ParametersAsArgumentList(index) |
505 if arguments: | 514 if arguments: |
506 arguments = ', ' + arguments | 515 arguments = ', ' + arguments |
507 return "JS('%s', 'new %s(%s)'%s)" % ( | 516 return "JS('%s', 'new %s(%s)'%s)" % ( |
508 self._interface_type_info.interface_name(), | 517 self._interface_type_info.interface_name(), |
509 constructor_info.name or self._interface.doc_js_name, | 518 constructor_info.name or self._interface.doc_js_name, |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 for library_name in libraries: | 1055 for library_name in libraries: |
1047 self._libraries[library_name] = DartLibrary( | 1056 self._libraries[library_name] = DartLibrary( |
1048 library_name, template_loader, library_type, output_dir) | 1057 library_name, template_loader, library_type, output_dir) |
1049 | 1058 |
1050 def AddFile(self, basename, library_name, path): | 1059 def AddFile(self, basename, library_name, path): |
1051 self._libraries[library_name].AddFile(path) | 1060 self._libraries[library_name].AddFile(path) |
1052 | 1061 |
1053 def Emit(self, emitter, auxiliary_dir): | 1062 def Emit(self, emitter, auxiliary_dir): |
1054 for lib in self._libraries.values(): | 1063 for lib in self._libraries.values(): |
1055 lib.Emit(emitter, auxiliary_dir) | 1064 lib.Emit(emitter, auxiliary_dir) |
OLD | NEW |