| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 # Methods with any of these require custom method registration code in the | 45 # Methods with any of these require custom method registration code in the |
| 46 # interface's configure*Template() function. | 46 # interface's configure*Template() function. |
| 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(argument, return_promise): | 55 def argument_needs_try_catch(method, argument): |
| 56 return_promise = method.idl_type and method.idl_type.name == 'Promise' |
| 56 idl_type = argument.idl_type | 57 idl_type = argument.idl_type |
| 57 base_type = idl_type.base_type | 58 base_type = idl_type.base_type |
| 58 | 59 |
| 59 return not ( | 60 return not( |
| 60 # These cases are handled by separate code paths in the | 61 # These cases are handled by separate code paths in the |
| 61 # generate_argument() macro in Source/bindings/templates/methods.cpp. | 62 # generate_argument() macro in Source/bindings/templates/methods.cpp. |
| 62 idl_type.is_callback_interface or | 63 idl_type.is_callback_interface or |
| 63 base_type == 'SerializedScriptValue' or | 64 base_type == 'SerializedScriptValue' or |
| 64 (argument.is_variadic and idl_type.is_wrapper_type) or | 65 (argument.is_variadic and idl_type.is_wrapper_type) or |
| 65 # String and enumeration arguments converted using one of the | 66 # String and enumeration arguments converted using one of the |
| 66 # TOSTRING_* macros except for _PROMISE variants in | 67 # TOSTRING_* macros except for _PROMISE variants in |
| 67 # 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. |
| 68 (base_type == 'DOMString' and not argument.is_variadic and | 69 ((base_type == 'DOMString' or idl_type.is_enum) and |
| 70 not argument.is_variadic and |
| 69 not return_promise)) | 71 not return_promise)) |
| 70 | 72 |
| 71 | 73 |
| 72 def use_local_result(method): | 74 def use_local_result(method): |
| 73 extended_attributes = method.extended_attributes | 75 extended_attributes = method.extended_attributes |
| 74 idl_type = method.idl_type | 76 idl_type = method.idl_type |
| 75 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or | 77 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or |
| 76 'ImplementedInPrivateScript' in extended_attributes or | 78 'ImplementedInPrivateScript' in extended_attributes or |
| 77 'RaisesException' in extended_attributes or | 79 'RaisesException' in extended_attributes or |
| 78 idl_type.is_union_type or | 80 idl_type.is_union_type or |
| 79 idl_type.is_explicit_nullable) | 81 idl_type.is_explicit_nullable) |
| 80 | 82 |
| 81 | 83 |
| 82 def method_context(interface, method): | 84 def method_context(interface, method): |
| 83 arguments = method.arguments | 85 arguments = method.arguments |
| 84 extended_attributes = method.extended_attributes | 86 extended_attributes = method.extended_attributes |
| 85 idl_type = method.idl_type | 87 idl_type = method.idl_type |
| 86 is_static = method.is_static | 88 is_static = method.is_static |
| 87 name = method.name | 89 name = method.name |
| 88 return_promise = idl_type.name == 'Promise' | |
| 89 | 90 |
| 90 idl_type.add_includes_for_type() | 91 idl_type.add_includes_for_type() |
| 91 this_cpp_value = cpp_value(interface, method, len(arguments)) | 92 this_cpp_value = cpp_value(interface, method, len(arguments)) |
| 92 | 93 |
| 93 def function_template(): | 94 def function_template(): |
| 94 if is_static: | 95 if is_static: |
| 95 return 'functionTemplate' | 96 return 'functionTemplate' |
| 96 if 'Unforgeable' in extended_attributes: | 97 if 'Unforgeable' in extended_attributes: |
| 97 return 'instanceTemplate' | 98 return 'instanceTemplate' |
| 98 return 'prototypeTemplate' | 99 return 'prototypeTemplate' |
| (...skipping 20 matching lines...) Expand all Loading... |
| 119 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s | 120 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s |
| 120 if is_custom_element_callbacks: | 121 if is_custom_element_callbacks: |
| 121 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') | 122 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') |
| 122 | 123 |
| 123 is_check_security_for_frame = ( | 124 is_check_security_for_frame = ( |
| 124 'CheckSecurity' in interface.extended_attributes and | 125 'CheckSecurity' in interface.extended_attributes and |
| 125 'DoNotCheckSecurity' not in extended_attributes) | 126 'DoNotCheckSecurity' not in extended_attributes) |
| 126 is_raises_exception = 'RaisesException' in extended_attributes | 127 is_raises_exception = 'RaisesException' in extended_attributes |
| 127 | 128 |
| 128 arguments_need_try_catch = ( | 129 arguments_need_try_catch = ( |
| 129 any(argument_needs_try_catch(argument, return_promise) | 130 any(argument_needs_try_catch(method, argument) |
| 130 for argument in arguments)) | 131 for argument in arguments)) |
| 131 | 132 |
| 132 return { | 133 return { |
| 133 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] | 134 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] |
| 134 'arguments': [argument_context(interface, method, argument, index) | 135 'arguments': [argument_context(interface, method, argument, index) |
| 135 for index, argument in enumerate(arguments)], | 136 for index, argument in enumerate(arguments)], |
| 136 'argument_declarations_for_private_script': | 137 'argument_declarations_for_private_script': |
| 137 argument_declarations_for_private_script(interface, method), | 138 argument_declarations_for_private_script(interface, method), |
| 138 'arguments_need_try_catch': arguments_need_try_catch, | 139 'arguments_need_try_catch': arguments_need_try_catch, |
| 139 'conditional_string': v8_utilities.conditional_string(method), | 140 'conditional_string': v8_utilities.conditional_string(method), |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 438 |
| 438 | 439 |
| 439 def argument_default_cpp_value(argument): | 440 def argument_default_cpp_value(argument): |
| 440 if not argument.default_value: | 441 if not argument.default_value: |
| 441 return None | 442 return None |
| 442 return argument.idl_type.literal_cpp_value(argument.default_value) | 443 return argument.idl_type.literal_cpp_value(argument.default_value) |
| 443 | 444 |
| 444 IdlTypeBase.union_arguments = None | 445 IdlTypeBase.union_arguments = None |
| 445 IdlUnionType.union_arguments = property(union_arguments) | 446 IdlUnionType.union_arguments = property(union_arguments) |
| 446 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | 447 IdlArgument.default_cpp_value = property(argument_default_cpp_value) |
| OLD | NEW |