OLD | NEW |
---|---|
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 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 from idl_definitions import IdlArgument, IdlOperation | 37 from idl_definitions import IdlArgument, IdlOperation |
38 from idl_types import IdlTypeBase, IdlUnionType, inherits_interface | 38 from idl_types import IdlTypeBase, IdlUnionType, inherits_interface |
39 from v8_globals import includes | 39 from v8_globals import includes |
40 import v8_types | 40 import v8_types |
41 import v8_utilities | 41 import v8_utilities |
42 from v8_utilities import (has_extended_attribute_value, is_unforgeable, | 42 from v8_utilities import (has_extended_attribute_value, is_unforgeable, |
43 is_legacy_interface_type_checking) | 43 is_legacy_interface_type_checking) |
44 | 44 |
45 | 45 |
46 # Methods with any of these require custom method registration code in the | |
47 # interface's configure*Template() function. | |
48 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ | |
49 'DoNotCheckSecurity', | |
50 ]) | |
51 | |
52 | |
53 def method_is_visible(method, interface_is_partial): | 46 def method_is_visible(method, interface_is_partial): |
54 if 'overloads' in method: | 47 if 'overloads' in method: |
55 return method['overloads']['visible'] and not (method['overloads']['has_ partial_overloads'] and interface_is_partial) | 48 return method['overloads']['visible'] and not (method['overloads']['has_ partial_overloads'] and interface_is_partial) |
56 return method['visible'] and 'overload_index' not in method | 49 return method['visible'] and 'overload_index' not in method |
57 | 50 |
58 | 51 |
59 def conditionally_exposed(method): | 52 def conditionally_exposed(method): |
60 exposed = method['overloads']['exposed_test_all'] if 'overloads' in method e lse method['exposed_test'] | 53 exposed = method['overloads']['exposed_test_all'] if 'overloads' in method e lse method['exposed_test'] |
61 secure_context = method['overloads']['secure_context_test_all'] if 'overload s' in method else method['secure_context_test'] | 54 secure_context = method['overloads']['secure_context_test_all'] if 'overload s' in method else method['secure_context_test'] |
62 return exposed or secure_context | 55 return exposed or secure_context |
63 | 56 |
64 | 57 |
65 def filter_conditionally_exposed(methods, interface_is_partial): | 58 def filter_conditionally_exposed(methods, interface_is_partial): |
66 return [method for method in methods if ( | 59 return [method for method in methods if ( |
67 method_is_visible(method, interface_is_partial) and conditionally_expose d(method))] | 60 method_is_visible(method, interface_is_partial) and conditionally_expose d(method))] |
68 | 61 |
69 | 62 |
70 def custom_registration(method): | 63 def custom_registration(method): |
71 if 'overloads' in method: | 64 if 'overloads' in method: |
72 return (method['overloads']['has_custom_registration_all'] or | 65 return (method['overloads']['runtime_determined_lengths'] or |
73 method['overloads']['runtime_determined_lengths'] or | |
74 (method['overloads']['runtime_enabled_function_all'] and not con ditionally_exposed(method))) | 66 (method['overloads']['runtime_enabled_function_all'] and not con ditionally_exposed(method))) |
75 return (method['has_custom_registration'] or | 67 return method['runtime_enabled_function'] and not conditionally_exposed(meth od) |
76 (method['runtime_enabled_function'] and not conditionally_exposed(me thod))) | |
77 | 68 |
78 | 69 |
79 def filter_custom_registration(methods, interface_is_partial): | 70 def filter_custom_registration(methods, interface_is_partial): |
80 return [method for method in methods if ( | 71 return [method for method in methods if ( |
81 method_is_visible(method, interface_is_partial) and custom_registration( method))] | 72 method_is_visible(method, interface_is_partial) and custom_registration( method))] |
82 | 73 |
83 | 74 |
84 def filter_method_configuration(methods, interface_is_partial): | 75 def filter_method_configuration(methods, interface_is_partial): |
85 return [method for method in methods if | 76 return [method for method in methods if |
86 method_is_visible(method, interface_is_partial) and | 77 method_is_visible(method, interface_is_partial) and |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi th', 'ScriptArguments') | 133 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi th', 'ScriptArguments') |
143 if is_call_with_script_arguments: | 134 if is_call_with_script_arguments: |
144 includes.update(['bindings/core/v8/ScriptCallStack.h', | 135 includes.update(['bindings/core/v8/ScriptCallStack.h', |
145 'core/inspector/ScriptArguments.h']) | 136 'core/inspector/ScriptArguments.h']) |
146 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState') | 137 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState') |
147 is_call_with_this_value = has_extended_attribute_value(method, 'CallWith', ' ThisValue') | 138 is_call_with_this_value = has_extended_attribute_value(method, 'CallWith', ' ThisValue') |
148 if is_call_with_script_state or is_call_with_this_value: | 139 if is_call_with_script_state or is_call_with_this_value: |
149 includes.add('bindings/core/v8/ScriptState.h') | 140 includes.add('bindings/core/v8/ScriptState.h') |
150 | 141 |
151 # [CheckSecurity] | 142 # [CheckSecurity] |
152 is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes | 143 is_cross_origin = 'CrossOrigin' in extended_attributes |
153 is_check_security_for_receiver = ( | 144 is_check_security_for_receiver = ( |
154 has_extended_attribute_value(interface, 'CheckSecurity', 'Receiver') and | 145 has_extended_attribute_value(interface, 'CheckSecurity', 'Receiver') and |
155 not is_do_not_check_security) | 146 not is_cross_origin) |
156 is_check_security_for_return_value = ( | 147 is_check_security_for_return_value = ( |
157 has_extended_attribute_value(method, 'CheckSecurity', 'ReturnValue')) | 148 has_extended_attribute_value(method, 'CheckSecurity', 'ReturnValue')) |
158 if is_check_security_for_receiver or is_check_security_for_return_value: | 149 if is_check_security_for_receiver or is_check_security_for_return_value: |
159 includes.add('bindings/core/v8/BindingSecurity.h') | 150 includes.add('bindings/core/v8/BindingSecurity.h') |
160 | 151 |
161 is_ce_reactions = 'CEReactions' in extended_attributes | 152 is_ce_reactions = 'CEReactions' in extended_attributes |
162 if is_ce_reactions: | 153 if is_ce_reactions: |
163 includes.add('core/dom/custom/CEReactionsScope.h') | 154 includes.add('core/dom/custom/CEReactionsScope.h') |
164 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s | 155 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s |
165 if is_custom_element_callbacks: | 156 if is_custom_element_callbacks: |
(...skipping 17 matching lines...) Expand all Loading... | |
183 | 174 |
184 return { | 175 return { |
185 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging] | 176 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging] |
186 'arguments': argument_contexts, | 177 'arguments': argument_contexts, |
187 'argument_declarations_for_private_script': | 178 'argument_declarations_for_private_script': |
188 argument_declarations_for_private_script(interface, method), | 179 argument_declarations_for_private_script(interface, method), |
189 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type) | 180 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type) |
190 if idl_type.is_explicit_nullable else idl_type.cpp_type), | 181 if idl_type.is_explicit_nullable else idl_type.cpp_type), |
191 'cpp_value': this_cpp_value, | 182 'cpp_value': this_cpp_value, |
192 'cpp_type_initializer': idl_type.cpp_type_initializer, | 183 'cpp_type_initializer': idl_type.cpp_type_initializer, |
193 'custom_registration_extended_attributes': | |
194 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection( | |
195 extended_attributes.iterkeys()), | |
196 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] | 184 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] |
197 'do_not_test_new_object': 'DoNotTestNewObject' in extended_attributes, | 185 'do_not_test_new_object': 'DoNotTestNewObject' in extended_attributes, |
198 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed] | 186 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed] |
199 # TODO(yukishiino): Retire has_custom_registration flag. Should be | |
dcheng
2016/11/02 01:46:42
I'm not sure if there were any other things linked
| |
200 # replaced with V8DOMConfiguration::PropertyLocationConfiguration. | |
201 'has_custom_registration': | |
202 v8_utilities.has_extended_attribute( | |
203 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), | |
204 'has_exception_state': | 187 'has_exception_state': |
205 is_raises_exception or | 188 is_raises_exception or |
206 is_check_security_for_receiver or | 189 is_check_security_for_receiver or |
207 any(argument for argument in arguments | 190 any(argument for argument in arguments |
208 if (argument.idl_type.name == 'SerializedScriptValue' or | 191 if (argument.idl_type.name == 'SerializedScriptValue' or |
209 argument_conversion_needs_exception_state(method, argument)) ), | 192 argument_conversion_needs_exception_state(method, argument)) ), |
210 'has_optional_argument_without_default_value': | 193 'has_optional_argument_without_default_value': |
211 any(True for argument_context in argument_contexts | 194 any(True for argument_context in argument_contexts |
212 if argument_context['is_optional_without_default_value']), | 195 if argument_context['is_optional_without_default_value']), |
213 'idl_type': idl_type.base_type, | 196 'idl_type': idl_type.base_type, |
214 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), | 197 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), |
215 'is_call_with_script_arguments': is_call_with_script_arguments, | 198 'is_call_with_script_arguments': is_call_with_script_arguments, |
216 'is_call_with_script_state': is_call_with_script_state, | 199 'is_call_with_script_state': is_call_with_script_state, |
217 'is_call_with_this_value': is_call_with_this_value, | 200 'is_call_with_this_value': is_call_with_this_value, |
218 'is_ce_reactions': is_ce_reactions, | 201 'is_ce_reactions': is_ce_reactions, |
219 'is_check_security_for_receiver': is_check_security_for_receiver, | 202 'is_check_security_for_receiver': is_check_security_for_receiver, |
220 'is_check_security_for_return_value': is_check_security_for_return_value , | 203 'is_check_security_for_return_value': is_check_security_for_return_value , |
204 'is_cross_origin': 'CrossOrigin' in extended_attributes, | |
221 'is_custom': 'Custom' in extended_attributes and | 205 'is_custom': 'Custom' in extended_attributes and |
222 not (is_custom_call_prologue or is_custom_call_epilogue), | 206 not (is_custom_call_prologue or is_custom_call_epilogue), |
223 'is_custom_call_prologue': is_custom_call_prologue, | 207 'is_custom_call_prologue': is_custom_call_prologue, |
224 'is_custom_call_epilogue': is_custom_call_epilogue, | 208 'is_custom_call_epilogue': is_custom_call_epilogue, |
225 'is_custom_element_callbacks': is_custom_element_callbacks, | 209 'is_custom_element_callbacks': is_custom_element_callbacks, |
226 'is_do_not_check_security': is_do_not_check_security, | |
227 'is_explicit_nullable': idl_type.is_explicit_nullable, | 210 'is_explicit_nullable': idl_type.is_explicit_nullable, |
228 'is_implemented_in_private_script': is_implemented_in_private_script, | 211 'is_implemented_in_private_script': is_implemented_in_private_script, |
229 'is_new_object': 'NewObject' in extended_attributes, | 212 'is_new_object': 'NewObject' in extended_attributes, |
230 'is_partial_interface_member': | 213 'is_partial_interface_member': |
231 'PartialInterfaceImplementedAs' in extended_attributes, | 214 'PartialInterfaceImplementedAs' in extended_attributes, |
232 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | 215 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, |
233 'is_post_message': is_post_message, | 216 'is_post_message': is_post_message, |
234 'is_raises_exception': is_raises_exception, | 217 'is_raises_exception': is_raises_exception, |
235 'is_static': is_static, | 218 'is_static': is_static, |
236 'is_unforgeable': is_unforgeable(interface, method), | 219 'is_unforgeable': is_unforgeable(interface, method), |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 return method.idl_type and method.idl_type.name == 'Promise' | 502 return method.idl_type and method.idl_type.name == 'Promise' |
520 | 503 |
521 IdlOperation.returns_promise = property(method_returns_promise) | 504 IdlOperation.returns_promise = property(method_returns_promise) |
522 | 505 |
523 | 506 |
524 def argument_conversion_needs_exception_state(method, argument): | 507 def argument_conversion_needs_exception_state(method, argument): |
525 idl_type = argument.idl_type | 508 idl_type = argument.idl_type |
526 return (idl_type.v8_conversion_needs_exception_state or | 509 return (idl_type.v8_conversion_needs_exception_state or |
527 argument.is_variadic or | 510 argument.is_variadic or |
528 (method.returns_promise and idl_type.is_string_type)) | 511 (method.returns_promise and idl_type.is_string_type)) |
OLD | NEW |