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

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

Issue 1316833003: bindings: Support (deprecated) Dictionary in IDL dictionary (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return None, 'v8::Null(isolate)' 92 return None, 'v8::Null(isolate)'
93 cpp_default_value = unwrapped_idl_type.literal_cpp_value( 93 cpp_default_value = unwrapped_idl_type.literal_cpp_value(
94 member.default_value) 94 member.default_value)
95 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value( 95 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value(
96 cpp_value=cpp_default_value, isolate='isolate', 96 cpp_value=cpp_default_value, isolate='isolate',
97 creation_context='creationContext') 97 creation_context='creationContext')
98 return cpp_default_value, v8_default_value 98 return cpp_default_value, v8_default_value
99 99
100 cpp_default_value, v8_default_value = default_values() 100 cpp_default_value, v8_default_value = default_values()
101 cpp_name = v8_utilities.cpp_name(member) 101 cpp_name = v8_utilities.cpp_name(member)
102 is_deprecated_dictionary = unwrapped_idl_type.name == 'Dictionary'
102 103
103 return { 104 return {
104 'cpp_default_value': cpp_default_value, 105 'cpp_default_value': cpp_default_value,
105 'cpp_name': cpp_name, 106 'cpp_name': cpp_name,
106 'cpp_type': unwrapped_idl_type.cpp_type, 107 'cpp_type': unwrapped_idl_type.cpp_type,
107 'cpp_value_to_v8_value': unwrapped_idl_type.cpp_value_to_v8_value( 108 'cpp_value_to_v8_value': unwrapped_idl_type.cpp_value_to_v8_value(
108 cpp_value='impl.%s()' % cpp_name, isolate='isolate', 109 cpp_value='impl.%s()' % cpp_name, isolate='isolate',
109 creation_context='creationContext', 110 creation_context='creationContext',
110 extended_attributes=extended_attributes), 111 extended_attributes=extended_attributes),
111 'deprecate_as': v8_utilities.deprecate_as(member), 112 'deprecate_as': v8_utilities.deprecate_as(member),
112 'enum_type': idl_type.enum_type, 113 'enum_type': idl_type.enum_type,
113 'enum_values': unwrapped_idl_type.enum_values, 114 'enum_values': unwrapped_idl_type.enum_values,
114 'has_method_name': has_method_name_for_dictionary_member(member), 115 'has_method_name': has_method_name_for_dictionary_member(member),
115 'idl_type': idl_type.base_type, 116 'idl_type': idl_type.base_type,
116 'is_interface_type': idl_type.is_interface_type and not idl_type.is_dict ionary, 117 'is_deprecated_dictionary': is_deprecated_dictionary,
118 'is_interface_type': idl_type.is_interface_type and not (idl_type.is_dic tionary_type or is_deprecated_dictionary),
117 'is_nullable': idl_type.is_nullable, 119 'is_nullable': idl_type.is_nullable,
118 'is_object': unwrapped_idl_type.name == 'Object', 120 'is_object': unwrapped_idl_type.name == 'Object',
haraken 2015/08/26 00:40:54 Maybe it would be better to change this to: 'is
bashi 2015/08/26 00:48:14 Done.
119 'is_required': member.is_required, 121 'is_required': member.is_required,
120 'name': member.name, 122 'name': member.name,
121 'setter_name': setter_name_for_dictionary_member(member), 123 'setter_name': setter_name_for_dictionary_member(member),
122 'null_setter_name': null_setter_name_for_dictionary_member(member), 124 'null_setter_name': null_setter_name_for_dictionary_member(member),
123 'v8_default_value': v8_default_value, 125 'v8_default_value': v8_default_value,
124 'v8_value_to_local_cpp_value': unwrapped_idl_type.v8_value_to_local_cpp_ value( 126 'v8_value_to_local_cpp_value': unwrapped_idl_type.v8_value_to_local_cpp_ value(
125 extended_attributes, member.name + 'Value', 127 extended_attributes, member.name + 'Value',
126 member.name, isolate='isolate', use_exception_state=True), 128 member.name, isolate='isolate', use_exception_state=True),
127 } 129 }
128 130
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 def getter_expression(): 172 def getter_expression():
171 if idl_type.impl_should_use_nullable_container: 173 if idl_type.impl_should_use_nullable_container:
172 return 'm_%s.get()' % cpp_name 174 return 'm_%s.get()' % cpp_name
173 return 'm_%s' % cpp_name 175 return 'm_%s' % cpp_name
174 176
175 def has_method_expression(): 177 def has_method_expression():
176 if idl_type.impl_should_use_nullable_container or idl_type.is_enum or id l_type.is_string_type or idl_type.is_union_type: 178 if idl_type.impl_should_use_nullable_container or idl_type.is_enum or id l_type.is_string_type or idl_type.is_union_type:
177 return '!m_%s.isNull()' % cpp_name 179 return '!m_%s.isNull()' % cpp_name
178 elif idl_type.name in ['Any', 'Object']: 180 elif idl_type.name in ['Any', 'Object']:
179 return '!(m_{0}.isEmpty() || m_{0}.isNull() || m_{0}.isUndefined())' .format(cpp_name) 181 return '!(m_{0}.isEmpty() || m_{0}.isNull() || m_{0}.isUndefined())' .format(cpp_name)
182 elif idl_type.name == 'Dictionary':
183 return '!m_%s.isUndefinedOrNull()' % cpp_name
180 else: 184 else:
181 return 'm_%s' % cpp_name 185 return 'm_%s' % cpp_name
182 186
183 def member_cpp_type(): 187 def member_cpp_type():
184 member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True) 188 member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True)
185 if idl_type.impl_should_use_nullable_container: 189 if idl_type.impl_should_use_nullable_container:
186 return v8_types.cpp_template_type('Nullable', member_cpp_type) 190 return v8_types.cpp_template_type('Nullable', member_cpp_type)
187 return member_cpp_type 191 return member_cpp_type
188 192
189 cpp_default_value = None 193 cpp_default_value = None
190 if member.default_value and not member.default_value.is_null: 194 if member.default_value and not member.default_value.is_null:
191 cpp_default_value = idl_type.literal_cpp_value(member.default_value) 195 cpp_default_value = idl_type.literal_cpp_value(member.default_value)
192 196
193 header_includes.update(idl_type.impl_includes_for_type(interfaces_info)) 197 header_includes.update(idl_type.impl_includes_for_type(interfaces_info))
194 return { 198 return {
195 'cpp_default_value': cpp_default_value, 199 'cpp_default_value': cpp_default_value,
196 'cpp_name': cpp_name, 200 'cpp_name': cpp_name,
197 'getter_expression': getter_expression(), 201 'getter_expression': getter_expression(),
198 'has_method_expression': has_method_expression(), 202 'has_method_expression': has_method_expression(),
199 'has_method_name': has_method_name_for_dictionary_member(member), 203 'has_method_name': has_method_name_for_dictionary_member(member),
200 'is_nullable': idl_type.is_nullable, 204 'is_nullable': idl_type.is_nullable,
201 'is_traceable': idl_type.is_traceable, 205 'is_traceable': idl_type.is_traceable,
202 'member_cpp_type': member_cpp_type(), 206 'member_cpp_type': member_cpp_type(),
203 'null_setter_name': null_setter_name_for_dictionary_member(member), 207 'null_setter_name': null_setter_name_for_dictionary_member(member),
204 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 208 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
205 'setter_name': setter_name_for_dictionary_member(member), 209 'setter_name': setter_name_for_dictionary_member(member),
206 } 210 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/idl-dictionary-unittest-expected.txt ('k') | Source/bindings/templates/dictionary_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698