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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 538 |
539 def v8_conversion_is_trivial(idl_type): | 539 def v8_conversion_is_trivial(idl_type): |
540 # The conversion is a simple expression that returns the converted value and | 540 # The conversion is a simple expression that returns the converted value and |
541 # cannot raise an exception. | 541 # cannot raise an exception. |
542 return (idl_type.base_type in TRIVIAL_CONVERSIONS or | 542 return (idl_type.base_type in TRIVIAL_CONVERSIONS or |
543 idl_type.is_wrapper_type) | 543 idl_type.is_wrapper_type) |
544 | 544 |
545 IdlType.v8_conversion_is_trivial = property(v8_conversion_is_trivial) | 545 IdlType.v8_conversion_is_trivial = property(v8_conversion_is_trivial) |
546 | 546 |
547 | 547 |
548 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, variable_name
, index, isolate, restricted_float=False): | 548 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, variable_name
, index, isolate): |
549 if idl_type.name == 'void': | 549 if idl_type.name == 'void': |
550 return '' | 550 return '' |
551 | 551 |
552 # Array or sequence types | 552 # Array or sequence types |
553 native_array_element_type = idl_type.native_array_element_type | 553 native_array_element_type = idl_type.native_array_element_type |
554 if native_array_element_type: | 554 if native_array_element_type: |
555 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type
, v8_value, index, isolate) | 555 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type
, v8_value, index, isolate) |
556 | 556 |
557 # Simple types | 557 # Simple types |
558 idl_type = idl_type.preprocessed_type | 558 idl_type = idl_type.preprocessed_type |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 if native_array_element_type.is_dictionary or native_array_element_type.
is_union_type: | 613 if native_array_element_type.is_dictionary or native_array_element_type.
is_union_type: |
614 vector_type = 'HeapVector' | 614 vector_type = 'HeapVector' |
615 else: | 615 else: |
616 vector_type = 'Vector' | 616 vector_type = 'Vector' |
617 expression_format = 'toImplArray<%s<{cpp_type}>>({v8_value}, {index}, {i
solate}, exceptionState)' % vector_type | 617 expression_format = 'toImplArray<%s<{cpp_type}>>({v8_value}, {index}, {i
solate}, exceptionState)' % vector_type |
618 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) | 618 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) |
619 return expression | 619 return expression |
620 | 620 |
621 | 621 |
622 # FIXME: this function should be refactored, as this takes too many flags. | 622 # FIXME: this function should be refactored, as this takes too many flags. |
623 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
e_name, index=None, declare_variable=True, isolate='info.GetIsolate()', bailout_
return_value=None, use_exception_state=False, restricted_float=False): | 623 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
e_name, index=None, declare_variable=True, |
| 624 isolate='info.GetIsolate()', bailout_return_valu
e=None, use_exception_state=False): |
624 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" | 625 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" |
625 | 626 |
626 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, raw_type=True) | 627 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, raw_type=True) |
627 idl_type = idl_type.preprocessed_type | 628 idl_type = idl_type.preprocessed_type |
628 | 629 |
629 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, v
ariable_name, index, isolate, restricted_float=restricted_float) | 630 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, v
ariable_name, index, isolate) |
630 | 631 |
631 # Optional expression that returns a value to be assigned to the local varia
ble. | 632 # Optional expression that returns a value to be assigned to the local varia
ble. |
632 assign_expression = None | 633 assign_expression = None |
633 # Optional void expression executed unconditionally. | 634 # Optional void expression executed unconditionally. |
634 set_expression = None | 635 set_expression = None |
635 # Optional expression that returns true if the conversion fails. | 636 # Optional expression that returns true if the conversion fails. |
636 check_expression = None | 637 check_expression = None |
637 # Optional expression used as the return value when returning. Only | 638 # Optional expression used as the return value when returning. Only |
638 # meaningful if 'check_expression' is not None. | 639 # meaningful if 'check_expression' is not None. |
639 return_expression = bailout_return_value | 640 return_expression = bailout_return_value |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 number_of_nullable_member_types_union) | 1029 number_of_nullable_member_types_union) |
1029 | 1030 |
1030 | 1031 |
1031 def includes_nullable_type_union(idl_type): | 1032 def includes_nullable_type_union(idl_type): |
1032 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 1033 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
1033 return idl_type.number_of_nullable_member_types == 1 | 1034 return idl_type.number_of_nullable_member_types == 1 |
1034 | 1035 |
1035 IdlTypeBase.includes_nullable_type = False | 1036 IdlTypeBase.includes_nullable_type = False |
1036 IdlNullableType.includes_nullable_type = True | 1037 IdlNullableType.includes_nullable_type = True |
1037 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 1038 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
OLD | NEW |