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 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value})
', | 468 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value})
', |
469 'SerializedScriptValue': 'SerializedScriptValue::create({v8_value}, {isolate
})', | 469 'SerializedScriptValue': 'SerializedScriptValue::create({v8_value}, {isolate
})', |
470 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', | 470 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', |
471 'Window': 'toDOMWindow({v8_value}, {isolate})', | 471 'Window': 'toDOMWindow({v8_value}, {isolate})', |
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_integer_type or | 477 return (idl_type.is_integer_type or |
| 478 idl_type.is_dictionary or |
478 idl_type.name in ('ByteString', 'ScalarValueString')) | 479 idl_type.name in ('ByteString', 'ScalarValueString')) |
479 | 480 |
480 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) |
481 | 482 |
482 | 483 |
483 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat
e): | 484 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat
e): |
484 if idl_type.name == 'void': | 485 if idl_type.name == 'void': |
485 return '' | 486 return '' |
486 | 487 |
487 # Array or sequence types | 488 # Array or sequence types |
(...skipping 13 matching lines...) Expand all Loading... |
501 else: | 502 else: |
502 arguments = v8_value | 503 arguments = v8_value |
503 | 504 |
504 if base_idl_type in V8_VALUE_TO_CPP_VALUE: | 505 if base_idl_type in V8_VALUE_TO_CPP_VALUE: |
505 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] | 506 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] |
506 elif idl_type.is_typed_array_element_type: | 507 elif idl_type.is_typed_array_element_type: |
507 cpp_expression_format = ( | 508 cpp_expression_format = ( |
508 '{v8_value}->Is{idl_type}() ? ' | 509 '{v8_value}->Is{idl_type}() ? ' |
509 'V8{idl_type}::toImpl(v8::Handle<v8::{idl_type}>::Cast({v8_value}))
: 0') | 510 'V8{idl_type}::toImpl(v8::Handle<v8::{idl_type}>::Cast({v8_value}))
: 0') |
510 elif idl_type.is_dictionary: | 511 elif idl_type.is_dictionary: |
511 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value})' | 512 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, exc
eptionState)' |
512 else: | 513 else: |
513 cpp_expression_format = ( | 514 cpp_expression_format = ( |
514 'V8{idl_type}::toImplWithTypeCheck({isolate}, {v8_value})') | 515 'V8{idl_type}::toImplWithTypeCheck({isolate}, {v8_value})') |
515 | 516 |
516 return cpp_expression_format.format(arguments=arguments, idl_type=base_idl_t
ype, v8_value=v8_value, isolate=isolate) | 517 return cpp_expression_format.format(arguments=arguments, idl_type=base_idl_t
ype, v8_value=v8_value, isolate=isolate) |
517 | 518 |
518 | 519 |
519 def v8_value_to_cpp_value_array_or_sequence(native_array_element_type, v8_value,
index, isolate='info.GetIsolate()'): | 520 def v8_value_to_cpp_value_array_or_sequence(native_array_element_type, v8_value,
index, isolate='info.GetIsolate()'): |
520 # Index is None for setters, index (starting at 0) for method arguments, | 521 # Index is None for setters, index (starting at 0) for method arguments, |
521 # and is used to provide a human-readable exception message | 522 # and is used to provide a human-readable exception message |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 | 797 |
797 | 798 |
798 ################################################################################ | 799 ################################################################################ |
799 # Utility properties for nullable types | 800 # Utility properties for nullable types |
800 ################################################################################ | 801 ################################################################################ |
801 | 802 |
802 | 803 |
803 def cpp_type_has_null_value(idl_type): | 804 def cpp_type_has_null_value(idl_type): |
804 # - String types (String/AtomicString) represent null as a null string, | 805 # - String types (String/AtomicString) represent null as a null string, |
805 # i.e. one for which String::isNull() returns true. | 806 # i.e. one for which String::isNull() returns true. |
| 807 # - Enum types, as they are implemented as Strings. |
806 # - Wrapper types (raw pointer or RefPtr/PassRefPtr) represent null as | 808 # - Wrapper types (raw pointer or RefPtr/PassRefPtr) represent null as |
807 # a null pointer. | 809 # a null pointer. |
808 # - Dictionary types represent null as a null pointer. They are garbage | 810 # - Dictionary types represent null as a null pointer. They are garbage |
809 # collected so their type is raw pointer. | 811 # collected so their type is raw pointer. |
810 return (idl_type.is_string_type or idl_type.is_wrapper_type or | 812 return (idl_type.is_string_type or idl_type.is_wrapper_type or |
811 idl_type.is_dictionary) | 813 idl_type.is_enum or idl_type.is_dictionary) |
812 | 814 |
813 IdlTypeBase.cpp_type_has_null_value = property(cpp_type_has_null_value) | 815 IdlTypeBase.cpp_type_has_null_value = property(cpp_type_has_null_value) |
814 | 816 |
815 | 817 |
816 def is_implicit_nullable(idl_type): | 818 def is_implicit_nullable(idl_type): |
817 # Nullable type where the corresponding C++ type supports a null value. | 819 # Nullable type where the corresponding C++ type supports a null value. |
818 return idl_type.is_nullable and idl_type.cpp_type_has_null_value | 820 return idl_type.is_nullable and idl_type.cpp_type_has_null_value |
819 | 821 |
820 | 822 |
821 def is_explicit_nullable(idl_type): | 823 def is_explicit_nullable(idl_type): |
822 # Nullable type that isn't implicit nullable (see above.) For such types, | 824 # Nullable type that isn't implicit nullable (see above.) For such types, |
823 # we use Nullable<T> or similar explicit ways to represent a null value. | 825 # we use Nullable<T> or similar explicit ways to represent a null value. |
824 return idl_type.is_nullable and not idl_type.is_implicit_nullable | 826 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
825 | 827 |
826 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) | 828 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |
827 IdlUnionType.is_implicit_nullable = False | 829 IdlUnionType.is_implicit_nullable = False |
828 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) | 830 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |
OLD | NEW |