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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 def use_local_result(method): | 55 def use_local_result(method): |
56 extended_attributes = method.extended_attributes | 56 extended_attributes = method.extended_attributes |
57 idl_type = method.idl_type | 57 idl_type = method.idl_type |
58 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or | 58 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or |
59 'ImplementedInPrivateScript' in extended_attributes or | 59 'ImplementedInPrivateScript' in extended_attributes or |
60 'RaisesException' in extended_attributes or | 60 'RaisesException' in extended_attributes or |
61 idl_type.is_union_type or | 61 idl_type.is_union_type or |
62 idl_type.is_explicit_nullable) | 62 idl_type.is_explicit_nullable) |
63 | 63 |
64 | 64 |
65 def use_output_parameter_for_result(idl_type): | |
66 return idl_type.is_dictionary or idl_type.is_union_type | |
67 | |
68 | |
69 def method_context(interface, method, is_visible=True): | 65 def method_context(interface, method, is_visible=True): |
70 arguments = method.arguments | 66 arguments = method.arguments |
71 extended_attributes = method.extended_attributes | 67 extended_attributes = method.extended_attributes |
72 idl_type = method.idl_type | 68 idl_type = method.idl_type |
73 is_static = method.is_static | 69 is_static = method.is_static |
74 name = method.name | 70 name = method.name |
75 | 71 |
76 idl_type.add_includes_for_type() | 72 idl_type.add_includes_for_type() |
77 this_cpp_value = cpp_value(interface, method, len(arguments)) | 73 this_cpp_value = cpp_value(interface, method, len(arguments)) |
78 | 74 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 argument for argument in arguments | 171 argument for argument in arguments |
176 if not argument.is_optional]), | 172 if not argument.is_optional]), |
177 'only_exposed_to_private_script': is_only_exposed_to_private_script, | 173 'only_exposed_to_private_script': is_only_exposed_to_private_script, |
178 'per_context_enabled_function': v8_utilities.per_context_enabled_functio
n_name(method), # [PerContextEnabled] | 174 'per_context_enabled_function': v8_utilities.per_context_enabled_functio
n_name(method), # [PerContextEnabled] |
179 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( | 175 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( |
180 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is
olate()', used_in_private_script=True), | 176 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is
olate()', used_in_private_script=True), |
181 'property_attributes': property_attributes(method), | 177 'property_attributes': property_attributes(method), |
182 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m
ethod), # [RuntimeEnabled] | 178 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m
ethod), # [RuntimeEnabled] |
183 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), | 179 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), |
184 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig
nature' in extended_attributes else 'defaultSignature', | 180 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig
nature' in extended_attributes else 'defaultSignature', |
185 'use_output_parameter_for_result': use_output_parameter_for_result(idl_t
ype), | 181 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res
ult, |
186 'use_local_result': use_local_result(method), | 182 'use_local_result': use_local_result(method), |
187 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 183 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
188 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | 184 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), |
189 'visible': is_visible, | 185 'visible': is_visible, |
190 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings], | 186 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings], |
191 } | 187 } |
192 | 188 |
193 | 189 |
194 def argument_context(interface, method, argument, index): | 190 def argument_context(interface, method, argument, index): |
195 extended_attributes = argument.extended_attributes | 191 extended_attributes = argument.extended_attributes |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 if method.idl_type.name != 'void': | 299 if method.idl_type.name != 'void': |
304 cpp_arguments.append('&result') | 300 cpp_arguments.append('&result') |
305 elif ('RaisesException' in method.extended_attributes or | 301 elif ('RaisesException' in method.extended_attributes or |
306 (method.is_constructor and | 302 (method.is_constructor and |
307 has_extended_attribute_value(interface, 'RaisesException', 'Constructor
'))): | 303 has_extended_attribute_value(interface, 'RaisesException', 'Constructor
'))): |
308 cpp_arguments.append('exceptionState') | 304 cpp_arguments.append('exceptionState') |
309 | 305 |
310 # If a method returns an IDL dictionary or union type, the return value is | 306 # If a method returns an IDL dictionary or union type, the return value is |
311 # passed as an argument to impl classes. | 307 # passed as an argument to impl classes. |
312 idl_type = method.idl_type | 308 idl_type = method.idl_type |
313 if idl_type and use_output_parameter_for_result(idl_type): | 309 if idl_type and idl_type.use_output_parameter_for_result: |
314 cpp_arguments.append('result') | 310 cpp_arguments.append('result') |
315 | 311 |
316 if method.name == 'Constructor': | 312 if method.name == 'Constructor': |
317 base_name = 'create' | 313 base_name = 'create' |
318 elif method.name == 'NamedConstructor': | 314 elif method.name == 'NamedConstructor': |
319 base_name = 'createForJSConstructor' | 315 base_name = 'createForJSConstructor' |
320 elif 'ImplementedInPrivateScript' in method.extended_attributes: | 316 elif 'ImplementedInPrivateScript' in method.extended_attributes: |
321 base_name = '%sMethod' % method.name | 317 base_name = '%sMethod' % method.name |
322 else: | 318 else: |
323 base_name = v8_utilities.cpp_name(method) | 319 base_name = v8_utilities.cpp_name(method) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 412 |
417 IdlOperation.returns_promise = property(method_returns_promise) | 413 IdlOperation.returns_promise = property(method_returns_promise) |
418 | 414 |
419 | 415 |
420 def argument_conversion_needs_exception_state(method, argument): | 416 def argument_conversion_needs_exception_state(method, argument): |
421 idl_type = argument.idl_type | 417 idl_type = argument.idl_type |
422 return (idl_type.v8_conversion_needs_exception_state or | 418 return (idl_type.v8_conversion_needs_exception_state or |
423 argument.is_variadic or | 419 argument.is_variadic or |
424 (method.returns_promise and (idl_type.is_string_type or | 420 (method.returns_promise and (idl_type.is_string_type or |
425 idl_type.is_enum))) | 421 idl_type.is_enum))) |
OLD | NEW |