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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if is_static: | 81 if is_static: |
82 return 'functionTemplate' | 82 return 'functionTemplate' |
83 if 'Unforgeable' in extended_attributes: | 83 if 'Unforgeable' in extended_attributes: |
84 return 'instanceTemplate' | 84 return 'instanceTemplate' |
85 return 'prototypeTemplate' | 85 return 'prototypeTemplate' |
86 | 86 |
87 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi
th', 'ScriptArguments') | 87 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi
th', 'ScriptArguments') |
88 if is_call_with_script_arguments: | 88 if is_call_with_script_arguments: |
89 includes.update(['bindings/v8/ScriptCallStackFactory.h', | 89 includes.update(['bindings/v8/ScriptCallStackFactory.h', |
90 'core/inspector/ScriptArguments.h']) | 90 'core/inspector/ScriptArguments.h']) |
91 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith',
'ScriptState') | 91 is_call_with_script_state = has_extended_attribute_value( |
| 92 method, 'CallWith', 'ScriptState') |
92 if is_call_with_script_state: | 93 if is_call_with_script_state: |
93 includes.add('bindings/v8/ScriptState.h') | 94 includes.add('bindings/v8/ScriptState.h') |
94 is_check_security_for_node = 'CheckSecurity' in extended_attributes | 95 is_check_security_for_node = has_extended_attribute_value( |
| 96 method, 'CheckSecurity', 'Node') |
95 if is_check_security_for_node: | 97 if is_check_security_for_node: |
96 includes.add('bindings/v8/BindingSecurity.h') | 98 includes.add('bindings/v8/BindingSecurity.h') |
97 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s | 99 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s |
98 if is_custom_element_callbacks: | 100 if is_custom_element_callbacks: |
99 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') | 101 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') |
100 | 102 |
101 has_event_listener_argument = any( | 103 has_event_listener_argument = any( |
102 argument for argument in arguments | 104 argument for argument in arguments |
103 if argument.idl_type.name == 'EventListener') | 105 if argument.idl_type.name == 'EventListenerOrNull') |
104 is_check_security_for_frame = ( | 106 is_check_security_for_frame = ( |
105 'CheckSecurity' in interface.extended_attributes and | 107 has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and |
106 'DoNotCheckSecurity' not in extended_attributes) | 108 'DoNotCheckSecurity' not in extended_attributes) |
107 is_raises_exception = 'RaisesException' in extended_attributes | 109 is_raises_exception = 'RaisesException' in extended_attributes |
108 | 110 |
109 arguments_need_try_catch = any(argument_needs_try_catch(argument) | 111 arguments_need_try_catch = any(argument_needs_try_catch(argument) |
110 for argument in arguments) | 112 for argument in arguments) |
111 | 113 |
112 return { | 114 return { |
113 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] | 115 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] |
114 'arguments': [argument_context(interface, method, argument, index) | 116 'arguments': [argument_context(interface, method, argument, index) |
115 for index, argument in enumerate(arguments)], | 117 for index, argument in enumerate(arguments)], |
116 'arguments_need_try_catch': arguments_need_try_catch, | 118 'arguments_need_try_catch': arguments_need_try_catch, |
117 'conditional_string': v8_utilities.conditional_string(method), | 119 'conditional_string': v8_utilities.conditional_string(method), |
118 'cpp_type': idl_type.cpp_type, | 120 'cpp_type': idl_type.cpp_type, |
119 'cpp_value': this_cpp_value, | 121 'cpp_value': this_cpp_value, |
120 'custom_registration_extended_attributes': | 122 'custom_registration_extended_attributes': |
121 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection( | 123 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection( |
122 extended_attributes.iterkeys()), | 124 extended_attributes.iterkeys()), |
123 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] | 125 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] |
124 'function_template': function_template(), | 126 'function_template': function_template(), |
125 'has_custom_registration': is_static or | 127 'has_custom_registration': is_static or |
126 v8_utilities.has_extended_attribute( | 128 v8_utilities.has_extended_attribute( |
127 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), | 129 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), |
128 'has_event_listener_argument': has_event_listener_argument, | 130 'has_event_listener_argument': has_event_listener_argument, |
129 'has_exception_state': | 131 'has_exception_state': |
130 has_event_listener_argument or | 132 interface.name == 'EventTarget' or # FIXME: merge with is_check_sec
urity_for_frame http://crbug.com/383699 |
131 is_raises_exception or | 133 is_raises_exception or |
132 is_check_security_for_frame or | 134 is_check_security_for_frame or |
133 any(argument for argument in arguments | 135 any(argument for argument in arguments |
134 if argument.idl_type.name == 'SerializedScriptValue' or | 136 if argument.idl_type.name == 'SerializedScriptValue' or |
135 argument.idl_type.may_raise_exception_on_conversion), | 137 argument.idl_type.may_raise_exception_on_conversion), |
136 'idl_type': idl_type.base_type, | 138 'idl_type': idl_type.base_type, |
137 'is_call_with_execution_context': has_extended_attribute_value(method, '
CallWith', 'ExecutionContext'), | 139 'is_call_with_execution_context': has_extended_attribute_value(method, '
CallWith', 'ExecutionContext'), |
138 'is_call_with_script_arguments': is_call_with_script_arguments, | 140 'is_call_with_script_arguments': is_call_with_script_arguments, |
139 'is_call_with_script_state': is_call_with_script_state, | 141 'is_call_with_script_state': is_call_with_script_state, |
140 'is_check_security_for_frame': is_check_security_for_frame, | 142 'is_check_security_for_frame': is_check_security_for_frame, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 used_as_argument=True, | 183 used_as_argument=True, |
182 used_as_variadic_argument=argument.is
_variadic), | 184 used_as_variadic_argument=argument.is
_variadic), |
183 'cpp_value': this_cpp_value, | 185 'cpp_value': this_cpp_value, |
184 # FIXME: check that the default value's type is compatible with the argu
ment's | 186 # FIXME: check that the default value's type is compatible with the argu
ment's |
185 'default_value': str(argument.default_value) if argument.default_value e
lse None, | 187 'default_value': str(argument.default_value) if argument.default_value e
lse None, |
186 'enum_validation_expression': idl_type.enum_validation_expression, | 188 'enum_validation_expression': idl_type.enum_validation_expression, |
187 # FIXME: remove once [Default] removed and just use argument.default_val
ue | 189 # FIXME: remove once [Default] removed and just use argument.default_val
ue |
188 'has_default': 'Default' in extended_attributes or argument.default_valu
e, | 190 'has_default': 'Default' in extended_attributes or argument.default_valu
e, |
189 'has_event_listener_argument': any( | 191 'has_event_listener_argument': any( |
190 argument_so_far for argument_so_far in method.arguments[:index] | 192 argument_so_far for argument_so_far in method.arguments[:index] |
191 if argument_so_far.idl_type.name == 'EventListener'), | 193 if argument_so_far.idl_type.name == 'EventListenerOrNull'), |
192 'has_type_checking_interface': | 194 'has_type_checking_interface': |
193 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface'
) or | 195 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface'
) or |
194 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and | 196 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and |
195 idl_type.is_wrapper_type, | 197 idl_type.is_wrapper_type, |
196 'has_type_checking_unrestricted': | 198 'has_type_checking_unrestricted': |
197 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or | 199 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or |
198 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and | 200 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and |
199 idl_type.name in ('Float', 'Double'), | 201 idl_type.name in ('Float', 'Double'), |
200 # Dictionary is special-cased, but arrays and sequences shouldn't be | 202 # Dictionary is special-cased, but arrays and sequences shouldn't be |
201 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, | 203 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, |
(...skipping 13 matching lines...) Expand all Loading... |
215 } | 217 } |
216 | 218 |
217 | 219 |
218 ################################################################################ | 220 ################################################################################ |
219 # Value handling | 221 # Value handling |
220 ################################################################################ | 222 ################################################################################ |
221 | 223 |
222 def cpp_value(interface, method, number_of_arguments): | 224 def cpp_value(interface, method, number_of_arguments): |
223 def cpp_argument(argument): | 225 def cpp_argument(argument): |
224 idl_type = argument.idl_type | 226 idl_type = argument.idl_type |
225 if idl_type.name == 'EventListener': | 227 if idl_type.name == 'EventListenerOrNull': |
226 if (interface.name == 'EventTarget' and | 228 if (interface.name == 'EventTarget' and |
227 method.name == 'removeEventListener'): | 229 method.name == 'removeEventListener'): |
228 # FIXME: remove this special case by moving get() into | 230 # FIXME: remove this special case by moving get() into |
229 # EventTarget::removeEventListener | 231 # EventTarget::removeEventListener |
230 return '%s.get()' % argument.name | 232 return '%s.get()' % argument.name |
231 return argument.name | 233 return argument.name |
232 if (idl_type.is_callback_interface or | 234 if (idl_type.is_callback_interface or |
233 idl_type.name in ['NodeFilter', 'XPathNSResolver']): | 235 idl_type.name in ['NodeFilter', 'XPathNSResolver']): |
234 # FIXME: remove this special case | 236 # FIXME: remove this special case |
235 return '%s.release()' % argument.name | 237 return '%s.release()' % argument.name |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 340 |
339 | 341 |
340 def union_arguments(idl_type): | 342 def union_arguments(idl_type): |
341 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" | 343 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" |
342 return [arg | 344 return [arg |
343 for i in range(len(idl_type.member_types)) | 345 for i in range(len(idl_type.member_types)) |
344 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 346 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
345 | 347 |
346 IdlType.union_arguments = property(lambda self: None) | 348 IdlType.union_arguments = property(lambda self: None) |
347 IdlUnionType.union_arguments = property(union_arguments) | 349 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |