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

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

Issue 2367543004: Extended implementation to use interface as arguments (Closed)
Patch Set: Addressed comments Created 4 years, 3 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
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/ScopedPersistent.h', 14 'bindings/core/v8/ScopedPersistent.h',
15 'platform/heap/Handle.h', 15 'platform/heap/Handle.h',
16 'wtf/text/WTFString.h', 16 'wtf/text/WTFString.h',
17 ]) 17 ])
18 CALLBACK_FUNCTION_CPP_INCLUDES = frozenset([ 18 CALLBACK_FUNCTION_CPP_INCLUDES = frozenset([
19 'bindings/core/v8/ScriptState.h', 19 'bindings/core/v8/ScriptState.h',
20 'bindings/core/v8/V8Binding.h', 20 'bindings/core/v8/V8Binding.h',
21 'wtf/Assertions.h', 21 'wtf/Assertions.h',
22 ]) 22 ])
23 23
24 24
25 def callback_function_context(callback_function): 25 def callback_function_context(callback_function):
26 includes.clear() 26 includes.clear()
27 includes.update(CALLBACK_FUNCTION_CPP_INCLUDES) 27 includes.update(CALLBACK_FUNCTION_CPP_INCLUDES)
28 idl_type = callback_function.idl_type 28 idl_type = callback_function.idl_type
29 idl_type_str = str(idl_type) 29 idl_type_str = str(idl_type)
30 forward_declarations = []
31 for argument in callback_function.arguments:
32 if argument.idl_type.is_interface_type:
33 forward_declarations.append(argument.idl_type)
34 argument.idl_type.add_includes_for_type(callback_function.extended_attri butes)
30 context = { 35 context = {
31 'cpp_class': callback_function.name, 36 'cpp_class': callback_function.name,
32 'cpp_includes': sorted(CALLBACK_FUNCTION_CPP_INCLUDES), 37 'cpp_includes': sorted(includes),
38 'forward_declarations': forward_declarations,
bashi 2016/09/23 05:45:18 sorted(forward_declarations)
lkawai 2016/09/23 06:05:36 Done.
33 'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES), 39 'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES),
34 'idl_type': idl_type_str, 40 'idl_type': idl_type_str,
35 'return_cpp_type': (idl_type.cpp_type + '&') if idl_type.cpp_type != 'vo id' else None, 41 'return_cpp_type': (idl_type.cpp_type + '&') if idl_type.cpp_type != 'vo id' else None,
36 'return_value': idl_type.v8_value_to_local_cpp_value( 42 'return_value': idl_type.v8_value_to_local_cpp_value(
37 callback_function.extended_attributes, 'v8ReturnValue', 'cppValue', 43 callback_function.extended_attributes, 'v8ReturnValue', 'cppValue',
38 bailout_return_value="false") if idl_type.cpp_type != 'void' else No ne, 44 bailout_return_value="false") if idl_type.cpp_type != 'void' else No ne,
39 'v8_class': v8_utilities.v8_class_name(callback_function), 45 'v8_class': v8_utilities.v8_class_name(callback_function),
40 } 46 }
41 context.update(arguments_context(callback_function.arguments, context['retur n_cpp_type'])) 47 context.update(arguments_context(callback_function.arguments, context['retur n_cpp_type']))
42 return context 48 return context
(...skipping 11 matching lines...) Expand all
54 argument_declarations = ['ScriptState* scriptState', 'ScriptWrappable* scrip tWrappable'] 60 argument_declarations = ['ScriptState* scriptState', 'ScriptWrappable* scrip tWrappable']
55 argument_declarations.extend( 61 argument_declarations.extend(
56 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) 62 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name)
57 for argument in arguments) 63 for argument in arguments)
58 if return_cpp_type: 64 if return_cpp_type:
59 argument_declarations.append('%s returnValue' % return_cpp_type) 65 argument_declarations.append('%s returnValue' % return_cpp_type)
60 return { 66 return {
61 'argument_declarations': argument_declarations, 67 'argument_declarations': argument_declarations,
62 'arguments': [argument_context(argument) for argument in arguments], 68 'arguments': [argument_context(argument) for argument in arguments],
63 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698