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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 if idl_type.base_type == 'DOMString' and not idl_type.array_or_sequence_type : | 407 if idl_type.base_type == 'DOMString' and not idl_type.array_or_sequence_type : |
408 format_string = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID({cpp_type}, {varia ble_name}, {cpp_value})' | 408 format_string = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID({cpp_type}, {varia ble_name}, {cpp_value})' |
409 elif idl_type.is_integer_type: | 409 elif idl_type.is_integer_type: |
410 format_string = 'V8TRYCATCH_EXCEPTION_VOID({cpp_type}, {variable_name}, {cpp_value}, exceptionState)' | 410 format_string = 'V8TRYCATCH_EXCEPTION_VOID({cpp_type}, {variable_name}, {cpp_value}, exceptionState)' |
411 else: | 411 else: |
412 format_string = 'V8TRYCATCH_VOID({cpp_type}, {variable_name}, {cpp_value })' | 412 format_string = 'V8TRYCATCH_VOID({cpp_type}, {variable_name}, {cpp_value })' |
413 | 413 |
414 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i ndex) | 414 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i ndex) |
415 return format_string.format(cpp_type=this_cpp_type, cpp_value=cpp_value, var iable_name=variable_name) | 415 return format_string.format(cpp_type=this_cpp_type, cpp_value=cpp_value, var iable_name=variable_name) |
416 | 416 |
417 | |
418 def v8_value_to_local_cpp_value_async(idl_type, extended_attributes, v8_value, v ariable_name, index=None): | |
Nils Barth (inactive)
2014/04/10 07:48:03
You're just adding 'info' here, right?
If so, coul
Nils Barth (inactive)
2014/04/10 07:59:47
Oh, and you're tacking on _PROMISE.
Anyway, I've p
yhirano
2014/04/11 10:19:04
Thanks, done
| |
419 """Returns an expression that converts a V8 value to a C++ value and stores it as a local value. | |
420 The generated code returns a rejected Promise when it sees an error rather t han throwing an exception. | |
421 """ | |
422 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut es, used_as_argument=True) | |
423 | |
424 idl_type = idl_type.preprocessed_type | |
425 | |
426 if idl_type.base_type == 'DOMString' and not idl_type.array_or_sequence_type : | |
427 format_string = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID_PROMISE({cpp_type} , {variable_name}, {cpp_value}, info)' | |
428 elif idl_type.is_integer_type: | |
429 format_string = 'V8TRYCATCH_EXCEPTION_VOID_PROMISE({cpp_type}, {variable _name}, {cpp_value}, info, exceptionState)' | |
430 else: | |
431 format_string = 'V8TRYCATCH_VOID_PROMISE({cpp_type}, {variable_name}, {c pp_value}, info)' | |
432 | |
433 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i ndex) | |
434 return format_string.format(cpp_type=this_cpp_type, cpp_value=cpp_value, var iable_name=variable_name) | |
435 | |
436 | |
417 IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 437 IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
438 IdlType.v8_value_to_local_cpp_value_async = v8_value_to_local_cpp_value_async | |
418 IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 439 IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
419 | 440 |
420 | 441 |
421 ################################################################################ | 442 ################################################################################ |
422 # C++ -> V8 | 443 # C++ -> V8 |
423 ################################################################################ | 444 ################################################################################ |
424 | 445 |
425 def preprocess_idl_type(idl_type): | 446 def preprocess_idl_type(idl_type): |
426 if idl_type.is_enum: | 447 if idl_type.is_enum: |
427 # Enumerations are internally DOMStrings | 448 # Enumerations are internally DOMStrings |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea tion_context='', extended_attributes=None): | 623 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea tion_context='', extended_attributes=None): |
603 """Returns an expression that converts a C++ value to a V8 value.""" | 624 """Returns an expression that converts a C++ value to a V8 value.""" |
604 # the isolate parameter is needed for callback interfaces | 625 # the isolate parameter is needed for callback interfaces |
605 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext ended_attributes) | 626 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext ended_attributes) |
606 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) | 627 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) |
607 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 628 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
608 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat ion_context=creation_context) | 629 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat ion_context=creation_context) |
609 return statement | 630 return statement |
610 | 631 |
611 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value | 632 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value |
OLD | NEW |