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

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

Issue 1526183004: Prevent SharedArrayBuffer views from being used in bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some tests Created 3 years, 11 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 228
229 def argument_context(interface, method, argument, index, is_visible=True): 229 def argument_context(interface, method, argument, index, is_visible=True):
230 extended_attributes = argument.extended_attributes 230 extended_attributes = argument.extended_attributes
231 idl_type = argument.idl_type 231 idl_type = argument.idl_type
232 if is_visible: 232 if is_visible:
233 idl_type.add_includes_for_type(extended_attributes) 233 idl_type.add_includes_for_type(extended_attributes)
234 this_cpp_value = cpp_value(interface, method, index) 234 this_cpp_value = cpp_value(interface, method, index)
235 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type 235 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
236 236
237 # ArrayBufferViews that contain SharedArrayBuffers are not allowed, in
238 # general. These conditions check various patterns that occur in the IDL
239 # files. has_array_buffer_view is a catch-all; if a new method is added
240 # which does not match any specified, it will raise an exception.
241 is_array_buffer_view = idl_type.is_array_buffer_view
242 is_flexible_array_buffer_view = (
243 'FlexibleArrayBufferView' in extended_attributes)
244 is_union_with_abv = (
245 idl_type.is_union_type and
246 any(member_type.is_array_buffer_view
247 for member_type in idl_type.member_types))
248 is_sequence_of_union_with_abv = (
249 idl_type.is_array_or_sequence_type and
250 idl_type.element_type.is_union_type and
251 any(member_type.is_array_buffer_view
252 for member_type in idl_type.element_type.member_types))
253 has_array_buffer_view = any(t.is_array_buffer_view
254 for t in idl_type.idl_types())
255
256 if has_array_buffer_view and not (
257 is_array_buffer_view or is_union_with_abv or
258 is_sequence_of_union_with_abv):
259 raise Exception('ArrayBufferView in argument with unsupported pattern.')
260
237 # [LegacyInterfaceTypeChecking] 261 # [LegacyInterfaceTypeChecking]
238 has_type_checking_interface = ( 262 has_type_checking_interface = (
239 not is_legacy_interface_type_checking(interface, method) and 263 not is_legacy_interface_type_checking(interface, method) and
240 idl_type.is_wrapper_type) 264 idl_type.is_wrapper_type)
241 265
242 set_default_value = argument.set_default_value 266 set_default_value = argument.set_default_value
243 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut es, 267 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut es,
244 raw_type=True, 268 raw_type=True,
245 used_as_variadic_argument=argument.is _variadic) 269 used_as_variadic_argument=argument.is _variadic)
246 context = { 270 context = {
247 'cpp_type': ( 271 'cpp_type': (
248 v8_types.cpp_template_type('Nullable', this_cpp_type) 272 v8_types.cpp_template_type('Nullable', this_cpp_type)
249 if idl_type.is_explicit_nullable and not argument.is_variadic 273 if idl_type.is_explicit_nullable and not argument.is_variadic
250 else this_cpp_type), 274 else this_cpp_type),
251 'cpp_value': this_cpp_value, 275 'cpp_value': this_cpp_value,
252 # FIXME: check that the default value's type is compatible with the argu ment's 276 # FIXME: check that the default value's type is compatible with the argu ment's
253 'set_default_value': set_default_value, 277 'set_default_value': set_default_value,
254 'enum_type': idl_type.enum_type, 278 'enum_type': idl_type.enum_type,
255 'enum_values': idl_type.enum_values, 279 'enum_values': idl_type.enum_values,
256 'handle': '%sHandle' % argument.name, 280 'handle': '%sHandle' % argument.name,
257 # FIXME: remove once [Default] removed and just use argument.default_val ue 281 # FIXME: remove once [Default] removed and just use argument.default_val ue
258 'has_default': 'Default' in extended_attributes or set_default_value, 282 'has_default': 'Default' in extended_attributes or set_default_value,
259 'has_type_checking_interface': has_type_checking_interface, 283 'has_type_checking_interface': has_type_checking_interface,
260 # Dictionary is special-cased, but arrays and sequences shouldn't be 284 # Dictionary is special-cased, but arrays and sequences shouldn't be
261 'idl_type': idl_type.base_type, 285 'idl_type': idl_type.base_type,
262 'idl_type_object': idl_type, 286 'idl_type_object': idl_type,
263 'index': index, 287 'index': index,
288 'is_array_buffer_view': is_array_buffer_view,
264 'is_callback_function': idl_type.is_callback_function, 289 'is_callback_function': idl_type.is_callback_function,
265 'is_callback_interface': idl_type.is_callback_interface, 290 'is_callback_interface': idl_type.is_callback_interface,
266 # FIXME: Remove generic 'Dictionary' special-casing 291 # FIXME: Remove generic 'Dictionary' special-casing
267 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio nary', 292 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio nary',
268 'is_explicit_nullable': idl_type.is_explicit_nullable, 293 'is_explicit_nullable': idl_type.is_explicit_nullable,
294 'is_flexible_array_buffer_view': is_flexible_array_buffer_view,
269 'is_nullable': idl_type.is_nullable, 295 'is_nullable': idl_type.is_nullable,
270 'is_optional': argument.is_optional, 296 'is_optional': argument.is_optional,
297 'is_sequence_of_union_with_array_buffer_view': is_sequence_of_union_with _abv,
298 'is_union_with_array_buffer_view': is_union_with_abv,
271 'is_variadic': argument.is_variadic, 299 'is_variadic': argument.is_variadic,
272 'is_variadic_wrapper_type': is_variadic_wrapper_type, 300 'is_variadic_wrapper_type': is_variadic_wrapper_type,
273 'is_wrapper_type': idl_type.is_wrapper_type, 301 'is_wrapper_type': idl_type.is_wrapper_type,
274 'name': argument.name, 302 'name': argument.name,
275 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes, 303 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes,
276 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), 304 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value),
277 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), 305 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True),
278 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(method, argum ent, index), 306 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(method, argum ent, index),
279 } 307 }
280 context.update({ 308 context.update({
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 return method.idl_type and method.idl_type.name == 'Promise' 475 return method.idl_type and method.idl_type.name == 'Promise'
448 476
449 IdlOperation.returns_promise = property(method_returns_promise) 477 IdlOperation.returns_promise = property(method_returns_promise)
450 478
451 479
452 def argument_conversion_needs_exception_state(method, argument): 480 def argument_conversion_needs_exception_state(method, argument):
453 idl_type = argument.idl_type 481 idl_type = argument.idl_type
454 return (idl_type.v8_conversion_needs_exception_state or 482 return (idl_type.v8_conversion_needs_exception_state or
455 argument.is_variadic or 483 argument.is_variadic or
456 (method.returns_promise and idl_type.is_string_type)) 484 (method.returns_promise and idl_type.is_string_type))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698