OLD | NEW |
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> | 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> |
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> | 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> |
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> | 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> |
5 # Copyright (C) 2006 Apple Computer, Inc. | 5 # Copyright (C) 2006 Apple Computer, Inc. |
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. | 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. |
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. | 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. |
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. | 10 # Copyright (C) 2012 Ericsson AB. All rights reserved. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 "short" => 1, | 162 "short" => 1, |
163 "long" => 1, | 163 "long" => 1, |
164 "long long" => 1, | 164 "long long" => 1, |
165 "unsigned short" => 1, | 165 "unsigned short" => 1, |
166 "unsigned long" => 1, | 166 "unsigned long" => 1, |
167 "unsigned long long" => 1, | 167 "unsigned long long" => 1, |
168 "float" => 1, | 168 "float" => 1, |
169 "double" => 1, | 169 "double" => 1, |
170 ); | 170 ); |
171 | 171 |
| 172 my %integerTypeHash = ("byte" => 1, |
| 173 "octet" => 1, |
| 174 "short" => 1, |
| 175 "long" => 1, |
| 176 "long long" => 1, |
| 177 "unsigned short" => 1, |
| 178 "unsigned long" => 1, |
| 179 "unsigned long long" => 1, |
| 180 ); |
| 181 |
172 my %nonWrapperTypes = ("CompareHow" => 1, | 182 my %nonWrapperTypes = ("CompareHow" => 1, |
173 "Dictionary" => 1, | 183 "Dictionary" => 1, |
174 "EventListener" => 1, | 184 "EventListener" => 1, |
175 "EventHandler" => 1, | 185 "EventHandler" => 1, |
176 "MediaQueryListListener" => 1, | 186 "MediaQueryListListener" => 1, |
177 "NodeFilter" => 1, | 187 "NodeFilter" => 1, |
178 "SerializedScriptValue" => 1, | 188 "SerializedScriptValue" => 1, |
179 "any" => 1, | 189 "any" => 1, |
180 ); | 190 ); |
181 | 191 |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 | 1022 |
1013 template<class CallbackInfo, class Wrappable> | 1023 template<class CallbackInfo, class Wrappable> |
1014 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<${
nativeType} > impl, Wrappable* wrappable) | 1024 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<${
nativeType} > impl, Wrappable* wrappable) |
1015 { | 1025 { |
1016 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); | 1026 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); |
1017 } | 1027 } |
1018 | 1028 |
1019 END | 1029 END |
1020 | 1030 |
1021 if (IsConstructorTemplate($interface, "Event")) { | 1031 if (IsConstructorTemplate($interface, "Event")) { |
1022 $header{nameSpaceWebCore}->add("bool fill${implClassName}Init(${implClas
sName}Init&, const Dictionary&);\n\n"); | 1032 $header{nameSpaceWebCore}->add("bool fill${implClassName}Init(${implClas
sName}Init&, const Dictionary&, ExceptionState&);\n\n"); |
1023 } | 1033 } |
1024 } | 1034 } |
1025 | 1035 |
1026 sub GetInternalFields | 1036 sub GetInternalFields |
1027 { | 1037 { |
1028 my $interface = shift; | 1038 my $interface = shift; |
1029 | 1039 |
1030 my @customInternalFields = (); | 1040 my @customInternalFields = (); |
1031 # Event listeners on DOM nodes are explicitly supported in the GC controller
. | 1041 # Event listeners on DOM nodes are explicitly supported in the GC controller
. |
1032 if (!InheritsInterface($interface, "Node") && | 1042 if (!InheritsInterface($interface, "Node") && |
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 } | 2866 } |
2857 } | 2867 } |
2858 | 2868 |
2859 sub GenerateEventConstructor | 2869 sub GenerateEventConstructor |
2860 { | 2870 { |
2861 my $interface = shift; | 2871 my $interface = shift; |
2862 my $interfaceName = $interface->name; | 2872 my $interfaceName = $interface->name; |
2863 my $implClassName = GetImplName($interface); | 2873 my $implClassName = GetImplName($interface); |
2864 my $v8ClassName = GetV8ClassName($interface); | 2874 my $v8ClassName = GetV8ClassName($interface); |
2865 | 2875 |
| 2876 my $constructorRaisesException = $interface->extendedAttributes->{"RaisesExc
eption"} && $interface->extendedAttributes->{"RaisesException"} eq "Constructor"
; |
| 2877 |
2866 my @anyAttributeNames; | 2878 my @anyAttributeNames; |
2867 my @serializableAnyAttributeNames; | 2879 my @serializableAnyAttributeNames; |
2868 foreach my $attribute (@{$interface->attributes}) { | 2880 foreach my $attribute (@{$interface->attributes}) { |
2869 if ($attribute->type eq "any") { | 2881 if ($attribute->type eq "any") { |
2870 push(@anyAttributeNames, $attribute->name); | 2882 push(@anyAttributeNames, $attribute->name); |
2871 if (!$attribute->extendedAttributes->{"Unserializable"}) { | 2883 if (!$attribute->extendedAttributes->{"Unserializable"}) { |
2872 push(@serializableAnyAttributeNames, $attribute->name); | 2884 push(@serializableAnyAttributeNames, $attribute->name); |
2873 } | 2885 } |
2874 } | 2886 } |
2875 } | 2887 } |
(...skipping 12 matching lines...) Expand all Loading... |
2888 END | 2900 END |
2889 | 2901 |
2890 foreach my $attrName (@anyAttributeNames) { | 2902 foreach my $attrName (@anyAttributeNames) { |
2891 $implementation{nameSpaceInternal}->add(" v8::Local<v8::Value> ${attr
Name};\n"); | 2903 $implementation{nameSpaceInternal}->add(" v8::Local<v8::Value> ${attr
Name};\n"); |
2892 } | 2904 } |
2893 | 2905 |
2894 $implementation{nameSpaceInternal}->add(<<END); | 2906 $implementation{nameSpaceInternal}->add(<<END); |
2895 ${implClassName}Init eventInit; | 2907 ${implClassName}Init eventInit; |
2896 if (info.Length() >= 2) { | 2908 if (info.Length() >= 2) { |
2897 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate
())); | 2909 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate
())); |
2898 if (!fill${implClassName}Init(eventInit, options)) | 2910 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 2911 if (!fill${implClassName}Init(eventInit, options, exceptionState)) { |
| 2912 exceptionState.throwIfNeeded(); |
2899 return; | 2913 return; |
| 2914 } |
2900 END | 2915 END |
2901 | 2916 |
2902 # Store 'any'-typed properties on the wrapper to avoid leaking them between
isolated worlds. | 2917 # Store 'any'-typed properties on the wrapper to avoid leaking them between
isolated worlds. |
2903 foreach my $attrName (@anyAttributeNames) { | 2918 foreach my $attrName (@anyAttributeNames) { |
2904 $implementation{nameSpaceInternal}->add(<<END); | 2919 $implementation{nameSpaceInternal}->add(<<END); |
2905 options.get("${attrName}", ${attrName}); | 2920 options.get("${attrName}", ${attrName}); |
2906 if (!${attrName}.IsEmpty()) | 2921 if (!${attrName}.IsEmpty()) |
2907 info.Holder()->SetHiddenValue(V8HiddenPropertyName::${attrName}(info
.GetIsolate()), ${attrName}); | 2922 info.Holder()->SetHiddenValue(V8HiddenPropertyName::${attrName}(info
.GetIsolate()), ${attrName}); |
2908 END | 2923 END |
2909 } | 2924 } |
2910 | 2925 |
2911 $implementation{nameSpaceInternal}->add(<<END); | 2926 $implementation{nameSpaceInternal}->add(<<END); |
2912 } | 2927 } |
| 2928 END |
2913 | 2929 |
2914 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit); | 2930 my $exceptionStateArgument = ""; |
| 2931 if ($constructorRaisesException) { |
| 2932 ${exceptionStateArgument} = ", exceptionState"; |
| 2933 $implementation{nameSpaceInternal}->add(<<END); |
| 2934 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
2915 END | 2935 END |
| 2936 } |
| 2937 |
| 2938 $implementation{nameSpaceInternal}->add(<<END); |
| 2939 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit${e
xceptionStateArgument}); |
| 2940 END |
| 2941 |
| 2942 if ($constructorRaisesException) { |
| 2943 $implementation{nameSpaceInternal}->add(<<END); |
| 2944 if (exceptionState.throwIfNeeded()) |
| 2945 return; |
| 2946 END |
| 2947 } |
2916 | 2948 |
2917 if (@serializableAnyAttributeNames) { | 2949 if (@serializableAnyAttributeNames) { |
2918 # If we're in an isolated world, create a SerializedScriptValue and stor
e it in the event for | 2950 # If we're in an isolated world, create a SerializedScriptValue and stor
e it in the event for |
2919 # later cloning if the property is accessed from another world. | 2951 # later cloning if the property is accessed from another world. |
2920 # The main world case is handled lazily (in Custom code). | 2952 # The main world case is handled lazily (in Custom code). |
2921 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 2953 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
2922 $implementation{nameSpaceInternal}->add(" if (isolatedWorldForIsolate
(info.GetIsolate())) {\n"); | 2954 $implementation{nameSpaceInternal}->add(" if (isolatedWorldForIsolate
(info.GetIsolate())) {\n"); |
2923 foreach my $attrName (@serializableAnyAttributeNames) { | 2955 foreach my $attrName (@serializableAnyAttributeNames) { |
2924 my $setter = "setSerialized" . FirstLetterToUpperCase($attrName); | 2956 my $setter = "setSerialized" . FirstLetterToUpperCase($attrName); |
2925 $implementation{nameSpaceInternal}->add(<<END); | 2957 $implementation{nameSpaceInternal}->add(<<END); |
2926 if (!${attrName}.IsEmpty()) | 2958 if (!${attrName}.IsEmpty()) |
2927 event->${setter}(SerializedScriptValue::createAndSwallowExceptions($
{attrName}, info.GetIsolate())); | 2959 event->${setter}(SerializedScriptValue::createAndSwallowExceptions($
{attrName}, info.GetIsolate())); |
2928 END | 2960 END |
2929 } | 2961 } |
2930 $implementation{nameSpaceInternal}->add(" }\n\n"); | 2962 $implementation{nameSpaceInternal}->add(" }\n\n"); |
2931 } | 2963 } |
2932 | 2964 |
2933 $implementation{nameSpaceInternal}->add(<<END); | 2965 $implementation{nameSpaceInternal}->add(<<END); |
2934 v8::Handle<v8::Object> wrapper = info.Holder(); | 2966 v8::Handle<v8::Object> wrapper = info.Holder(); |
2935 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$
{v8ClassName}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration
::Dependent); | 2967 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$
{v8ClassName}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration
::Dependent); |
2936 v8SetReturnValue(info, wrapper); | 2968 v8SetReturnValue(info, wrapper); |
2937 } | 2969 } |
2938 END | 2970 END |
2939 | 2971 |
2940 my $code = ""; | 2972 my $code = ""; |
2941 $code .= <<END; | 2973 $code .= <<END; |
2942 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary&
options) | 2974 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary&
options, ExceptionState& exceptionState) |
2943 { | 2975 { |
2944 END | 2976 END |
2945 | 2977 |
2946 if ($interface->parent) { | 2978 if ($interface->parent) { |
2947 my $interfaceBase = $interface->parent; | 2979 my $interfaceBase = $interface->parent; |
2948 $code .= <<END; | 2980 $code .= <<END; |
2949 if (!fill${interfaceBase}Init(eventInit, options)) | 2981 if (!fill${interfaceBase}Init(eventInit, options, exceptionState)) |
2950 return false; | 2982 return false; |
2951 | 2983 |
2952 END | 2984 END |
2953 } | 2985 } |
2954 | 2986 |
2955 foreach my $attribute (@{$interface->attributes}) { | 2987 foreach my $attribute (@{$interface->attributes}) { |
2956 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { | 2988 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { |
2957 if ($attribute->type ne "any") { | 2989 if ($attribute->type ne "any") { |
2958 my $attributeName = $attribute->name; | 2990 my $attributeName = $attribute->name; |
2959 my $attributeImplName = GetImplName($attribute); | 2991 my $attributeImplName = GetImplName($attribute); |
2960 my $deprecation = $attribute->extendedAttributes->{"DeprecateAs"
}; | 2992 my $deprecation = $attribute->extendedAttributes->{"DeprecateAs"
}; |
2961 my $dictionaryGetter = "options.get(\"$attributeName\", eventIni
t.$attributeImplName)"; | 2993 |
| 2994 my $typeNameArgument = ""; |
| 2995 my $nullableArgument = ""; |
| 2996 my $integerConversionArgument = ""; |
| 2997 |
| 2998 # Construct the arguments to the corresponding Dictionary.conver
t() method. |
| 2999 if ($attribute->extendedAttributes->{"EnforceRange"}) { |
| 3000 $integerConversionArgument = ", EnforceRange"; |
| 3001 } elsif ($attribute->extendedAttributes->{"Clamp"}) { |
| 3002 $integerConversionArgument = ", Clamp"; |
| 3003 } elsif (IsIntegerType($attribute->type)) { |
| 3004 $integerConversionArgument = ", NormalConversion"; |
| 3005 } elsif ($attribute->type eq "boolean" || $attribute->type eq "d
ouble") { |
| 3006 ; |
| 3007 } elsif ($attribute->type eq "DOMString" || IsEnumType($attribut
e->type) || IsCallbackFunctionType($attribute->type)) { |
| 3008 ; |
| 3009 } elsif ($attribute->isNullable) { |
| 3010 $nullableArgument = ", true"; |
| 3011 $typeNameArgument = ", \"" . $attribute->type . "\""; |
| 3012 } else { |
| 3013 $nullableArgument = ", false"; |
| 3014 $typeNameArgument = ", \"" . $attribute->type . "\""; |
| 3015 } |
| 3016 if ($typeNameArgument eq ", \"object\"") { |
| 3017 # Too generic, leave as empty for equally good error message
. |
| 3018 $typeNameArgument = ", \"\""; |
| 3019 } |
| 3020 |
| 3021 my $dictionaryGetter = "options.convert(\"$attributeName\"${type
NameArgument}${nullableArgument}${integerConversionArgument}, eventInit.$attribu
teImplName, exceptionState)"; |
2962 if ($attribute->extendedAttributes->{"DeprecateAs"}) { | 3022 if ($attribute->extendedAttributes->{"DeprecateAs"}) { |
2963 $code .= " if ($dictionaryGetter)\n"; | 3023 $code .= " if ($dictionaryGetter) {\n"; |
2964 $code .= " " . GenerateDeprecationNotification($attribute
->extendedAttributes->{"DeprecateAs"}); | 3024 $code .= " if (options.hasProperty(\"$attributeName\"
))\n"; |
| 3025 $code .= " " . GenerateDeprecationNotification($attri
bute->extendedAttributes->{"DeprecateAs"}); |
| 3026 $code .= " } else {\n"; |
| 3027 $code .= " return false;\n"; |
| 3028 $code .= " }\n"; |
2965 } else { | 3029 } else { |
2966 $code .= " $dictionaryGetter;\n"; | 3030 $code .= " if (!$dictionaryGetter)\n"; |
| 3031 $code .= " return false;\n"; |
2967 } | 3032 } |
2968 } | 3033 } |
2969 } | 3034 } |
2970 } | 3035 } |
2971 | 3036 |
2972 $code .= <<END; | 3037 $code .= <<END; |
2973 return true; | 3038 return true; |
2974 } | 3039 } |
2975 | 3040 |
2976 END | 3041 END |
(...skipping 2958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5935 } | 6000 } |
5936 | 6001 |
5937 sub IsPrimitiveType | 6002 sub IsPrimitiveType |
5938 { | 6003 { |
5939 my $type = shift; | 6004 my $type = shift; |
5940 | 6005 |
5941 return 1 if $primitiveTypeHash{$type}; | 6006 return 1 if $primitiveTypeHash{$type}; |
5942 return 0; | 6007 return 0; |
5943 } | 6008 } |
5944 | 6009 |
| 6010 sub IsIntegerType |
| 6011 { |
| 6012 my $type = shift; |
| 6013 |
| 6014 return 1 if $integerTypeHash{$type}; |
| 6015 return 0; |
| 6016 } |
| 6017 |
5945 sub IsCallbackFunctionType | 6018 sub IsCallbackFunctionType |
5946 { | 6019 { |
5947 my $type = shift; | 6020 my $type = shift; |
5948 | 6021 |
5949 return 1 if $callbackFunctionTypeHash{$type}; | 6022 return 1 if $callbackFunctionTypeHash{$type}; |
5950 return 0; | 6023 return 0; |
5951 } | 6024 } |
5952 | 6025 |
5953 sub IsEnumType | 6026 sub IsEnumType |
5954 { | 6027 { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6336 | 6409 |
6337 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6410 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
6338 return 1 if $interface->extendedAttributes->{"CustomWrap"}; | 6411 return 1 if $interface->extendedAttributes->{"CustomWrap"}; |
6339 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6412 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6340 return 1 if InheritsInterface($interface, "Document"); | 6413 return 1 if InheritsInterface($interface, "Document"); |
6341 | 6414 |
6342 return 0; | 6415 return 0; |
6343 } | 6416 } |
6344 | 6417 |
6345 1; | 6418 1; |
OLD | NEW |