Chromium Code Reviews| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 'number_of_arguments': len(arguments), | 168 'number_of_arguments': len(arguments), |
| 169 'number_of_required_arguments': len([ | 169 'number_of_required_arguments': len([ |
| 170 argument for argument in arguments | 170 argument for argument in arguments |
| 171 if not (argument.is_optional or argument.is_variadic)]), | 171 if not (argument.is_optional or argument.is_variadic)]), |
| 172 'number_of_required_or_variadic_arguments': len([ | 172 'number_of_required_or_variadic_arguments': len([ |
| 173 argument for argument in arguments | 173 argument for argument in arguments |
| 174 if not argument.is_optional]), | 174 if not argument.is_optional]), |
| 175 'only_exposed_to_private_script': is_only_exposed_to_private_script, | 175 'only_exposed_to_private_script': is_only_exposed_to_private_script, |
| 176 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(method), # [PerContextEnabled] | 176 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(method), # [PerContextEnabled] |
| 177 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value( | 177 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value( |
| 178 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', used_in_private_script=True), | 178 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', bailout_return_value='false'), |
| 179 'property_attributes': property_attributes(interface, method), | 179 'property_attributes': property_attributes(interface, method), |
| 180 'returns_promise': method.returns_promise, | |
| 180 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled] | 181 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled] |
| 181 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), | 182 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), |
| 182 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig nature' in extended_attributes else 'defaultSignature', | 183 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig nature' in extended_attributes else 'defaultSignature', |
| 183 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res ult, | 184 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res ult, |
| 184 'use_local_result': use_local_result(method), | 185 'use_local_result': use_local_result(method), |
| 185 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), | 186 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), |
| 186 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), | 187 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), |
| 187 'visible': is_visible, | 188 'visible': is_visible, |
| 188 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings], | 189 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings], |
| 189 } | 190 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 'is_variadic': argument.is_variadic, | 236 'is_variadic': argument.is_variadic, |
| 236 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 237 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
| 237 'is_wrapper_type': idl_type.is_wrapper_type, | 238 'is_wrapper_type': idl_type.is_wrapper_type, |
| 238 'name': argument.name, | 239 'name': argument.name, |
| 239 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( | 240 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
| 240 argument.name, isolate='scriptState->isolate()', | 241 argument.name, isolate='scriptState->isolate()', |
| 241 creation_context='scriptState->context()->Global()'), | 242 creation_context='scriptState->context()->Global()'), |
| 242 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes, | 243 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes, |
| 243 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), | 244 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), |
| 244 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), | 245 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), |
| 245 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex, return_promise=method.returns_promise, restricted_float=restricted_float), | 246 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(method, argum ent, index, restricted_float=restricted_float), |
| 246 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type), | 247 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type), |
| 247 } | 248 } |
| 248 | 249 |
| 249 | 250 |
| 250 def argument_declarations_for_private_script(interface, method): | 251 def argument_declarations_for_private_script(interface, method): |
| 251 argument_declarations = ['LocalFrame* frame'] | 252 argument_declarations = ['LocalFrame* frame'] |
| 252 argument_declarations.append('%s* holderImpl' % interface.name) | 253 argument_declarations.append('%s* holderImpl' % interface.name) |
| 253 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( | 254 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( |
| 254 used_as_rvalue_type=True), argument.name) for argument in method.argumen ts]) | 255 used_as_rvalue_type=True), argument.name) for argument in method.argumen ts]) |
| 255 if method.idl_type.name != 'void': | 256 if method.idl_type.name != 'void': |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 # result is of type Nullable<T> | 341 # result is of type Nullable<T> |
| 341 cpp_value = 'result.get()' | 342 cpp_value = 'result.get()' |
| 342 else: | 343 else: |
| 343 cpp_value = 'result' | 344 cpp_value = 'result' |
| 344 release = idl_type.release | 345 release = idl_type.release |
| 345 | 346 |
| 346 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else '' | 347 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else '' |
| 347 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w rappable=script_wrappable, release=release, for_main_world=for_main_world) | 348 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w rappable=script_wrappable, release=release, for_main_world=for_main_world) |
| 348 | 349 |
| 349 | 350 |
| 350 def v8_value_to_local_cpp_variadic_value(argument, index, return_promise): | 351 def v8_value_to_local_cpp_variadic_value(method, argument, index, return_promise ): |
| 351 assert argument.is_variadic | 352 assert argument.is_variadic |
| 352 idl_type = argument.idl_type | 353 idl_type = argument.idl_type |
| 353 | 354 |
| 354 suffix = '' | 355 if method.returns_promise: |
| 356 helper = 'convertAndCheck' | |
| 357 else: | |
| 358 helper = 'convertAndThrow' | |
| 355 | 359 |
| 356 macro = 'TONATIVE_VOID_EXCEPTIONSTATE' | 360 macro = 'TONATIVE_CONVERT' |
| 357 macro_args = [ | 361 arguments = [ |
| 358 argument.name, | 362 '%s(%s = toImplArguments<%s>(info, %s, exceptionState), exceptionState)' % (helper, argument.name, idl_type.cpp_type, index), |
| 359 'toImplArguments<%s>(info, %s, exceptionState)' % (idl_type.cpp_type, in dex), | 363 'return' |
| 360 'exceptionState', | |
| 361 ] | 364 ] |
| 362 | 365 |
| 363 if return_promise: | 366 return '%s(%s)' % (macro, ', '.join(arguments)) |
|
bashi
2015/02/23 23:44:06
Just use 'TONATIVE_CONVERT' and remove |macro|?
| |
| 364 suffix += '_PROMISE' | |
| 365 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())']) | |
| 366 | |
| 367 suffix += '_INTERNAL' | |
| 368 | |
| 369 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) | |
| 370 | 367 |
| 371 | 368 |
| 372 def v8_value_to_local_cpp_value(argument, index, return_promise=False, restricte d_float=False): | 369 def v8_value_to_local_cpp_value(method, argument, index, return_promise=False, r estricted_float=False): |
| 373 extended_attributes = argument.extended_attributes | 370 extended_attributes = argument.extended_attributes |
| 374 idl_type = argument.idl_type | 371 idl_type = argument.idl_type |
| 375 name = argument.name | 372 name = argument.name |
| 376 if argument.is_variadic: | 373 if argument.is_variadic: |
| 377 return v8_value_to_local_cpp_variadic_value(argument, index, return_prom ise) | 374 return v8_value_to_local_cpp_variadic_value(method, argument, index, ret urn_promise) |
| 378 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]' % index, | 375 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]' % index, |
| 379 name, index=index, declare_varia ble=False, | 376 name, index=index, declare_varia ble=False, |
| 380 return_promise=return_promise, | 377 use_exception_state=method.retur ns_promise, |
| 381 restricted_float=restricted_floa t) | 378 restricted_float=restricted_floa t) |
| 382 | 379 |
| 383 | 380 |
| 384 ################################################################################ | 381 ################################################################################ |
| 385 # Auxiliary functions | 382 # Auxiliary functions |
| 386 ################################################################################ | 383 ################################################################################ |
| 387 | 384 |
| 388 # [NotEnumerable] | 385 # [NotEnumerable] |
| 389 def property_attributes(interface, method): | 386 def property_attributes(interface, method): |
| 390 extended_attributes = method.extended_attributes | 387 extended_attributes = method.extended_attributes |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 | 445 |
| 449 IdlOperation.returns_promise = property(method_returns_promise) | 446 IdlOperation.returns_promise = property(method_returns_promise) |
| 450 | 447 |
| 451 | 448 |
| 452 def argument_conversion_needs_exception_state(method, argument): | 449 def argument_conversion_needs_exception_state(method, argument): |
| 453 idl_type = argument.idl_type | 450 idl_type = argument.idl_type |
| 454 return (idl_type.v8_conversion_needs_exception_state or | 451 return (idl_type.v8_conversion_needs_exception_state or |
| 455 argument.is_variadic or | 452 argument.is_variadic or |
| 456 (method.returns_promise and (idl_type.is_string_type or | 453 (method.returns_promise and (idl_type.is_string_type or |
| 457 idl_type.is_enum))) | 454 idl_type.is_enum))) |
| OLD | NEW |