| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Generate template values for a callback function. | 5 """Generate template values for a callback function. |
| 6 | 6 |
| 7 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 7 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 from v8_globals import includes # pylint: disable=W0403 | 10 from v8_globals import includes # pylint: disable=W0403 |
| 11 import v8_utilities # pylint: disable=W0403 | 11 import v8_utilities # pylint: disable=W0403 |
| 12 | 12 |
| 13 CALLBACK_FUNCTION_H_INCLUDES = frozenset([ | 13 CALLBACK_FUNCTION_H_INCLUDES = frozenset([ |
| 14 'bindings/core/v8/ExceptionState.h', | |
| 15 'bindings/core/v8/ScopedPersistent.h', | 14 'bindings/core/v8/ScopedPersistent.h', |
| 16 'platform/heap/Handle.h', | 15 'platform/heap/Handle.h', |
| 17 'wtf/text/WTFString.h', | 16 'wtf/text/WTFString.h', |
| 18 ]) | 17 ]) |
| 19 CALLBACK_FUNCTION_CPP_INCLUDES = frozenset([ | 18 CALLBACK_FUNCTION_CPP_INCLUDES = frozenset([ |
| 19 'bindings/core/v8/ExceptionState.h', |
| 20 'bindings/core/v8/ScriptState.h', | 20 'bindings/core/v8/ScriptState.h', |
| 21 'bindings/core/v8/ToV8.h', | 21 'bindings/core/v8/ToV8.h', |
| 22 'bindings/core/v8/V8Binding.h', | 22 'bindings/core/v8/V8Binding.h', |
| 23 'core/dom/ExecutionContext.h', | 23 'core/dom/ExecutionContext.h', |
| 24 'wtf/Assertions.h', | 24 'wtf/Assertions.h', |
| 25 ]) | 25 ]) |
| 26 | 26 |
| 27 | 27 |
| 28 def callback_function_context(callback_function): | 28 def callback_function_context(callback_function): |
| 29 includes.clear() | 29 includes.clear() |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return { | 62 return { |
| 63 'argument_name': '%sArgument' % argument.name, | 63 'argument_name': '%sArgument' % argument.name, |
| 64 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value( | 64 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value( |
| 65 argument.name, isolate='scriptState->isolate()', | 65 argument.name, isolate='scriptState->isolate()', |
| 66 creation_context='scriptState->context()->Global()'), | 66 creation_context='scriptState->context()->Global()'), |
| 67 } | 67 } |
| 68 | 68 |
| 69 argument_declarations = [ | 69 argument_declarations = [ |
| 70 'ScriptState* scriptState', | 70 'ScriptState* scriptState', |
| 71 'ScriptWrappable* scriptWrappable', | 71 'ScriptWrappable* scriptWrappable', |
| 72 'ExceptionState& exceptionState', | |
| 73 ] | 72 ] |
| 74 argument_declarations.extend( | 73 argument_declarations.extend( |
| 75 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) | 74 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) |
| 76 for argument in arguments) | 75 for argument in arguments) |
| 77 if return_cpp_type: | 76 if return_cpp_type: |
| 78 argument_declarations.append('%s returnValue' % return_cpp_type) | 77 argument_declarations.append('%s returnValue' % return_cpp_type) |
| 79 return { | 78 return { |
| 80 'argument_declarations': argument_declarations, | 79 'argument_declarations': argument_declarations, |
| 81 'arguments': [argument_context(argument) for argument in arguments], | 80 'arguments': [argument_context(argument) for argument in arguments], |
| 82 } | 81 } |
| OLD | NEW |