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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 'idl_type_object': idl_type, | 161 'idl_type_object': idl_type, |
162 'index': index, | 162 'index': index, |
163 'is_clamp': 'Clamp' in extended_attributes, | 163 'is_clamp': 'Clamp' in extended_attributes, |
164 'is_callback_interface': idl_type.is_callback_interface, | 164 'is_callback_interface': idl_type.is_callback_interface, |
165 'is_nullable': idl_type.is_nullable, | 165 'is_nullable': idl_type.is_nullable, |
166 'is_optional': argument.is_optional, | 166 'is_optional': argument.is_optional, |
167 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 167 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
168 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type), | 168 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type), |
169 'is_wrapper_type': idl_type.is_wrapper_type, | 169 'is_wrapper_type': idl_type.is_wrapper_type, |
170 'name': argument.name, | 170 'name': argument.name, |
171 'default_value': argument.default_value, | |
Nils Barth (inactive)
2014/05/16 12:22:54
Alphabetical order please.
| |
171 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), | 172 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), |
172 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), | 173 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), |
173 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex), | 174 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex), |
174 } | 175 } |
175 | 176 |
176 | 177 |
177 ################################################################################ | 178 ################################################################################ |
178 # Value handling | 179 # Value handling |
179 ################################################################################ | 180 ################################################################################ |
180 | 181 |
181 def cpp_value(interface, method, number_of_arguments): | 182 def cpp_value(interface, method, number_of_arguments): |
182 def cpp_argument(argument): | 183 def cpp_argument(argument): |
183 idl_type = argument.idl_type | 184 idl_type = argument.idl_type |
184 if idl_type.name == 'EventListener': | 185 if idl_type.name == 'EventListener': |
185 if (interface.name == 'EventTarget' and | 186 if (interface.name == 'EventTarget' and |
186 method.name == 'removeEventListener'): | 187 method.name == 'removeEventListener'): |
187 # FIXME: remove this special case by moving get() into | 188 # FIXME: remove this special case by moving get() into |
188 # EventTarget::removeEventListener | 189 # EventTarget::removeEventListener |
189 return '%s.get()' % argument.name | 190 return '%s.get()' % argument.name |
190 return argument.name | 191 return argument.name |
191 if (idl_type.is_callback_interface or | 192 if (idl_type.is_callback_interface or |
192 idl_type.name in ['NodeFilter', 'XPathNSResolver']): | 193 idl_type.name in ['NodeFilter', 'XPathNSResolver']): |
193 # FIXME: remove this special case | 194 # FIXME: remove this special case |
194 return '%s.release()' % argument.name | 195 return '%s.release()' % argument.name |
195 return argument.name | 196 return argument.name |
196 | 197 |
197 # Truncate omitted optional arguments | 198 # Truncate omitted optional arguments |
Nils Barth (inactive)
2014/05/16 12:22:54
Could you move these down to the cpp_arguments.ext
| |
198 arguments = method.arguments[:number_of_arguments] | 199 required_arguments = method.arguments[:number_of_arguments] |
200 optional_arguments = method.arguments[number_of_arguments:] | |
199 cpp_arguments = v8_utilities.call_with_arguments(method) | 201 cpp_arguments = v8_utilities.call_with_arguments(method) |
200 # Members of IDL partial interface definitions are implemented in C++ as | 202 # Members of IDL partial interface definitions are implemented in C++ as |
201 # static member functions, which for instance members (non-static members) | 203 # static member functions, which for instance members (non-static members) |
202 # take *impl as their first argument | 204 # take *impl as their first argument |
203 if ('PartialInterfaceImplementedAs' in method.extended_attributes and | 205 if ('PartialInterfaceImplementedAs' in method.extended_attributes and |
204 not method.is_static): | 206 not method.is_static): |
205 cpp_arguments.append('*impl') | 207 cpp_arguments.append('*impl') |
206 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) | 208 cpp_arguments.extend(cpp_argument(argument) for argument in required_argumen ts) |
Nils Barth (inactive)
2014/05/16 12:22:54
Line breaks please, here and next line:
loop and c
| |
209 cpp_arguments.extend(argument.default_value for argument in optional_argumen ts if argument.is_optional and argument.default_value) | |
207 this_union_arguments = method.idl_type and method.idl_type.union_arguments | 210 this_union_arguments = method.idl_type and method.idl_type.union_arguments |
208 if this_union_arguments: | 211 if this_union_arguments: |
209 cpp_arguments.extend(this_union_arguments) | 212 cpp_arguments.extend(this_union_arguments) |
210 | 213 |
211 if 'RaisesException' in method.extended_attributes: | 214 if 'RaisesException' in method.extended_attributes: |
212 cpp_arguments.append('exceptionState') | 215 cpp_arguments.append('exceptionState') |
213 | 216 |
214 if method.name == 'Constructor': | 217 if method.name == 'Constructor': |
215 base_name = 'create' | 218 base_name = 'create' |
216 elif method.name == 'NamedConstructor': | 219 elif method.name == 'NamedConstructor': |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 | 280 |
278 | 281 |
279 def union_arguments(idl_type): | 282 def union_arguments(idl_type): |
280 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" | 283 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" |
281 return [arg | 284 return [arg |
282 for i in range(len(idl_type.member_types)) | 285 for i in range(len(idl_type.member_types)) |
283 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 286 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
284 | 287 |
285 IdlType.union_arguments = property(lambda self: None) | 288 IdlType.union_arguments = property(lambda self: None) |
286 IdlUnionType.union_arguments = property(union_arguments) | 289 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |