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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | 184 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), |
185 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings], | 185 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings], |
186 } | 186 } |
187 | 187 |
188 | 188 |
189 def argument_context(interface, method, argument, index): | 189 def argument_context(interface, method, argument, index): |
190 extended_attributes = argument.extended_attributes | 190 extended_attributes = argument.extended_attributes |
191 idl_type = argument.idl_type | 191 idl_type = argument.idl_type |
192 this_cpp_value = cpp_value(interface, method, index) | 192 this_cpp_value = cpp_value(interface, method, index) |
193 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | 193 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type |
| 194 type_checking_interface = (has_extended_attribute_value(interface, 'TypeChec
king', 'Interface') or has_extended_attribute_value(method, 'TypeChecking', 'Int
erface')) and idl_type.is_wrapper_type |
194 | 195 |
195 if ('ImplementedInPrivateScript' in extended_attributes and | 196 if ('ImplementedInPrivateScript' in extended_attributes and |
196 not idl_type.is_wrapper_type and | 197 not idl_type.is_wrapper_type and |
197 not idl_type.is_basic_type): | 198 not idl_type.is_basic_type): |
198 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | 199 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') |
199 | 200 |
200 default_cpp_value = argument.default_cpp_value | 201 default_cpp_value = argument.default_cpp_value |
201 return { | 202 return { |
202 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut
es, | 203 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut
es, |
203 raw_type=True, | 204 raw_type=True, |
(...skipping 23 matching lines...) Expand all Loading... |
227 'is_nullable': idl_type.is_nullable, | 228 'is_nullable': idl_type.is_nullable, |
228 'is_optional': argument.is_optional, | 229 'is_optional': argument.is_optional, |
229 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 230 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
230 'is_wrapper_type': idl_type.is_wrapper_type, | 231 'is_wrapper_type': idl_type.is_wrapper_type, |
231 'name': argument.name, | 232 'name': argument.name, |
232 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( | 233 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
233 argument.name, isolate='scriptState->isolate()', | 234 argument.name, isolate='scriptState->isolate()', |
234 creation_context='scriptState->context()->Global()'), | 235 creation_context='scriptState->context()->Global()'), |
235 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 236 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
236 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | 237 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), |
237 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind
ex, return_promise=method.returns_promise), | 238 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind
ex, type_checking_interface, return_promise=method.returns_promise), |
238 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc
_type), | 239 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc
_type), |
| 240 'type_checked_already': False, |
239 } | 241 } |
240 | 242 |
241 | 243 |
242 def argument_declarations_for_private_script(interface, method): | 244 def argument_declarations_for_private_script(interface, method): |
243 argument_declarations = ['LocalFrame* frame'] | 245 argument_declarations = ['LocalFrame* frame'] |
244 argument_declarations.append('%s* holderImpl' % interface.name) | 246 argument_declarations.append('%s* holderImpl' % interface.name) |
245 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( | 247 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( |
246 used_as_rvalue_type=True), argument.name) for argument in method.argumen
ts]) | 248 used_as_rvalue_type=True), argument.name) for argument in method.argumen
ts]) |
247 if method.idl_type.name != 'void': | 249 if method.idl_type.name != 'void': |
248 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu
lt')) | 250 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu
lt')) |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 357 |
356 if return_promise: | 358 if return_promise: |
357 suffix += '_PROMISE' | 359 suffix += '_PROMISE' |
358 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())']) | 360 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())']) |
359 | 361 |
360 suffix += '_INTERNAL' | 362 suffix += '_INTERNAL' |
361 | 363 |
362 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) | 364 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) |
363 | 365 |
364 | 366 |
365 def v8_value_to_local_cpp_value(argument, index, return_promise=False): | 367 def v8_value_to_local_cpp_value(argument, index, type_checked, return_promise=Fa
lse): |
366 extended_attributes = argument.extended_attributes | 368 extended_attributes = argument.extended_attributes |
367 idl_type = argument.idl_type | 369 idl_type = argument.idl_type |
368 name = argument.name | 370 name = argument.name |
369 if argument.is_variadic: | 371 if argument.is_variadic: |
370 return v8_value_to_local_cpp_variadic_value(argument, index, return_prom
ise) | 372 return v8_value_to_local_cpp_variadic_value(argument, index, return_prom
ise) |
371 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]'
% index, | 373 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]'
% index, |
372 name, index=index, declare_varia
ble=False, return_promise=return_promise) | 374 name, type_checked, index=index,
declare_variable=False, return_promise=return_promise) |
373 | 375 |
374 | 376 |
375 ################################################################################ | 377 ################################################################################ |
376 # Auxiliary functions | 378 # Auxiliary functions |
377 ################################################################################ | 379 ################################################################################ |
378 | 380 |
379 # [NotEnumerable] | 381 # [NotEnumerable] |
380 def property_attributes(method): | 382 def property_attributes(method): |
381 extended_attributes = method.extended_attributes | 383 extended_attributes = method.extended_attributes |
382 property_attributes_list = [] | 384 property_attributes_list = [] |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 443 |
442 IdlOperation.returns_promise = property(method_returns_promise) | 444 IdlOperation.returns_promise = property(method_returns_promise) |
443 | 445 |
444 | 446 |
445 def argument_conversion_needs_exception_state(method, argument): | 447 def argument_conversion_needs_exception_state(method, argument): |
446 idl_type = argument.idl_type | 448 idl_type = argument.idl_type |
447 return (idl_type.v8_conversion_needs_exception_state or | 449 return (idl_type.v8_conversion_needs_exception_state or |
448 argument.is_variadic or | 450 argument.is_variadic or |
449 (method.returns_promise and (idl_type.is_string_type or | 451 (method.returns_promise and (idl_type.is_string_type or |
450 idl_type.is_enum))) | 452 idl_type.is_enum))) |
OLD | NEW |