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

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

Issue 335113002: IDL: Support argument default values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 6 years, 5 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/templates/methods.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 return '%s(%s)' % (macro, ', '.join(macro_args)) 302 return '%s(%s)' % (macro, ', '.join(macro_args))
303 303
304 304
305 def v8_value_to_local_cpp_value(argument, index): 305 def v8_value_to_local_cpp_value(argument, index):
306 extended_attributes = argument.extended_attributes 306 extended_attributes = argument.extended_attributes
307 idl_type = argument.idl_type 307 idl_type = argument.idl_type
308 name = argument.name 308 name = argument.name
309 if argument.is_variadic: 309 if argument.is_variadic:
310 return v8_value_to_local_cpp_variadic_value(argument, index) 310 return v8_value_to_local_cpp_variadic_value(argument, index)
311 # FIXME: This special way of handling string arguments with null defaults 311 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]' % index,
312 # can go away once we fully support default values.
313 if (argument.is_optional and
314 idl_type.is_string_type and
315 argument.default_value and argument.default_value.is_null):
316 v8_value = 'argumentOrNull(info, %s)' % index
317 else:
318 v8_value = 'info[%s]' % index
319 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value,
320 name, index=index, declare_varia ble=False) 312 name, index=index, declare_varia ble=False)
321 313
322 314
323 ################################################################################ 315 ################################################################################
324 # Auxiliary functions 316 # Auxiliary functions
325 ################################################################################ 317 ################################################################################
326 318
327 # [NotEnumerable] 319 # [NotEnumerable]
328 def property_attributes(method): 320 def property_attributes(method):
329 extended_attributes = method.extended_attributes 321 extended_attributes = method.extended_attributes
330 property_attributes_list = [] 322 property_attributes_list = []
331 if 'NotEnumerable' in extended_attributes: 323 if 'NotEnumerable' in extended_attributes:
332 property_attributes_list.append('v8::DontEnum') 324 property_attributes_list.append('v8::DontEnum')
333 if 'ReadOnly' in extended_attributes: 325 if 'ReadOnly' in extended_attributes:
334 property_attributes_list.append('v8::ReadOnly') 326 property_attributes_list.append('v8::ReadOnly')
335 if property_attributes_list: 327 if property_attributes_list:
336 property_attributes_list.insert(0, 'v8::DontDelete') 328 property_attributes_list.insert(0, 'v8::DontDelete')
337 return property_attributes_list 329 return property_attributes_list
338 330
339 331
340 def union_arguments(idl_type): 332 def union_arguments(idl_type):
341 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" 333 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value"""
342 return [arg 334 return [arg
343 for i in range(len(idl_type.member_types)) 335 for i in range(len(idl_type.member_types))
344 for arg in ['result%sEnabled' % i, 'result%s' % i]] 336 for arg in ['result%sEnabled' % i, 'result%s' % i]]
345 337
346 IdlType.union_arguments = property(lambda self: None) 338 IdlType.union_arguments = property(lambda self: None)
347 IdlUnionType.union_arguments = property(union_arguments) 339 IdlUnionType.union_arguments = property(union_arguments)
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698