| 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 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES), | 44 'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES), |
| 45 'idl_type': idl_type_str, | 45 'idl_type': idl_type_str, |
| 46 } | 46 } |
| 47 | 47 |
| 48 if idl_type_str != 'void': | 48 if idl_type_str != 'void': |
| 49 context.update({ | 49 context.update({ |
| 50 'return_cpp_type': idl_type.cpp_type + '&', | 50 'return_cpp_type': idl_type.cpp_type + '&', |
| 51 'return_value': idl_type.v8_value_to_local_cpp_value( | 51 'return_value': idl_type.v8_value_to_local_cpp_value( |
| 52 callback_function.extended_attributes, | 52 callback_function.extended_attributes, |
| 53 'v8ReturnValue', 'cppValue', | 53 'v8ReturnValue', 'cppValue', |
| 54 isolate='scriptState->isolate()', bailout_return_value='false'), | 54 isolate='m_scriptState->isolate()', |
| 55 bailout_return_value='false'), |
| 55 }) | 56 }) |
| 56 | 57 |
| 57 context.update(arguments_context(callback_function.arguments, context.get('r
eturn_cpp_type'))) | 58 context.update(arguments_context(callback_function.arguments, context.get('r
eturn_cpp_type'))) |
| 58 return context | 59 return context |
| 59 | 60 |
| 60 | 61 |
| 61 def arguments_context(arguments, return_cpp_type): | 62 def arguments_context(arguments, return_cpp_type): |
| 62 def argument_context(argument): | 63 def argument_context(argument): |
| 63 return { | 64 return { |
| 64 'argument_name': '%sArgument' % argument.name, | 65 'argument_name': '%sArgument' % argument.name, |
| 65 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value( | 66 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value( |
| 66 argument.name, isolate='scriptState->isolate()', | 67 argument.name, isolate='m_scriptState->isolate()', |
| 67 creation_context='scriptState->context()->Global()'), | 68 creation_context='m_scriptState->context()->Global()'), |
| 68 } | 69 } |
| 69 | 70 |
| 70 argument_declarations = [ | 71 argument_declarations = [ |
| 71 'ScriptState* scriptState', | |
| 72 'ScriptWrappable* scriptWrappable', | 72 'ScriptWrappable* scriptWrappable', |
| 73 ] | 73 ] |
| 74 argument_declarations.extend( | 74 argument_declarations.extend( |
| 75 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) | 75 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) |
| 76 for argument in arguments) | 76 for argument in arguments) |
| 77 if return_cpp_type: | 77 if return_cpp_type: |
| 78 argument_declarations.append('%s returnValue' % return_cpp_type) | 78 argument_declarations.append('%s returnValue' % return_cpp_type) |
| 79 return { | 79 return { |
| 80 'argument_declarations': argument_declarations, | 80 'argument_declarations': argument_declarations, |
| 81 'arguments': [argument_context(argument) for argument in arguments], | 81 'arguments': [argument_context(argument) for argument in arguments], |
| 82 } | 82 } |
| OLD | NEW |