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

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

Issue 2837923003: Make NodeFilter a legacy callback interface. (Closed)
Patch Set: templates.gni, etc. Created 3 years, 7 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 (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 17 matching lines...) Expand all
28 28
29 """Generate template values for a callback interface. 29 """Generate template values for a callback interface.
30 30
31 Extends IdlTypeBase with property |callback_cpp_type|. 31 Extends IdlTypeBase with property |callback_cpp_type|.
32 32
33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler 33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
34 """ 34 """
35 35
36 from idl_types import IdlTypeBase 36 from idl_types import IdlTypeBase
37 from v8_globals import includes 37 from v8_globals import includes
38 from v8_interface import constant_context
38 import v8_types 39 import v8_types
39 import v8_utilities 40 import v8_utilities
40 41
41 CALLBACK_INTERFACE_H_INCLUDES = frozenset([ 42 CALLBACK_INTERFACE_H_INCLUDES = frozenset([
42 'bindings/core/v8/DOMWrapperWorld.h', 43 'bindings/core/v8/DOMWrapperWorld.h',
43 'bindings/core/v8/ScopedPersistent.h', 44 'bindings/core/v8/ScopedPersistent.h',
44 ]) 45 ])
45 CALLBACK_INTERFACE_CPP_INCLUDES = frozenset([ 46 CALLBACK_INTERFACE_CPP_INCLUDES = frozenset([
46 'bindings/core/v8/ScriptController.h', 47 'bindings/core/v8/ScriptController.h',
47 'bindings/core/v8/V8BindingForCore.h', 48 'bindings/core/v8/V8BindingForCore.h',
48 'core/dom/ExecutionContext.h', 49 'core/dom/ExecutionContext.h',
49 'platform/wtf/Assertions.h', 50 'platform/wtf/Assertions.h',
50 'platform/wtf/GetPtr.h', 51 'platform/wtf/GetPtr.h',
51 'platform/wtf/RefPtr.h', 52 'platform/wtf/RefPtr.h',
52 ]) 53 ])
54 LEGACY_CALLBACK_INTERFACE_CPP_INCLUDES = frozenset([
55 'bindings/core/v8/ScriptController.h',
56 'bindings/core/v8/V8BindingForCore.h',
57 'bindings/core/v8/V8DOMConfiguration.h',
58 'core/dom/ExecutionContext.h',
59 'platform/wtf/Assertions.h',
60 ])
53 61
54 62
55 def cpp_type(idl_type): 63 def cpp_type(idl_type):
56 # FIXME: remove this function by making callback types consistent 64 # FIXME: remove this function by making callback types consistent
57 # (always use usual v8_types.cpp_type) 65 # (always use usual v8_types.cpp_type)
58 idl_type_name = idl_type.name 66 idl_type_name = idl_type.name
59 if idl_type_name == 'String': 67 if idl_type_name == 'String':
60 return 'const String&' 68 return 'const String&'
61 if idl_type_name == 'void': 69 if idl_type_name == 'void':
62 return 'void' 70 return 'void'
(...skipping 12 matching lines...) Expand all
75 includes.update(CALLBACK_INTERFACE_CPP_INCLUDES) 83 includes.update(CALLBACK_INTERFACE_CPP_INCLUDES)
76 return { 84 return {
77 'cpp_class': callback_interface.name, 85 'cpp_class': callback_interface.name,
78 'v8_class': v8_utilities.v8_class_name(callback_interface), 86 'v8_class': v8_utilities.v8_class_name(callback_interface),
79 'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES), 87 'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES),
80 'methods': [method_context(operation) 88 'methods': [method_context(operation)
81 for operation in callback_interface.operations], 89 for operation in callback_interface.operations],
82 } 90 }
83 91
84 92
93 def legacy_callback_interface_context(callback_interface, _):
94 includes.clear()
95 includes.update(LEGACY_CALLBACK_INTERFACE_CPP_INCLUDES)
96 return {
97 # TODO(bashi): Fix crbug.com/630986, and add 'methods'.
98 'constants': [constant_context(constant, callback_interface)
99 for constant in callback_interface.constants],
100 'cpp_class': callback_interface.name,
101 'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES),
102 'interface_name': callback_interface.name,
103 'v8_class': v8_utilities.v8_class_name(callback_interface),
104 }
105
106
85 def add_includes_for_operation(operation): 107 def add_includes_for_operation(operation):
86 operation.idl_type.add_includes_for_type() 108 operation.idl_type.add_includes_for_type()
87 for argument in operation.arguments: 109 for argument in operation.arguments:
88 argument.idl_type.add_includes_for_type() 110 argument.idl_type.add_includes_for_type()
89 111
90 112
91 def method_context(operation): 113 def method_context(operation):
92 extended_attributes = operation.extended_attributes 114 extended_attributes = operation.extended_attributes
93 idl_type = operation.idl_type 115 idl_type = operation.idl_type
94 idl_type_str = str(idl_type) 116 idl_type_str = str(idl_type)
(...skipping 26 matching lines...) Expand all
121 } 143 }
122 144
123 argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle e lse [] 145 argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle e lse []
124 argument_declarations.extend( 146 argument_declarations.extend(
125 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) 147 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name)
126 for argument in arguments) 148 for argument in arguments)
127 return { 149 return {
128 'argument_declarations': argument_declarations, 150 'argument_declarations': argument_declarations,
129 'arguments': [argument_context(argument) for argument in arguments], 151 'arguments': [argument_context(argument) for argument in arguments],
130 } 152 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/utilities.py ('k') | third_party/WebKit/Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698