| 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 logging | 10 import logging |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 mixins = self._backend.Mixins() | 561 mixins = self._backend.Mixins() |
| 562 | 562 |
| 563 mixins_str = '' | 563 mixins_str = '' |
| 564 if mixins: | 564 if mixins: |
| 565 mixins_str = ' with ' + ', '.join(mixins) | 565 mixins_str = ' with ' + ', '.join(mixins) |
| 566 if not base_class: | 566 if not base_class: |
| 567 base_class = 'Interceptor' | 567 base_class = 'Interceptor' |
| 568 elif (base_class == 'NativeFieldWrapperClass2' and | 568 elif (base_class == 'NativeFieldWrapperClass2' and |
| 569 self._options.dart_js_interop and | 569 self._options.dart_js_interop and |
| 570 not(isinstance(self._backend, Dart2JSBackend))): | 570 not(isinstance(self._backend, Dart2JSBackend))): |
| 571 base_class = 'JsoNativeFieldWrapper' | 571 base_class = 'DartHtmlDomObject' |
| 572 | 572 |
| 573 annotations = self._metadata.GetFormattedMetadata( | 573 annotations = self._metadata.GetFormattedMetadata( |
| 574 self._library_name, self._interface, None, '') | 574 self._library_name, self._interface, None, '') |
| 575 | 575 |
| 576 class_modifiers = '' | 576 class_modifiers = '' |
| 577 if (self._renamer.ShouldSuppressInterface(self._interface) or | 577 if (self._renamer.ShouldSuppressInterface(self._interface) or |
| 578 IsPureInterface(self._interface.id)): | 578 IsPureInterface(self._interface.id)): |
| 579 # XMLHttpRequestProgressEvent can't be abstract we need to instantiate | 579 # XMLHttpRequestProgressEvent can't be abstract we need to instantiate |
| 580 # for JsInterop. | 580 # for JsInterop. |
| 581 if (not(isinstance(self._backend, Dart2JSBackend)) and | 581 if (not(isinstance(self._backend, Dart2JSBackend)) and |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 return new {0}._internalWrap(); | 613 return new {0}._internalWrap(); |
| 614 }} | 614 }} |
| 615 | 615 |
| 616 factory {0}._internalWrap() {{ | 616 factory {0}._internalWrap() {{ |
| 617 return new {0}.internal_(); | 617 return new {0}.internal_(); |
| 618 }} | 618 }} |
| 619 | 619 |
| 620 {0}.internal_() : super.internal_(); | 620 {0}.internal_() : super.internal_(); |
| 621 | 621 |
| 622 '''.format(class_name) | 622 '''.format(class_name) |
| 623 if base_class == 'NativeFieldWrapperClass2' or base_class == 'JsoNativeField
Wrapper': | 623 if base_class == 'NativeFieldWrapperClass2' or base_class == 'DartHtmlDomObj
ect': |
| 624 js_interop_wrapper = ''' | 624 js_interop_wrapper = ''' |
| 625 static {0} internalCreate{0}() {{ | 625 static {0} internalCreate{0}() {{ |
| 626 return new {0}._internalWrap(); | 626 return new {0}._internalWrap(); |
| 627 }} | 627 }} |
| 628 | 628 |
| 629 js.JsObject blink_jsObject; | |
| 630 | |
| 631 factory {0}._internalWrap() {{ | 629 factory {0}._internalWrap() {{ |
| 632 return new {0}.internal_(); | 630 return new {0}.internal_(); |
| 633 }} | 631 }} |
| 634 | 632 |
| 635 {0}.internal_() {{ }} | 633 {0}.internal_() {{ }} |
| 636 | 634 |
| 637 {1}'''.format(class_name, js_interop_equivalence_op) | 635 {1}'''.format(class_name, js_interop_equivalence_op) |
| 638 # Change to use the synthesized class so we can construct with a mixin | 636 # Change to use the synthesized class so we can construct with a mixin |
| 639 # classes prefixed with name of NativeFieldWrapperClass2 don't have a | 637 # classes prefixed with name of NativeFieldWrapperClass2 don't have a |
| 640 # default constructor so classes with mixins can't be new'd. | 638 # default constructor so classes with mixins can't be new'd. |
| 641 if (self._options.templates._conditions['DARTIUM'] and | 639 if (self._options.templates._conditions['DARTIUM'] and |
| 642 self._options.dart_js_interop and | 640 self._options.dart_js_interop and |
| 643 (self._interface.id == 'NamedNodeMap' or | 641 (self._interface.id == 'NamedNodeMap' or |
| 644 self._interface.id == 'CSSStyleDeclaration')): | 642 self._interface.id == 'CSSStyleDeclaration')): |
| 645 base_class = 'JsoNativeFieldWrapper' | 643 base_class = 'DartHtmlDomObject' |
| 646 | 644 |
| 647 implementation_members_emitter = implementation_emitter.Emit( | 645 implementation_members_emitter = implementation_emitter.Emit( |
| 648 self._backend.ImplementationTemplate(), | 646 self._backend.ImplementationTemplate(), |
| 649 LIBRARYNAME='dart.dom.%s' % self._library_name, | 647 LIBRARYNAME='dart.dom.%s' % self._library_name, |
| 650 ANNOTATIONS=annotations, | 648 ANNOTATIONS=annotations, |
| 651 CLASS_MODIFIERS=class_modifiers, | 649 CLASS_MODIFIERS=class_modifiers, |
| 652 CLASSNAME=class_name, | 650 CLASSNAME=class_name, |
| 653 EXTENDS=' extends %s' % base_class if base_class else '', | 651 EXTENDS=' extends %s' % base_class if base_class else '', |
| 654 IMPLEMENTS=implements_str, | 652 IMPLEMENTS=implements_str, |
| 655 MIXINS=mixins_str, | 653 MIXINS=mixins_str, |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 | 1334 |
| 1337 def AddFile(self, basename, library_name, path): | 1335 def AddFile(self, basename, library_name, path): |
| 1338 self._libraries[library_name].AddFile(path) | 1336 self._libraries[library_name].AddFile(path) |
| 1339 | 1337 |
| 1340 def AddTypeEntry(self, library_name, idl_name, dart_name): | 1338 def AddTypeEntry(self, library_name, idl_name, dart_name): |
| 1341 self._libraries[library_name].AddTypeEntry(idl_name, dart_name) | 1339 self._libraries[library_name].AddTypeEntry(idl_name, dart_name) |
| 1342 | 1340 |
| 1343 def Emit(self, emitter, auxiliary_dir): | 1341 def Emit(self, emitter, auxiliary_dir): |
| 1344 for lib in self._libraries.values(): | 1342 for lib in self._libraries.values(): |
| 1345 lib.Emit(emitter, auxiliary_dir) | 1343 lib.Emit(emitter, auxiliary_dir) |
| OLD | NEW |