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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 # FIXME: Support union type. | 563 # FIXME: Support union type. |
564 if idl_type.is_union_type: | 564 if idl_type.is_union_type: |
565 return '' | 565 return '' |
566 | 566 |
567 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, raw_type=True) | 567 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut
es, raw_type=True) |
568 | 568 |
569 idl_type = idl_type.preprocessed_type | 569 idl_type = idl_type.preprocessed_type |
570 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i
ndex, isolate) | 570 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i
ndex, isolate) |
571 args = [variable_name, cpp_value] | 571 args = [variable_name, cpp_value] |
572 if idl_type.base_type == 'DOMString': | 572 if idl_type.base_type == 'DOMString': |
573 macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_VOID
' | 573 if return_promise: |
| 574 macro = 'TOSTRING_VOID_EXCEPTIONSTATE' |
| 575 else: |
| 576 macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_
VOID' |
574 elif idl_type.v8_conversion_needs_exception_state: | 577 elif idl_type.v8_conversion_needs_exception_state: |
575 macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else
'TONATIVE_VOID_EXCEPTIONSTATE' | 578 macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else
'TONATIVE_VOID_EXCEPTIONSTATE' |
576 args.append('exceptionState') | |
577 elif idl_type.v8_conversion_is_trivial: | 579 elif idl_type.v8_conversion_is_trivial: |
578 assignment = '%s = %s' % (variable_name, cpp_value) | 580 assignment = '%s = %s' % (variable_name, cpp_value) |
579 if declare_variable: | 581 if declare_variable: |
580 return '%s %s' % (this_cpp_type, assignment) | 582 return '%s %s' % (this_cpp_type, assignment) |
581 return assignment | 583 return assignment |
582 else: | 584 else: |
583 macro = 'TONATIVE_DEFAULT' if used_in_private_script else 'TONATIVE_VOID
' | 585 macro = 'TONATIVE_DEFAULT' if used_in_private_script else 'TONATIVE_VOID
' |
584 | 586 |
| 587 if macro.endswith('_EXCEPTIONSTATE'): |
| 588 args.append('exceptionState') |
| 589 |
585 if used_in_private_script: | 590 if used_in_private_script: |
586 args.append('false') | 591 args.append('false') |
587 | 592 |
588 # Macros come in several variants, to minimize expensive creation of | 593 # Macros come in several variants, to minimize expensive creation of |
589 # v8::TryCatch. | 594 # v8::TryCatch. |
590 suffix = '' | 595 suffix = '' |
591 | 596 |
592 if return_promise: | 597 if return_promise: |
593 suffix += '_PROMISE' | 598 suffix += '_PROMISE' |
594 args.append('info') | 599 args.append('info') |
595 if macro == 'TONATIVE_VOID_EXCEPTIONSTATE': | 600 if macro.endswith('_EXCEPTIONSTATE'): |
596 args.append('ScriptState::current(%s)' % isolate) | 601 args.append('ScriptState::current(%s)' % isolate) |
597 | 602 |
598 if declare_variable: | 603 if declare_variable: |
599 args.insert(0, this_cpp_type) | 604 args.insert(0, this_cpp_type) |
600 else: | 605 else: |
601 suffix += '_INTERNAL' | 606 suffix += '_INTERNAL' |
602 | 607 |
603 return '%s(%s)' % (macro + suffix, ', '.join(args)) | 608 return '%s(%s)' % (macro + suffix, ', '.join(args)) |
604 | 609 |
605 IdlTypeBase.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 610 IdlTypeBase.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 | 850 |
846 | 851 |
847 def is_explicit_nullable(idl_type): | 852 def is_explicit_nullable(idl_type): |
848 # Nullable type that isn't implicit nullable (see above.) For such types, | 853 # Nullable type that isn't implicit nullable (see above.) For such types, |
849 # we use Nullable<T> or similar explicit ways to represent a null value. | 854 # we use Nullable<T> or similar explicit ways to represent a null value. |
850 return idl_type.is_nullable and not idl_type.is_implicit_nullable | 855 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
851 | 856 |
852 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) | 857 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |
853 IdlUnionType.is_implicit_nullable = False | 858 IdlUnionType.is_implicit_nullable = False |
854 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) | 859 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |
OLD | NEW |