| 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_types |
| 5 import v8_utilities | 6 import v8_utilities |
| 6 | 7 |
| 7 | 8 |
| 8 UNION_H_INCLUDES = frozenset([ | 9 UNION_H_INCLUDES = frozenset([ |
| 9 'bindings/core/v8/Dictionary.h', | 10 'bindings/core/v8/Dictionary.h', |
| 10 'bindings/core/v8/ExceptionState.h', | 11 'bindings/core/v8/ExceptionState.h', |
| 11 'bindings/core/v8/V8Binding.h', | 12 'bindings/core/v8/V8Binding.h', |
| 12 'platform/heap/Handle.h', | 13 'platform/heap/Handle.h', |
| 13 ]) | 14 ]) |
| 14 | 15 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return { | 53 return { |
| 53 'containers': [container_context(union_type, interfaces_info) | 54 'containers': [container_context(union_type, interfaces_info) |
| 54 for union_type in union_types_for_containers], | 55 for union_type in union_types_for_containers], |
| 55 'cpp_includes': sorted(cpp_includes - UNION_CPP_INCLUDES_BLACKLIST), | 56 'cpp_includes': sorted(cpp_includes - UNION_CPP_INCLUDES_BLACKLIST), |
| 56 'header_forward_decls': sorted(header_forward_decls), | 57 'header_forward_decls': sorted(header_forward_decls), |
| 57 'header_includes': sorted(header_includes), | 58 'header_includes': sorted(header_includes), |
| 58 } | 59 } |
| 59 | 60 |
| 60 | 61 |
| 61 def container_context(union_type, interfaces_info): | 62 def container_context(union_type, interfaces_info): |
| 63 cpp_includes.clear() |
| 64 cpp_includes.update(set([ |
| 65 'bindings/core/v8/ToV8.h', |
| 66 ])) |
| 67 header_forward_decls.clear() |
| 68 header_includes.clear() |
| 69 header_includes.update(UNION_H_INCLUDES) |
| 62 members = [] | 70 members = [] |
| 63 | 71 |
| 64 # These variables refer to member contexts if the given union type has | 72 # These variables refer to member contexts if the given union type has |
| 65 # corresponding types. They are used for V8 -> impl conversion. | 73 # corresponding types. They are used for V8 -> impl conversion. |
| 66 array_buffer_type = None | 74 array_buffer_type = None |
| 67 array_buffer_view_type = None | 75 array_buffer_view_type = None |
| 68 array_or_sequence_type = None | 76 array_or_sequence_type = None |
| 69 boolean_type = None | 77 boolean_type = None |
| 70 dictionary_type = None | 78 dictionary_type = None |
| 71 interface_types = [] | 79 interface_types = [] |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 else: | 115 else: |
| 108 raise Exception('%s is not supported as an union member.' % member.n
ame) | 116 raise Exception('%s is not supported as an union member.' % member.n
ame) |
| 109 | 117 |
| 110 # Nullable restriction checks | 118 # Nullable restriction checks |
| 111 nullable_members = union_type.number_of_nullable_member_types | 119 nullable_members = union_type.number_of_nullable_member_types |
| 112 if nullable_members > 1: | 120 if nullable_members > 1: |
| 113 raise Exception('%s contains more than one nullable members' % union_typ
e.name) | 121 raise Exception('%s contains more than one nullable members' % union_typ
e.name) |
| 114 if dictionary_type and nullable_members == 1: | 122 if dictionary_type and nullable_members == 1: |
| 115 raise Exception('%s has a dictionary and a nullable member' % union_type
.name) | 123 raise Exception('%s has a dictionary and a nullable member' % union_type
.name) |
| 116 | 124 |
| 125 cpp_class = union_type.cpp_type |
| 117 return { | 126 return { |
| 118 'array_buffer_type': array_buffer_type, | 127 'array_buffer_type': array_buffer_type, |
| 119 'array_buffer_view_type': array_buffer_view_type, | 128 'array_buffer_view_type': array_buffer_view_type, |
| 120 'array_or_sequence_type': array_or_sequence_type, | 129 'array_or_sequence_type': array_or_sequence_type, |
| 121 'boolean_type': boolean_type, | 130 'boolean_type': boolean_type, |
| 122 'cpp_class': union_type.cpp_type, | 131 'cpp_class': cpp_class, |
| 132 'cpp_includes': sorted(cpp_includes - UNION_CPP_INCLUDES_BLACKLIST), |
| 123 'dictionary_type': dictionary_type, | 133 'dictionary_type': dictionary_type, |
| 134 'header_includes': sorted(header_includes - UNION_CPP_INCLUDES_BLACKLIST
), |
| 135 'header_forward_decls': sorted(header_forward_decls), |
| 124 'includes_nullable_type': union_type.includes_nullable_type, | 136 'includes_nullable_type': union_type.includes_nullable_type, |
| 125 'interface_types': interface_types, | 137 'interface_types': interface_types, |
| 126 'members': members, | 138 'members': members, |
| 127 'numeric_type': numeric_type, | 139 'numeric_type': numeric_type, |
| 128 'object_type': object_type, | 140 'object_type': object_type, |
| 129 'string_type': string_type, | 141 'string_type': string_type, |
| 130 'type_string': str(union_type), | 142 'type_string': str(union_type), |
| 143 'v8_class': v8_types.v8_type(cpp_class), |
| 131 } | 144 } |
| 132 | 145 |
| 133 | 146 |
| 134 def _update_includes_and_forward_decls(member, interface_info): | 147 def _update_includes_and_forward_decls(member, interface_info): |
| 135 if interface_info: | 148 if interface_info: |
| 136 cpp_includes.update(interface_info.get( | 149 cpp_includes.update(interface_info.get( |
| 137 'dependencies_include_paths', [])) | 150 'dependencies_include_paths', [])) |
| 138 # TODO(bashi): Workaround for http://crbug.com/524424 | 151 # TODO(bashi): Workaround for http://crbug.com/524424 |
| 139 # Avoid using forward declaration for IDL dictionaries so that they | 152 # Avoid using forward declaration for IDL dictionaries so that they |
| 140 # aren't imcomplete types in UnionTypes.h. This enables an IDL | 153 # aren't imcomplete types in UnionTypes.h. This enables an IDL |
| (...skipping 26 matching lines...) Expand all Loading... |
| 167 creation_context='creationContext'), | 180 creation_context='creationContext'), |
| 168 'enum_values': member.enum_values, | 181 'enum_values': member.enum_values, |
| 169 'is_traceable': member.is_traceable, | 182 'is_traceable': member.is_traceable, |
| 170 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), | 183 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), |
| 171 'specific_type_enum': 'SpecificType' + member.name, | 184 'specific_type_enum': 'SpecificType' + member.name, |
| 172 'type_name': member.name, | 185 'type_name': member.name, |
| 173 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( | 186 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( |
| 174 {}, 'v8Value', 'cppValue', isolate='isolate', | 187 {}, 'v8Value', 'cppValue', isolate='isolate', |
| 175 use_exception_state=True, restricted_float=True), | 188 use_exception_state=True, restricted_float=True), |
| 176 } | 189 } |
| OLD | NEW |