| 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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 582 (self._interface.id == 'XMLHttpRequestProgressEvent' or | 582 (self._interface.id == 'XMLHttpRequestProgressEvent' or |
| 583 self._interface.id == 'DOMStringMap')): | 583 self._interface.id == 'DOMStringMap')): |
| 584 # Suppress abstract for XMLHttpRequestProgressEvent and DOMStringMap | 584 # Suppress abstract for XMLHttpRequestProgressEvent and DOMStringMap |
| 585 # for Dartium. Need to be able to instantiate the class; can't be abstr
act. | 585 # for Dartium. Need to be able to instantiate the class; can't be abstr
act. |
| 586 class_modifiers = '' | 586 class_modifiers = '' |
| 587 else: | 587 else: |
| 588 # For Dartium w/ JsInterop these suppressed interfaces are needed to | 588 # For Dartium w/ JsInterop these suppressed interfaces are needed to |
| 589 # instanciate the internal classes when wrap_jso is called for a JS obje
ct. | 589 # instanciate the internal classes. |
| 590 if (self._renamer.ShouldSuppressInterface(self._interface) and | 590 if (self._renamer.ShouldSuppressInterface(self._interface) and |
| 591 not(isinstance(self._backend, Dart2JSBackend)) and | 591 not(isinstance(self._backend, Dart2JSBackend)) and |
| 592 self._options.dart_js_interop): | 592 self._options.dart_js_interop): |
| 593 class_modifiers = '' | 593 class_modifiers = '' |
| 594 else: | 594 else: |
| 595 class_modifiers = 'abstract ' | 595 class_modifiers = 'abstract ' |
| 596 | 596 |
| 597 native_spec = '' | 597 native_spec = '' |
| 598 if not IsPureInterface(self._interface.id): | 598 if not IsPureInterface(self._interface.id): |
| 599 native_spec = self._backend.NativeSpec() | 599 native_spec = self._backend.NativeSpec() |
| 600 | 600 |
| 601 class_name = self._interface_type_info.implementation_name() | 601 class_name = self._interface_type_info.implementation_name() |
| 602 | 602 |
| 603 js_interop_equivalence_op = \ | |
| 604 ' bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || ide
ntical(this, other);\n' \ | |
| 605 + ' int get hashCode => unwrap_jso(this).hashCode;\n' | |
| 606 # ClientRect overrides the equivalence operator. | |
| 607 if interface_name == 'ClientRect' or interface_name == 'DomRectReadOnly': | |
| 608 js_interop_equivalence_op = '' | |
| 609 | |
| 610 js_interop_wrapper = ''' | 603 js_interop_wrapper = ''' |
| 611 | 604 |
| 612 @Deprecated("Internal Use Only") | 605 @Deprecated("Internal Use Only") |
| 613 static {0} internalCreate{0}() {{ | 606 static {0} internalCreate{0}() {{ |
| 614 return new {0}._internalWrap(); | 607 return new {0}._internalWrap(); |
| 615 }} | 608 }} |
| 616 | 609 |
| 617 external factory {0}._internalWrap(); | 610 external factory {0}._internalWrap(); |
| 618 | 611 |
| 619 @Deprecated("Internal Use Only") | 612 @Deprecated("Internal Use Only") |
| 620 {0}.internal_() : super.internal_(); | 613 {0}.internal_() : super.internal_(); |
| 621 | 614 |
| 622 '''.format(class_name) | 615 '''.format(class_name) |
| 623 if base_class == 'NativeFieldWrapperClass2' or base_class == 'DartHtmlDomObj
ect': | 616 if base_class == 'NativeFieldWrapperClass2' or base_class == 'DartHtmlDomObj
ect': |
| 624 js_interop_wrapper = ''' | 617 js_interop_wrapper = ''' |
| 625 @Deprecated("Internal Use Only") | 618 @Deprecated("Internal Use Only") |
| 626 static {0} internalCreate{0}() {{ | 619 static {0} internalCreate{0}() {{ |
| 627 return new {0}._internalWrap(); | 620 return new {0}._internalWrap(); |
| 628 }} | 621 }} |
| 629 | 622 |
| 630 factory {0}._internalWrap() {{ | 623 factory {0}._internalWrap() {{ |
| 631 return new {0}.internal_(); | 624 return new {0}.internal_(); |
| 632 }} | 625 }} |
| 633 | 626 |
| 634 @Deprecated("Internal Use Only") | 627 @Deprecated("Internal Use Only") |
| 635 {0}.internal_() {{ }} | 628 {0}.internal_() {{ }} |
| 636 | 629 '''.format(class_name) |
| 637 {1}'''.format(class_name, js_interop_equivalence_op) | |
| 638 # Change to use the synthesized class so we can construct with a mixin | 630 # Change to use the synthesized class so we can construct with a mixin |
| 639 # classes prefixed with name of NativeFieldWrapperClass2 don't have a | 631 # classes prefixed with name of NativeFieldWrapperClass2 don't have a |
| 640 # default constructor so classes with mixins can't be new'd. | 632 # default constructor so classes with mixins can't be new'd. |
| 641 if (self._options.templates._conditions['DARTIUM'] and | 633 if (self._options.templates._conditions['DARTIUM'] and |
| 642 self._options.dart_js_interop and | 634 self._options.dart_js_interop and |
| 643 (self._interface.id == 'NamedNodeMap' or | 635 (self._interface.id == 'NamedNodeMap' or |
| 644 self._interface.id == 'CSSStyleDeclaration')): | 636 self._interface.id == 'CSSStyleDeclaration')): |
| 645 base_class = 'DartHtmlDomObject' | 637 base_class = 'DartHtmlDomObject' |
| 646 | 638 |
| 647 implementation_members_emitter = implementation_emitter.Emit( | 639 implementation_members_emitter = implementation_emitter.Emit( |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 | 1328 |
| 1337 def AddFile(self, basename, library_name, path): | 1329 def AddFile(self, basename, library_name, path): |
| 1338 self._libraries[library_name].AddFile(path) | 1330 self._libraries[library_name].AddFile(path) |
| 1339 | 1331 |
| 1340 def AddTypeEntry(self, library_name, idl_name, dart_name): | 1332 def AddTypeEntry(self, library_name, idl_name, dart_name): |
| 1341 self._libraries[library_name].AddTypeEntry(idl_name, dart_name) | 1333 self._libraries[library_name].AddTypeEntry(idl_name, dart_name) |
| 1342 | 1334 |
| 1343 def Emit(self, emitter, auxiliary_dir): | 1335 def Emit(self, emitter, auxiliary_dir): |
| 1344 for lib in self._libraries.values(): | 1336 for lib in self._libraries.values(): |
| 1345 lib.Emit(emitter, auxiliary_dir) | 1337 lib.Emit(emitter, auxiliary_dir) |
| OLD | NEW |