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

Side by Side Diff: Source/bindings/scripts/v8_methods.py

Issue 329223004: [DeprecateAs] if call addEventListener or removeEventListener without enough arguments Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test update/simplification Created 6 years, 6 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 | Annotate | Revision Log
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if is_static: 70 if is_static:
71 return 'functionTemplate' 71 return 'functionTemplate'
72 if 'Unforgeable' in extended_attributes: 72 if 'Unforgeable' in extended_attributes:
73 return 'instanceTemplate' 73 return 'instanceTemplate'
74 return 'prototypeTemplate' 74 return 'prototypeTemplate'
75 75
76 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi th', 'ScriptArguments') 76 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi th', 'ScriptArguments')
77 if is_call_with_script_arguments: 77 if is_call_with_script_arguments:
78 includes.update(['bindings/v8/ScriptCallStackFactory.h', 78 includes.update(['bindings/v8/ScriptCallStackFactory.h',
79 'core/inspector/ScriptArguments.h']) 79 'core/inspector/ScriptArguments.h'])
80 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState') 80 is_call_with_script_state = has_extended_attribute_value(
81 method, 'CallWith', 'ScriptState')
81 if is_call_with_script_state: 82 if is_call_with_script_state:
82 includes.add('bindings/v8/ScriptState.h') 83 includes.add('bindings/v8/ScriptState.h')
83 is_check_security_for_node = 'CheckSecurity' in extended_attributes 84 is_check_security_for_node = has_extended_attribute_value(
85 method, 'CheckSecurity', 'Node')
84 if is_check_security_for_node: 86 if is_check_security_for_node:
85 includes.add('bindings/v8/BindingSecurity.h') 87 includes.add('bindings/v8/BindingSecurity.h')
86 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s 88 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s
87 if is_custom_element_callbacks: 89 if is_custom_element_callbacks:
88 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') 90 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h')
89 91
90 has_event_listener_argument = any( 92 has_event_listener_argument = any(
91 argument for argument in arguments 93 argument for argument in arguments
92 if argument.idl_type.name == 'EventListener') 94 if argument.idl_type.name == 'EventListenerOrNull')
haraken 2014/06/12 04:23:23 Shouldn't this be: if argument.idl_type.name ==
Nils Barth (inactive) 2014/06/12 04:55:40 The only use of EventListener is as a nullable typ
93 is_check_security_for_frame = ( 95 is_check_security_for_frame = (
94 'CheckSecurity' in interface.extended_attributes and 96 has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and
95 'DoNotCheckSecurity' not in extended_attributes) 97 'DoNotCheckSecurity' not in extended_attributes)
96 is_raises_exception = 'RaisesException' in extended_attributes 98 is_raises_exception = 'RaisesException' in extended_attributes
97 99
98 arguments_need_try_catch = any(argument_needs_try_catch(argument) 100 arguments_need_try_catch = any(argument_needs_try_catch(argument)
99 for argument in arguments) 101 for argument in arguments)
100 102
101 return { 103 return {
102 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging] 104 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging]
103 'arguments': [generate_argument(interface, method, argument, index) 105 'arguments': [generate_argument(interface, method, argument, index)
104 for index, argument in enumerate(arguments)], 106 for index, argument in enumerate(arguments)],
105 'arguments_need_try_catch': arguments_need_try_catch, 107 'arguments_need_try_catch': arguments_need_try_catch,
106 'conditional_string': v8_utilities.conditional_string(method), 108 'conditional_string': v8_utilities.conditional_string(method),
107 'cpp_type': idl_type.cpp_type, 109 'cpp_type': idl_type.cpp_type,
108 'cpp_value': this_cpp_value, 110 'cpp_value': this_cpp_value,
109 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] 111 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs]
110 'do_not_check_signature': not(is_static or 112 'do_not_check_signature': not(is_static or
111 v8_utilities.has_extended_attribute(method, 113 v8_utilities.has_extended_attribute(method,
112 ['DoNotCheckSecurity', 'DoNotCheckSignature', 'NotEnumerable', 114 ['DoNotCheckSecurity', 'DoNotCheckSignature', 'NotEnumerable',
113 'ReadOnly', 'RuntimeEnabled', 'Unforgeable'])), 115 'ReadOnly', 'RuntimeEnabled', 'Unforgeable'])),
114 'function_template': function_template(), 116 'function_template': function_template(),
115 'idl_type': idl_type.base_type, 117 'idl_type': idl_type.base_type,
116 'has_event_listener_argument': has_event_listener_argument, 118 'has_event_listener_argument': has_event_listener_argument,
117 'has_exception_state': 119 'has_exception_state':
118 has_event_listener_argument or 120 interface.name == 'EventTarget' or # FIXME: merge with is_check_sec urity_for_frame http://crbug.com/383699
119 is_raises_exception or 121 is_raises_exception or
120 is_check_security_for_frame or 122 is_check_security_for_frame or
121 any(argument for argument in arguments 123 any(argument for argument in arguments
122 if argument.idl_type.name == 'SerializedScriptValue' or 124 if argument.idl_type.name == 'SerializedScriptValue' or
123 argument.idl_type.is_integer_type), 125 argument.idl_type.is_integer_type),
124 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), 126 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'),
125 'is_call_with_script_arguments': is_call_with_script_arguments, 127 'is_call_with_script_arguments': is_call_with_script_arguments,
126 'is_call_with_script_state': is_call_with_script_state, 128 'is_call_with_script_state': is_call_with_script_state,
127 'is_check_security_for_frame': is_check_security_for_frame, 129 'is_check_security_for_frame': is_check_security_for_frame,
128 'is_check_security_for_node': is_check_security_for_node, 130 'is_check_security_for_node': is_check_security_for_node,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 167
166 return { 168 return {
167 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es, 169 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es,
168 used_as_argument=True, 170 used_as_argument=True,
169 used_as_variadic_argument=argument.is _variadic), 171 used_as_variadic_argument=argument.is _variadic),
170 'cpp_value': this_cpp_value, 172 'cpp_value': this_cpp_value,
171 'enum_validation_expression': idl_type.enum_validation_expression, 173 'enum_validation_expression': idl_type.enum_validation_expression,
172 'has_default': 'Default' in extended_attributes, 174 'has_default': 'Default' in extended_attributes,
173 'has_event_listener_argument': any( 175 'has_event_listener_argument': any(
174 argument_so_far for argument_so_far in method.arguments[:index] 176 argument_so_far for argument_so_far in method.arguments[:index]
175 if argument_so_far.idl_type.name == 'EventListener'), 177 if argument_so_far.idl_type.name == 'EventListenerOrNull'),
176 'has_type_checking_interface': 178 'has_type_checking_interface':
177 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or 179 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or
178 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and 180 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
179 idl_type.is_wrapper_type, 181 idl_type.is_wrapper_type,
180 'has_type_checking_unrestricted': 182 'has_type_checking_unrestricted':
181 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or 183 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or
182 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and 184 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and
183 idl_type.name in ('Float', 'Double'), 185 idl_type.name in ('Float', 'Double'),
184 # Dictionary is special-cased, but arrays and sequences shouldn't be 186 # Dictionary is special-cased, but arrays and sequences shouldn't be
185 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, 187 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type,
(...skipping 13 matching lines...) Expand all
199 } 201 }
200 202
201 203
202 ################################################################################ 204 ################################################################################
203 # Value handling 205 # Value handling
204 ################################################################################ 206 ################################################################################
205 207
206 def cpp_value(interface, method, number_of_arguments): 208 def cpp_value(interface, method, number_of_arguments):
207 def cpp_argument(argument): 209 def cpp_argument(argument):
208 idl_type = argument.idl_type 210 idl_type = argument.idl_type
209 if idl_type.name == 'EventListener': 211 if idl_type.name == 'EventListenerOrNull':
210 if (interface.name == 'EventTarget' and 212 if (interface.name == 'EventTarget' and
211 method.name == 'removeEventListener'): 213 method.name == 'removeEventListener'):
212 # FIXME: remove this special case by moving get() into 214 # FIXME: remove this special case by moving get() into
213 # EventTarget::removeEventListener 215 # EventTarget::removeEventListener
214 return '%s.get()' % argument.name 216 return '%s.get()' % argument.name
215 return argument.name 217 return argument.name
216 if (idl_type.is_callback_interface or 218 if (idl_type.is_callback_interface or
217 idl_type.name in ['NodeFilter', 'XPathNSResolver']): 219 idl_type.name in ['NodeFilter', 'XPathNSResolver']):
218 # FIXME: remove this special case 220 # FIXME: remove this special case
219 return '%s.release()' % argument.name 221 return '%s.release()' % argument.name
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 315
314 316
315 def union_arguments(idl_type): 317 def union_arguments(idl_type):
316 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" 318 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value"""
317 return [arg 319 return [arg
318 for i in range(len(idl_type.member_types)) 320 for i in range(len(idl_type.member_types))
319 for arg in ['result%sEnabled' % i, 'result%s' % i]] 321 for arg in ['result%sEnabled' % i, 'result%s' % i]]
320 322
321 IdlType.union_arguments = property(lambda self: None) 323 IdlType.union_arguments = property(lambda self: None)
322 IdlUnionType.union_arguments = property(union_arguments) 324 IdlUnionType.union_arguments = property(union_arguments)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698