Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: Source/bindings/scripts/v8_union.py

Issue 854113002: IDL: Enumeration support in union types (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/Dictionary.h', 9 'bindings/core/v8/Dictionary.h',
10 'bindings/core/v8/ExceptionState.h', 10 'bindings/core/v8/ExceptionState.h',
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if dictionary_type and nullable_members == 1: 111 if dictionary_type and nullable_members == 1:
112 raise Exception('%s has a dictionary and a nullable member' % union_type .name) 112 raise Exception('%s has a dictionary and a nullable member' % union_type .name)
113 113
114 return { 114 return {
115 'array_buffer_type': array_buffer_type, 115 'array_buffer_type': array_buffer_type,
116 'array_buffer_view_type': array_buffer_view_type, 116 'array_buffer_view_type': array_buffer_view_type,
117 'array_or_sequence_type': array_or_sequence_type, 117 'array_or_sequence_type': array_or_sequence_type,
118 'boolean_type': boolean_type, 118 'boolean_type': boolean_type,
119 'cpp_class': union_type.cpp_type, 119 'cpp_class': union_type.cpp_type,
120 'dictionary_type': dictionary_type, 120 'dictionary_type': dictionary_type,
121 'type_string': str(union_type),
122 'includes_nullable_type': union_type.includes_nullable_type, 121 'includes_nullable_type': union_type.includes_nullable_type,
123 'interface_types': interface_types, 122 'interface_types': interface_types,
124 'members': members, 123 'members': members,
125 'needs_trace': any(member['is_traceable'] for member in members), 124 'needs_trace': any(member['is_traceable'] for member in members),
126 'numeric_type': numeric_type, 125 'numeric_type': numeric_type,
127 'string_type': string_type, 126 'string_type': string_type,
127 'type_string': str(union_type),
128 } 128 }
129 129
130 130
131 def member_context(member, interfaces_info): 131 def member_context(member, interfaces_info):
132 cpp_includes.update(member.includes_for_type) 132 cpp_includes.update(member.includes_for_type)
133 interface_info = interfaces_info.get(member.name, None) 133 interface_info = interfaces_info.get(member.name, None)
134 if interface_info: 134 if interface_info:
135 cpp_includes.update(interface_info.get('dependencies_include_paths', []) ) 135 cpp_includes.update(interface_info.get('dependencies_include_paths', []) )
136 header_forward_decls.add(member.implemented_as) 136 header_forward_decls.add(member.implemented_as)
137 if member.is_nullable: 137 if member.is_nullable:
138 member = member.inner_type 138 member = member.inner_type
139 return { 139 return {
140 'cpp_name': v8_utilities.uncapitalize(member.name), 140 'cpp_name': v8_utilities.uncapitalize(member.name),
141 'cpp_type': member.cpp_type_args(used_in_cpp_sequence=True), 141 'cpp_type': member.cpp_type_args(used_in_cpp_sequence=True),
142 'cpp_local_type': member.cpp_type, 142 'cpp_local_type': member.cpp_type,
143 'cpp_value_to_v8_value': member.cpp_value_to_v8_value( 143 'cpp_value_to_v8_value': member.cpp_value_to_v8_value(
144 cpp_value='impl.getAs%s()' % member.name, isolate='isolate', 144 cpp_value='impl.getAs%s()' % member.name, isolate='isolate',
145 creation_context='creationContext'), 145 creation_context='creationContext'),
146 'enum_validation_expression': member.enum_validation_expression,
146 'is_traceable': member.is_traceable, 147 'is_traceable': member.is_traceable,
147 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), 148 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True),
148 'specific_type_enum': 'SpecificType' + member.name, 149 'specific_type_enum': 'SpecificType' + member.name,
149 'type_name': member.name, 150 'type_name': member.name,
150 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( 151 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value(
151 {}, 'v8Value', 'cppValue', isolate='isolate', 152 {}, 'v8Value', 'cppValue', isolate='isolate',
152 needs_exception_state_for_string=True), 153 needs_exception_state_for_string=True),
153 } 154 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/idl-union-type-unittest-expected.txt ('k') | Source/bindings/templates/union.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698