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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 this_cpp_value = cpp_value(interface, method, index) | 216 this_cpp_value = cpp_value(interface, method, index) |
217 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | 217 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type |
218 return_promise = (method.idl_type.name == 'Promise' if method.idl_type | 218 return_promise = (method.idl_type.name == 'Promise' if method.idl_type |
219 else False) | 219 else False) |
220 | 220 |
221 if ('ImplementedInPrivateScript' in extended_attributes and | 221 if ('ImplementedInPrivateScript' in extended_attributes and |
222 not idl_type.is_wrapper_type and | 222 not idl_type.is_wrapper_type and |
223 not idl_type.is_basic_type): | 223 not idl_type.is_basic_type): |
224 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | 224 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') |
225 | 225 |
| 226 default_cpp_value = argument.default_cpp_value |
226 return { | 227 return { |
227 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut
es, | 228 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut
es, |
228 raw_type=True, | 229 raw_type=True, |
229 used_as_variadic_argument=argument.is
_variadic), | 230 used_as_variadic_argument=argument.is
_variadic), |
230 'cpp_value': this_cpp_value, | 231 'cpp_value': this_cpp_value, |
231 # FIXME: check that the default value's type is compatible with the argu
ment's | 232 # FIXME: check that the default value's type is compatible with the argu
ment's |
232 'default_value': argument.default_cpp_value, | 233 'default_value': default_cpp_value, |
233 'enum_validation_expression': idl_type.enum_validation_expression, | 234 'enum_validation_expression': idl_type.enum_validation_expression, |
234 'handle': '%sHandle' % argument.name, | 235 'handle': '%sHandle' % argument.name, |
235 # FIXME: remove once [Default] removed and just use argument.default_val
ue | 236 # FIXME: remove once [Default] removed and just use argument.default_val
ue |
236 'has_default': 'Default' in extended_attributes or argument.default_valu
e, | 237 'has_default': 'Default' in extended_attributes or default_cpp_value, |
237 'has_type_checking_interface': | 238 'has_type_checking_interface': |
238 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface'
) or | 239 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface'
) or |
239 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and | 240 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and |
240 idl_type.is_wrapper_type, | 241 idl_type.is_wrapper_type, |
241 'has_type_checking_unrestricted': | 242 'has_type_checking_unrestricted': |
242 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or | 243 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or |
243 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and | 244 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and |
244 idl_type.name in ('Float', 'Double'), | 245 idl_type.name in ('Float', 'Double'), |
245 # Dictionary is special-cased, but arrays and sequences shouldn't be | 246 # Dictionary is special-cased, but arrays and sequences shouldn't be |
246 'idl_type': idl_type.base_type, | 247 'idl_type': idl_type.base_type, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 440 } |
440 | 441 |
441 | 442 |
442 def union_arguments(idl_type): | 443 def union_arguments(idl_type): |
443 return [union_member_argument_context(member_idl_type, index) | 444 return [union_member_argument_context(member_idl_type, index) |
444 for index, member_idl_type | 445 for index, member_idl_type |
445 in enumerate(idl_type.member_types)] | 446 in enumerate(idl_type.member_types)] |
446 | 447 |
447 | 448 |
448 def argument_default_cpp_value(argument): | 449 def argument_default_cpp_value(argument): |
| 450 if argument.idl_type.is_dictionary: |
| 451 # We always create impl objects for IDL dictionaries. |
| 452 return '%s::create()' % argument.idl_type.base_type |
449 if not argument.default_value: | 453 if not argument.default_value: |
450 return None | 454 return None |
451 return argument.idl_type.literal_cpp_value(argument.default_value) | 455 return argument.idl_type.literal_cpp_value(argument.default_value) |
452 | 456 |
453 IdlTypeBase.union_arguments = None | 457 IdlTypeBase.union_arguments = None |
454 IdlUnionType.union_arguments = property(union_arguments) | 458 IdlUnionType.union_arguments = property(union_arguments) |
455 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | 459 IdlArgument.default_cpp_value = property(argument_default_cpp_value) |
OLD | NEW |