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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 135 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
136 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings] | 136 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings] |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 def generate_argument(interface, method, argument, index): | 140 def generate_argument(interface, method, argument, index): |
141 extended_attributes = argument.extended_attributes | 141 extended_attributes = argument.extended_attributes |
142 idl_type = argument.idl_type | 142 idl_type = argument.idl_type |
143 this_cpp_value = cpp_value(interface, method, index) | 143 this_cpp_value = cpp_value(interface, method, index) |
144 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | 144 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type |
| 145 |
145 return { | 146 return { |
146 'cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=is_variadic_wrap
per_type), | 147 'cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=is_variadic_wrap
per_type), |
147 'cpp_value': this_cpp_value, | 148 'cpp_value': this_cpp_value, |
148 'enum_validation_expression': idl_type.enum_validation_expression, | 149 'enum_validation_expression': idl_type.enum_validation_expression, |
149 'has_default': 'Default' in extended_attributes, | 150 'has_default': 'Default' in extended_attributes, |
150 'has_event_listener_argument': any( | 151 'has_event_listener_argument': any( |
151 argument_so_far for argument_so_far in method.arguments[:index] | 152 argument_so_far for argument_so_far in method.arguments[:index] |
152 if argument_so_far.idl_type.name == 'EventListener'), | 153 if argument_so_far.idl_type.name == 'EventListener'), |
153 'has_legacy_overload_string': # [LegacyOverloadString] | 154 'has_legacy_overload_string': # [LegacyOverloadString] |
154 'LegacyOverloadString' in extended_attributes, | 155 'LegacyOverloadString' in extended_attributes, |
155 'has_type_checking_interface': | 156 'has_type_checking_interface': |
156 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface'
) or | 157 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface'
) or |
157 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and | 158 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and |
158 idl_type.is_wrapper_type, | 159 idl_type.is_wrapper_type, |
| 160 'has_type_checking_unrestricted': |
| 161 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or |
| 162 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and |
| 163 idl_type.name in ('Float', 'Double'), |
159 # Dictionary is special-cased, but arrays and sequences shouldn't be | 164 # Dictionary is special-cased, but arrays and sequences shouldn't be |
160 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, | 165 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, |
161 'idl_type_object': idl_type, | 166 'idl_type_object': idl_type, |
162 'index': index, | 167 'index': index, |
163 'is_clamp': 'Clamp' in extended_attributes, | 168 'is_clamp': 'Clamp' in extended_attributes, |
164 'is_callback_interface': idl_type.is_callback_interface, | 169 'is_callback_interface': idl_type.is_callback_interface, |
165 'is_nullable': idl_type.is_nullable, | 170 'is_nullable': idl_type.is_nullable, |
166 'is_optional': argument.is_optional, | 171 'is_optional': argument.is_optional, |
167 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 172 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
168 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc
_type), | 173 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc
_type), |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 282 |
278 | 283 |
279 def union_arguments(idl_type): | 284 def union_arguments(idl_type): |
280 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" | 285 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" |
281 return [arg | 286 return [arg |
282 for i in range(len(idl_type.member_types)) | 287 for i in range(len(idl_type.member_types)) |
283 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 288 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
284 | 289 |
285 IdlType.union_arguments = property(lambda self: None) | 290 IdlType.union_arguments = property(lambda self: None) |
286 IdlUnionType.union_arguments = property(union_arguments) | 291 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |