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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 extended_attributes = argument.extended_attributes | 191 extended_attributes = argument.extended_attributes |
192 idl_type = argument.idl_type | 192 idl_type = argument.idl_type |
193 this_cpp_value = cpp_value(interface, method, index) | 193 this_cpp_value = cpp_value(interface, method, index) |
194 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | 194 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type |
195 | 195 |
196 type_checking_interface = ( | 196 type_checking_interface = ( |
197 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or | 197 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or |
198 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and | 198 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and |
199 idl_type.is_wrapper_type) | 199 idl_type.is_wrapper_type) |
200 | 200 |
| 201 restricted_float = ( |
| 202 has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted')
or |
| 203 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted')) |
| 204 |
201 if ('ImplementedInPrivateScript' in extended_attributes and | 205 if ('ImplementedInPrivateScript' in extended_attributes and |
202 not idl_type.is_wrapper_type and | 206 not idl_type.is_wrapper_type and |
203 not idl_type.is_basic_type): | 207 not idl_type.is_basic_type): |
204 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | 208 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') |
205 | 209 |
206 set_default_value = argument.set_default_value | 210 set_default_value = argument.set_default_value |
207 return { | 211 return { |
208 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut
es, | 212 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut
es, |
209 raw_type=True, | 213 raw_type=True, |
210 used_as_variadic_argument=argument.is
_variadic), | 214 used_as_variadic_argument=argument.is
_variadic), |
211 'cpp_value': this_cpp_value, | 215 'cpp_value': this_cpp_value, |
212 # FIXME: check that the default value's type is compatible with the argu
ment's | 216 # FIXME: check that the default value's type is compatible with the argu
ment's |
213 'set_default_value': set_default_value, | 217 'set_default_value': set_default_value, |
214 'enum_validation_expression': idl_type.enum_validation_expression, | 218 'enum_validation_expression': idl_type.enum_validation_expression, |
215 'handle': '%sHandle' % argument.name, | 219 'handle': '%sHandle' % argument.name, |
216 # FIXME: remove once [Default] removed and just use argument.default_val
ue | 220 # FIXME: remove once [Default] removed and just use argument.default_val
ue |
217 'has_default': 'Default' in extended_attributes or set_default_value, | 221 'has_default': 'Default' in extended_attributes or set_default_value, |
218 'has_type_checking_interface': type_checking_interface, | 222 'has_type_checking_interface': type_checking_interface, |
219 'has_type_checking_unrestricted': | |
220 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or | |
221 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and | |
222 idl_type.name in ('Float', 'Double'), | |
223 # Dictionary is special-cased, but arrays and sequences shouldn't be | 223 # Dictionary is special-cased, but arrays and sequences shouldn't be |
224 'idl_type': idl_type.base_type, | 224 'idl_type': idl_type.base_type, |
225 'idl_type_object': idl_type, | 225 'idl_type_object': idl_type, |
226 'index': index, | 226 'index': index, |
227 'is_callback_function': idl_type.is_callback_function, | 227 'is_callback_function': idl_type.is_callback_function, |
228 'is_callback_interface': idl_type.is_callback_interface, | 228 'is_callback_interface': idl_type.is_callback_interface, |
229 # FIXME: Remove generic 'Dictionary' special-casing | 229 # FIXME: Remove generic 'Dictionary' special-casing |
230 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio
nary', | 230 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio
nary', |
231 'is_nullable': idl_type.is_nullable, | 231 'is_nullable': idl_type.is_nullable, |
232 'is_optional': argument.is_optional, | 232 'is_optional': argument.is_optional, |
233 'is_variadic': argument.is_variadic, | 233 'is_variadic': argument.is_variadic, |
234 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 234 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
235 'is_wrapper_type': idl_type.is_wrapper_type, | 235 'is_wrapper_type': idl_type.is_wrapper_type, |
236 'name': argument.name, | 236 'name': argument.name, |
237 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( | 237 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
238 argument.name, isolate='scriptState->isolate()', | 238 argument.name, isolate='scriptState->isolate()', |
239 creation_context='scriptState->context()->Global()'), | 239 creation_context='scriptState->context()->Global()'), |
240 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion'
in extended_attributes, | 240 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion'
in extended_attributes, |
241 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 241 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
242 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | 242 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), |
243 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind
ex, return_promise=method.returns_promise), | 243 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind
ex, return_promise=method.returns_promise, restricted_float=restricted_float), |
244 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc
_type), | 244 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc
_type), |
245 } | 245 } |
246 | 246 |
247 | 247 |
248 def argument_declarations_for_private_script(interface, method): | 248 def argument_declarations_for_private_script(interface, method): |
249 argument_declarations = ['LocalFrame* frame'] | 249 argument_declarations = ['LocalFrame* frame'] |
250 argument_declarations.append('%s* holderImpl' % interface.name) | 250 argument_declarations.append('%s* holderImpl' % interface.name) |
251 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( | 251 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( |
252 used_as_rvalue_type=True), argument.name) for argument in method.argumen
ts]) | 252 used_as_rvalue_type=True), argument.name) for argument in method.argumen
ts]) |
253 if method.idl_type.name != 'void': | 253 if method.idl_type.name != 'void': |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 360 |
361 if return_promise: | 361 if return_promise: |
362 suffix += '_PROMISE' | 362 suffix += '_PROMISE' |
363 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())']) | 363 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())']) |
364 | 364 |
365 suffix += '_INTERNAL' | 365 suffix += '_INTERNAL' |
366 | 366 |
367 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) | 367 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) |
368 | 368 |
369 | 369 |
370 def v8_value_to_local_cpp_value(argument, index, return_promise=False): | 370 def v8_value_to_local_cpp_value(argument, index, return_promise=False, restricte
d_float=False): |
371 extended_attributes = argument.extended_attributes | 371 extended_attributes = argument.extended_attributes |
372 idl_type = argument.idl_type | 372 idl_type = argument.idl_type |
373 name = argument.name | 373 name = argument.name |
374 if argument.is_variadic: | 374 if argument.is_variadic: |
375 return v8_value_to_local_cpp_variadic_value(argument, index, return_prom
ise) | 375 return v8_value_to_local_cpp_variadic_value(argument, index, return_prom
ise) |
376 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]'
% index, | 376 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]'
% index, |
377 name, index=index, declare_varia
ble=False, | 377 name, index=index, declare_varia
ble=False, |
378 return_promise=return_promise) | 378 return_promise=return_promise, |
| 379 restricted_float=restricted_floa
t) |
379 | 380 |
380 | 381 |
381 ################################################################################ | 382 ################################################################################ |
382 # Auxiliary functions | 383 # Auxiliary functions |
383 ################################################################################ | 384 ################################################################################ |
384 | 385 |
385 # [NotEnumerable] | 386 # [NotEnumerable] |
386 def property_attributes(method): | 387 def property_attributes(method): |
387 extended_attributes = method.extended_attributes | 388 extended_attributes = method.extended_attributes |
388 property_attributes_list = [] | 389 property_attributes_list = [] |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 439 |
439 IdlOperation.returns_promise = property(method_returns_promise) | 440 IdlOperation.returns_promise = property(method_returns_promise) |
440 | 441 |
441 | 442 |
442 def argument_conversion_needs_exception_state(method, argument): | 443 def argument_conversion_needs_exception_state(method, argument): |
443 idl_type = argument.idl_type | 444 idl_type = argument.idl_type |
444 return (idl_type.v8_conversion_needs_exception_state or | 445 return (idl_type.v8_conversion_needs_exception_state or |
445 argument.is_variadic or | 446 argument.is_variadic or |
446 (method.returns_promise and (idl_type.is_string_type or | 447 (method.returns_promise and (idl_type.is_string_type or |
447 idl_type.is_enum))) | 448 idl_type.is_enum))) |
OLD | NEW |