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 # 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, |
184 'enum_validation_expression': idl_type.enum_validation_expression, | 186 'enum_validation_expression': idl_type.enum_validation_expression, |
185 'has_default': 'Default' in extended_attributes, | 187 # FIXME: remove once [Default] removed and just use argument.default_val
ue |
| 188 'has_default': 'Default' in extended_attributes or argument.default_valu
e, |
186 'has_event_listener_argument': any( | 189 'has_event_listener_argument': any( |
187 argument_so_far for argument_so_far in method.arguments[:index] | 190 argument_so_far for argument_so_far in method.arguments[:index] |
188 if argument_so_far.idl_type.name == 'EventListener'), | 191 if argument_so_far.idl_type.name == 'EventListener'), |
189 'has_type_checking_interface': | 192 'has_type_checking_interface': |
190 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface'
) or | 193 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface'
) or |
191 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and | 194 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and |
192 idl_type.is_wrapper_type, | 195 idl_type.is_wrapper_type, |
193 'has_type_checking_unrestricted': | 196 'has_type_checking_unrestricted': |
194 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or | 197 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or |
195 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and | 198 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 294 |
292 return '%s(%s)' % (macro, ', '.join(macro_args)) | 295 return '%s(%s)' % (macro, ', '.join(macro_args)) |
293 | 296 |
294 | 297 |
295 def v8_value_to_local_cpp_value(argument, index): | 298 def v8_value_to_local_cpp_value(argument, index): |
296 extended_attributes = argument.extended_attributes | 299 extended_attributes = argument.extended_attributes |
297 idl_type = argument.idl_type | 300 idl_type = argument.idl_type |
298 name = argument.name | 301 name = argument.name |
299 if argument.is_variadic: | 302 if argument.is_variadic: |
300 return v8_value_to_local_cpp_variadic_value(argument, index) | 303 return v8_value_to_local_cpp_variadic_value(argument, index) |
301 # [Default=NullString] | 304 # FIXME: This special way of handling string arguments with null defaults |
| 305 # can go away once we fully support default values. |
302 if (argument.is_optional and idl_type.name in ('String', 'ByteString') and | 306 if (argument.is_optional and idl_type.name in ('String', 'ByteString') and |
303 extended_attributes.get('Default') == 'NullString'): | 307 argument.default_value and argument.default_value.is_null): |
304 v8_value = 'argumentOrNull(info, %s)' % index | 308 v8_value = 'argumentOrNull(info, %s)' % index |
305 else: | 309 else: |
306 v8_value = 'info[%s]' % index | 310 v8_value = 'info[%s]' % index |
307 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, | 311 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, |
308 name, index=index, declare_varia
ble=False) | 312 name, index=index, declare_varia
ble=False) |
309 | 313 |
310 | 314 |
311 ################################################################################ | 315 ################################################################################ |
312 # Auxiliary functions | 316 # Auxiliary functions |
313 ################################################################################ | 317 ################################################################################ |
(...skipping 12 matching lines...) Expand all Loading... |
326 | 330 |
327 | 331 |
328 def union_arguments(idl_type): | 332 def union_arguments(idl_type): |
329 """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""" |
330 return [arg | 334 return [arg |
331 for i in range(len(idl_type.member_types)) | 335 for i in range(len(idl_type.member_types)) |
332 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 336 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
333 | 337 |
334 IdlType.union_arguments = property(lambda self: None) | 338 IdlType.union_arguments = property(lambda self: None) |
335 IdlUnionType.union_arguments = property(union_arguments) | 339 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |