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

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

Issue 272213005: Support WebIDL optional default value syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 139
140 def generate_argument(interface, method, argument, index): 140 def generate_argument(interface, method, argument, index):
141 extended_attributes = argument.extended_attributes 141 extended_attributes = argument.extended_attributes
142 idl_type = argument.idl_type 142 idl_type = argument.idl_type
143 this_cpp_value = cpp_value(interface, method, index) 143 this_cpp_value = cpp_value(interface, method, index)
144 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type 144 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
145 return { 145 return {
146 'cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=is_variadic_wrap per_type), 146 'cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=is_variadic_wrap per_type),
147 'cpp_value': this_cpp_value, 147 'cpp_value': this_cpp_value,
148 'default_value': argument.default_value,
148 'enum_validation_expression': idl_type.enum_validation_expression, 149 'enum_validation_expression': idl_type.enum_validation_expression,
149 'has_default': 'Default' in extended_attributes, 150 'has_default': 'Default' in extended_attributes,
150 'has_event_listener_argument': any( 151 'has_event_listener_argument': any(
151 argument_so_far for argument_so_far in method.arguments[:index] 152 argument_so_far for argument_so_far in method.arguments[:index]
152 if argument_so_far.idl_type.name == 'EventListener'), 153 if argument_so_far.idl_type.name == 'EventListener'),
153 'has_legacy_overload_string': # [LegacyOverloadString] 154 'has_legacy_overload_string': # [LegacyOverloadString]
154 'LegacyOverloadString' in extended_attributes, 155 'LegacyOverloadString' in extended_attributes,
155 'has_type_checking_interface': 156 'has_type_checking_interface':
156 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or 157 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or
157 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and 158 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
(...skipping 29 matching lines...) Expand all
187 # FIXME: remove this special case by moving get() into 188 # FIXME: remove this special case by moving get() into
188 # EventTarget::removeEventListener 189 # EventTarget::removeEventListener
189 return '%s.get()' % argument.name 190 return '%s.get()' % argument.name
190 return argument.name 191 return argument.name
191 if (idl_type.is_callback_interface or 192 if (idl_type.is_callback_interface or
192 idl_type.name in ['NodeFilter', 'XPathNSResolver']): 193 idl_type.name in ['NodeFilter', 'XPathNSResolver']):
193 # FIXME: remove this special case 194 # FIXME: remove this special case
194 return '%s.release()' % argument.name 195 return '%s.release()' % argument.name
195 return argument.name 196 return argument.name
196 197
197 # Truncate omitted optional arguments
198 arguments = method.arguments[:number_of_arguments]
199 cpp_arguments = v8_utilities.call_with_arguments(method) 198 cpp_arguments = v8_utilities.call_with_arguments(method)
200 # Members of IDL partial interface definitions are implemented in C++ as 199 # Members of IDL partial interface definitions are implemented in C++ as
201 # static member functions, which for instance members (non-static members) 200 # static member functions, which for instance members (non-static members)
202 # take *impl as their first argument 201 # take *impl as their first argument
203 if ('PartialInterfaceImplementedAs' in method.extended_attributes and 202 if ('PartialInterfaceImplementedAs' in method.extended_attributes and
204 not method.is_static): 203 not method.is_static):
205 cpp_arguments.append('*impl') 204 cpp_arguments.append('*impl')
206 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) 205 cpp_arguments.extend(cpp_argument(argument)
206 for argument in method.arguments[:number_of_arguments])
207 cpp_arguments.extend(argument.default_value
208 for argument in method.arguments[number_of_arguments:]
209 if argument.is_optional and argument.default_value)
207 this_union_arguments = method.idl_type and method.idl_type.union_arguments 210 this_union_arguments = method.idl_type and method.idl_type.union_arguments
208 if this_union_arguments: 211 if this_union_arguments:
209 cpp_arguments.extend(this_union_arguments) 212 cpp_arguments.extend(this_union_arguments)
210 213
211 if 'RaisesException' in method.extended_attributes: 214 if 'RaisesException' in method.extended_attributes:
212 cpp_arguments.append('exceptionState') 215 cpp_arguments.append('exceptionState')
213 216
214 if method.name == 'Constructor': 217 if method.name == 'Constructor':
215 base_name = 'create' 218 base_name = 'create'
216 elif method.name == 'NamedConstructor': 219 elif method.name == 'NamedConstructor':
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 280
278 281
279 def union_arguments(idl_type): 282 def union_arguments(idl_type):
280 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" 283 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value"""
281 return [arg 284 return [arg
282 for i in range(len(idl_type.member_types)) 285 for i in range(len(idl_type.member_types))
283 for arg in ['result%sEnabled' % i, 'result%s' % i]] 286 for arg in ['result%sEnabled' % i, 'result%s' % i]]
284 287
285 IdlType.union_arguments = property(lambda self: None) 288 IdlType.union_arguments = property(lambda self: None)
286 IdlUnionType.union_arguments = property(union_arguments) 289 IdlUnionType.union_arguments = property(union_arguments)
OLDNEW
« Source/bindings/scripts/idl_definitions.py ('K') | « Source/bindings/scripts/idl_definitions.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698