| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import v8_utilities | 5 import v8_utilities |
| 6 | 6 |
| 7 | 7 |
| 8 UNION_H_INCLUDES = frozenset([ | 8 UNION_H_INCLUDES = frozenset([ |
| 9 'bindings/core/v8/ExceptionState.h', | 9 'bindings/core/v8/ExceptionState.h', |
| 10 'bindings/core/v8/V8Binding.h', | 10 'bindings/core/v8/V8Binding.h', |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 elif member.base_type == 'ArrayBufferView': | 67 elif member.base_type == 'ArrayBufferView': |
| 68 if array_buffer_view_type: | 68 if array_buffer_view_type: |
| 69 raise Exception('%s is ambiguous.' % union_type.name) | 69 raise Exception('%s is ambiguous.' % union_type.name) |
| 70 array_buffer_view_type = context | 70 array_buffer_view_type = context |
| 71 elif member.is_interface_type: | 71 elif member.is_interface_type: |
| 72 interface_types.append(context) | 72 interface_types.append(context) |
| 73 elif member.is_dictionary: | 73 elif member.is_dictionary: |
| 74 if dictionary_type: | 74 if dictionary_type: |
| 75 raise Exception('%s is ambiguous.' % union_type.name) | 75 raise Exception('%s is ambiguous.' % union_type.name) |
| 76 dictionary_type = context | 76 dictionary_type = context |
| 77 elif member.base_type == 'boolean': | 77 elif member is union_type.boolean_member_type: |
| 78 if boolean_type: | |
| 79 raise Exception('%s is ambiguous.' % union_type.name) | |
| 80 boolean_type = context | 78 boolean_type = context |
| 81 elif member.is_numeric_type: | 79 elif member is union_type.numeric_member_type: |
| 82 if numeric_type: | |
| 83 raise Exception('%s is ambiguous.' % union_type.name) | |
| 84 numeric_type = context | 80 numeric_type = context |
| 85 elif member.is_string_type: | 81 elif member is union_type.string_member_type: |
| 86 if string_type: | |
| 87 raise Exception('%s is ambiguous.' % union_type.name) | |
| 88 string_type = context | 82 string_type = context |
| 89 else: | 83 else: |
| 90 raise Exception('%s is not supported as an union member.' % member.n
ame) | 84 raise Exception('%s is not supported as an union member.' % member.n
ame) |
| 91 | 85 |
| 92 # Nullable restriction checks | 86 # Nullable restriction checks |
| 93 nullable_members = union_type.number_of_nullable_member_types | 87 nullable_members = union_type.number_of_nullable_member_types |
| 94 if nullable_members > 1: | 88 if nullable_members > 1: |
| 95 raise Exception('%s contains more than one nullable members' % union_typ
e.name) | 89 raise Exception('%s contains more than one nullable members' % union_typ
e.name) |
| 96 if dictionary_type and nullable_members == 1: | 90 if dictionary_type and nullable_members == 1: |
| 97 raise Exception('%s has a dictionary and a nullable member' % union_type
.name) | 91 raise Exception('%s has a dictionary and a nullable member' % union_type
.name) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 126 'cpp_value_to_v8_value': member.cpp_value_to_v8_value( | 120 'cpp_value_to_v8_value': member.cpp_value_to_v8_value( |
| 127 cpp_value='impl.getAs%s()' % member.name, isolate='isolate', | 121 cpp_value='impl.getAs%s()' % member.name, isolate='isolate', |
| 128 creation_context='creationContext'), | 122 creation_context='creationContext'), |
| 129 'is_traceable': member.is_traceable, | 123 'is_traceable': member.is_traceable, |
| 130 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), | 124 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), |
| 131 'specific_type_enum': 'SpecificType' + member.name, | 125 'specific_type_enum': 'SpecificType' + member.name, |
| 132 'type_name': member.name, | 126 'type_name': member.name, |
| 133 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( | 127 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( |
| 134 {}, 'v8Value', 'cppValue', needs_exception_state_for_string=True), | 128 {}, 'v8Value', 'cppValue', needs_exception_state_for_string=True), |
| 135 } | 129 } |
| OLD | NEW |