| 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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 if 'TreatReturnedNullStringAs' not in extended_attributes: | 721 if 'TreatReturnedNullStringAs' not in extended_attributes: |
| 722 return base_idl_type | 722 return base_idl_type |
| 723 treat_returned_null_string_as = extended_attributes['TreatReturnedNullSt
ringAs'] | 723 treat_returned_null_string_as = extended_attributes['TreatReturnedNullSt
ringAs'] |
| 724 if treat_returned_null_string_as == 'Null': | 724 if treat_returned_null_string_as == 'Null': |
| 725 return 'StringOrNull' | 725 return 'StringOrNull' |
| 726 if treat_returned_null_string_as == 'Undefined': | 726 if treat_returned_null_string_as == 'Undefined': |
| 727 return 'StringOrUndefined' | 727 return 'StringOrUndefined' |
| 728 raise 'Unrecognized TreatReturnedNullStringAs value: "%s"' % treat_retur
ned_null_string_as | 728 raise 'Unrecognized TreatReturnedNullStringAs value: "%s"' % treat_retur
ned_null_string_as |
| 729 if idl_type.is_basic_type or base_idl_type == 'ScriptValue': | 729 if idl_type.is_basic_type or base_idl_type == 'ScriptValue': |
| 730 return base_idl_type | 730 return base_idl_type |
| 731 # Generic dictionary type |
| 732 if base_idl_type == 'Dictionary': |
| 733 return 'Dictionary' |
| 731 | 734 |
| 732 # Data type with potential additional includes | 735 # Data type with potential additional includes |
| 733 add_includes_for_type(idl_type) | 736 add_includes_for_type(idl_type) |
| 734 if base_idl_type in V8_SET_RETURN_VALUE: # Special v8SetReturnValue treatme
nt | 737 if base_idl_type in V8_SET_RETURN_VALUE: # Special v8SetReturnValue treatme
nt |
| 735 return base_idl_type | 738 return base_idl_type |
| 736 | 739 |
| 737 # Pointer type | 740 # Pointer type |
| 738 return 'DOMWrapper' | 741 return 'DOMWrapper' |
| 739 | 742 |
| 740 IdlTypeBase.v8_conversion_type = v8_conversion_type | 743 IdlTypeBase.v8_conversion_type = v8_conversion_type |
| (...skipping 19 matching lines...) Expand all Loading... |
| 760 # and then use general v8SetReturnValue. | 763 # and then use general v8SetReturnValue. |
| 761 'array': 'v8SetReturnValue(info, {cpp_value})', | 764 'array': 'v8SetReturnValue(info, {cpp_value})', |
| 762 'Date': 'v8SetReturnValue(info, {cpp_value})', | 765 'Date': 'v8SetReturnValue(info, {cpp_value})', |
| 763 'EventHandler': 'v8SetReturnValue(info, {cpp_value})', | 766 'EventHandler': 'v8SetReturnValue(info, {cpp_value})', |
| 764 'ScriptValue': 'v8SetReturnValue(info, {cpp_value})', | 767 'ScriptValue': 'v8SetReturnValue(info, {cpp_value})', |
| 765 'SerializedScriptValue': 'v8SetReturnValue(info, {cpp_value})', | 768 'SerializedScriptValue': 'v8SetReturnValue(info, {cpp_value})', |
| 766 # DOMWrapper | 769 # DOMWrapper |
| 767 'DOMWrapperForMainWorld': 'v8SetReturnValueForMainWorld(info, WTF::getPtr({c
pp_value}))', | 770 'DOMWrapperForMainWorld': 'v8SetReturnValueForMainWorld(info, WTF::getPtr({c
pp_value}))', |
| 768 'DOMWrapperFast': 'v8SetReturnValueFast(info, WTF::getPtr({cpp_value}), {scr
ipt_wrappable})', | 771 'DOMWrapperFast': 'v8SetReturnValueFast(info, WTF::getPtr({cpp_value}), {scr
ipt_wrappable})', |
| 769 'DOMWrapperDefault': 'v8SetReturnValue(info, {cpp_value})', | 772 'DOMWrapperDefault': 'v8SetReturnValue(info, {cpp_value})', |
| 773 # Generic dictionary type |
| 774 'Dictionary': 'v8SetReturnValue(info, {cpp_value})', |
| 770 # Union types or dictionaries | 775 # Union types or dictionaries |
| 771 'DictionaryOrUnion': 'v8SetReturnValue(info, result)', | 776 'DictionaryOrUnion': 'v8SetReturnValue(info, result)', |
| 772 } | 777 } |
| 773 | 778 |
| 774 | 779 |
| 775 def v8_set_return_value(idl_type, cpp_value, extended_attributes=None, script_wr
appable='', release=False, for_main_world=False): | 780 def v8_set_return_value(idl_type, cpp_value, extended_attributes=None, script_wr
appable='', release=False, for_main_world=False): |
| 776 """Returns a statement that converts a C++ value to a V8 value and sets it a
s a return value. | 781 """Returns a statement that converts a C++ value to a V8 value and sets it a
s a return value. |
| 777 | 782 |
| 778 """ | 783 """ |
| 779 def dom_wrapper_conversion_type(): | 784 def dom_wrapper_conversion_type(): |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', | 822 'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', |
| 818 'float': 'v8::Number::New({isolate}, {cpp_value})', | 823 'float': 'v8::Number::New({isolate}, {cpp_value})', |
| 819 'unrestricted float': 'v8::Number::New({isolate}, {cpp_value})', | 824 'unrestricted float': 'v8::Number::New({isolate}, {cpp_value})', |
| 820 'double': 'v8::Number::New({isolate}, {cpp_value})', | 825 'double': 'v8::Number::New({isolate}, {cpp_value})', |
| 821 'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})', | 826 'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})', |
| 822 'void': 'v8Undefined()', | 827 'void': 'v8Undefined()', |
| 823 # [TreatReturnedNullStringAs] | 828 # [TreatReturnedNullStringAs] |
| 824 'StringOrNull': '{cpp_value}.isNull() ? v8::Handle<v8::Value>(v8::Null({isol
ate})) : v8String({isolate}, {cpp_value})', | 829 'StringOrNull': '{cpp_value}.isNull() ? v8::Handle<v8::Value>(v8::Null({isol
ate})) : v8String({isolate}, {cpp_value})', |
| 825 'StringOrUndefined': '{cpp_value}.isNull() ? v8Undefined() : v8String({isola
te}, {cpp_value})', | 830 'StringOrUndefined': '{cpp_value}.isNull() ? v8Undefined() : v8String({isola
te}, {cpp_value})', |
| 826 # Special cases | 831 # Special cases |
| 832 'Dictionary': '{cpp_value}.v8Value()', |
| 827 'EventHandler': '{cpp_value} ? v8::Handle<v8::Value>(V8AbstractEventListener
::cast({cpp_value})->getListenerObject(impl->executionContext())) : v8::Handle<v
8::Value>(v8::Null({isolate}))', | 833 'EventHandler': '{cpp_value} ? v8::Handle<v8::Value>(V8AbstractEventListener
::cast({cpp_value})->getListenerObject(impl->executionContext())) : v8::Handle<v
8::Value>(v8::Null({isolate}))', |
| 828 'ScriptValue': '{cpp_value}.v8Value()', | 834 'ScriptValue': '{cpp_value}.v8Value()', |
| 829 'SerializedScriptValue': '{cpp_value} ? {cpp_value}->deserialize() : v8::Han
dle<v8::Value>(v8::Null({isolate}))', | 835 'SerializedScriptValue': '{cpp_value} ? {cpp_value}->deserialize() : v8::Han
dle<v8::Value>(v8::Null({isolate}))', |
| 830 # General | 836 # General |
| 831 'array': 'v8Array({cpp_value}, {creation_context}, {isolate})', | 837 'array': 'v8Array({cpp_value}, {creation_context}, {isolate})', |
| 832 'DOMWrapper': 'toV8({cpp_value}, {creation_context}, {isolate})', | 838 'DOMWrapper': 'toV8({cpp_value}, {creation_context}, {isolate})', |
| 833 # Union types or dictionaries | 839 # Union types or dictionaries |
| 834 'DictionaryOrUnion': 'toV8({cpp_value}, {creation_context}, {isolate})', | 840 'DictionaryOrUnion': 'toV8({cpp_value}, {creation_context}, {isolate})', |
| 835 } | 841 } |
| 836 | 842 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 number_of_nullable_member_types_union) | 914 number_of_nullable_member_types_union) |
| 909 | 915 |
| 910 | 916 |
| 911 def includes_nullable_type_union(idl_type): | 917 def includes_nullable_type_union(idl_type): |
| 912 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 918 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
| 913 return idl_type.number_of_nullable_member_types == 1 | 919 return idl_type.number_of_nullable_member_types == 1 |
| 914 | 920 |
| 915 IdlTypeBase.includes_nullable_type = False | 921 IdlTypeBase.includes_nullable_type = False |
| 916 IdlNullableType.includes_nullable_type = True | 922 IdlNullableType.includes_nullable_type = True |
| 917 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 923 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
| OLD | NEW |