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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
481 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_ type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}))' | 481 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_ type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}))' |
482 add_includes_for_type(native_array_element_type) | 482 add_includes_for_type(native_array_element_type) |
483 else: | 483 else: |
484 ref_ptr_type = None | 484 ref_ptr_type = None |
485 this_cpp_type = native_array_element_type.cpp_type | 485 this_cpp_type = native_array_element_type.cpp_type |
486 expression_format = 'toNativeArray<{cpp_type}>({v8_value}, {index}, {iso late})' | 486 expression_format = 'toNativeArray<{cpp_type}>({v8_value}, {index}, {iso late})' |
487 expression = expression_format.format(native_array_element_type=native_array _element_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_ty pe, v8_value=v8_value, isolate=isolate) | 487 expression = expression_format.format(native_array_element_type=native_array _element_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_ty pe, v8_value=v8_value, isolate=isolate) |
488 return expression | 488 return expression |
489 | 489 |
490 | 490 |
491 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl e_name, index=None, declare_variable=True, isolate='info.GetIsolate()', used_in_ private_script=False): | 491 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl e_name, index=None, declare_variable=True, isolate='info.GetIsolate()', used_in_ private_script=False, async=False): |
492 """Returns an expression that converts a V8 value to a C++ value and stores it as a local value.""" | 492 """Returns an expression that converts a V8 value to a C++ value and stores it as a local value.""" |
493 | 493 |
494 # FIXME: Support union type. | 494 # FIXME: Support union type. |
495 if idl_type.is_union_type: | 495 if idl_type.is_union_type: |
496 return '' | 496 return '' |
497 | 497 |
498 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut es, raw_type=True) | 498 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut es, raw_type=True) |
499 | 499 |
500 idl_type = idl_type.preprocessed_type | 500 idl_type = idl_type.preprocessed_type |
501 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i ndex, isolate) | 501 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i ndex, isolate) |
502 args = [variable_name, cpp_value] | 502 args = [variable_name, cpp_value] |
503 if idl_type.base_type == 'DOMString' and not idl_type.native_array_element_t ype: | 503 if idl_type.base_type == 'DOMString' and not idl_type.native_array_element_t ype: |
504 macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_VOID ' | 504 macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_VOID ' |
505 elif idl_type.may_raise_exception_on_conversion: | 505 elif idl_type.may_raise_exception_on_conversion: |
506 macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else 'TONATIVE_VOID_EXCEPTIONSTATE' | 506 macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else 'TONATIVE_VOID_EXCEPTIONSTATE' |
507 args.append('exceptionState') | 507 args.append('exceptionState') |
508 else: | 508 else: |
509 macro = 'TONATIVE_DEFAULT' if used_in_private_script else 'TONATIVE_VOID ' | 509 macro = 'TONATIVE_DEFAULT' if used_in_private_script else 'TONATIVE_VOID ' |
510 | 510 |
511 if used_in_private_script: | 511 if used_in_private_script: |
512 args.append('false') | 512 args.append('false') |
513 | 513 |
514 # Macros come in several variants, to minimize expensive creation of | 514 # Macros come in several variants, to minimize expensive creation of |
515 # v8::TryCatch. | 515 # v8::TryCatch. |
516 suffix = '' | 516 suffix = '' |
517 | 517 |
518 suffix = '' | |
Jens Widell
2014/07/30 10:29:10
This line duplicates the one above.
yhirano
2014/07/31 03:03:25
Thanks, done.
| |
519 | |
520 if async: | |
521 suffix += '_ASYNC' | |
522 args.append('info') | |
523 if macro == 'TONATIVE_VOID_EXCEPTIONSTATE': | |
524 args.insert(0, 'ScriptState::current(%s)' % isolate) | |
525 | |
518 if declare_variable: | 526 if declare_variable: |
519 args.insert(0, this_cpp_type) | 527 args.insert(0, this_cpp_type) |
520 else: | 528 else: |
521 suffix += '_INTERNAL' | 529 suffix += '_INTERNAL' |
522 | 530 |
523 return '%s(%s)' % (macro + suffix, ', '.join(args)) | 531 return '%s(%s)' % (macro + suffix, ', '.join(args)) |
524 | 532 |
525 | 533 |
526 IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 534 IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
527 IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 535 IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
763 | 771 |
764 def is_explicit_nullable(idl_type): | 772 def is_explicit_nullable(idl_type): |
765 # Nullable type that isn't implicit nullable (see above.) For such types, | 773 # Nullable type that isn't implicit nullable (see above.) For such types, |
766 # we use Nullable<T> or similar explicit ways to represent a null value. | 774 # we use Nullable<T> or similar explicit ways to represent a null value. |
767 return idl_type.is_nullable and not idl_type.is_implicit_nullable | 775 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
768 | 776 |
769 IdlType.is_implicit_nullable = property(is_implicit_nullable) | 777 IdlType.is_implicit_nullable = property(is_implicit_nullable) |
770 IdlType.is_explicit_nullable = property(is_explicit_nullable) | 778 IdlType.is_explicit_nullable = property(is_explicit_nullable) |
771 IdlUnionType.is_implicit_nullable = False | 779 IdlUnionType.is_implicit_nullable = False |
772 IdlUnionType.is_explicit_nullable = property(is_explicit_nullable) | 780 IdlUnionType.is_explicit_nullable = property(is_explicit_nullable) |
OLD | NEW |