| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 property_attributes_list.append('v8::ReadOnly') | 399 property_attributes_list.append('v8::ReadOnly') |
| 400 if property_attributes_list: | 400 if property_attributes_list: |
| 401 property_attributes_list.insert(0, 'v8::DontDelete') | 401 property_attributes_list.insert(0, 'v8::DontDelete') |
| 402 return property_attributes_list | 402 return property_attributes_list |
| 403 | 403 |
| 404 | 404 |
| 405 def union_member_argument_context(idl_type, index): | 405 def union_member_argument_context(idl_type, index): |
| 406 """Returns a context of union member for argument.""" | 406 """Returns a context of union member for argument.""" |
| 407 this_cpp_value = 'result%d' % index | 407 this_cpp_value = 'result%d' % index |
| 408 this_cpp_type = idl_type.cpp_type | 408 this_cpp_type = idl_type.cpp_type |
| 409 this_cpp_type_initializer = idl_type.cpp_type_initializer |
| 409 cpp_return_value = this_cpp_value | 410 cpp_return_value = this_cpp_value |
| 410 | 411 |
| 411 if not idl_type.cpp_type_has_null_value: | 412 if not idl_type.cpp_type_has_null_value: |
| 412 this_cpp_type = v8_types.cpp_template_type('Nullable', this_cpp_type) | 413 this_cpp_type = v8_types.cpp_template_type('Nullable', this_cpp_type) |
| 414 this_cpp_type_initializer = '' |
| 413 cpp_return_value = '%s.get()' % this_cpp_value | 415 cpp_return_value = '%s.get()' % this_cpp_value |
| 414 | 416 |
| 415 if idl_type.is_string_type: | 417 if idl_type.is_string_type: |
| 416 null_check_value = '!%s.isNull()' % this_cpp_value | 418 null_check_value = '!%s.isNull()' % this_cpp_value |
| 417 else: | 419 else: |
| 418 null_check_value = this_cpp_value | 420 null_check_value = this_cpp_value |
| 419 | 421 |
| 420 return { | 422 return { |
| 421 'cpp_type': this_cpp_type, | 423 'cpp_type': this_cpp_type, |
| 424 'cpp_type_initializer': this_cpp_type_initializer, |
| 422 'cpp_value': this_cpp_value, | 425 'cpp_value': this_cpp_value, |
| 423 'null_check_value': null_check_value, | 426 'null_check_value': null_check_value, |
| 424 'v8_set_return_value': idl_type.v8_set_return_value( | 427 'v8_set_return_value': idl_type.v8_set_return_value( |
| 425 cpp_value=cpp_return_value, | 428 cpp_value=cpp_return_value, |
| 426 release=idl_type.release), | 429 release=idl_type.release), |
| 427 } | 430 } |
| 428 | 431 |
| 429 | 432 |
| 430 def union_arguments(idl_type): | 433 def union_arguments(idl_type): |
| 431 return [union_member_argument_context(member_idl_type, index) | 434 return [union_member_argument_context(member_idl_type, index) |
| 432 for index, member_idl_type | 435 for index, member_idl_type |
| 433 in enumerate(idl_type.member_types)] | 436 in enumerate(idl_type.member_types)] |
| 434 | 437 |
| 435 | 438 |
| 436 def argument_default_cpp_value(argument): | 439 def argument_default_cpp_value(argument): |
| 437 if not argument.default_value: | 440 if not argument.default_value: |
| 438 return None | 441 return None |
| 439 return argument.idl_type.literal_cpp_value(argument.default_value) | 442 return argument.idl_type.literal_cpp_value(argument.default_value) |
| 440 | 443 |
| 441 IdlTypeBase.union_arguments = None | 444 IdlTypeBase.union_arguments = None |
| 442 IdlUnionType.union_arguments = property(union_arguments) | 445 IdlUnionType.union_arguments = property(union_arguments) |
| 443 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | 446 IdlArgument.default_cpp_value = property(argument_default_cpp_value) |
| OLD | NEW |