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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ | 47 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ |
48 'DoNotCheckSecurity', | 48 'DoNotCheckSecurity', |
49 'DoNotCheckSignature', | 49 'DoNotCheckSignature', |
50 'NotEnumerable', | 50 'NotEnumerable', |
51 'Unforgeable', | 51 'Unforgeable', |
52 ]) | 52 ]) |
53 | 53 |
54 | 54 |
55 def argument_needs_try_catch(method, argument): | 55 def argument_needs_try_catch(method, argument): |
56 return_promise = method.idl_type and method.idl_type.name == 'Promise' | 56 return_promise = method.idl_type and method.idl_type.name == 'Promise' |
57 is_clamp = 'Clamp' in argument.extended_attributes | |
58 idl_type = argument.idl_type | 57 idl_type = argument.idl_type |
59 base_type = idl_type.base_type | 58 base_type = idl_type.base_type |
60 | 59 |
61 return not( | 60 return not( |
62 # These cases are handled by separate code paths in the | 61 # These cases are handled by separate code paths in the |
63 # generate_argument() macro in Source/bindings/templates/methods.cpp. | 62 # generate_argument() macro in Source/bindings/templates/methods.cpp. |
64 idl_type.is_callback_interface or | 63 idl_type.is_callback_interface or |
65 base_type == 'SerializedScriptValue' or | 64 base_type == 'SerializedScriptValue' or |
66 (argument.is_variadic and idl_type.is_wrapper_type) or | 65 (argument.is_variadic and idl_type.is_wrapper_type) or |
67 # String and enumeration arguments converted using one of the | 66 # String and enumeration arguments converted using one of the |
68 # TOSTRING_* macros except for _PROMISE variants in | 67 # TOSTRING_* macros except for _PROMISE variants in |
69 # Source/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch. | 68 # Source/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch. |
70 ((base_type == 'DOMString' or idl_type.is_enum) and | 69 ((base_type == 'DOMString' or idl_type.is_enum) and |
71 not argument.is_variadic and | 70 not argument.is_variadic and |
72 not return_promise) or | 71 not return_promise) or |
73 # Conversion that take an ExceptionState& argument throw all their | 72 # Conversion that take an ExceptionState& argument throw all their |
74 # exceptions via it, and doesn't need/use a TryCatch, except if the | 73 # exceptions via it, and doesn't need/use a TryCatch, except if the |
75 # argument has [Clamp], in which case it uses a separate code path in | 74 # argument has [Clamp], in which case it uses a separate code path in |
76 # Source/bindings/templates/methods.cpp, which *does* use a TryCatch. | 75 # Source/bindings/templates/methods.cpp, which *does* use a TryCatch. |
77 (idl_type.v8_conversion_needs_exception_state and | 76 idl_type.v8_conversion_needs_exception_state) |
78 not is_clamp)) | |
79 | 77 |
80 | 78 |
81 def use_local_result(method): | 79 def use_local_result(method): |
82 extended_attributes = method.extended_attributes | 80 extended_attributes = method.extended_attributes |
83 idl_type = method.idl_type | 81 idl_type = method.idl_type |
84 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or | 82 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or |
85 'ImplementedInPrivateScript' in extended_attributes or | 83 'ImplementedInPrivateScript' in extended_attributes or |
86 'RaisesException' in extended_attributes or | 84 'RaisesException' in extended_attributes or |
87 idl_type.is_union_type or | 85 idl_type.is_union_type or |
88 idl_type.is_explicit_nullable) | 86 idl_type.is_explicit_nullable) |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and | 245 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and |
248 idl_type.is_wrapper_type, | 246 idl_type.is_wrapper_type, |
249 'has_type_checking_unrestricted': | 247 'has_type_checking_unrestricted': |
250 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or | 248 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or |
251 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and | 249 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and |
252 idl_type.name in ('Float', 'Double'), | 250 idl_type.name in ('Float', 'Double'), |
253 # Dictionary is special-cased, but arrays and sequences shouldn't be | 251 # Dictionary is special-cased, but arrays and sequences shouldn't be |
254 'idl_type': idl_type.base_type, | 252 'idl_type': idl_type.base_type, |
255 'idl_type_object': idl_type, | 253 'idl_type_object': idl_type, |
256 'index': index, | 254 'index': index, |
257 'is_clamp': 'Clamp' in extended_attributes, | |
258 'is_callback_interface': idl_type.is_callback_interface, | 255 'is_callback_interface': idl_type.is_callback_interface, |
259 'is_nullable': idl_type.is_nullable, | 256 'is_nullable': idl_type.is_nullable, |
260 'is_optional': argument.is_optional, | 257 'is_optional': argument.is_optional, |
261 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 258 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
262 'is_wrapper_type': idl_type.is_wrapper_type, | 259 'is_wrapper_type': idl_type.is_wrapper_type, |
263 'name': argument.name, | 260 'name': argument.name, |
264 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( | 261 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
265 argument.name, isolate='scriptState->isolate()', | 262 argument.name, isolate='scriptState->isolate()', |
266 creation_context='scriptState->context()->Global()'), | 263 creation_context='scriptState->context()->Global()'), |
267 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 264 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 if argument.idl_type.is_dictionary: | 454 if argument.idl_type.is_dictionary: |
458 # We always create impl objects for IDL dictionaries. | 455 # We always create impl objects for IDL dictionaries. |
459 return '%s::create()' % argument.idl_type.base_type | 456 return '%s::create()' % argument.idl_type.base_type |
460 if not argument.default_value: | 457 if not argument.default_value: |
461 return None | 458 return None |
462 return argument.idl_type.literal_cpp_value(argument.default_value) | 459 return argument.idl_type.literal_cpp_value(argument.default_value) |
463 | 460 |
464 IdlTypeBase.union_arguments = None | 461 IdlTypeBase.union_arguments = None |
465 IdlUnionType.union_arguments = property(union_arguments) | 462 IdlUnionType.union_arguments = property(union_arguments) |
466 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | 463 IdlArgument.default_cpp_value = property(argument_default_cpp_value) |
OLD | NEW |