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

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

Issue 860353002: IDL: Add toRestricted{Float,Double}() helpers to V8Binding.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add FIXME comment Created 5 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 if is_check_security_for_node: 55 if is_check_security_for_node:
56 includes.add('bindings/core/v8/BindingSecurity.h') 56 includes.add('bindings/core/v8/BindingSecurity.h')
57 # [CustomElementCallbacks], [Reflect] 57 # [CustomElementCallbacks], [Reflect]
58 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s 58 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s
59 is_reflect = 'Reflect' in extended_attributes 59 is_reflect = 'Reflect' in extended_attributes
60 if is_custom_element_callbacks or is_reflect: 60 if is_custom_element_callbacks or is_reflect:
61 includes.add('core/dom/custom/CustomElementProcessingStack.h') 61 includes.add('core/dom/custom/CustomElementProcessingStack.h')
62 # [PerWorldBindings] 62 # [PerWorldBindings]
63 if 'PerWorldBindings' in extended_attributes: 63 if 'PerWorldBindings' in extended_attributes:
64 assert idl_type.is_wrapper_type or 'LogActivity' in extended_attributes, '[PerWorldBindings] should only be used with wrapper types: %s.%s' % (interface .name, attribute.name) 64 assert idl_type.is_wrapper_type or 'LogActivity' in extended_attributes, '[PerWorldBindings] should only be used with wrapper types: %s.%s' % (interface .name, attribute.name)
65 # [TypeChecking]
66 has_type_checking_unrestricted = (
67 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or
68 has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted') ) and
69 idl_type.name in ('Float', 'Double'))
70 # [ImplementedInPrivateScript] 65 # [ImplementedInPrivateScript]
71 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_ attributes 66 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_ attributes
72 if is_implemented_in_private_script: 67 if is_implemented_in_private_script:
73 includes.add('bindings/core/v8/PrivateScriptRunner.h') 68 includes.add('bindings/core/v8/PrivateScriptRunner.h')
74 includes.add('core/frame/LocalFrame.h') 69 includes.add('core/frame/LocalFrame.h')
75 includes.add('platform/ScriptForbiddenScope.h') 70 includes.add('platform/ScriptForbiddenScope.h')
76 71
77 # [OnlyExposedToPrivateScript] 72 # [OnlyExposedToPrivateScript]
78 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended _attributes 73 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended _attributes
79 74
(...skipping 13 matching lines...) Expand all
93 'constructor_type': idl_type.constructor_type_name 88 'constructor_type': idl_type.constructor_type_name
94 if is_constructor_attribute(attribute) else None, 89 if is_constructor_attribute(attribute) else None,
95 'cpp_name': cpp_name(attribute), 90 'cpp_name': cpp_name(attribute),
96 'cpp_type': idl_type.cpp_type, 91 'cpp_type': idl_type.cpp_type,
97 'cpp_type_initializer': idl_type.cpp_type_initializer, 92 'cpp_type_initializer': idl_type.cpp_type_initializer,
98 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 93 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs]
99 'enum_validation_expression': idl_type.enum_validation_expression, 94 'enum_validation_expression': idl_type.enum_validation_expression,
100 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] 95 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed]
101 'has_custom_getter': has_custom_getter(attribute), 96 'has_custom_getter': has_custom_getter(attribute),
102 'has_custom_setter': has_custom_setter(attribute), 97 'has_custom_setter': has_custom_setter(attribute),
103 'has_type_checking_unrestricted': has_type_checking_unrestricted,
104 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType 98 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType
105 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va lue(attribute, 'CallWith', 'ExecutionContext'), 99 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va lue(attribute, 'CallWith', 'ExecutionContext'),
106 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a ttribute, 'CallWith', 'ScriptState'), 100 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a ttribute, 'CallWith', 'ScriptState'),
107 'is_check_security_for_node': is_check_security_for_node, 101 'is_check_security_for_node': is_check_security_for_node,
108 'is_custom_element_callbacks': is_custom_element_callbacks, 102 'is_custom_element_callbacks': is_custom_element_callbacks,
109 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes, 103 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes,
110 'is_getter_raises_exception': # [RaisesException] 104 'is_getter_raises_exception': # [RaisesException]
111 'RaisesException' in extended_attributes and 105 'RaisesException' in extended_attributes and
112 extended_attributes['RaisesException'] in (None, 'Getter'), 106 extended_attributes['RaisesException'] in (None, 'Getter'),
113 'is_implemented_in_private_script': is_implemented_in_private_script, 107 'is_implemented_in_private_script': is_implemented_in_private_script,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 312
319 # [RaisesException], [RaisesException=Setter] 313 # [RaisesException], [RaisesException=Setter]
320 is_setter_raises_exception = ( 314 is_setter_raises_exception = (
321 'RaisesException' in extended_attributes and 315 'RaisesException' in extended_attributes and
322 extended_attributes['RaisesException'] in [None, 'Setter']) 316 extended_attributes['RaisesException'] in [None, 'Setter'])
323 # [TypeChecking=Interface] 317 # [TypeChecking=Interface]
324 has_type_checking_interface = ( 318 has_type_checking_interface = (
325 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or 319 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or
326 has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) a nd 320 has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) a nd
327 idl_type.is_wrapper_type) 321 idl_type.is_wrapper_type)
322 # [TypeChecking=Unrestricted]
323 restricted_float = (
324 has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or
325 has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted'))
328 326
329 context.update({ 327 context.update({
330 'has_setter_exception_state': 328 'has_setter_exception_state':
331 is_setter_raises_exception or has_type_checking_interface or 329 is_setter_raises_exception or has_type_checking_interface or
332 context['has_type_checking_unrestricted'] or
333 idl_type.v8_conversion_needs_exception_state, 330 idl_type.v8_conversion_needs_exception_state,
334 'has_type_checking_interface': has_type_checking_interface, 331 'has_type_checking_interface': has_type_checking_interface,
335 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri bute_value( 332 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri bute_value(
336 attribute, 'SetterCallWith', 'ExecutionContext'), 333 attribute, 'SetterCallWith', 'ExecutionContext'),
337 'is_setter_raises_exception': is_setter_raises_exception, 334 'is_setter_raises_exception': is_setter_raises_exception,
338 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( 335 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
339 'cppValue', isolate='scriptState->isolate()', 336 'cppValue', isolate='scriptState->isolate()',
340 creation_context='scriptState->context()->Global()'), 337 creation_context='scriptState->context()->Global()'),
341 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( 338 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(
342 extended_attributes, 'v8Value', 'cppValue'), 339 extended_attributes, 'v8Value', 'cppValue', restricted_float=restric ted_float),
343 }) 340 })
344 341
345 # setter_expression() depends on context values we set above. 342 # setter_expression() depends on context values we set above.
346 context['cpp_setter'] = setter_expression(interface, attribute, context) 343 context['cpp_setter'] = setter_expression(interface, attribute, context)
347 344
348 345
349 def setter_expression(interface, attribute, context): 346 def setter_expression(interface, attribute, context):
350 extended_attributes = attribute.extended_attributes 347 extended_attributes = attribute.extended_attributes
351 arguments = v8_utilities.call_with_arguments( 348 arguments = v8_utilities.call_with_arguments(
352 extended_attributes.get('SetterCallWith') or 349 extended_attributes.get('SetterCallWith') or
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 lambda self: strip_suffix(self.base_type, 'Constructor')) 496 lambda self: strip_suffix(self.base_type, 'Constructor'))
500 497
501 498
502 def is_constructor_attribute(attribute): 499 def is_constructor_attribute(attribute):
503 # FIXME: replace this with [ConstructorAttribute] extended attribute 500 # FIXME: replace this with [ConstructorAttribute] extended attribute
504 return attribute.idl_type.name.endswith('Constructor') 501 return attribute.idl_type.name.endswith('Constructor')
505 502
506 503
507 def constructor_getter_context(interface, attribute, context): 504 def constructor_getter_context(interface, attribute, context):
508 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 505 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698