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 21 matching lines...) Expand all Loading... |
32 Extends IdlTypeBase and IdlUnionType with property |union_arguments|. | 32 Extends IdlTypeBase and IdlUnionType with property |union_arguments|. |
33 | 33 |
34 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 34 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
35 """ | 35 """ |
36 | 36 |
37 from idl_definitions import IdlArgument, IdlOperation | 37 from idl_definitions import IdlArgument, IdlOperation |
38 from idl_types import IdlTypeBase, IdlUnionType, inherits_interface | 38 from idl_types import IdlTypeBase, IdlUnionType, inherits_interface |
39 from v8_globals import includes | 39 from v8_globals import includes |
40 import v8_types | 40 import v8_types |
41 import v8_utilities | 41 import v8_utilities |
42 from v8_utilities import has_extended_attribute_value, is_unforgeable | 42 from v8_utilities import (has_extended_attribute_value, is_unforgeable, |
| 43 is_legacy_interface_type_checking) |
43 | 44 |
44 | 45 |
45 # Methods with any of these require custom method registration code in the | 46 # Methods with any of these require custom method registration code in the |
46 # interface's configure*Template() function. | 47 # interface's configure*Template() function. |
47 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ | 48 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ |
48 'DoNotCheckSecurity', | 49 'DoNotCheckSecurity', |
49 'DoNotCheckSignature', | 50 'DoNotCheckSignature', |
50 'NotEnumerable', | 51 'NotEnumerable', |
51 'Unforgeable', | 52 'Unforgeable', |
52 ]) | 53 ]) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings], | 190 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings], |
190 } | 191 } |
191 | 192 |
192 | 193 |
193 def argument_context(interface, method, argument, index): | 194 def argument_context(interface, method, argument, index): |
194 extended_attributes = argument.extended_attributes | 195 extended_attributes = argument.extended_attributes |
195 idl_type = argument.idl_type | 196 idl_type = argument.idl_type |
196 this_cpp_value = cpp_value(interface, method, index) | 197 this_cpp_value = cpp_value(interface, method, index) |
197 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | 198 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type |
198 | 199 |
199 type_checking_interface = ( | 200 # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking] |
200 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or | 201 has_type_checking_interface = ( |
201 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and | 202 not is_legacy_interface_type_checking(interface, method) and |
202 idl_type.is_wrapper_type) | 203 idl_type.is_wrapper_type) |
203 | 204 |
204 if ('ImplementedInPrivateScript' in extended_attributes and | 205 if ('ImplementedInPrivateScript' in extended_attributes and |
205 not idl_type.is_wrapper_type and | 206 not idl_type.is_wrapper_type and |
206 not idl_type.is_basic_type): | 207 not idl_type.is_basic_type): |
207 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | 208 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') |
208 | 209 |
209 set_default_value = argument.set_default_value | 210 set_default_value = argument.set_default_value |
210 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, | 211 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, |
211 raw_type=True, | 212 raw_type=True, |
212 used_as_variadic_argument=argument.is
_variadic) | 213 used_as_variadic_argument=argument.is
_variadic) |
213 return { | 214 return { |
214 'cpp_type': ( | 215 'cpp_type': ( |
215 v8_types.cpp_template_type('Nullable', this_cpp_type) | 216 v8_types.cpp_template_type('Nullable', this_cpp_type) |
216 if idl_type.is_explicit_nullable and not argument.is_variadic | 217 if idl_type.is_explicit_nullable and not argument.is_variadic |
217 else this_cpp_type), | 218 else this_cpp_type), |
218 'cpp_value': this_cpp_value, | 219 'cpp_value': this_cpp_value, |
219 # FIXME: check that the default value's type is compatible with the argu
ment's | 220 # FIXME: check that the default value's type is compatible with the argu
ment's |
220 'set_default_value': set_default_value, | 221 'set_default_value': set_default_value, |
221 'enum_validation_expression': idl_type.enum_validation_expression, | 222 'enum_validation_expression': idl_type.enum_validation_expression, |
222 'handle': '%sHandle' % argument.name, | 223 'handle': '%sHandle' % argument.name, |
223 # FIXME: remove once [Default] removed and just use argument.default_val
ue | 224 # FIXME: remove once [Default] removed and just use argument.default_val
ue |
224 'has_default': 'Default' in extended_attributes or set_default_value, | 225 'has_default': 'Default' in extended_attributes or set_default_value, |
225 'has_type_checking_interface': type_checking_interface, | 226 'has_type_checking_interface': has_type_checking_interface, |
226 # Dictionary is special-cased, but arrays and sequences shouldn't be | 227 # Dictionary is special-cased, but arrays and sequences shouldn't be |
227 'idl_type': idl_type.base_type, | 228 'idl_type': idl_type.base_type, |
228 'idl_type_object': idl_type, | 229 'idl_type_object': idl_type, |
229 'index': index, | 230 'index': index, |
230 'is_callback_function': idl_type.is_callback_function, | 231 'is_callback_function': idl_type.is_callback_function, |
231 'is_callback_interface': idl_type.is_callback_interface, | 232 'is_callback_interface': idl_type.is_callback_interface, |
232 # FIXME: Remove generic 'Dictionary' special-casing | 233 # FIXME: Remove generic 'Dictionary' special-casing |
233 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio
nary', | 234 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio
nary', |
234 'is_explicit_nullable': idl_type.is_explicit_nullable, | 235 'is_explicit_nullable': idl_type.is_explicit_nullable, |
235 'is_nullable': idl_type.is_nullable, | 236 'is_nullable': idl_type.is_nullable, |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 448 |
448 IdlOperation.returns_promise = property(method_returns_promise) | 449 IdlOperation.returns_promise = property(method_returns_promise) |
449 | 450 |
450 | 451 |
451 def argument_conversion_needs_exception_state(method, argument): | 452 def argument_conversion_needs_exception_state(method, argument): |
452 idl_type = argument.idl_type | 453 idl_type = argument.idl_type |
453 return (idl_type.v8_conversion_needs_exception_state or | 454 return (idl_type.v8_conversion_needs_exception_state or |
454 argument.is_variadic or | 455 argument.is_variadic or |
455 (method.returns_promise and (idl_type.is_string_type or | 456 (method.returns_promise and (idl_type.is_string_type or |
456 idl_type.is_enum))) | 457 idl_type.is_enum))) |
OLD | NEW |