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

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

Issue 1130763006: IDL: Add any support to IDL dictionary and use it in CustomEventInit (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 dictionary.parent, interfaces_info) 158 dictionary.parent, interfaces_info)
159 parent_interface_info = interfaces_info.get(dictionary.parent) 159 parent_interface_info = interfaces_info.get(dictionary.parent)
160 if parent_interface_info: 160 if parent_interface_info:
161 context['header_includes'].add( 161 context['header_includes'].add(
162 parent_interface_info['include_path']) 162 parent_interface_info['include_path'])
163 return context 163 return context
164 164
165 165
166 def member_impl_context(member, interfaces_info, header_includes): 166 def member_impl_context(member, interfaces_info, header_includes):
167 idl_type = unwrap_nullable_if_needed(member.idl_type) 167 idl_type = unwrap_nullable_if_needed(member.idl_type)
168 is_any = idl_type.name == 'Any'
168 is_object = idl_type.name == 'Object' 169 is_object = idl_type.name == 'Object'
haraken 2015/05/18 01:59:44 Do we need to distinguish is_any from is_object?
bashi 2015/05/20 00:22:01 No. Actually, we don't need to put |is_any| and |i
169 cpp_name = v8_utilities.cpp_name(member) 170 cpp_name = v8_utilities.cpp_name(member)
170 171
171 def getter_expression(): 172 def getter_expression():
172 if idl_type.impl_should_use_nullable_container: 173 if idl_type.impl_should_use_nullable_container:
173 return 'm_%s.get()' % cpp_name 174 return 'm_%s.get()' % cpp_name
174 return 'm_%s' % cpp_name 175 return 'm_%s' % cpp_name
175 176
176 def has_method_expression(): 177 def has_method_expression():
177 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:
178 return '!m_%s.isNull()' % cpp_name 179 return '!m_%s.isNull()' % cpp_name
179 elif is_object: 180 elif is_object or is_any:
180 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)
181 else: 182 else:
182 return 'm_%s' % cpp_name 183 return 'm_%s' % cpp_name
183 184
184 def member_cpp_type(): 185 def member_cpp_type():
185 member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True) 186 member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True)
186 if idl_type.impl_should_use_nullable_container: 187 if idl_type.impl_should_use_nullable_container:
187 return v8_types.cpp_template_type('Nullable', member_cpp_type) 188 return v8_types.cpp_template_type('Nullable', member_cpp_type)
188 return member_cpp_type 189 return member_cpp_type
189 190
190 cpp_default_value = None 191 cpp_default_value = None
191 if member.default_value and not member.default_value.is_null: 192 if member.default_value and not member.default_value.is_null:
192 cpp_default_value = idl_type.literal_cpp_value(member.default_value) 193 cpp_default_value = idl_type.literal_cpp_value(member.default_value)
193 194
194 header_includes.update(idl_type.impl_includes_for_type(interfaces_info)) 195 header_includes.update(idl_type.impl_includes_for_type(interfaces_info))
195 return { 196 return {
196 'cpp_default_value': cpp_default_value, 197 'cpp_default_value': cpp_default_value,
197 'cpp_name': cpp_name, 198 'cpp_name': cpp_name,
198 'getter_expression': getter_expression(), 199 'getter_expression': getter_expression(),
199 'has_method_expression': has_method_expression(), 200 'has_method_expression': has_method_expression(),
200 'has_method_name': has_method_name_for_dictionary_member(member), 201 'has_method_name': has_method_name_for_dictionary_member(member),
202 'is_any': is_any,
201 'is_object': is_object, 203 'is_object': is_object,
202 'is_traceable': idl_type.is_traceable, 204 'is_traceable': idl_type.is_traceable,
203 'member_cpp_type': member_cpp_type(), 205 'member_cpp_type': member_cpp_type(),
204 'null_setter_name': null_setter_name_for_dictionary_member(member), 206 'null_setter_name': null_setter_name_for_dictionary_member(member),
205 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 207 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
206 'setter_name': setter_name_for_dictionary_member(member), 208 'setter_name': setter_name_for_dictionary_member(member),
207 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698