OLD | NEW |
---|---|
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 Loading... | |
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 'default_value': str(argument.default_value) if argument.default_value e lse None, | |
Nils Barth (inactive)
2014/06/16 09:18:17
Could you add a FIXME here to check that the type
| |
184 'enum_validation_expression': idl_type.enum_validation_expression, | 185 'enum_validation_expression': idl_type.enum_validation_expression, |
185 'has_default': 'Default' in extended_attributes, | 186 # FIXME: remove once [Default] removed and just use argument.default_val ue |
187 'has_default': 'Default' in extended_attributes or argument.default_valu e, | |
186 'has_event_listener_argument': any( | 188 'has_event_listener_argument': any( |
187 argument_so_far for argument_so_far in method.arguments[:index] | 189 argument_so_far for argument_so_far in method.arguments[:index] |
188 if argument_so_far.idl_type.name == 'EventListener'), | 190 if argument_so_far.idl_type.name == 'EventListener'), |
189 'has_type_checking_interface': | 191 'has_type_checking_interface': |
190 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or | 192 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or |
191 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and | 193 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and |
192 idl_type.is_wrapper_type, | 194 idl_type.is_wrapper_type, |
193 'has_type_checking_unrestricted': | 195 'has_type_checking_unrestricted': |
194 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or | 196 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or |
195 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and | 197 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 | 293 |
292 return '%s(%s)' % (macro, ', '.join(macro_args)) | 294 return '%s(%s)' % (macro, ', '.join(macro_args)) |
293 | 295 |
294 | 296 |
295 def v8_value_to_local_cpp_value(argument, index): | 297 def v8_value_to_local_cpp_value(argument, index): |
296 extended_attributes = argument.extended_attributes | 298 extended_attributes = argument.extended_attributes |
297 idl_type = argument.idl_type | 299 idl_type = argument.idl_type |
298 name = argument.name | 300 name = argument.name |
299 if argument.is_variadic: | 301 if argument.is_variadic: |
300 return v8_value_to_local_cpp_variadic_value(argument, index) | 302 return v8_value_to_local_cpp_variadic_value(argument, index) |
301 # [Default=NullString] | 303 # FIXME: This special way of handling string arguments with null defaults |
304 # can go away once we fully support default values. | |
302 if (argument.is_optional and idl_type.name in ('String', 'ByteString') and | 305 if (argument.is_optional and idl_type.name in ('String', 'ByteString') and |
303 extended_attributes.get('Default') == 'NullString'): | 306 argument.default_value and argument.default_value.is_null): |
haraken
2014/06/13 13:46:52
Just to confirm: If you write:
void foo(optiona
Jens Widell
2014/06/13 14:14:52
Yes. The argumentOrNull() function returns an empt
haraken
2014/06/13 14:32:53
Sorry for not being clear. I understand that your
Jens Widell
2014/06/13 14:49:46
I see. :-) Well, if I read the spec correctly, you
haraken
2014/06/13 14:59:03
Makes sense, thanks!
Nils Barth (inactive)
2014/06/16 09:18:17
Same conclusion as Joshua
(i.e., go ahead with thi
Jens Widell
2014/06/16 09:37:14
You are (both) right, naturally. And it was of cou
| |
304 v8_value = 'argumentOrNull(info, %s)' % index | 307 v8_value = 'argumentOrNull(info, %s)' % index |
305 else: | 308 else: |
306 v8_value = 'info[%s]' % index | 309 v8_value = 'info[%s]' % index |
307 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, | 310 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, |
308 name, index=index, declare_varia ble=False) | 311 name, index=index, declare_varia ble=False) |
309 | 312 |
310 | 313 |
311 ################################################################################ | 314 ################################################################################ |
312 # Auxiliary functions | 315 # Auxiliary functions |
313 ################################################################################ | 316 ################################################################################ |
(...skipping 12 matching lines...) Expand all Loading... | |
326 | 329 |
327 | 330 |
328 def union_arguments(idl_type): | 331 def union_arguments(idl_type): |
329 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" | 332 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" |
330 return [arg | 333 return [arg |
331 for i in range(len(idl_type.member_types)) | 334 for i in range(len(idl_type.member_types)) |
332 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 335 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
333 | 336 |
334 IdlType.union_arguments = property(lambda self: None) | 337 IdlType.union_arguments = property(lambda self: None) |
335 IdlUnionType.union_arguments = property(union_arguments) | 338 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |