Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/v8_callback_function.py

Issue 2802223002: bindings: Throw a type error if converting an interface or callback function fails. (Closed)
Patch Set: Add |callback_function_name| to the callback function template Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 21 matching lines...) Expand all
32 includes.update(CALLBACK_FUNCTION_CPP_INCLUDES) 32 includes.update(CALLBACK_FUNCTION_CPP_INCLUDES)
33 idl_type = callback_function.idl_type 33 idl_type = callback_function.idl_type
34 idl_type_str = str(idl_type) 34 idl_type_str = str(idl_type)
35 forward_declarations = [] 35 forward_declarations = []
36 for argument in callback_function.arguments: 36 for argument in callback_function.arguments:
37 if argument.idl_type.is_interface_type: 37 if argument.idl_type.is_interface_type:
38 forward_declarations.append(argument.idl_type) 38 forward_declarations.append(argument.idl_type)
39 argument.idl_type.add_includes_for_type(callback_function.extended_attri butes) 39 argument.idl_type.add_includes_for_type(callback_function.extended_attri butes)
40 40
41 context = { 41 context = {
42 # While both |callback_function_name| and |cpp_class| are identical at
43 # the moment, the two are being defined because their values may change
44 # in the future (e.g. if we support [ImplementedAs=] in callback
45 # functions).
46 'callback_function_name': callback_function.name,
42 'cpp_class': callback_function.name, 47 'cpp_class': callback_function.name,
43 'cpp_includes': sorted(includes), 48 'cpp_includes': sorted(includes),
44 'forward_declarations': sorted(forward_declarations), 49 'forward_declarations': sorted(forward_declarations),
45 'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES), 50 'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES),
46 'idl_type': idl_type_str, 51 'idl_type': idl_type_str,
47 } 52 }
48 53
49 if idl_type_str != 'void': 54 if idl_type_str != 'void':
50 context.update({ 55 context.update({
51 'return_cpp_type': idl_type.cpp_type + '&', 56 'return_cpp_type': idl_type.cpp_type + '&',
(...skipping 22 matching lines...) Expand all
74 ] 79 ]
75 argument_declarations.extend( 80 argument_declarations.extend(
76 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) 81 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name)
77 for argument in arguments) 82 for argument in arguments)
78 if return_cpp_type: 83 if return_cpp_type:
79 argument_declarations.append('%s returnValue' % return_cpp_type) 84 argument_declarations.append('%s returnValue' % return_cpp_type)
80 return { 85 return {
81 'argument_declarations': argument_declarations, 86 'argument_declarations': argument_declarations,
82 'arguments': [argument_context(argument) for argument in arguments], 87 'arguments': [argument_context(argument) for argument in arguments],
83 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698