| 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 # Simple types | 763 # Simple types |
| 764 base_idl_type = idl_type.base_type | 764 base_idl_type = idl_type.base_type |
| 765 # Basic types, without additional includes | 765 # Basic types, without additional includes |
| 766 if base_idl_type in CPP_INT_TYPES: | 766 if base_idl_type in CPP_INT_TYPES: |
| 767 return 'int' | 767 return 'int' |
| 768 if base_idl_type in CPP_UNSIGNED_TYPES: | 768 if base_idl_type in CPP_UNSIGNED_TYPES: |
| 769 return 'unsigned' | 769 return 'unsigned' |
| 770 if idl_type.is_string_type: | 770 if idl_type.is_string_type: |
| 771 if idl_type.is_nullable: | 771 if idl_type.is_nullable: |
| 772 return 'StringOrNull' | 772 return 'StringOrNull' |
| 773 if 'TreatReturnedNullStringAs' not in extended_attributes: | 773 return base_idl_type |
| 774 return base_idl_type | |
| 775 treat_returned_null_string_as = extended_attributes['TreatReturnedNullSt
ringAs'] | |
| 776 if treat_returned_null_string_as == 'Null': | |
| 777 return 'StringOrNull' | |
| 778 if treat_returned_null_string_as == 'Undefined': | |
| 779 return 'StringOrUndefined' | |
| 780 raise 'Unrecognized TreatReturnedNullStringAs value: "%s"' % treat_retur
ned_null_string_as | |
| 781 if idl_type.is_basic_type or base_idl_type == 'ScriptValue': | 774 if idl_type.is_basic_type or base_idl_type == 'ScriptValue': |
| 782 return base_idl_type | 775 return base_idl_type |
| 783 # Generic dictionary type | 776 # Generic dictionary type |
| 784 if base_idl_type == 'Dictionary': | 777 if base_idl_type == 'Dictionary': |
| 785 return 'Dictionary' | 778 return 'Dictionary' |
| 786 | 779 |
| 787 # Data type with potential additional includes | 780 # Data type with potential additional includes |
| 788 if base_idl_type in V8_SET_RETURN_VALUE: # Special v8SetReturnValue treatme
nt | 781 if base_idl_type in V8_SET_RETURN_VALUE: # Special v8SetReturnValue treatme
nt |
| 789 return base_idl_type | 782 return base_idl_type |
| 790 | 783 |
| 791 # Pointer type | 784 # Pointer type |
| 792 return 'DOMWrapper' | 785 return 'DOMWrapper' |
| 793 | 786 |
| 794 IdlTypeBase.v8_conversion_type = v8_conversion_type | 787 IdlTypeBase.v8_conversion_type = v8_conversion_type |
| 795 | 788 |
| 796 | 789 |
| 797 V8_SET_RETURN_VALUE = { | 790 V8_SET_RETURN_VALUE = { |
| 798 'boolean': 'v8SetReturnValueBool(info, {cpp_value})', | 791 'boolean': 'v8SetReturnValueBool(info, {cpp_value})', |
| 799 'int': 'v8SetReturnValueInt(info, {cpp_value})', | 792 'int': 'v8SetReturnValueInt(info, {cpp_value})', |
| 800 'unsigned': 'v8SetReturnValueUnsigned(info, {cpp_value})', | 793 'unsigned': 'v8SetReturnValueUnsigned(info, {cpp_value})', |
| 801 'DOMString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', | 794 'DOMString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', |
| 802 'ByteString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())'
, | 795 'ByteString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())'
, |
| 803 'USVString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', | 796 'USVString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', |
| 804 # [TreatReturnedNullStringAs] | |
| 805 'StringOrNull': 'v8SetReturnValueStringOrNull(info, {cpp_value}, info.GetIso
late())', | 797 'StringOrNull': 'v8SetReturnValueStringOrNull(info, {cpp_value}, info.GetIso
late())', |
| 806 'StringOrUndefined': 'v8SetReturnValueStringOrUndefined(info, {cpp_value}, i
nfo.GetIsolate())', | |
| 807 'void': '', | 798 'void': '', |
| 808 # No special v8SetReturnValue* function (set value directly) | 799 # No special v8SetReturnValue* function (set value directly) |
| 809 'float': 'v8SetReturnValue(info, {cpp_value})', | 800 'float': 'v8SetReturnValue(info, {cpp_value})', |
| 810 'unrestricted float': 'v8SetReturnValue(info, {cpp_value})', | 801 'unrestricted float': 'v8SetReturnValue(info, {cpp_value})', |
| 811 'double': 'v8SetReturnValue(info, {cpp_value})', | 802 'double': 'v8SetReturnValue(info, {cpp_value})', |
| 812 'unrestricted double': 'v8SetReturnValue(info, {cpp_value})', | 803 'unrestricted double': 'v8SetReturnValue(info, {cpp_value})', |
| 813 # No special v8SetReturnValue* function, but instead convert value to V8 | 804 # No special v8SetReturnValue* function, but instead convert value to V8 |
| 814 # and then use general v8SetReturnValue. | 805 # and then use general v8SetReturnValue. |
| 815 'array': 'v8SetReturnValue(info, {cpp_value})', | 806 'array': 'v8SetReturnValue(info, {cpp_value})', |
| 816 'Date': 'v8SetReturnValue(info, {cpp_value})', | 807 'Date': 'v8SetReturnValue(info, {cpp_value})', |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 'ByteString': 'v8String({isolate}, {cpp_value})', | 874 'ByteString': 'v8String({isolate}, {cpp_value})', |
| 884 'USVString': 'v8String({isolate}, {cpp_value})', | 875 'USVString': 'v8String({isolate}, {cpp_value})', |
| 885 'boolean': 'v8Boolean({cpp_value}, {isolate})', | 876 'boolean': 'v8Boolean({cpp_value}, {isolate})', |
| 886 'int': 'v8::Integer::New({isolate}, {cpp_value})', | 877 'int': 'v8::Integer::New({isolate}, {cpp_value})', |
| 887 'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', | 878 'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', |
| 888 'float': 'v8::Number::New({isolate}, {cpp_value})', | 879 'float': 'v8::Number::New({isolate}, {cpp_value})', |
| 889 'unrestricted float': 'v8::Number::New({isolate}, {cpp_value})', | 880 'unrestricted float': 'v8::Number::New({isolate}, {cpp_value})', |
| 890 'double': 'v8::Number::New({isolate}, {cpp_value})', | 881 'double': 'v8::Number::New({isolate}, {cpp_value})', |
| 891 'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})', | 882 'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})', |
| 892 'void': 'v8Undefined()', | 883 'void': 'v8Undefined()', |
| 893 # [TreatReturnedNullStringAs] | |
| 894 'StringOrNull': '{cpp_value}.isNull() ? v8::Local<v8::Value>(v8::Null({isola
te})) : v8String({isolate}, {cpp_value})', | 884 'StringOrNull': '{cpp_value}.isNull() ? v8::Local<v8::Value>(v8::Null({isola
te})) : v8String({isolate}, {cpp_value})', |
| 895 'StringOrUndefined': '{cpp_value}.isNull() ? v8Undefined() : v8String({isola
te}, {cpp_value})', | |
| 896 # Special cases | 885 # Special cases |
| 897 'Dictionary': '{cpp_value}.v8Value()', | 886 'Dictionary': '{cpp_value}.v8Value()', |
| 898 'EventHandler': '{cpp_value} ? v8::Local<v8::Value>(V8AbstractEventListener:
:cast({cpp_value})->getListenerObject(impl->executionContext())) : v8::Local<v8:
:Value>(v8::Null({isolate}))', | 887 'EventHandler': '{cpp_value} ? v8::Local<v8::Value>(V8AbstractEventListener:
:cast({cpp_value})->getListenerObject(impl->executionContext())) : v8::Local<v8:
:Value>(v8::Null({isolate}))', |
| 899 'ScriptValue': '{cpp_value}.v8Value()', | 888 'ScriptValue': '{cpp_value}.v8Value()', |
| 900 'SerializedScriptValue': '{cpp_value} ? {cpp_value}->deserialize() : v8::Loc
al<v8::Value>(v8::Null({isolate}))', | 889 'SerializedScriptValue': '{cpp_value} ? {cpp_value}->deserialize() : v8::Loc
al<v8::Value>(v8::Null({isolate}))', |
| 901 # General | 890 # General |
| 902 'array': 'toV8({cpp_value}, {creation_context}, {isolate})', | 891 'array': 'toV8({cpp_value}, {creation_context}, {isolate})', |
| 903 'DOMWrapper': 'toV8({cpp_value}, {creation_context}, {isolate})', | 892 'DOMWrapper': 'toV8({cpp_value}, {creation_context}, {isolate})', |
| 904 # Passing nullable dictionaries isn't a pattern currently used | 893 # Passing nullable dictionaries isn't a pattern currently used |
| 905 # anywhere in the web platform, and more work would be needed in | 894 # anywhere in the web platform, and more work would be needed in |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 number_of_nullable_member_types_union) | 1006 number_of_nullable_member_types_union) |
| 1018 | 1007 |
| 1019 | 1008 |
| 1020 def includes_nullable_type_union(idl_type): | 1009 def includes_nullable_type_union(idl_type): |
| 1021 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 1010 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
| 1022 return idl_type.number_of_nullable_member_types == 1 | 1011 return idl_type.number_of_nullable_member_types == 1 |
| 1023 | 1012 |
| 1024 IdlTypeBase.includes_nullable_type = False | 1013 IdlTypeBase.includes_nullable_type = False |
| 1025 IdlNullableType.includes_nullable_type = True | 1014 IdlNullableType.includes_nullable_type = True |
| 1026 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 1015 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
| OLD | NEW |