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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 # static member functions, which for instance members (non-static members) | 297 # static member functions, which for instance members (non-static members) |
298 # take *impl as their first argument | 298 # take *impl as their first argument |
299 if ('PartialInterfaceImplementedAs' in method.extended_attributes and | 299 if ('PartialInterfaceImplementedAs' in method.extended_attributes and |
300 not 'ImplementedInPrivateScript' in method.extended_attributes and | 300 not 'ImplementedInPrivateScript' in method.extended_attributes and |
301 not method.is_static): | 301 not method.is_static): |
302 cpp_arguments.append('*impl') | 302 cpp_arguments.append('*impl') |
303 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) | 303 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) |
304 | 304 |
305 this_union_arguments = method.idl_type and method.idl_type.union_arguments | 305 this_union_arguments = method.idl_type and method.idl_type.union_arguments |
306 if this_union_arguments: | 306 if this_union_arguments: |
307 cpp_arguments.extend(this_union_arguments) | 307 cpp_arguments.extend([member_argument['cpp_value'] |
| 308 for member_argument in this_union_arguments]) |
308 | 309 |
309 if 'ImplementedInPrivateScript' in method.extended_attributes: | 310 if 'ImplementedInPrivateScript' in method.extended_attributes: |
310 if method.idl_type.name != 'void': | 311 if method.idl_type.name != 'void': |
311 cpp_arguments.append('&result') | 312 cpp_arguments.append('&result') |
312 elif ('RaisesException' in method.extended_attributes or | 313 elif ('RaisesException' in method.extended_attributes or |
313 (method.is_constructor and | 314 (method.is_constructor and |
314 has_extended_attribute_value(interface, 'RaisesException', 'Constructor
'))): | 315 has_extended_attribute_value(interface, 'RaisesException', 'Constructor
'))): |
315 cpp_arguments.append('exceptionState') | 316 cpp_arguments.append('exceptionState') |
316 | 317 |
317 if method.name == 'Constructor': | 318 if method.name == 'Constructor': |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 property_attributes_list = [] | 395 property_attributes_list = [] |
395 if 'NotEnumerable' in extended_attributes: | 396 if 'NotEnumerable' in extended_attributes: |
396 property_attributes_list.append('v8::DontEnum') | 397 property_attributes_list.append('v8::DontEnum') |
397 if 'Unforgeable' in extended_attributes: | 398 if 'Unforgeable' in extended_attributes: |
398 property_attributes_list.append('v8::ReadOnly') | 399 property_attributes_list.append('v8::ReadOnly') |
399 if property_attributes_list: | 400 if property_attributes_list: |
400 property_attributes_list.insert(0, 'v8::DontDelete') | 401 property_attributes_list.insert(0, 'v8::DontDelete') |
401 return property_attributes_list | 402 return property_attributes_list |
402 | 403 |
403 | 404 |
| 405 def union_member_argument_context(idl_type, index): |
| 406 """Returns a context of union member for argument.""" |
| 407 this_cpp_value = 'result%d' % index |
| 408 this_cpp_type = idl_type.cpp_type |
| 409 cpp_return_value = this_cpp_value |
| 410 |
| 411 if not idl_type.cpp_type_has_null_value: |
| 412 this_cpp_type = v8_types.cpp_template_type('Nullable', this_cpp_type) |
| 413 cpp_return_value = '%s.get()' % this_cpp_value |
| 414 |
| 415 if idl_type.is_string_type: |
| 416 null_check_value = '!%s.isNull()' % this_cpp_value |
| 417 else: |
| 418 null_check_value = this_cpp_value |
| 419 |
| 420 return { |
| 421 'cpp_type': this_cpp_type, |
| 422 'cpp_value': this_cpp_value, |
| 423 'null_check_value': null_check_value, |
| 424 'v8_set_return_value': idl_type.v8_set_return_value( |
| 425 cpp_value=cpp_return_value, |
| 426 release=idl_type.release), |
| 427 } |
| 428 |
| 429 |
404 def union_arguments(idl_type): | 430 def union_arguments(idl_type): |
405 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" | 431 return [union_member_argument_context(member_idl_type, index) |
406 return [arg | 432 for index, member_idl_type |
407 for i in range(len(idl_type.member_types)) | 433 in enumerate(idl_type.member_types)] |
408 for arg in ['result%sEnabled' % i, 'result%s' % i]] | |
409 | 434 |
410 | 435 |
411 def argument_default_cpp_value(argument): | 436 def argument_default_cpp_value(argument): |
412 if not argument.default_value: | 437 if not argument.default_value: |
413 return None | 438 return None |
414 return argument.idl_type.literal_cpp_value(argument.default_value) | 439 return argument.idl_type.literal_cpp_value(argument.default_value) |
415 | 440 |
416 IdlTypeBase.union_arguments = None | 441 IdlTypeBase.union_arguments = None |
417 IdlUnionType.union_arguments = property(union_arguments) | 442 IdlUnionType.union_arguments = property(union_arguments) |
418 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | 443 IdlArgument.default_cpp_value = property(argument_default_cpp_value) |
OLD | NEW |