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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 | 74 |
75 def filter_custom_registration(methods, interface_is_partial): | 75 def filter_custom_registration(methods, interface_is_partial): |
76 return [method for method in methods if ( | 76 return [method for method in methods if ( |
77 method_is_visible(method, interface_is_partial) and custom_registration(
method))] | 77 method_is_visible(method, interface_is_partial) and custom_registration(
method))] |
78 | 78 |
79 | 79 |
80 def filter_method_configuration(methods, interface_is_partial): | 80 def filter_method_configuration(methods, interface_is_partial): |
81 return [method for method in methods if | 81 return [method for method in methods if |
82 method_is_visible(method, interface_is_partial) and | 82 method_is_visible(method, interface_is_partial) and |
83 method['should_be_exposed_to_script'] and | |
84 not method['origin_trial_feature_name'] and | 83 not method['origin_trial_feature_name'] and |
85 not conditionally_exposed(method) and | 84 not conditionally_exposed(method) and |
86 not custom_registration(method)] | 85 not custom_registration(method)] |
87 | 86 |
88 | 87 |
89 def method_for_origin_trial_feature(methods, feature_name, interface_is_partial)
: | 88 def method_for_origin_trial_feature(methods, feature_name, interface_is_partial)
: |
90 """Filters the list of methods, and returns those defined for the named orig
in trial feature.""" | 89 """Filters the list of methods, and returns those defined for the named orig
in trial feature.""" |
91 return [method for method in methods if | 90 return [method for method in methods if |
92 method_is_visible(method, interface_is_partial) and | 91 method_is_visible(method, interface_is_partial) and |
93 method['should_be_exposed_to_script'] and | |
94 method['origin_trial_feature_name'] == feature_name and | 92 method['origin_trial_feature_name'] == feature_name and |
95 not conditionally_exposed(method) and | 93 not conditionally_exposed(method) and |
96 not custom_registration(method)] | 94 not custom_registration(method)] |
97 | 95 |
98 | 96 |
99 def method_filters(): | 97 def method_filters(): |
100 return {'conditionally_exposed': filter_conditionally_exposed, | 98 return {'conditionally_exposed': filter_conditionally_exposed, |
101 'custom_registration': filter_custom_registration, | 99 'custom_registration': filter_custom_registration, |
102 'has_method_configuration': filter_method_configuration, | 100 'has_method_configuration': filter_method_configuration, |
103 'method_for_origin_trial_feature': method_for_origin_trial_feature} | 101 'method_for_origin_trial_feature': method_for_origin_trial_feature} |
104 | 102 |
105 | 103 |
106 def use_local_result(method): | 104 def use_local_result(method): |
107 extended_attributes = method.extended_attributes | 105 extended_attributes = method.extended_attributes |
108 idl_type = method.idl_type | 106 idl_type = method.idl_type |
109 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or | 107 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or |
110 'ImplementedInPrivateScript' in extended_attributes or | |
111 'NewObject' in extended_attributes or | 108 'NewObject' in extended_attributes or |
112 'RaisesException' in extended_attributes or | 109 'RaisesException' in extended_attributes or |
113 idl_type.is_union_type or | 110 idl_type.is_union_type or |
114 idl_type.is_explicit_nullable) | 111 idl_type.is_explicit_nullable) |
115 | 112 |
116 | 113 |
117 def method_context(interface, method, is_visible=True): | 114 def method_context(interface, method, is_visible=True): |
118 arguments = method.arguments | 115 arguments = method.arguments |
119 extended_attributes = method.extended_attributes | 116 extended_attributes = method.extended_attributes |
120 idl_type = method.idl_type | 117 idl_type = method.idl_type |
121 is_static = method.is_static | 118 is_static = method.is_static |
122 name = method.name | 119 name = method.name |
123 | 120 |
124 if is_visible: | 121 if is_visible: |
125 idl_type.add_includes_for_type(extended_attributes) | 122 idl_type.add_includes_for_type(extended_attributes) |
126 | 123 |
127 this_cpp_value = cpp_value(interface, method, len(arguments)) | 124 this_cpp_value = cpp_value(interface, method, len(arguments)) |
128 | 125 |
129 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_
attributes | |
130 if is_implemented_in_private_script: | |
131 includes.add('bindings/core/v8/PrivateScriptRunner.h') | |
132 includes.add('core/frame/LocalFrame.h') | |
133 includes.add('platform/ScriptForbiddenScope.h') | |
134 | |
135 # [OnlyExposedToPrivateScript] | |
136 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended
_attributes | |
137 | |
138 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi
th', 'ScriptArguments') | 126 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi
th', 'ScriptArguments') |
139 if is_call_with_script_arguments: | 127 if is_call_with_script_arguments: |
140 includes.update(['bindings/core/v8/ScriptCallStack.h', | 128 includes.update(['bindings/core/v8/ScriptCallStack.h', |
141 'core/inspector/ScriptArguments.h']) | 129 'core/inspector/ScriptArguments.h']) |
142 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith',
'ScriptState') | 130 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith',
'ScriptState') |
143 is_call_with_this_value = has_extended_attribute_value(method, 'CallWith', '
ThisValue') | 131 is_call_with_this_value = has_extended_attribute_value(method, 'CallWith', '
ThisValue') |
144 if is_call_with_script_state or is_call_with_this_value: | 132 if is_call_with_script_state or is_call_with_this_value: |
145 includes.add('bindings/core/v8/ScriptState.h') | 133 includes.add('bindings/core/v8/ScriptState.h') |
146 | 134 |
147 # [CheckSecurity] | 135 # [CheckSecurity] |
(...skipping 26 matching lines...) Expand all Loading... |
174 if 'LenientThis' in extended_attributes: | 162 if 'LenientThis' in extended_attributes: |
175 raise Exception('[LenientThis] is not supported for operations.') | 163 raise Exception('[LenientThis] is not supported for operations.') |
176 | 164 |
177 argument_contexts = [ | 165 argument_contexts = [ |
178 argument_context(interface, method, argument, index, is_visible=is_visib
le) | 166 argument_context(interface, method, argument, index, is_visible=is_visib
le) |
179 for index, argument in enumerate(arguments)] | 167 for index, argument in enumerate(arguments)] |
180 | 168 |
181 return { | 169 return { |
182 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] | 170 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] |
183 'arguments': argument_contexts, | 171 'arguments': argument_contexts, |
184 'argument_declarations_for_private_script': | |
185 argument_declarations_for_private_script(interface, method), | |
186 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type) | 172 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type) |
187 if idl_type.is_explicit_nullable else idl_type.cpp_type), | 173 if idl_type.is_explicit_nullable else idl_type.cpp_type), |
188 'cpp_value': this_cpp_value, | 174 'cpp_value': this_cpp_value, |
189 'cpp_type_initializer': idl_type.cpp_type_initializer, | 175 'cpp_type_initializer': idl_type.cpp_type_initializer, |
190 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] | 176 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] |
191 'do_not_test_new_object': 'DoNotTestNewObject' in extended_attributes, | 177 'do_not_test_new_object': 'DoNotTestNewObject' in extended_attributes, |
192 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed] | 178 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed] |
193 'has_exception_state': | 179 'has_exception_state': |
194 is_raises_exception or | 180 is_raises_exception or |
195 is_check_security_for_receiver or | 181 is_check_security_for_receiver or |
(...skipping 11 matching lines...) Expand all Loading... |
207 'is_ce_reactions': is_ce_reactions, | 193 'is_ce_reactions': is_ce_reactions, |
208 'is_check_security_for_receiver': is_check_security_for_receiver, | 194 'is_check_security_for_receiver': is_check_security_for_receiver, |
209 'is_check_security_for_return_value': is_check_security_for_return_value
, | 195 'is_check_security_for_return_value': is_check_security_for_return_value
, |
210 'is_cross_origin': 'CrossOrigin' in extended_attributes, | 196 'is_cross_origin': 'CrossOrigin' in extended_attributes, |
211 'is_custom': 'Custom' in extended_attributes and | 197 'is_custom': 'Custom' in extended_attributes and |
212 not (is_custom_call_prologue or is_custom_call_epilogue), | 198 not (is_custom_call_prologue or is_custom_call_epilogue), |
213 'is_custom_call_prologue': is_custom_call_prologue, | 199 'is_custom_call_prologue': is_custom_call_prologue, |
214 'is_custom_call_epilogue': is_custom_call_epilogue, | 200 'is_custom_call_epilogue': is_custom_call_epilogue, |
215 'is_custom_element_callbacks': is_custom_element_callbacks, | 201 'is_custom_element_callbacks': is_custom_element_callbacks, |
216 'is_explicit_nullable': idl_type.is_explicit_nullable, | 202 'is_explicit_nullable': idl_type.is_explicit_nullable, |
217 'is_implemented_in_private_script': is_implemented_in_private_script, | |
218 'is_new_object': 'NewObject' in extended_attributes, | 203 'is_new_object': 'NewObject' in extended_attributes, |
219 'is_partial_interface_member': | 204 'is_partial_interface_member': |
220 'PartialInterfaceImplementedAs' in extended_attributes, | 205 'PartialInterfaceImplementedAs' in extended_attributes, |
221 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | 206 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, |
222 'is_post_message': is_post_message, | 207 'is_post_message': is_post_message, |
223 'is_raises_exception': is_raises_exception, | 208 'is_raises_exception': is_raises_exception, |
224 'is_static': is_static, | 209 'is_static': is_static, |
225 'is_unforgeable': is_unforgeable(interface, method), | 210 'is_unforgeable': is_unforgeable(interface, method), |
226 'is_variadic': arguments and arguments[-1].is_variadic, | 211 'is_variadic': arguments and arguments[-1].is_variadic, |
227 'measure_as': v8_utilities.measure_as(method, interface), # [MeasureAs] | 212 'measure_as': v8_utilities.measure_as(method, interface), # [MeasureAs] |
228 'name': name, | 213 'name': name, |
229 'number_of_arguments': len(arguments), | 214 'number_of_arguments': len(arguments), |
230 'number_of_required_arguments': len([ | 215 'number_of_required_arguments': len([ |
231 argument for argument in arguments | 216 argument for argument in arguments |
232 if not (argument.is_optional or argument.is_variadic)]), | 217 if not (argument.is_optional or argument.is_variadic)]), |
233 'number_of_required_or_variadic_arguments': len([ | 218 'number_of_required_or_variadic_arguments': len([ |
234 argument for argument in arguments | 219 argument for argument in arguments |
235 if not argument.is_optional]), | 220 if not argument.is_optional]), |
236 'on_instance': v8_utilities.on_instance(interface, method), | 221 'on_instance': v8_utilities.on_instance(interface, method), |
237 'on_interface': v8_utilities.on_interface(interface, method), | 222 'on_interface': v8_utilities.on_interface(interface, method), |
238 'on_prototype': v8_utilities.on_prototype(interface, method), | 223 'on_prototype': v8_utilities.on_prototype(interface, method), |
239 'only_exposed_to_private_script': is_only_exposed_to_private_script, | |
240 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct
ion_name(method), # [OriginTrialEnabled] | 224 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct
ion_name(method), # [OriginTrialEnabled] |
241 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(meth
od), # [OriginTrialEnabled] | 225 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(meth
od), # [OriginTrialEnabled] |
242 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( | |
243 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is
olate()', bailout_return_value='false'), | |
244 'property_attributes': property_attributes(interface, method), | 226 'property_attributes': property_attributes(interface, method), |
245 'returns_promise': method.returns_promise, | 227 'returns_promise': method.returns_promise, |
246 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m
ethod), # [RuntimeEnabled] | 228 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m
ethod), # [RuntimeEnabled] |
247 'secure_context_test': v8_utilities.secure_context(method, interface),
# [SecureContext] | 229 'secure_context_test': v8_utilities.secure_context(method, interface),
# [SecureContext] |
248 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), | |
249 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res
ult, | 230 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res
ult, |
250 'use_local_result': use_local_result(method), | 231 'use_local_result': use_local_result(method), |
251 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 232 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
252 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | 233 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), |
253 'visible': is_visible, | 234 'visible': is_visible, |
254 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings], | 235 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings], |
255 } | 236 } |
256 | 237 |
257 | 238 |
258 def argument_context(interface, method, argument, index, is_visible=True): | 239 def argument_context(interface, method, argument, index, is_visible=True): |
259 extended_attributes = argument.extended_attributes | 240 extended_attributes = argument.extended_attributes |
260 idl_type = argument.idl_type | 241 idl_type = argument.idl_type |
261 if is_visible: | 242 if is_visible: |
262 idl_type.add_includes_for_type(extended_attributes) | 243 idl_type.add_includes_for_type(extended_attributes) |
263 this_cpp_value = cpp_value(interface, method, index) | 244 this_cpp_value = cpp_value(interface, method, index) |
264 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | 245 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type |
265 | 246 |
266 # [LegacyInterfaceTypeChecking] | 247 # [LegacyInterfaceTypeChecking] |
267 has_type_checking_interface = ( | 248 has_type_checking_interface = ( |
268 not is_legacy_interface_type_checking(interface, method) and | 249 not is_legacy_interface_type_checking(interface, method) and |
269 idl_type.is_wrapper_type) | 250 idl_type.is_wrapper_type) |
270 | 251 |
271 if ('ImplementedInPrivateScript' in extended_attributes and | |
272 not idl_type.is_wrapper_type and | |
273 not idl_type.is_basic_type): | |
274 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | |
275 | |
276 set_default_value = argument.set_default_value | 252 set_default_value = argument.set_default_value |
277 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, | 253 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, |
278 raw_type=True, | 254 raw_type=True, |
279 used_as_variadic_argument=argument.is
_variadic) | 255 used_as_variadic_argument=argument.is
_variadic) |
280 context = { | 256 context = { |
281 'cpp_type': ( | 257 'cpp_type': ( |
282 v8_types.cpp_template_type('Nullable', this_cpp_type) | 258 v8_types.cpp_template_type('Nullable', this_cpp_type) |
283 if idl_type.is_explicit_nullable and not argument.is_variadic | 259 if idl_type.is_explicit_nullable and not argument.is_variadic |
284 else this_cpp_type), | 260 else this_cpp_type), |
285 'cpp_value': this_cpp_value, | 261 'cpp_value': this_cpp_value, |
(...skipping 13 matching lines...) Expand all Loading... |
299 'is_callback_interface': idl_type.is_callback_interface, | 275 'is_callback_interface': idl_type.is_callback_interface, |
300 # FIXME: Remove generic 'Dictionary' special-casing | 276 # FIXME: Remove generic 'Dictionary' special-casing |
301 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio
nary', | 277 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio
nary', |
302 'is_explicit_nullable': idl_type.is_explicit_nullable, | 278 'is_explicit_nullable': idl_type.is_explicit_nullable, |
303 'is_nullable': idl_type.is_nullable, | 279 'is_nullable': idl_type.is_nullable, |
304 'is_optional': argument.is_optional, | 280 'is_optional': argument.is_optional, |
305 'is_variadic': argument.is_variadic, | 281 'is_variadic': argument.is_variadic, |
306 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 282 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
307 'is_wrapper_type': idl_type.is_wrapper_type, | 283 'is_wrapper_type': idl_type.is_wrapper_type, |
308 'name': argument.name, | 284 'name': argument.name, |
309 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( | |
310 argument.name, isolate='scriptState->isolate()', | |
311 creation_context='scriptState->context()->Global()'), | |
312 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion'
in extended_attributes, | 285 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion'
in extended_attributes, |
313 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 286 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
314 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | 287 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), |
315 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(method, argum
ent, index), | 288 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(method, argum
ent, index), |
316 } | 289 } |
317 context.update({ | 290 context.update({ |
318 'is_optional_without_default_value': | 291 'is_optional_without_default_value': |
319 context['is_optional'] and | 292 context['is_optional'] and |
320 not context['has_default'] and | 293 not context['has_default'] and |
321 not context['is_dictionary'] and | 294 not context['is_dictionary'] and |
322 not context['is_callback_interface'], | 295 not context['is_callback_interface'], |
323 }) | 296 }) |
324 return context | 297 return context |
325 | 298 |
326 | 299 |
327 def argument_declarations_for_private_script(interface, method): | |
328 argument_declarations = ['LocalFrame* frame'] | |
329 argument_declarations.append('%s* holderImpl' % interface.name) | |
330 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( | |
331 used_as_rvalue_type=True), argument.name) for argument in method.argumen
ts]) | |
332 if method.idl_type.name != 'void': | |
333 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu
lt')) | |
334 return argument_declarations | |
335 | |
336 | |
337 ################################################################################ | 300 ################################################################################ |
338 # Value handling | 301 # Value handling |
339 ################################################################################ | 302 ################################################################################ |
340 | 303 |
341 def cpp_value(interface, method, number_of_arguments): | 304 def cpp_value(interface, method, number_of_arguments): |
342 # Truncate omitted optional arguments | 305 # Truncate omitted optional arguments |
343 arguments = method.arguments[:number_of_arguments] | 306 arguments = method.arguments[:number_of_arguments] |
344 cpp_arguments = [] | 307 cpp_arguments = [] |
345 if 'ImplementedInPrivateScript' in method.extended_attributes: | |
346 cpp_arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate(
)->GetCurrentContext()))') | |
347 cpp_arguments.append('impl') | |
348 | 308 |
349 if method.is_constructor: | 309 if method.is_constructor: |
350 call_with_values = interface.extended_attributes.get('ConstructorCallWit
h') | 310 call_with_values = interface.extended_attributes.get('ConstructorCallWit
h') |
351 else: | 311 else: |
352 call_with_values = method.extended_attributes.get('CallWith') | 312 call_with_values = method.extended_attributes.get('CallWith') |
353 cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values)) | 313 cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values)) |
354 | 314 |
355 # Members of IDL partial interface definitions are implemented in C++ as | 315 # Members of IDL partial interface definitions are implemented in C++ as |
356 # static member functions, which for instance members (non-static members) | 316 # static member functions, which for instance members (non-static members) |
357 # take *impl as their first argument | 317 # take *impl as their first argument |
358 if ('PartialInterfaceImplementedAs' in method.extended_attributes and | 318 if ('PartialInterfaceImplementedAs' in method.extended_attributes and |
359 'ImplementedInPrivateScript' not in method.extended_attributes and | |
360 not method.is_static): | 319 not method.is_static): |
361 cpp_arguments.append('*impl') | 320 cpp_arguments.append('*impl') |
362 cpp_arguments.extend(argument.name for argument in arguments) | 321 cpp_arguments.extend(argument.name for argument in arguments) |
363 | 322 |
364 if 'ImplementedInPrivateScript' in method.extended_attributes: | 323 if ('RaisesException' in method.extended_attributes or |
365 if method.idl_type.name != 'void': | |
366 cpp_arguments.append('&result') | |
367 elif ('RaisesException' in method.extended_attributes or | |
368 (method.is_constructor and | 324 (method.is_constructor and |
369 has_extended_attribute_value(interface, 'RaisesException', 'Construct
or'))): | 325 has_extended_attribute_value(interface, 'RaisesException', 'Construct
or'))): |
370 cpp_arguments.append('exceptionState') | 326 cpp_arguments.append('exceptionState') |
371 | 327 |
372 # If a method returns an IDL dictionary or union type, the return value is | 328 # If a method returns an IDL dictionary or union type, the return value is |
373 # passed as an argument to impl classes. | 329 # passed as an argument to impl classes. |
374 idl_type = method.idl_type | 330 idl_type = method.idl_type |
375 if idl_type and idl_type.use_output_parameter_for_result: | 331 if idl_type and idl_type.use_output_parameter_for_result: |
376 cpp_arguments.append('result') | 332 cpp_arguments.append('result') |
377 | 333 |
378 if method.name == 'Constructor': | 334 if method.name == 'Constructor': |
379 base_name = 'create' | 335 base_name = 'create' |
380 elif method.name == 'NamedConstructor': | 336 elif method.name == 'NamedConstructor': |
381 base_name = 'createForJSConstructor' | 337 base_name = 'createForJSConstructor' |
382 elif 'ImplementedInPrivateScript' in method.extended_attributes: | |
383 base_name = '%sMethod' % method.name | |
384 else: | 338 else: |
385 base_name = v8_utilities.cpp_name(method) | 339 base_name = v8_utilities.cpp_name(method) |
386 | 340 |
387 cpp_method_name = v8_utilities.scoped_name(interface, method, base_name) | 341 cpp_method_name = v8_utilities.scoped_name(interface, method, base_name) |
388 return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) | 342 return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) |
389 | 343 |
390 | 344 |
391 def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False)
: | 345 def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False)
: |
392 idl_type = method.idl_type | 346 idl_type = method.idl_type |
393 extended_attributes = method.extended_attributes | 347 extended_attributes = method.extended_attributes |
394 if not idl_type or idl_type.name == 'void': | 348 if not idl_type or idl_type.name == 'void': |
395 # Constructors and void methods don't have a return type | 349 # Constructors and void methods don't have a return type |
396 return None | 350 return None |
397 | 351 |
398 if ('ImplementedInPrivateScript' in extended_attributes and | |
399 not idl_type.is_wrapper_type and | |
400 not idl_type.is_basic_type): | |
401 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | |
402 | |
403 # [CallWith=ScriptState], [RaisesException] | 352 # [CallWith=ScriptState], [RaisesException] |
404 if use_local_result(method): | 353 if use_local_result(method): |
405 if idl_type.is_explicit_nullable: | 354 if idl_type.is_explicit_nullable: |
406 # result is of type Nullable<T> | 355 # result is of type Nullable<T> |
407 cpp_value = 'result.get()' | 356 cpp_value = 'result.get()' |
408 else: | 357 else: |
409 cpp_value = 'result' | 358 cpp_value = 'result' |
410 | 359 |
411 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' | 360 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' |
412 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w
rappable=script_wrappable, for_main_world=for_main_world, is_static=method.is_st
atic) | 361 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w
rappable=script_wrappable, for_main_world=for_main_world, is_static=method.is_st
atic) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 return method.idl_type and method.idl_type.name == 'Promise' | 457 return method.idl_type and method.idl_type.name == 'Promise' |
509 | 458 |
510 IdlOperation.returns_promise = property(method_returns_promise) | 459 IdlOperation.returns_promise = property(method_returns_promise) |
511 | 460 |
512 | 461 |
513 def argument_conversion_needs_exception_state(method, argument): | 462 def argument_conversion_needs_exception_state(method, argument): |
514 idl_type = argument.idl_type | 463 idl_type = argument.idl_type |
515 return (idl_type.v8_conversion_needs_exception_state or | 464 return (idl_type.v8_conversion_needs_exception_state or |
516 argument.is_variadic or | 465 argument.is_variadic or |
517 (method.returns_promise and idl_type.is_string_type)) | 466 (method.returns_promise and idl_type.is_string_type)) |
OLD | NEW |