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 24 matching lines...) Expand all Loading... |
35 if argument.idl_type.is_interface_type: | 35 if argument.idl_type.is_interface_type: |
36 forward_declarations.append(argument.idl_type) | 36 forward_declarations.append(argument.idl_type) |
37 argument.idl_type.add_includes_for_type(callback_function.extended_attri
butes) | 37 argument.idl_type.add_includes_for_type(callback_function.extended_attri
butes) |
38 | 38 |
39 context = { | 39 context = { |
40 'cpp_class': callback_function.name, | 40 'cpp_class': callback_function.name, |
41 'cpp_includes': sorted(includes), | 41 'cpp_includes': sorted(includes), |
42 'forward_declarations': sorted(forward_declarations), | 42 'forward_declarations': sorted(forward_declarations), |
43 'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES), | 43 'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES), |
44 'idl_type': idl_type_str, | 44 'idl_type': idl_type_str, |
45 'v8_class': v8_utilities.v8_class_name(callback_function), | |
46 } | 45 } |
47 | 46 |
48 if idl_type_str != 'void': | 47 if idl_type_str != 'void': |
49 context.update({ | 48 context.update({ |
50 'return_cpp_type': idl_type.cpp_type + '&', | 49 'return_cpp_type': idl_type.cpp_type + '&', |
51 'return_value': idl_type.v8_value_to_local_cpp_value( | 50 'return_value': idl_type.v8_value_to_local_cpp_value( |
52 callback_function.extended_attributes, | 51 callback_function.extended_attributes, |
53 'v8ReturnValue', 'cppValue', | 52 'v8ReturnValue', 'cppValue', |
54 isolate='scriptState->isolate()', bailout_return_value='false'), | 53 isolate='scriptState->isolate()', bailout_return_value='false'), |
55 }) | 54 }) |
(...skipping 18 matching lines...) Expand all Loading... |
74 ] | 73 ] |
75 argument_declarations.extend( | 74 argument_declarations.extend( |
76 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) | 75 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) |
77 for argument in arguments) | 76 for argument in arguments) |
78 if return_cpp_type: | 77 if return_cpp_type: |
79 argument_declarations.append('%s returnValue' % return_cpp_type) | 78 argument_declarations.append('%s returnValue' % return_cpp_type) |
80 return { | 79 return { |
81 'argument_declarations': argument_declarations, | 80 'argument_declarations': argument_declarations, |
82 'arguments': [argument_context(argument) for argument in arguments], | 81 'arguments': [argument_context(argument) for argument in arguments], |
83 } | 82 } |
OLD | NEW |