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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 'is_nullable': idl_type.is_nullable, | 167 'is_nullable': idl_type.is_nullable, |
168 'is_optional': argument.is_optional, | 168 'is_optional': argument.is_optional, |
169 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes, | 169 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes, |
170 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 170 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
171 'vector_type': 'WillBeHeapVector' if use_heap_vector_type else 'Vector', | 171 'vector_type': 'WillBeHeapVector' if use_heap_vector_type else 'Vector', |
172 'is_wrapper_type': idl_type.is_wrapper_type, | 172 'is_wrapper_type': idl_type.is_wrapper_type, |
173 'name': argument.name, | 173 'name': argument.name, |
174 '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_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), |
175 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 175 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
176 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind
ex), | 176 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind
ex), |
| 177 'v8_value_to_local_cpp_value_async': v8_value_to_local_cpp_value_async(a
rgument, index), |
177 } | 178 } |
178 | 179 |
179 | 180 |
180 ################################################################################ | 181 ################################################################################ |
181 # Value handling | 182 # Value handling |
182 ################################################################################ | 183 ################################################################################ |
183 | 184 |
184 def cpp_value(interface, method, number_of_arguments): | 185 def cpp_value(interface, method, number_of_arguments): |
185 def cpp_argument(argument): | 186 def cpp_argument(argument): |
186 idl_type = argument.idl_type | 187 idl_type = argument.idl_type |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 # [Default=NullString] | 249 # [Default=NullString] |
249 if (argument.is_optional and idl_type.name == 'String' and | 250 if (argument.is_optional and idl_type.name == 'String' and |
250 extended_attributes.get('Default') == 'NullString'): | 251 extended_attributes.get('Default') == 'NullString'): |
251 v8_value = 'argumentOrNull(info, %s)' % index | 252 v8_value = 'argumentOrNull(info, %s)' % index |
252 else: | 253 else: |
253 v8_value = 'info[%s]' % index | 254 v8_value = 'info[%s]' % index |
254 return idl_type.v8_value_to_local_cpp_value(argument.extended_attributes, | 255 return idl_type.v8_value_to_local_cpp_value(argument.extended_attributes, |
255 v8_value, name, index=index) | 256 v8_value, name, index=index) |
256 | 257 |
257 | 258 |
| 259 def v8_value_to_local_cpp_value_async(argument, index): |
| 260 extended_attributes = argument.extended_attributes |
| 261 idl_type = argument.idl_type |
| 262 name = argument.name |
| 263 if argument.is_variadic: |
| 264 vector_type = 'WillBeHeapVector' if idl_type.is_will_be_garbage_collecte
d else 'Vector' |
| 265 return 'V8TRYCATCH_VOID_PROMISE({vector_type}<{cpp_type}>, {name}, toNat
iveArguments<{cpp_type}>(info, {index}), info)'.format( |
| 266 cpp_type=idl_type.cpp_type, name=name, index=index, vector_type=
vector_type) |
| 267 # [Default=NullString] |
| 268 if (argument.is_optional and idl_type.name == 'String' and |
| 269 extended_attributes.get('Default') == 'NullString'): |
| 270 v8_value = 'argumentOrNull(info, %s)' % index |
| 271 else: |
| 272 v8_value = 'info[%s]' % index |
| 273 return idl_type.v8_value_to_local_cpp_value_async(argument.extended_attribut
es, |
| 274 v8_value, name, index=inde
x) |
| 275 |
| 276 |
258 ################################################################################ | 277 ################################################################################ |
259 # Auxiliary functions | 278 # Auxiliary functions |
260 ################################################################################ | 279 ################################################################################ |
261 | 280 |
262 # [NotEnumerable] | 281 # [NotEnumerable] |
263 def property_attributes(method): | 282 def property_attributes(method): |
264 extended_attributes = method.extended_attributes | 283 extended_attributes = method.extended_attributes |
265 property_attributes_list = [] | 284 property_attributes_list = [] |
266 if 'NotEnumerable' in extended_attributes: | 285 if 'NotEnumerable' in extended_attributes: |
267 property_attributes_list.append('v8::DontEnum') | 286 property_attributes_list.append('v8::DontEnum') |
268 if 'ReadOnly' in extended_attributes: | 287 if 'ReadOnly' in extended_attributes: |
269 property_attributes_list.append('v8::ReadOnly') | 288 property_attributes_list.append('v8::ReadOnly') |
270 if property_attributes_list: | 289 if property_attributes_list: |
271 property_attributes_list.insert(0, 'v8::DontDelete') | 290 property_attributes_list.insert(0, 'v8::DontDelete') |
272 return property_attributes_list | 291 return property_attributes_list |
273 | 292 |
274 | 293 |
275 def union_arguments(idl_type): | 294 def union_arguments(idl_type): |
276 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" | 295 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" |
277 return [arg | 296 return [arg |
278 for i in range(len(idl_type.member_types)) | 297 for i in range(len(idl_type.member_types)) |
279 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 298 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
280 | 299 |
281 IdlType.union_arguments = property(lambda self: None) | 300 IdlType.union_arguments = property(lambda self: None) |
282 IdlUnionType.union_arguments = property(union_arguments) | 301 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |