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 |
57 idl_type = argument.idl_type | 58 idl_type = argument.idl_type |
58 base_type = idl_type.base_type | 59 base_type = idl_type.base_type |
59 | 60 |
60 return not( | 61 return not( |
61 # These cases are handled by separate code paths in the | 62 # These cases are handled by separate code paths in the |
62 # generate_argument() macro in Source/bindings/templates/methods.cpp. | 63 # generate_argument() macro in Source/bindings/templates/methods.cpp. |
63 idl_type.is_callback_interface or | 64 idl_type.is_callback_interface or |
64 base_type == 'SerializedScriptValue' or | 65 base_type == 'SerializedScriptValue' or |
65 (argument.is_variadic and idl_type.is_wrapper_type) or | 66 (argument.is_variadic and idl_type.is_wrapper_type) or |
66 # String and enumeration arguments converted using one of the | 67 # String and enumeration arguments converted using one of the |
67 # TOSTRING_* macros except for _PROMISE variants in | 68 # TOSTRING_* macros except for _PROMISE variants in |
68 # Source/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch. | 69 # Source/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch. |
69 ((base_type == 'DOMString' or idl_type.is_enum) and | 70 ((base_type == 'DOMString' or idl_type.is_enum) and |
70 not argument.is_variadic and | 71 not argument.is_variadic and |
71 not return_promise)) | 72 not return_promise) or |
| 73 # Conversion that take an ExceptionState& argument throw all their |
| 74 # 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 |
| 76 # Source/bindings/templates/methods.cpp, which *does* use a TryCatch. |
| 77 (idl_type.v8_conversion_needs_exception_state and |
| 78 not is_clamp)) |
72 | 79 |
73 | 80 |
74 def use_local_result(method): | 81 def use_local_result(method): |
75 extended_attributes = method.extended_attributes | 82 extended_attributes = method.extended_attributes |
76 idl_type = method.idl_type | 83 idl_type = method.idl_type |
77 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or | 84 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or |
78 'ImplementedInPrivateScript' in extended_attributes or | 85 'ImplementedInPrivateScript' in extended_attributes or |
79 'RaisesException' in extended_attributes or | 86 'RaisesException' in extended_attributes or |
80 idl_type.is_union_type or | 87 idl_type.is_union_type or |
81 idl_type.is_explicit_nullable) | 88 idl_type.is_explicit_nullable) |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 if argument.idl_type.is_dictionary: | 457 if argument.idl_type.is_dictionary: |
451 # We always create impl objects for IDL dictionaries. | 458 # We always create impl objects for IDL dictionaries. |
452 return '%s::create()' % argument.idl_type.base_type | 459 return '%s::create()' % argument.idl_type.base_type |
453 if not argument.default_value: | 460 if not argument.default_value: |
454 return None | 461 return None |
455 return argument.idl_type.literal_cpp_value(argument.default_value) | 462 return argument.idl_type.literal_cpp_value(argument.default_value) |
456 | 463 |
457 IdlTypeBase.union_arguments = None | 464 IdlTypeBase.union_arguments = None |
458 IdlUnionType.union_arguments = property(union_arguments) | 465 IdlUnionType.union_arguments = property(union_arguments) |
459 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | 466 IdlArgument.default_cpp_value = property(argument_default_cpp_value) |
OLD | NEW |