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

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

Issue 953473002: bindings: Supports [Replaceable] accessors. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 # [CheckSecurity] 53 # [CheckSecurity]
54 is_check_security_for_node = 'CheckSecurity' in extended_attributes 54 is_check_security_for_node = 'CheckSecurity' in extended_attributes
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 # [ExposeJSAccessors]
63 if 'PerWorldBindings' in extended_attributes: 63 is_expose_js_accessors = 'ExposeJSAccessors' 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)
65 # [ImplementedInPrivateScript] 64 # [ImplementedInPrivateScript]
66 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_ attributes 65 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_ attributes
67 if is_implemented_in_private_script: 66 if is_implemented_in_private_script:
68 includes.add('bindings/core/v8/PrivateScriptRunner.h') 67 includes.add('bindings/core/v8/PrivateScriptRunner.h')
69 includes.add('core/frame/LocalFrame.h') 68 includes.add('core/frame/LocalFrame.h')
70 includes.add('platform/ScriptForbiddenScope.h') 69 includes.add('platform/ScriptForbiddenScope.h')
71
72 # [OnlyExposedToPrivateScript] 70 # [OnlyExposedToPrivateScript]
73 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended _attributes 71 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended _attributes
72 # [PerWorldBindings]
73 if 'PerWorldBindings' in extended_attributes:
74 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)
74 75
75 if (base_idl_type == 'EventHandler' and 76 if (base_idl_type == 'EventHandler' and
76 interface.name in ['Window', 'WorkerGlobalScope'] and 77 interface.name in ['Window', 'WorkerGlobalScope'] and
77 attribute.name == 'onerror'): 78 attribute.name == 'onerror'):
78 includes.add('bindings/core/v8/V8ErrorHandler.h') 79 includes.add('bindings/core/v8/V8ErrorHandler.h')
79 80
80 context = { 81 context = {
81 'access_control_list': access_control_list(interface, attribute), 82 'access_control_list': access_control_list(interface, attribute),
82 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_ world_list(attribute, 'Getter'), # [ActivityLogging] 83 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_ world_list(attribute, 'Getter'), # [ActivityLogging]
83 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_ world_list(attribute, 'Setter'), # [ActivityLogging] 84 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_ world_list(attribute, 'Setter'), # [ActivityLogging]
(...skipping 10 matching lines...) Expand all
94 'enum_validation_expression': idl_type.enum_validation_expression, 95 'enum_validation_expression': idl_type.enum_validation_expression,
95 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] 96 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed]
96 'has_custom_getter': has_custom_getter(attribute), 97 'has_custom_getter': has_custom_getter(attribute),
97 'has_custom_setter': has_custom_setter(attribute), 98 'has_custom_setter': has_custom_setter(attribute),
98 'has_side_effect_on_get': 'HasSideEffectOnGet' in extended_attributes, 99 'has_side_effect_on_get': 'HasSideEffectOnGet' in extended_attributes,
99 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType 100 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType
100 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va lue(attribute, 'CallWith', 'ExecutionContext'), 101 'is_call_with_execution_context': v8_utilities.has_extended_attribute_va lue(attribute, 'CallWith', 'ExecutionContext'),
101 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a ttribute, 'CallWith', 'ScriptState'), 102 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(a ttribute, 'CallWith', 'ScriptState'),
102 'is_check_security_for_node': is_check_security_for_node, 103 'is_check_security_for_node': is_check_security_for_node,
103 'is_custom_element_callbacks': is_custom_element_callbacks, 104 'is_custom_element_callbacks': is_custom_element_callbacks,
104 'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes, 105 'is_expose_js_accessors': is_expose_js_accessors,
105 'is_getter_raises_exception': # [RaisesException] 106 'is_getter_raises_exception': # [RaisesException]
106 'RaisesException' in extended_attributes and 107 'RaisesException' in extended_attributes and
107 extended_attributes['RaisesException'] in (None, 'Getter'), 108 extended_attributes['RaisesException'] in (None, 'Getter'),
108 'is_implemented_in_private_script': is_implemented_in_private_script, 109 'is_implemented_in_private_script': is_implemented_in_private_script,
109 'is_initialized_by_event_constructor': 110 'is_initialized_by_event_constructor':
110 'InitializedByEventConstructor' in extended_attributes, 111 'InitializedByEventConstructor' in extended_attributes,
111 'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute), 112 'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute),
112 'is_nullable': idl_type.is_nullable, 113 'is_nullable': idl_type.is_nullable,
113 'is_explicit_nullable': idl_type.is_explicit_nullable, 114 'is_explicit_nullable': idl_type.is_explicit_nullable,
114 'is_partial_interface_member': 115 'is_partial_interface_member':
(...skipping 12 matching lines...) Expand all
127 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(attribute), # [PerContextEnabled] 128 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(attribute), # [PerContextEnabled]
128 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value( 129 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value(
129 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', used_in_private_script=True), 130 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', used_in_private_script=True),
130 'property_attributes': property_attributes(interface, attribute), 131 'property_attributes': property_attributes(interface, attribute),
131 'put_forwards': 'PutForwards' in extended_attributes, 132 'put_forwards': 'PutForwards' in extended_attributes,
132 'reflect_empty': extended_attributes.get('ReflectEmpty'), 133 'reflect_empty': extended_attributes.get('ReflectEmpty'),
133 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), 134 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
134 'reflect_missing': extended_attributes.get('ReflectMissing'), 135 'reflect_missing': extended_attributes.get('ReflectMissing'),
135 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '), 136 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '),
136 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled] 137 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled]
137 'setter_callback': setter_callback_name(interface, attribute), 138 'setter_callback': setter_callback_name(interface, attribute, is_expose_ js_accessors),
138 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), 139 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),
139 'world_suffixes': ['', 'ForMainWorld'] 140 'world_suffixes': ['', 'ForMainWorld']
140 if 'PerWorldBindings' in extended_attributes 141 if 'PerWorldBindings' in extended_attributes
141 else [''], # [PerWorldBindings] 142 else [''], # [PerWorldBindings]
142 } 143 }
143 144
144 if is_constructor_attribute(attribute): 145 if is_constructor_attribute(attribute):
145 constructor_getter_context(interface, attribute, context) 146 constructor_getter_context(interface, attribute, context)
146 return context 147 return context
147 if not has_custom_getter(attribute): 148 if not has_custom_getter(attribute):
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 else: 421 else:
421 namespace = 'HTMLNames' 422 namespace = 'HTMLNames'
422 includes.add('core/%s.h' % namespace) 423 includes.add('core/%s.h' % namespace)
423 return '%s::%sAttr' % (namespace, content_attribute_name) 424 return '%s::%sAttr' % (namespace, content_attribute_name)
424 425
425 426
426 ################################################################################ 427 ################################################################################
427 # Attribute configuration 428 # Attribute configuration
428 ################################################################################ 429 ################################################################################
429 430
430 # [Replaceable] 431 # [PutForwards], [Replaceable]
431 def setter_callback_name(interface, attribute): 432 def setter_callback_name(interface, attribute, is_expose_js_accessors):
432 cpp_class_name = cpp_name(interface) 433 cpp_class_name = cpp_name(interface)
433 cpp_class_name_or_partial = cpp_name_or_partial(interface) 434 cpp_class_name_or_partial = cpp_name_or_partial(interface)
434 435
435 extended_attributes = attribute.extended_attributes 436 extended_attributes = attribute.extended_attributes
436 if (('Replaceable' in extended_attributes and 437 if (not is_expose_js_accessors and
437 'PutForwards' not in extended_attributes) or 438 ('Replaceable' in extended_attributes or
haraken 2015/02/23 14:48:52 Why can we remove "'PutForwards' not in extended_a
Yuki 2015/02/23 15:18:42 [Replaceable] and [PutForwards] conflict each othe
haraken 2015/02/23 17:34:00 Sounds like a good idea.
438 is_constructor_attribute(attribute)): 439 is_constructor_attribute(attribute))):
439 return '%sV8Internal::%sForceSetAttributeOnThisCallback' % ( 440 return '%sV8Internal::%sForceSetAttributeOnThisCallback' % (
haraken 2015/02/23 14:48:52 Help me understand: What's a difference between a
Yuki 2015/02/23 15:18:42 Basically we have the same implementation for "rep
haraken 2015/02/23 17:33:59 Ah, now I understand what this CL is doing :) It
Yuki 2015/02/25 14:19:29 Done.
440 cpp_class_name_or_partial, cpp_class_name) 441 cpp_class_name_or_partial, cpp_class_name)
441 if attribute.is_read_only and 'PutForwards' not in extended_attributes: 442 if (attribute.is_read_only and
443 'PutForwards' not in extended_attributes and
444 'Replaceable' not in extended_attributes):
haraken 2015/02/23 14:48:52 Fix indentation.
Yuki 2015/02/23 15:18:42 We need this indentation. Otherwise, I got a lint
442 return '0' 445 return '0'
443 return '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_name_or_partia l, attribute.name) 446 return '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_name_or_partia l, attribute.name)
444 447
445 448
446 # [DoNotCheckSecurity], [Unforgeable] 449 # [DoNotCheckSecurity], [Unforgeable]
447 def access_control_list(interface, attribute): 450 def access_control_list(interface, attribute):
448 extended_attributes = attribute.extended_attributes 451 extended_attributes = attribute.extended_attributes
449 access_control = [] 452 access_control = []
450 if 'DoNotCheckSecurity' in extended_attributes: 453 if 'DoNotCheckSecurity' in extended_attributes:
451 do_not_check_security = extended_attributes['DoNotCheckSecurity'] 454 do_not_check_security = extended_attributes['DoNotCheckSecurity']
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 lambda self: strip_suffix(self.base_type, 'Constructor')) 501 lambda self: strip_suffix(self.base_type, 'Constructor'))
499 502
500 503
501 def is_constructor_attribute(attribute): 504 def is_constructor_attribute(attribute):
502 # FIXME: replace this with [ConstructorAttribute] extended attribute 505 # FIXME: replace this with [ConstructorAttribute] extended attribute
503 return attribute.idl_type.name.endswith('Constructor') 506 return attribute.idl_type.name.endswith('Constructor')
504 507
505 508
506 def constructor_getter_context(interface, attribute, context): 509 def constructor_getter_context(interface, attribute, context):
507 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 510 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_interface.py » ('j') | Source/bindings/templates/attributes.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698