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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 'XPathNSResolver': 'toXPathNSResolver({v8_value}, {isolate})', | 468 'XPathNSResolver': 'toXPathNSResolver({v8_value}, {isolate})', |
469 } | 469 } |
470 | 470 |
471 | 471 |
472 def v8_conversion_needs_exception_state(idl_type): | 472 def v8_conversion_needs_exception_state(idl_type): |
473 return (idl_type.is_numeric_type or | 473 return (idl_type.is_numeric_type or |
474 idl_type.is_dictionary or | 474 idl_type.is_dictionary or |
475 idl_type.name in ('ByteString', 'ScalarValueString')) | 475 idl_type.name in ('ByteString', 'ScalarValueString')) |
476 | 476 |
477 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep
tion_state) | 477 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep
tion_state) |
| 478 IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True |
478 | 479 |
479 | 480 |
480 def v8_conversion_is_trivial(idl_type): | 481 def v8_conversion_is_trivial(idl_type): |
481 # The conversion is a simple expression that returns the converted value and | 482 # The conversion is a simple expression that returns the converted value and |
482 # cannot raise an exception. | 483 # cannot raise an exception. |
483 return (idl_type.base_type == 'boolean' or | 484 return (idl_type.base_type == 'boolean' or |
484 idl_type.base_type == 'Dictionary' or | 485 idl_type.base_type == 'Dictionary' or |
485 idl_type.is_wrapper_type) | 486 idl_type.is_wrapper_type) |
486 | 487 |
487 IdlType.v8_conversion_is_trivial = property(v8_conversion_is_trivial) | 488 IdlType.v8_conversion_is_trivial = property(v8_conversion_is_trivial) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 # Index is None for setters, index (starting at 0) for method arguments, | 530 # Index is None for setters, index (starting at 0) for method arguments, |
530 # and is used to provide a human-readable exception message | 531 # and is used to provide a human-readable exception message |
531 if index is None: | 532 if index is None: |
532 index = 0 # special case, meaning "setter" | 533 index = 0 # special case, meaning "setter" |
533 else: | 534 else: |
534 index += 1 # human-readable index | 535 index += 1 # human-readable index |
535 if (native_array_element_type.is_interface_type and | 536 if (native_array_element_type.is_interface_type and |
536 native_array_element_type.name != 'Dictionary'): | 537 native_array_element_type.name != 'Dictionary'): |
537 this_cpp_type = None | 538 this_cpp_type = None |
538 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ
e.gc_type) | 539 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ
e.gc_type) |
539 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_
type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}))' | 540 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_
type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}, exceptionS
tate))' |
540 add_includes_for_type(native_array_element_type) | 541 add_includes_for_type(native_array_element_type) |
541 else: | 542 else: |
542 ref_ptr_type = None | 543 ref_ptr_type = None |
543 this_cpp_type = native_array_element_type.cpp_type | 544 this_cpp_type = native_array_element_type.cpp_type |
544 expression_format = 'toImplArray<{cpp_type}>({v8_value}, {index}, {isola
te})' | 545 expression_format = 'toImplArray<{cpp_type}>({v8_value}, {index}, {isola
te}, exceptionState)' |
545 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) | 546 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) |
546 return expression | 547 return expression |
547 | 548 |
548 | 549 |
549 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, return_promise=False): | 550 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, return_promise=False): |
550 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" | 551 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" |
551 | 552 |
552 # FIXME: Support union type. | 553 # FIXME: Support union type. |
553 if idl_type.is_union_type: | 554 if idl_type.is_union_type: |
554 return '' | 555 return '' |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 | 835 |
835 | 836 |
836 def is_explicit_nullable(idl_type): | 837 def is_explicit_nullable(idl_type): |
837 # Nullable type that isn't implicit nullable (see above.) For such types, | 838 # Nullable type that isn't implicit nullable (see above.) For such types, |
838 # we use Nullable<T> or similar explicit ways to represent a null value. | 839 # we use Nullable<T> or similar explicit ways to represent a null value. |
839 return idl_type.is_nullable and not idl_type.is_implicit_nullable | 840 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
840 | 841 |
841 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) | 842 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |
842 IdlUnionType.is_implicit_nullable = False | 843 IdlUnionType.is_implicit_nullable = False |
843 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) | 844 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |
OLD | NEW |