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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 428 |
429 | 429 |
430 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
e_name, index=None): | 430 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
e_name, index=None): |
431 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" | 431 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" |
432 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, used_as_argument=True) | 432 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, used_as_argument=True) |
433 | 433 |
434 idl_type = idl_type.preprocessed_type | 434 idl_type = idl_type.preprocessed_type |
435 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i
ndex) | 435 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i
ndex) |
436 args = [this_cpp_type, variable_name, cpp_value] | 436 args = [this_cpp_type, variable_name, cpp_value] |
437 if idl_type.base_type == 'DOMString' and not idl_type.array_or_sequence_type
: | 437 if idl_type.base_type == 'DOMString' and not idl_type.array_or_sequence_type
: |
438 v8trycatch_void = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID' | 438 macro = 'TOSTRING_VOID' |
439 elif idl_type.is_integer_type: | 439 elif idl_type.is_integer_type: |
440 v8trycatch_void = 'V8TRYCATCH_EXCEPTION_VOID' | 440 macro = 'TONATIVE_VOID_EXCEPTIONSTATE' |
441 args.append('exceptionState') | 441 args.append('exceptionState') |
442 else: | 442 else: |
443 v8trycatch_void = 'V8TRYCATCH_VOID' | 443 macro = 'TONATIVE_VOID' |
444 | 444 |
445 return '%s(%s)' % (v8trycatch_void, ', '.join(args)) | 445 return '%s(%s)' % (macro, ', '.join(args)) |
446 | 446 |
447 IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 447 IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
448 IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 448 IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
449 | 449 |
450 | 450 |
451 ################################################################################ | 451 ################################################################################ |
452 # C++ -> V8 | 452 # C++ -> V8 |
453 ################################################################################ | 453 ################################################################################ |
454 | 454 |
455 def preprocess_idl_type(idl_type): | 455 def preprocess_idl_type(idl_type): |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='', extended_attributes=None): | 633 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='', extended_attributes=None): |
634 """Returns an expression that converts a C++ value to a V8 value.""" | 634 """Returns an expression that converts a C++ value to a V8 value.""" |
635 # the isolate parameter is needed for callback interfaces | 635 # the isolate parameter is needed for callback interfaces |
636 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) | 636 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) |
637 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) | 637 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) |
638 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 638 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
639 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) | 639 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) |
640 return statement | 640 return statement |
641 | 641 |
642 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value | 642 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value |
OLD | NEW |