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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) | 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] | 421 args = [this_cpp_type, variable_name, cpp_value] |
422 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
: |
423 v8trycatch_void = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID' | 423 macro = 'V8STRINGRESOURCE_PREPARE_VOID' |
424 elif idl_type.is_integer_type: | 424 elif idl_type.is_integer_type: |
425 v8trycatch_void = 'V8TRYCATCH_EXCEPTION_VOID' | 425 macro = 'V8TRYCATCH_VOID_EXCEPTION' |
426 args.append('exceptionState') | 426 args.append('exceptionState') |
427 else: | 427 else: |
428 v8trycatch_void = 'V8TRYCATCH_VOID' | 428 macro = 'V8TRYCATCH_VOID' |
429 | 429 |
430 return '%s(%s)' % (v8trycatch_void, ', '.join(args)) | 430 return '%s(%s)' % (macro, ', '.join(args)) |
431 | 431 |
432 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 |
433 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 |
434 | 434 |
435 | 435 |
436 ################################################################################ | 436 ################################################################################ |
437 # C++ -> V8 | 437 # C++ -> V8 |
438 ################################################################################ | 438 ################################################################################ |
439 | 439 |
440 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... |
617 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): |
618 """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.""" |
619 # the isolate parameter is needed for callback interfaces | 619 # the isolate parameter is needed for callback interfaces |
620 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) |
621 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) | 621 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) |
622 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 622 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
623 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) |
624 return statement | 624 return statement |
625 | 625 |
626 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 |