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

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

Issue 339683002: Revert of IDL: Support optional argument default value syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 extended_attributes = argument.extended_attributes 174 extended_attributes = argument.extended_attributes
175 idl_type = argument.idl_type 175 idl_type = argument.idl_type
176 this_cpp_value = cpp_value(interface, method, index) 176 this_cpp_value = cpp_value(interface, method, index)
177 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type 177 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
178 178
179 return { 179 return {
180 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es, 180 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es,
181 used_as_argument=True, 181 used_as_argument=True,
182 used_as_variadic_argument=argument.is _variadic), 182 used_as_variadic_argument=argument.is _variadic),
183 'cpp_value': this_cpp_value, 183 'cpp_value': this_cpp_value,
184 # FIXME: check that the default value's type is compatible with the argu ment's
185 'default_value': str(argument.default_value) if argument.default_value e lse None,
186 'enum_validation_expression': idl_type.enum_validation_expression, 184 'enum_validation_expression': idl_type.enum_validation_expression,
187 # FIXME: remove once [Default] removed and just use argument.default_val ue 185 'has_default': 'Default' in extended_attributes,
188 'has_default': 'Default' in extended_attributes or argument.default_valu e,
189 'has_event_listener_argument': any( 186 'has_event_listener_argument': any(
190 argument_so_far for argument_so_far in method.arguments[:index] 187 argument_so_far for argument_so_far in method.arguments[:index]
191 if argument_so_far.idl_type.name == 'EventListener'), 188 if argument_so_far.idl_type.name == 'EventListener'),
192 'has_type_checking_interface': 189 'has_type_checking_interface':
193 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or 190 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or
194 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and 191 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
195 idl_type.is_wrapper_type, 192 idl_type.is_wrapper_type,
196 'has_type_checking_unrestricted': 193 'has_type_checking_unrestricted':
197 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or 194 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or
198 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and 195 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 291
295 return '%s(%s)' % (macro, ', '.join(macro_args)) 292 return '%s(%s)' % (macro, ', '.join(macro_args))
296 293
297 294
298 def v8_value_to_local_cpp_value(argument, index): 295 def v8_value_to_local_cpp_value(argument, index):
299 extended_attributes = argument.extended_attributes 296 extended_attributes = argument.extended_attributes
300 idl_type = argument.idl_type 297 idl_type = argument.idl_type
301 name = argument.name 298 name = argument.name
302 if argument.is_variadic: 299 if argument.is_variadic:
303 return v8_value_to_local_cpp_variadic_value(argument, index) 300 return v8_value_to_local_cpp_variadic_value(argument, index)
304 # FIXME: This special way of handling string arguments with null defaults 301 # [Default=NullString]
305 # can go away once we fully support default values.
306 if (argument.is_optional and idl_type.name in ('String', 'ByteString') and 302 if (argument.is_optional and idl_type.name in ('String', 'ByteString') and
307 argument.default_value and argument.default_value.is_null): 303 extended_attributes.get('Default') == 'NullString'):
308 v8_value = 'argumentOrNull(info, %s)' % index 304 v8_value = 'argumentOrNull(info, %s)' % index
309 else: 305 else:
310 v8_value = 'info[%s]' % index 306 v8_value = 'info[%s]' % index
311 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, 307 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value,
312 name, index=index, declare_varia ble=False) 308 name, index=index, declare_varia ble=False)
313 309
314 310
315 ################################################################################ 311 ################################################################################
316 # Auxiliary functions 312 # Auxiliary functions
317 ################################################################################ 313 ################################################################################
(...skipping 12 matching lines...) Expand all
330 326
331 327
332 def union_arguments(idl_type): 328 def union_arguments(idl_type):
333 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" 329 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value"""
334 return [arg 330 return [arg
335 for i in range(len(idl_type.member_types)) 331 for i in range(len(idl_type.member_types))
336 for arg in ['result%sEnabled' % i, 'result%s' % i]] 332 for arg in ['result%sEnabled' % i, 'result%s' % i]]
337 333
338 IdlType.union_arguments = property(lambda self: None) 334 IdlType.union_arguments = property(lambda self: None)
339 IdlUnionType.union_arguments = property(union_arguments) 335 IdlUnionType.union_arguments = property(union_arguments)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/idl_definitions.py ('k') | Source/bindings/tests/idls/TestInterfaceConstructor2.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698