| 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 systems to generate | 6 """This module provides shared functionality for the systems to generate |
| 7 native binding from the IDL database.""" | 7 native binding from the IDL database.""" |
| 8 | 8 |
| 9 import emitter | 9 import emitter |
| 10 import os | 10 import os |
| 11 from generator import * | 11 from generator import * |
| 12 from htmldartgenerator import * | 12 from htmldartgenerator import * |
| 13 from idlnode import IDLArgument, IDLAttribute | 13 from idlnode import IDLArgument, IDLAttribute |
| 14 from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES | 14 from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES |
| 15 | 15 |
| 16 # This is an ugly hack to get things working on the M35 roll. Once we |
| 17 # generate dart:blink from the new scripts, this shouldn't be needed. |
| 18 _cpp_resolver_string_map = { |
| 19 'XMLHttpRequest_constructorCallback_RESOLVER_STRING_0_': |
| 20 'XMLHttpRequest_constructorCallback_RESOLVER_STRING_1_XMLHttpRequestOption
s', |
| 21 } |
| 22 |
| 16 # TODO(vsm): This logic needs to pulled from the source IDL. These tables are | 23 # TODO(vsm): This logic needs to pulled from the source IDL. These tables are |
| 17 # an ugly workaround. | 24 # an ugly workaround. |
| 18 _cpp_callback_map = { | 25 _cpp_callback_map = { |
| 19 ('DataTransferItem', 'webkitGetAsEntry'): 'DataTransferItemFileSystem', | 26 ('DataTransferItem', 'webkitGetAsEntry'): 'DataTransferItemFileSystem', |
| 20 ('Document', 'fonts'): 'DocumentFontFaceSet', | 27 ('Document', 'fonts'): 'DocumentFontFaceSet', |
| 21 ('Document', 'webkitIsFullScreen'): 'DocumentFullscreen', | 28 ('Document', 'webkitIsFullScreen'): 'DocumentFullscreen', |
| 22 ('Document', 'webkitFullScreenKeyboardInputAllowed'): 'DocumentFullscreen', | 29 ('Document', 'webkitFullScreenKeyboardInputAllowed'): 'DocumentFullscreen', |
| 23 ('Document', 'webkitCurrentFullScreenElement'): 'DocumentFullscreen', | 30 ('Document', 'webkitCurrentFullScreenElement'): 'DocumentFullscreen', |
| 24 ('Document', 'webkitCancelFullScreen'): 'DocumentFullscreen', | 31 ('Document', 'webkitCancelFullScreen'): 'DocumentFullscreen', |
| 25 ('Document', 'webkitFullscreenEnabled'): 'DocumentFullscreen', | 32 ('Document', 'webkitFullscreenEnabled'): 'DocumentFullscreen', |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 type_ids = [p.type.id for p in arguments[:argument_count]] | 587 type_ids = [p.type.id for p in arguments[:argument_count]] |
| 581 constructor_callback_id = \ | 588 constructor_callback_id = \ |
| 582 DeriveResolverString(self._interface.id, cpp_suffix, None, type_ids) | 589 DeriveResolverString(self._interface.id, cpp_suffix, None, type_ids) |
| 583 else: | 590 else: |
| 584 constructor_callback_id = self._interface.id + '_' + constructor_callbac
k_cpp_name | 591 constructor_callback_id = self._interface.id + '_' + constructor_callbac
k_cpp_name |
| 585 | 592 |
| 586 if self._dart_use_blink: | 593 if self._dart_use_blink: |
| 587 # First we emit the toplevel function | 594 # First we emit the toplevel function |
| 588 dart_native_name = \ | 595 dart_native_name = \ |
| 589 DeriveNativeName(self._interface.id, constructor_callback_cpp_name,
"") | 596 DeriveNativeName(self._interface.id, constructor_callback_cpp_name,
"") |
| 597 if constructor_callback_id in _cpp_resolver_string_map: |
| 598 constructor_callback_id = \ |
| 599 _cpp_resolver_string_map[constructor_callback_id] |
| 590 self._native_library_emitter.Emit( | 600 self._native_library_emitter.Emit( |
| 591 '\n' | 601 '\n' |
| 592 '$FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n', | 602 '$FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n', |
| 593 FACTORY_METHOD_NAME=dart_native_name, | 603 FACTORY_METHOD_NAME=dart_native_name, |
| 594 PARAMETERS=parameters, | 604 PARAMETERS=parameters, |
| 595 ID=constructor_callback_id) | 605 ID=constructor_callback_id) |
| 596 | 606 |
| 597 # Then we emit the impedance matching wrapper to call out to the | 607 # Then we emit the impedance matching wrapper to call out to the |
| 598 # toplevel wrapper | 608 # toplevel wrapper |
| 599 if not emit_to_native: | 609 if not emit_to_native: |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 self._EmitExplicitIndexedGetter(dart_element_type) | 1011 self._EmitExplicitIndexedGetter(dart_element_type) |
| 1002 else: | 1012 else: |
| 1003 if self._dart_use_blink: | 1013 if self._dart_use_blink: |
| 1004 dart_native_name = \ | 1014 dart_native_name = \ |
| 1005 DeriveNativeName(self._interface.id, "NativeIndexed", "Getter") | 1015 DeriveNativeName(self._interface.id, "NativeIndexed", "Getter") |
| 1006 # First emit a toplevel function to do the native call | 1016 # First emit a toplevel function to do the native call |
| 1007 # Calls to this are emitted elsewhere, | 1017 # Calls to this are emitted elsewhere, |
| 1008 resolver_string = \ | 1018 resolver_string = \ |
| 1009 DeriveResolverString(self._interface.id, "item", "Callback", | 1019 DeriveResolverString(self._interface.id, "item", "Callback", |
| 1010 ["unsigned long"]) | 1020 ["unsigned long"]) |
| 1021 if resolver_string in _cpp_resolver_string_map: |
| 1022 resolver_string = \ |
| 1023 _cpp_resolver_string_map[resolver_string] |
| 1011 self._native_library_emitter.Emit( | 1024 self._native_library_emitter.Emit( |
| 1012 '\n' | 1025 '\n' |
| 1013 '$(DART_NATIVE_NAME)(mthis, index) ' | 1026 '$(DART_NATIVE_NAME)(mthis, index) ' |
| 1014 'native "$(RESOLVER_STRING)";\n', | 1027 'native "$(RESOLVER_STRING)";\n', |
| 1015 DART_NATIVE_NAME = dart_native_name, | 1028 DART_NATIVE_NAME = dart_native_name, |
| 1016 RESOLVER_STRING=resolver_string) | 1029 RESOLVER_STRING=resolver_string) |
| 1017 | 1030 |
| 1018 # Emit the method which calls the toplevel function, along with | 1031 # Emit the method which calls the toplevel function, along with |
| 1019 # the [] operator. | 1032 # the [] operator. |
| 1020 self._members_emitter.Emit( | 1033 self._members_emitter.Emit( |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 native_binding = \ | 1655 native_binding = \ |
| 1643 '%s_%s_%s' % (self._interface.id, idl_name, native_suffix) | 1656 '%s_%s_%s' % (self._interface.id, idl_name, native_suffix) |
| 1644 | 1657 |
| 1645 if self._dart_use_blink: | 1658 if self._dart_use_blink: |
| 1646 if not static: | 1659 if not static: |
| 1647 formals = ", ".join(['mthis'] + parameters) | 1660 formals = ", ".join(['mthis'] + parameters) |
| 1648 actuals = ", ".join(['this'] + parameters) | 1661 actuals = ", ".join(['this'] + parameters) |
| 1649 else: | 1662 else: |
| 1650 formals = ", ".join(parameters) | 1663 formals = ", ".join(parameters) |
| 1651 actuals = ", ".join(parameters) | 1664 actuals = ", ".join(parameters) |
| 1652 | 1665 if native_binding in _cpp_resolver_string_map: |
| 1666 native_binding = \ |
| 1667 _cpp_resolver_string_map[native_binding] |
| 1653 self._native_library_emitter.Emit( | 1668 self._native_library_emitter.Emit( |
| 1654 '\n' | 1669 '\n' |
| 1655 '$DART_NAME($FORMALS) native "$NATIVE_BINDING";\n', | 1670 '$DART_NAME($FORMALS) native "$NATIVE_BINDING";\n', |
| 1656 DART_NAME=dart_native_name, | 1671 DART_NAME=dart_native_name, |
| 1657 FORMALS=formals, | 1672 FORMALS=formals, |
| 1658 NATIVE_BINDING=native_binding) | 1673 NATIVE_BINDING=native_binding) |
| 1659 | 1674 |
| 1660 if not emit_to_native: | 1675 if not emit_to_native: |
| 1661 caller_emitter = self._members_emitter | 1676 caller_emitter = self._members_emitter |
| 1662 full_dart_name = DeriveQualifiedName(self._native_library_name, | 1677 full_dart_name = DeriveQualifiedName(self._native_library_name, |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 e.Emit("};\n"); | 1951 e.Emit("};\n"); |
| 1937 e.Emit('\n'); | 1952 e.Emit('\n'); |
| 1938 e.Emit('} // namespace WebCore\n'); | 1953 e.Emit('} // namespace WebCore\n'); |
| 1939 | 1954 |
| 1940 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1955 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1941 return ( | 1956 return ( |
| 1942 interface.id.endswith('Event') and | 1957 interface.id.endswith('Event') and |
| 1943 operation.id.startswith('init') and | 1958 operation.id.startswith('init') and |
| 1944 argument.ext_attrs.get('Default') == 'Undefined' and | 1959 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1945 argument.type.id == 'DOMString') | 1960 argument.type.id == 'DOMString') |
| OLD | NEW |