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

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

Issue 937773002: IDL: Support default values for dictionary members of union types (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_types.py » ('j') | Source/bindings/scripts/v8_types.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """Generate template contexts of dictionaries for both v8 bindings and 5 """Generate template contexts of dictionaries for both v8 bindings and
6 implementation classes that are used by blink's core/modules. 6 implementation classes that are used by blink's core/modules.
7 """ 7 """
8 8
9 import operator 9 import operator
10 from idl_types import IdlType 10 from idl_types import IdlType
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 restricted_float = ( 83 restricted_float = (
84 has_extended_attribute_value(dictionary, 'TypeChecking', 'Unrestricted') or 84 has_extended_attribute_value(dictionary, 'TypeChecking', 'Unrestricted') or
85 has_extended_attribute_value(member, 'TypeChecking', 'Unrestricted')) 85 has_extended_attribute_value(member, 'TypeChecking', 'Unrestricted'))
86 86
87 def default_values(): 87 def default_values():
88 if not member.default_value: 88 if not member.default_value:
89 return None, None 89 return None, None
90 if member.default_value.is_null: 90 if member.default_value.is_null:
91 return None, 'v8::Null(isolate)' 91 return None, 'v8::Null(isolate)'
92 cpp_default_value = str(member.default_value) 92 cpp_default_value = unwrapped_idl_type.literal_cpp_value(
93 member.default_value)
93 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value( 94 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value(
94 cpp_value=cpp_default_value, isolate='isolate', 95 cpp_value=cpp_default_value, isolate='isolate',
95 creation_context='creationContext') 96 creation_context='creationContext')
96 return cpp_default_value, v8_default_value 97 return cpp_default_value, v8_default_value
97 98
98 cpp_default_value, v8_default_value = default_values() 99 cpp_default_value, v8_default_value = default_values()
99 cpp_name = v8_utilities.cpp_name(member) 100 cpp_name = v8_utilities.cpp_name(member)
100 101
101 return { 102 return {
102 'cpp_default_value': cpp_default_value, 103 'cpp_default_value': cpp_default_value,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 return 'm_%s' % cpp_name 180 return 'm_%s' % cpp_name
180 181
181 def member_cpp_type(): 182 def member_cpp_type():
182 member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True) 183 member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True)
183 if idl_type.impl_should_use_nullable_container: 184 if idl_type.impl_should_use_nullable_container:
184 return v8_types.cpp_template_type('Nullable', member_cpp_type) 185 return v8_types.cpp_template_type('Nullable', member_cpp_type)
185 return member_cpp_type 186 return member_cpp_type
186 187
187 cpp_default_value = None 188 cpp_default_value = None
188 if member.default_value and not member.default_value.is_null: 189 if member.default_value and not member.default_value.is_null:
189 cpp_default_value = str(member.default_value) 190 cpp_default_value = idl_type.literal_cpp_value(member.default_value)
190 191
191 header_includes.update(idl_type.impl_includes_for_type(interfaces_info)) 192 header_includes.update(idl_type.impl_includes_for_type(interfaces_info))
192 return { 193 return {
193 'cpp_default_value': cpp_default_value, 194 'cpp_default_value': cpp_default_value,
194 'cpp_name': cpp_name, 195 'cpp_name': cpp_name,
195 'getter_expression': getter_expression(), 196 'getter_expression': getter_expression(),
196 'has_method_expression': has_method_expression(), 197 'has_method_expression': has_method_expression(),
197 'has_method_name': has_method_name_for_dictionary_member(member), 198 'has_method_name': has_method_name_for_dictionary_member(member),
198 'is_object': is_object, 199 'is_object': is_object,
199 'is_traceable': idl_type.is_traceable, 200 'is_traceable': idl_type.is_traceable,
200 'member_cpp_type': member_cpp_type(), 201 'member_cpp_type': member_cpp_type(),
201 'null_setter_name': null_setter_name_for_dictionary_member(member), 202 'null_setter_name': null_setter_name_for_dictionary_member(member),
202 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 203 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
203 'setter_name': setter_name_for_dictionary_member(member), 204 'setter_name': setter_name_for_dictionary_member(member),
204 } 205 }
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_types.py » ('j') | Source/bindings/scripts/v8_types.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698