| 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 # and is used to provide a human-readable exception message | 583 # and is used to provide a human-readable exception message |
| 584 if index is None: | 584 if index is None: |
| 585 index = 0 # special case, meaning "setter" | 585 index = 0 # special case, meaning "setter" |
| 586 else: | 586 else: |
| 587 index += 1 # human-readable index | 587 index += 1 # human-readable index |
| 588 if (native_array_element_type.is_interface_type and | 588 if (native_array_element_type.is_interface_type and |
| 589 native_array_element_type.name != 'Dictionary'): | 589 native_array_element_type.name != 'Dictionary'): |
| 590 this_cpp_type = None | 590 this_cpp_type = None |
| 591 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ
e.gc_type) | 591 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ
e.gc_type) |
| 592 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_
type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}, exceptionS
tate))' | 592 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_
type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}, exceptionS
tate))' |
| 593 elif native_array_element_type.is_dictionary: | |
| 594 ref_ptr_type = None | |
| 595 this_cpp_type = native_array_element_type.cpp_type | |
| 596 expression_format = 'toImplHeapArray<{cpp_type}>({v8_value}, {index}, {i
solate}, exceptionState)' | |
| 597 else: | 593 else: |
| 598 ref_ptr_type = None | 594 ref_ptr_type = None |
| 599 this_cpp_type = native_array_element_type.cpp_type | 595 this_cpp_type = native_array_element_type.cpp_type |
| 600 expression_format = 'toImplArray<{cpp_type}>({v8_value}, {index}, {isola
te}, exceptionState)' | 596 if native_array_element_type.is_dictionary: |
| 597 vector_type = 'HeapVector' |
| 598 else: |
| 599 vector_type = 'Vector' |
| 600 expression_format = 'toImplArray<%s<{cpp_type}>>({v8_value}, {index}, {i
solate}, exceptionState)' % vector_type |
| 601 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) | 601 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) |
| 602 return expression | 602 return expression |
| 603 | 603 |
| 604 | 604 |
| 605 # FIXME: this function should be refactored, as this takes too many flags. | 605 # FIXME: this function should be refactored, as this takes too many flags. |
| 606 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): | 606 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): |
| 607 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" | 607 """Returns an expression that converts a V8 value to a C++ value and stores
it as a local value.""" |
| 608 | 608 |
| 609 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, raw_type=True) | 609 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, raw_type=True) |
| 610 idl_type = idl_type.preprocessed_type | 610 idl_type = idl_type.preprocessed_type |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 number_of_nullable_member_types_union) | 978 number_of_nullable_member_types_union) |
| 979 | 979 |
| 980 | 980 |
| 981 def includes_nullable_type_union(idl_type): | 981 def includes_nullable_type_union(idl_type): |
| 982 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 982 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
| 983 return idl_type.number_of_nullable_member_types == 1 | 983 return idl_type.number_of_nullable_member_types == 1 |
| 984 | 984 |
| 985 IdlTypeBase.includes_nullable_type = False | 985 IdlTypeBase.includes_nullable_type = False |
| 986 IdlNullableType.includes_nullable_type = True | 986 IdlNullableType.includes_nullable_type = True |
| 987 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 987 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
| OLD | NEW |