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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 expression_format = 'toNativeArray<{cpp_type}>({v8_value}, {index}, info
.GetIsolate())' | 410 expression_format = 'toNativeArray<{cpp_type}>({v8_value}, {index}, info
.GetIsolate())' |
411 expression = expression_format.format(array_or_sequence_type=array_or_sequen
ce_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_type, v8
_value=v8_value) | 411 expression = expression_format.format(array_or_sequence_type=array_or_sequen
ce_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_type, v8
_value=v8_value) |
412 return expression | 412 return expression |
413 | 413 |
414 | 414 |
415 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
e_name, index=None): | 415 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
e_name, index=None): |
416 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" | 416 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" |
417 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, used_as_argument=True) | 417 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, used_as_argument=True) |
418 | 418 |
419 idl_type = idl_type.preprocessed_type | 419 idl_type = idl_type.preprocessed_type |
| 420 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i
ndex) |
| 421 args = [this_cpp_type, variable_name, cpp_value] |
420 if idl_type.base_type == 'DOMString' and not idl_type.array_or_sequence_type
: | 422 if idl_type.base_type == 'DOMString' and not idl_type.array_or_sequence_type
: |
421 format_string = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID({cpp_type}, {varia
ble_name}, {cpp_value})' | 423 v8trycatch_void = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID' |
422 elif idl_type.is_integer_type: | 424 elif idl_type.is_integer_type: |
423 format_string = 'V8TRYCATCH_EXCEPTION_VOID({cpp_type}, {variable_name},
{cpp_value}, exceptionState)' | 425 v8trycatch_void = 'V8TRYCATCH_EXCEPTION_VOID' |
| 426 args.append('exceptionState') |
424 else: | 427 else: |
425 format_string = 'V8TRYCATCH_VOID({cpp_type}, {variable_name}, {cpp_value
})' | 428 v8trycatch_void = 'V8TRYCATCH_VOID' |
426 | 429 |
427 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i
ndex) | 430 return '%s(%s)' % (v8trycatch_void, ', '.join(args)) |
428 return format_string.format(cpp_type=this_cpp_type, cpp_value=cpp_value, var
iable_name=variable_name) | |
429 | 431 |
430 IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 432 IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
431 IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 433 IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
432 | 434 |
433 | 435 |
434 ################################################################################ | 436 ################################################################################ |
435 # C++ -> V8 | 437 # C++ -> V8 |
436 ################################################################################ | 438 ################################################################################ |
437 | 439 |
438 def preprocess_idl_type(idl_type): | 440 def preprocess_idl_type(idl_type): |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='', extended_attributes=None): | 617 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='', extended_attributes=None): |
616 """Returns an expression that converts a C++ value to a V8 value.""" | 618 """Returns an expression that converts a C++ value to a V8 value.""" |
617 # the isolate parameter is needed for callback interfaces | 619 # the isolate parameter is needed for callback interfaces |
618 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) | 620 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) |
619 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) | 621 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) |
620 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 622 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
621 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) | 623 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) |
622 return statement | 624 return statement |
623 | 625 |
624 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value | 626 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value |
OLD | NEW |