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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), | 173 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), |
174 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), | 174 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), |
175 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex), | 175 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex), |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 ################################################################################ | 179 ################################################################################ |
180 # Value handling | 180 # Value handling |
181 ################################################################################ | 181 ################################################################################ |
182 | 182 |
183 def cpp_value(interface, method, number_of_arguments): | 183 def cpp_value(interface, method, number_of_arguments, for_constructor=False): |
Nils Barth (inactive)
2014/04/09 02:00:27
I don't think for_constructor is necessary:
you ca
sof
2014/04/09 07:31:59
'method' is an IdlOperation/IdlAttribute/.. object
Nils Barth (inactive)
2014/04/09 09:36:38
Got it!
| |
184 def cpp_argument(argument): | 184 def cpp_argument(argument): |
185 idl_type = argument.idl_type | 185 idl_type = argument.idl_type |
186 if idl_type.name == 'EventListener': | 186 if idl_type.name == 'EventListener': |
187 if (interface.name == 'EventTarget' and | 187 if (interface.name == 'EventTarget' and |
188 method.name == 'removeEventListener'): | 188 method.name == 'removeEventListener'): |
189 # FIXME: remove this special case by moving get() into | 189 # FIXME: remove this special case by moving get() into |
190 # EventTarget::removeEventListener | 190 # EventTarget::removeEventListener |
191 return '%s.get()' % argument.name | 191 return '%s.get()' % argument.name |
192 return argument.name | 192 return argument.name |
193 if (idl_type.is_callback_interface or | 193 if (idl_type.is_callback_interface or |
194 idl_type.name in ['NodeFilter', 'XPathNSResolver']): | 194 idl_type.name in ['NodeFilter', 'XPathNSResolver']): |
195 # FIXME: remove this special case | 195 # FIXME: remove this special case |
196 return '%s.release()' % argument.name | 196 return '%s.release()' % argument.name |
197 return argument.name | 197 return argument.name |
198 | 198 |
199 # Truncate omitted optional arguments | 199 # Truncate omitted optional arguments |
200 arguments = method.arguments[:number_of_arguments] | 200 arguments = method.arguments[:number_of_arguments] |
201 cpp_arguments = v8_utilities.call_with_arguments(method) | 201 cpp_arguments = v8_utilities.call_with_arguments(method) |
202 # Members of IDL partial interface definitions are implemented in C++ as | 202 # Members of IDL partial interface definitions are implemented in C++ as |
203 # static member functions, which for instance members (non-static members) | 203 # static member functions, which for instance members (non-static members) |
204 # take *impl as their first argument | 204 # take *impl as their first argument |
205 if ('PartialInterfaceImplementedAs' in method.extended_attributes and | 205 if ('PartialInterfaceImplementedAs' in method.extended_attributes and |
206 not method.is_static): | 206 not method.is_static): |
207 cpp_arguments.append('*impl') | 207 cpp_arguments.append('*impl') |
208 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) | 208 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) |
209 this_union_arguments = method.idl_type.union_arguments | 209 this_union_arguments = method.idl_type and method.idl_type.union_arguments |
210 if this_union_arguments: | 210 if this_union_arguments: |
211 cpp_arguments.extend(this_union_arguments) | 211 cpp_arguments.extend(this_union_arguments) |
212 | 212 |
213 if 'RaisesException' in method.extended_attributes: | 213 if 'RaisesException' in method.extended_attributes: |
214 cpp_arguments.append('exceptionState') | 214 cpp_arguments.append('exceptionState') |
215 | 215 |
216 cpp_method_name = v8_utilities.scoped_name(interface, method, v8_utilities.c pp_name(method)) | 216 if for_constructor: |
217 cpp_method_name = "%s::create" % v8_utilities.cpp_name(interface) | |
Nils Barth (inactive)
2014/04/09 02:00:27
I think you can push this into v8_utilities.scoped
sof
2014/04/09 07:31:59
For the same reasons as the above comment, attribu
| |
218 else: | |
219 cpp_method_name = v8_utilities.scoped_name(interface, method, v8_utiliti es.cpp_name(method)) | |
217 return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) | 220 return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) |
218 | 221 |
219 | 222 |
220 def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False) : | 223 def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False) : |
221 idl_type = method.idl_type | 224 idl_type = method.idl_type |
222 extended_attributes = method.extended_attributes | 225 extended_attributes = method.extended_attributes |
223 if idl_type.name == 'void': | 226 if idl_type.name == 'void': |
224 return None | 227 return None |
225 | 228 |
226 release = False | 229 release = False |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 | 275 |
273 | 276 |
274 def union_arguments(idl_type): | 277 def union_arguments(idl_type): |
275 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" | 278 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" |
276 return [arg | 279 return [arg |
277 for i in range(len(idl_type.member_types)) | 280 for i in range(len(idl_type.member_types)) |
278 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 281 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
279 | 282 |
280 IdlType.union_arguments = property(lambda self: None) | 283 IdlType.union_arguments = property(lambda self: None) |
281 IdlUnionType.union_arguments = property(union_arguments) | 284 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |