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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 extended_attributes = argument.extended_attributes | 193 extended_attributes = argument.extended_attributes |
194 idl_type = argument.idl_type | 194 idl_type = argument.idl_type |
195 this_cpp_value = cpp_value(interface, method, index) | 195 this_cpp_value = cpp_value(interface, method, index) |
196 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | 196 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type |
197 | 197 |
198 if ('ImplementedInPrivateScript' in extended_attributes and | 198 if ('ImplementedInPrivateScript' in extended_attributes and |
199 not idl_type.is_wrapper_type and | 199 not idl_type.is_wrapper_type and |
200 not idl_type.is_basic_type): | 200 not idl_type.is_basic_type): |
201 raise Exception('Private scripts supports only primitive types and DOM w rappers.') | 201 raise Exception('Private scripts supports only primitive types and DOM w rappers.') |
202 | 202 |
203 default_value = argument.default_cpp_value | |
203 return { | 204 return { |
204 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es, | 205 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es, |
205 raw_type=True, | 206 raw_type=True, |
206 used_as_variadic_argument=argument.is _variadic), | 207 used_as_variadic_argument=argument.is _variadic), |
207 'cpp_value': this_cpp_value, | 208 'cpp_value': this_cpp_value, |
208 # FIXME: check that the default value's type is compatible with the argu ment's | 209 # FIXME: check that the default value's type is compatible with the argu ment's |
209 'default_value': argument.default_cpp_value, | 210 'default_value': default_value, |
210 'enum_validation_expression': idl_type.enum_validation_expression, | 211 'enum_validation_expression': idl_type.enum_validation_expression, |
211 'handle': '%sHandle' % argument.name, | 212 'handle': '%sHandle' % argument.name, |
212 # FIXME: remove once [Default] removed and just use argument.default_val ue | 213 # FIXME: remove once [Default] removed and just use argument.default_val ue |
213 'has_default': 'Default' in extended_attributes or argument.default_valu e, | 214 'has_default': 'Default' in extended_attributes or default_value, |
214 'has_type_checking_interface': | 215 'has_type_checking_interface': |
215 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or | 216 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or |
216 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and | 217 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and |
217 idl_type.is_wrapper_type, | 218 idl_type.is_wrapper_type, |
218 'has_type_checking_unrestricted': | 219 'has_type_checking_unrestricted': |
219 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or | 220 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or |
220 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and | 221 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and |
221 idl_type.name in ('Float', 'Double'), | 222 idl_type.name in ('Float', 'Double'), |
222 # Dictionary is special-cased, but arrays and sequences shouldn't be | 223 # Dictionary is special-cased, but arrays and sequences shouldn't be |
223 'idl_type': not idl_type.native_array_element_type and idl_type.base_typ e, | 224 'idl_type': not idl_type.native_array_element_type and idl_type.base_typ e, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 | 380 |
380 | 381 |
381 def union_arguments(idl_type): | 382 def union_arguments(idl_type): |
382 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" | 383 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" |
383 return [arg | 384 return [arg |
384 for i in range(len(idl_type.member_types)) | 385 for i in range(len(idl_type.member_types)) |
385 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 386 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
386 | 387 |
387 | 388 |
388 def argument_default_cpp_value(argument): | 389 def argument_default_cpp_value(argument): |
390 if argument.idl_type.is_dictionary: | |
391 # Dictionaries always have the default value | |
Nils Barth (inactive)
2014/07/18 21:52:35
the/a:
# Dictionaries always have a default value
bashi
2014/07/22 02:33:58
Done.
| |
392 return '%s::create()' % argument.idl_type.base_type | |
389 if not argument.default_value: | 393 if not argument.default_value: |
390 return None | 394 return None |
391 return argument.idl_type.literal_cpp_value(argument.default_value) | 395 return argument.idl_type.literal_cpp_value(argument.default_value) |
392 | 396 |
393 IdlType.union_arguments = property(lambda self: None) | 397 IdlType.union_arguments = property(lambda self: None) |
394 IdlUnionType.union_arguments = property(union_arguments) | 398 IdlUnionType.union_arguments = property(union_arguments) |
395 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | 399 IdlArgument.default_cpp_value = property(argument_default_cpp_value) |
OLD | NEW |