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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 (base_type == 'DOMString' and not argument.is_variadic)) | 67 (base_type == 'DOMString' and not argument.is_variadic)) |
68 | 68 |
69 | 69 |
70 def use_local_result(method): | 70 def use_local_result(method): |
71 extended_attributes = method.extended_attributes | 71 extended_attributes = method.extended_attributes |
72 idl_type = method.idl_type | 72 idl_type = method.idl_type |
73 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or | 73 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or |
74 'ImplementedInPrivateScript' in extended_attributes or | 74 'ImplementedInPrivateScript' in extended_attributes or |
75 'RaisesException' in extended_attributes or | 75 'RaisesException' in extended_attributes or |
76 idl_type.is_union_type or | 76 idl_type.is_union_type or |
77 (idl_type.is_nullable and not idl_type.is_nullable_simple)) | 77 idl_type.is_explicit_nullable) |
78 | 78 |
79 | 79 |
80 def method_context(interface, method): | 80 def method_context(interface, method): |
81 arguments = method.arguments | 81 arguments = method.arguments |
82 extended_attributes = method.extended_attributes | 82 extended_attributes = method.extended_attributes |
83 idl_type = method.idl_type | 83 idl_type = method.idl_type |
84 is_static = method.is_static | 84 is_static = method.is_static |
85 name = method.name | 85 name = method.name |
86 | 86 |
87 idl_type.add_includes_for_type() | 87 idl_type.add_includes_for_type() |
(...skipping 25 matching lines...) Expand all Loading... |
113 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') | 113 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') |
114 | 114 |
115 is_check_security_for_frame = ( | 115 is_check_security_for_frame = ( |
116 'CheckSecurity' in interface.extended_attributes and | 116 'CheckSecurity' in interface.extended_attributes and |
117 'DoNotCheckSecurity' not in extended_attributes) | 117 'DoNotCheckSecurity' not in extended_attributes) |
118 is_raises_exception = 'RaisesException' in extended_attributes | 118 is_raises_exception = 'RaisesException' in extended_attributes |
119 | 119 |
120 arguments_need_try_catch = any(argument_needs_try_catch(argument) | 120 arguments_need_try_catch = any(argument_needs_try_catch(argument) |
121 for argument in arguments) | 121 for argument in arguments) |
122 | 122 |
123 is_nullable = idl_type.is_nullable and not idl_type.is_nullable_simple | |
124 | |
125 return { | 123 return { |
126 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] | 124 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] |
127 'arguments': [argument_context(interface, method, argument, index) | 125 'arguments': [argument_context(interface, method, argument, index) |
128 for index, argument in enumerate(arguments)], | 126 for index, argument in enumerate(arguments)], |
129 'argument_declarations_for_private_script': | 127 'argument_declarations_for_private_script': |
130 argument_declarations_for_private_script(interface, method), | 128 argument_declarations_for_private_script(interface, method), |
131 'arguments_need_try_catch': arguments_need_try_catch, | 129 'arguments_need_try_catch': arguments_need_try_catch, |
132 'conditional_string': v8_utilities.conditional_string(method), | 130 'conditional_string': v8_utilities.conditional_string(method), |
133 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type) | 131 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type) |
134 if is_nullable else idl_type.cpp_type), | 132 if idl_type.is_explicit_nullable else idl_type.cpp_type), |
135 'cpp_value': this_cpp_value, | 133 'cpp_value': this_cpp_value, |
136 'custom_registration_extended_attributes': | 134 'custom_registration_extended_attributes': |
137 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection( | 135 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection( |
138 extended_attributes.iterkeys()), | 136 extended_attributes.iterkeys()), |
139 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] | 137 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] |
140 'function_template': function_template(), | 138 'function_template': function_template(), |
141 'has_custom_registration': is_static or | 139 'has_custom_registration': is_static or |
142 v8_utilities.has_extended_attribute( | 140 v8_utilities.has_extended_attribute( |
143 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), | 141 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), |
144 'has_exception_state': | 142 'has_exception_state': |
145 is_raises_exception or | 143 is_raises_exception or |
146 is_check_security_for_frame or | 144 is_check_security_for_frame or |
147 interface.name == 'EventTarget' or # FIXME: merge with is_check_sec
urity_for_frame http://crbug.com/383699 | 145 interface.name == 'EventTarget' or # FIXME: merge with is_check_sec
urity_for_frame http://crbug.com/383699 |
148 any(argument for argument in arguments | 146 any(argument for argument in arguments |
149 if argument.idl_type.name == 'SerializedScriptValue' or | 147 if argument.idl_type.name == 'SerializedScriptValue' or |
150 argument.idl_type.may_raise_exception_on_conversion), | 148 argument.idl_type.may_raise_exception_on_conversion), |
151 'idl_type': idl_type.base_type, | 149 'idl_type': idl_type.base_type, |
152 'is_call_with_execution_context': has_extended_attribute_value(method, '
CallWith', 'ExecutionContext'), | 150 'is_call_with_execution_context': has_extended_attribute_value(method, '
CallWith', 'ExecutionContext'), |
153 'is_call_with_script_arguments': is_call_with_script_arguments, | 151 'is_call_with_script_arguments': is_call_with_script_arguments, |
154 'is_call_with_script_state': is_call_with_script_state, | 152 'is_call_with_script_state': is_call_with_script_state, |
155 'is_check_security_for_frame': is_check_security_for_frame, | 153 'is_check_security_for_frame': is_check_security_for_frame, |
156 'is_check_security_for_node': is_check_security_for_node, | 154 'is_check_security_for_node': is_check_security_for_node, |
157 'is_custom': 'Custom' in extended_attributes, | 155 'is_custom': 'Custom' in extended_attributes, |
158 'is_custom_element_callbacks': is_custom_element_callbacks, | 156 'is_custom_element_callbacks': is_custom_element_callbacks, |
159 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, | 157 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, |
160 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute
s, | 158 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute
s, |
| 159 'is_explicit_nullable': idl_type.is_explicit_nullable, |
161 'is_implemented_in_private_script': is_implemented_in_private_script, | 160 'is_implemented_in_private_script': is_implemented_in_private_script, |
162 'is_nullable': is_nullable, | |
163 'is_partial_interface_member': | 161 'is_partial_interface_member': |
164 'PartialInterfaceImplementedAs' in extended_attributes, | 162 'PartialInterfaceImplementedAs' in extended_attributes, |
165 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | 163 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, |
166 'is_raises_exception': is_raises_exception, | 164 'is_raises_exception': is_raises_exception, |
167 'is_read_only': 'Unforgeable' in extended_attributes, | 165 'is_read_only': 'Unforgeable' in extended_attributes, |
168 'is_static': is_static, | 166 'is_static': is_static, |
169 'use_local_result': use_local_result(method), | 167 'use_local_result': use_local_result(method), |
170 'is_variadic': arguments and arguments[-1].is_variadic, | 168 'is_variadic': arguments and arguments[-1].is_variadic, |
171 'measure_as': v8_utilities.measure_as(method), # [MeasureAs] | 169 'measure_as': v8_utilities.measure_as(method), # [MeasureAs] |
172 'name': name, | 170 'name': name, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 return None | 324 return None |
327 | 325 |
328 if ('ImplementedInPrivateScript' in extended_attributes and | 326 if ('ImplementedInPrivateScript' in extended_attributes and |
329 not idl_type.is_wrapper_type and | 327 not idl_type.is_wrapper_type and |
330 not idl_type.is_basic_type): | 328 not idl_type.is_basic_type): |
331 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | 329 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') |
332 | 330 |
333 release = False | 331 release = False |
334 # [CallWith=ScriptState], [RaisesException] | 332 # [CallWith=ScriptState], [RaisesException] |
335 if use_local_result(method): | 333 if use_local_result(method): |
336 if idl_type.is_nullable and not idl_type.is_nullable_simple: | 334 if idl_type.is_explicit_nullable: |
337 # result is of type Nullable<T> | 335 # result is of type Nullable<T> |
338 cpp_value = 'result.get()' | 336 cpp_value = 'result.get()' |
339 else: | 337 else: |
340 cpp_value = 'result' | 338 cpp_value = 'result' |
341 release = idl_type.release | 339 release = idl_type.release |
342 | 340 |
343 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' | 341 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' |
344 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w
rappable=script_wrappable, release=release, for_main_world=for_main_world) | 342 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w
rappable=script_wrappable, release=release, for_main_world=for_main_world) |
345 | 343 |
346 | 344 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 390 |
393 | 391 |
394 def argument_default_cpp_value(argument): | 392 def argument_default_cpp_value(argument): |
395 if not argument.default_value: | 393 if not argument.default_value: |
396 return None | 394 return None |
397 return argument.idl_type.literal_cpp_value(argument.default_value) | 395 return argument.idl_type.literal_cpp_value(argument.default_value) |
398 | 396 |
399 IdlType.union_arguments = property(lambda self: None) | 397 IdlType.union_arguments = property(lambda self: None) |
400 IdlUnionType.union_arguments = property(union_arguments) | 398 IdlUnionType.union_arguments = property(union_arguments) |
401 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | 399 IdlArgument.default_cpp_value = property(argument_default_cpp_value) |
OLD | NEW |