| 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 'XPathNSResolver': 'toXPathNSResolver({v8_value}, {isolate})', | 472 'XPathNSResolver': 'toXPathNSResolver({v8_value}, {isolate})', |
| 473 } | 473 } |
| 474 | 474 |
| 475 | 475 |
| 476 def v8_conversion_needs_exception_state(idl_type): | 476 def v8_conversion_needs_exception_state(idl_type): |
| 477 return (idl_type.is_numeric_type or | 477 return (idl_type.is_numeric_type or |
| 478 idl_type.is_dictionary or | 478 idl_type.is_dictionary or |
| 479 idl_type.name in ('ByteString', 'ScalarValueString')) | 479 idl_type.name in ('ByteString', 'ScalarValueString')) |
| 480 | 480 |
| 481 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep
tion_state) | 481 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep
tion_state) |
| 482 IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True |
| 482 | 483 |
| 483 | 484 |
| 484 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat
e): | 485 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat
e): |
| 485 if idl_type.name == 'void': | 486 if idl_type.name == 'void': |
| 486 return '' | 487 return '' |
| 487 | 488 |
| 488 # Array or sequence types | 489 # Array or sequence types |
| 489 native_array_element_type = idl_type.native_array_element_type | 490 native_array_element_type = idl_type.native_array_element_type |
| 490 if native_array_element_type: | 491 if native_array_element_type: |
| 491 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type
, v8_value, index) | 492 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type
, v8_value, index) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 521 # Index is None for setters, index (starting at 0) for method arguments, | 522 # Index is None for setters, index (starting at 0) for method arguments, |
| 522 # and is used to provide a human-readable exception message | 523 # and is used to provide a human-readable exception message |
| 523 if index is None: | 524 if index is None: |
| 524 index = 0 # special case, meaning "setter" | 525 index = 0 # special case, meaning "setter" |
| 525 else: | 526 else: |
| 526 index += 1 # human-readable index | 527 index += 1 # human-readable index |
| 527 if (native_array_element_type.is_interface_type and | 528 if (native_array_element_type.is_interface_type and |
| 528 native_array_element_type.name != 'Dictionary'): | 529 native_array_element_type.name != 'Dictionary'): |
| 529 this_cpp_type = None | 530 this_cpp_type = None |
| 530 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ
e.gc_type) | 531 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ
e.gc_type) |
| 531 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_
type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}))' | 532 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_
type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}, exceptionS
tate))' |
| 532 add_includes_for_type(native_array_element_type) | 533 add_includes_for_type(native_array_element_type) |
| 533 else: | 534 else: |
| 534 ref_ptr_type = None | 535 ref_ptr_type = None |
| 535 this_cpp_type = native_array_element_type.cpp_type | 536 this_cpp_type = native_array_element_type.cpp_type |
| 536 expression_format = 'toImplArray<{cpp_type}>({v8_value}, {index}, {isola
te})' | 537 expression_format = 'toImplArray<{cpp_type}>({v8_value}, {index}, {isola
te}, exceptionState)' |
| 537 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) | 538 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) |
| 538 return expression | 539 return expression |
| 539 | 540 |
| 540 | 541 |
| 541 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): | 542 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): |
| 542 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" | 543 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" |
| 543 | 544 |
| 544 # FIXME: Support union type. | 545 # FIXME: Support union type. |
| 545 if idl_type.is_union_type: | 546 if idl_type.is_union_type: |
| 546 return '' | 547 return '' |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 | 822 |
| 822 | 823 |
| 823 def is_explicit_nullable(idl_type): | 824 def is_explicit_nullable(idl_type): |
| 824 # Nullable type that isn't implicit nullable (see above.) For such types, | 825 # Nullable type that isn't implicit nullable (see above.) For such types, |
| 825 # we use Nullable<T> or similar explicit ways to represent a null value. | 826 # we use Nullable<T> or similar explicit ways to represent a null value. |
| 826 return idl_type.is_nullable and not idl_type.is_implicit_nullable | 827 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
| 827 | 828 |
| 828 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) | 829 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |
| 829 IdlUnionType.is_implicit_nullable = False | 830 IdlUnionType.is_implicit_nullable = False |
| 830 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) | 831 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |
| OLD | NEW |