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

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

Issue 352133002: IDL: fix handling of non-decimal and unsigned default values (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
« no previous file with comments | « Source/bindings/scripts/idl_definitions.py ('k') | Source/bindings/scripts/v8_types.py » ('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 15 matching lines...) Expand all
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 """Generate template values for methods. 29 """Generate template values for methods.
30 30
31 Extends IdlType and IdlUnionType with property |union_arguments|. 31 Extends IdlType and IdlUnionType with property |union_arguments|.
32 32
33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler 33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
34 """ 34 """
35 35
36 from idl_definitions import IdlArgument
36 from idl_types import IdlType, IdlUnionType, inherits_interface 37 from idl_types import IdlType, IdlUnionType, inherits_interface
37 from v8_globals import includes 38 from v8_globals import includes
38 import v8_types 39 import v8_types
39 import v8_utilities 40 import v8_utilities
40 from v8_utilities import has_extended_attribute_value 41 from v8_utilities import has_extended_attribute_value
41 42
42 43
43 # Methods with any of these require custom method registration code in the 44 # Methods with any of these require custom method registration code in the
44 # interface's configure*Template() function. 45 # interface's configure*Template() function.
45 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ 46 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 idl_type = argument.idl_type 172 idl_type = argument.idl_type
172 this_cpp_value = cpp_value(interface, method, index) 173 this_cpp_value = cpp_value(interface, method, index)
173 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type 174 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
174 175
175 return { 176 return {
176 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es, 177 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es,
177 raw_type=True, 178 raw_type=True,
178 used_as_variadic_argument=argument.is _variadic), 179 used_as_variadic_argument=argument.is _variadic),
179 'cpp_value': this_cpp_value, 180 'cpp_value': this_cpp_value,
180 # FIXME: check that the default value's type is compatible with the argu ment's 181 # FIXME: check that the default value's type is compatible with the argu ment's
181 'default_value': str(argument.default_value) if argument.default_value e lse None, 182 'default_value': argument.default_cpp_value,
182 'enum_validation_expression': idl_type.enum_validation_expression, 183 'enum_validation_expression': idl_type.enum_validation_expression,
183 # FIXME: remove once [Default] removed and just use argument.default_val ue 184 # FIXME: remove once [Default] removed and just use argument.default_val ue
184 'has_default': 'Default' in extended_attributes or argument.default_valu e, 185 'has_default': 'Default' in extended_attributes or argument.default_valu e,
185 'has_type_checking_interface': 186 'has_type_checking_interface':
186 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or 187 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or
187 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and 188 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
188 idl_type.is_wrapper_type, 189 idl_type.is_wrapper_type,
189 'has_type_checking_unrestricted': 190 'has_type_checking_unrestricted':
190 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or 191 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or
191 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and 192 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 property_attributes_list.insert(0, 'v8::DontDelete') 322 property_attributes_list.insert(0, 'v8::DontDelete')
322 return property_attributes_list 323 return property_attributes_list
323 324
324 325
325 def union_arguments(idl_type): 326 def union_arguments(idl_type):
326 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" 327 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value"""
327 return [arg 328 return [arg
328 for i in range(len(idl_type.member_types)) 329 for i in range(len(idl_type.member_types))
329 for arg in ['result%sEnabled' % i, 'result%s' % i]] 330 for arg in ['result%sEnabled' % i, 'result%s' % i]]
330 331
332
333 def argument_default_cpp_value(argument):
334 if not argument.default_value:
335 return None
336 return argument.idl_type.literal_cpp_value(argument.default_value)
337
331 IdlType.union_arguments = property(lambda self: None) 338 IdlType.union_arguments = property(lambda self: None)
332 IdlUnionType.union_arguments = property(union_arguments) 339 IdlUnionType.union_arguments = property(union_arguments)
340 IdlArgument.default_cpp_value = property(argument_default_cpp_value)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/idl_definitions.py ('k') | Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698