| 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 |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 if requires_script_execution_context: | 857 if requires_script_execution_context: |
| 858 body_emitter.Emit( | 858 body_emitter.Emit( |
| 859 ' ScriptExecutionContext* context = DartUtilities::scriptExecut
ionContext();\n' | 859 ' ScriptExecutionContext* context = DartUtilities::scriptExecut
ionContext();\n' |
| 860 ' if (!context) {\n' | 860 ' if (!context) {\n' |
| 861 ' exception = Dart_NewStringFromCString("Failed to retrieve
a context");\n' | 861 ' exception = Dart_NewStringFromCString("Failed to retrieve
a context");\n' |
| 862 ' goto fail;\n' | 862 ' goto fail;\n' |
| 863 ' }\n\n') | 863 ' }\n\n') |
| 864 | 864 |
| 865 if requires_script_state: | 865 if requires_script_state: |
| 866 body_emitter.Emit( | 866 body_emitter.Emit( |
| 867 ' ScriptState* currentState = ScriptState::current();\n' | 867 ' ScriptState* currentState = DartUtilities::currentScriptState
();\n' |
| 868 ' if (!currentState) {\n' | 868 ' if (!currentState) {\n' |
| 869 ' exception = Dart_NewStringFromCString("Failed to retrieve
a script state");\n' | 869 ' exception = Dart_NewStringFromCString("Failed to retrieve
a script state");\n' |
| 870 ' goto fail;\n' | 870 ' goto fail;\n' |
| 871 ' }\n' | 871 ' }\n' |
| 872 ' ScriptState& state = *currentState;\n\n') | 872 ' ScriptState& state = *currentState;\n\n') |
| 873 | 873 |
| 874 if requires_dom_window or requires_document: | 874 if requires_dom_window or requires_document: |
| 875 self._cpp_impl_includes.add('"DOMWindow.h"') | 875 self._cpp_impl_includes.add('"DOMWindow.h"') |
| 876 body_emitter.Emit( | 876 body_emitter.Emit( |
| 877 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIsol
ate();\n' | 877 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIsol
ate();\n' |
| 878 ' if (!domWindow) {\n' | 878 ' if (!domWindow) {\n' |
| 879 ' exception = Dart_NewStringFromCString("Failed to fetch do
mWindow");\n' | 879 ' exception = Dart_NewStringFromCString("Failed to fetch do
mWindow");\n' |
| 880 ' goto fail;\n' | 880 ' goto fail;\n' |
| 881 ' }\n' | 881 ' }\n' |
| 882 ' Document* document = domWindow->document();\n') | 882 ' Document* document = domWindow->document();\n') |
| 883 | 883 |
| 884 if needs_receiver: | 884 if needs_receiver: |
| 885 body_emitter.Emit( | 885 body_emitter.Emit( |
| 886 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE
BCORE_CLASS_NAME >(args);\n', | 886 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE
BCORE_CLASS_NAME >(args);\n', |
| 887 WEBCORE_CLASS_NAME=self._interface_type_info.native_type()) | 887 WEBCORE_CLASS_NAME=self._interface_type_info.native_type()) |
| 888 | 888 |
| 889 if requires_stack_info: | 889 if requires_stack_info: |
| 890 self._cpp_impl_includes.add('"ScriptArguments.h"') | 890 self._cpp_impl_includes.add('"ScriptArguments.h"') |
| 891 self._cpp_impl_includes.add('"ScriptCallStack.h"') | 891 self._cpp_impl_includes.add('"ScriptCallStack.h"') |
| 892 body_emitter.Emit( | 892 body_emitter.Emit( |
| 893 '\n' | 893 '\n' |
| 894 ' ScriptState* currentState = ScriptState::current();\n' | 894 ' ScriptState* currentState = DartUtilities::currentScriptState
();\n' |
| 895 ' if (!currentState) {\n' | 895 ' if (!currentState) {\n' |
| 896 ' exception = Dart_NewStringFromCString("Failed to retrieve
a script state");\n' | 896 ' exception = Dart_NewStringFromCString("Failed to retrieve
a script state");\n' |
| 897 ' goto fail;\n' | 897 ' goto fail;\n' |
| 898 ' }\n' | 898 ' }\n' |
| 899 ' ScriptState& state = *currentState;\n' | 899 ' ScriptState& state = *currentState;\n' |
| 900 '\n' | 900 '\n' |
| 901 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN
DEX);\n' | 901 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN
DEX);\n' |
| 902 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create
ScriptArguments(customArgument, exception));\n' | 902 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create
ScriptArguments(customArgument, exception));\n' |
| 903 ' if (!scriptArguments)\n' | 903 ' if (!scriptArguments)\n' |
| 904 ' goto fail;\n' | 904 ' goto fail;\n' |
| 905 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' | 905 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' |
| 906 ' if (!scriptCallStack->size())\n' | 906 ' if (!scriptCallStack->size())\n' |
| 907 ' return;\n', | 907 ' return;\n', |
| 908 INDEX=len(arguments) + 1) | 908 INDEX=len(arguments) + 1) |
| 909 | 909 |
| 910 if requires_script_arguments: | 910 if requires_script_arguments: |
| 911 self._cpp_impl_includes.add('"ScriptArguments.h"') | 911 self._cpp_impl_includes.add('"ScriptArguments.h"') |
| 912 body_emitter.Emit( | 912 body_emitter.Emit( |
| 913 '\n' | 913 '\n' |
| 914 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN
DEX);\n' | 914 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN
DEX);\n' |
| 915 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create
ScriptArguments(customArgument, exception));\n' | 915 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create
ScriptArguments(customArgument, exception));\n' |
| 916 ' if (!scriptArguments)\n' | 916 ' if (!scriptArguments)\n' |
| 917 ' goto fail;\n' | 917 ' goto fail;\n', |
| 918 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' | |
| 919 ' if (!scriptCallStack->size())\n' | |
| 920 ' return;\n', | |
| 921 INDEX=len(arguments) + 1) | 918 INDEX=len(arguments) + 1) |
| 922 | 919 |
| 923 if needs_custom_element_callbacks: | 920 if needs_custom_element_callbacks: |
| 924 body_emitter.Emit(' CustomElementCallbackDispatcher::CallbackDelive
ryScope deliveryScope;\n'); | 921 body_emitter.Emit(' CustomElementCallbackDispatcher::CallbackDelive
ryScope deliveryScope;\n'); |
| 925 | 922 |
| 926 # Emit arguments. | 923 # Emit arguments. |
| 927 start_index = 1 if needs_receiver else 0 | 924 start_index = 1 if needs_receiver else 0 |
| 928 for i, argument in enumerate(arguments): | 925 for i, argument in enumerate(arguments): |
| 929 type_info = self._TypeInfo(argument.type.id) | 926 type_info = self._TypeInfo(argument.type.id) |
| 930 self._cpp_impl_includes |= set(type_info.conversion_includes()) | 927 self._cpp_impl_includes |= set(type_info.conversion_includes()) |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 e.Emit('\n'); | 1276 e.Emit('\n'); |
| 1280 e.Emit('} // namespace WebCore\n'); | 1277 e.Emit('} // namespace WebCore\n'); |
| 1281 self._emitters.Flush() | 1278 self._emitters.Flush() |
| 1282 | 1279 |
| 1283 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1280 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1284 return ( | 1281 return ( |
| 1285 interface.id.endswith('Event') and | 1282 interface.id.endswith('Event') and |
| 1286 operation.id.startswith('init') and | 1283 operation.id.startswith('init') and |
| 1287 argument.ext_attrs.get('Default') == 'Undefined' and | 1284 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1288 argument.type.id == 'DOMString') | 1285 argument.type.id == 'DOMString') |
| OLD | NEW |