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&, const String& = \"\");\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, const String& forEventName) |
2943 { | 2975 { |
| 2976 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? Str
ing("${interfaceName}") : forEventName, "", exceptionState); |
2944 END | 2977 END |
2945 | 2978 |
2946 if ($interface->parent) { | 2979 if ($interface->parent) { |
2947 my $interfaceBase = $interface->parent; | 2980 my $interfaceBase = $interface->parent; |
2948 $code .= <<END; | 2981 $code .= <<END; |
2949 if (!fill${interfaceBase}Init(eventInit, options)) | 2982 if (!fill${interfaceBase}Init(eventInit, options, exceptionState, forEventNa
me.isEmpty() ? String("${interfaceName}") : forEventName)) |
2950 return false; | 2983 return false; |
2951 | 2984 |
2952 END | 2985 END |
2953 } | 2986 } |
2954 | 2987 |
2955 foreach my $attribute (@{$interface->attributes}) { | 2988 foreach my $attribute (@{$interface->attributes}) { |
2956 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { | 2989 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { |
2957 if ($attribute->type ne "any") { | 2990 if ($attribute->type ne "any") { |
2958 my $attributeName = $attribute->name; | 2991 my $attributeName = $attribute->name; |
2959 my $attributeImplName = GetImplName($attribute); | 2992 my $attributeImplName = GetImplName($attribute); |
2960 my $deprecation = $attribute->extendedAttributes->{"DeprecateAs"
}; | 2993 my $deprecation = $attribute->extendedAttributes->{"DeprecateAs"
}; |
2961 my $dictionaryGetter = "options.get(\"$attributeName\", eventIni
t.$attributeImplName)"; | 2994 |
| 2995 # Construct the arguments to the corresponding Dictionary.conver
t() method. |
| 2996 my @convertArguments = (); |
| 2997 if ($attribute->extendedAttributes->{"EnforceRange"}) { |
| 2998 push(@convertArguments, "EnforceRange"); |
| 2999 } elsif ($attribute->extendedAttributes->{"Clamp"}) { |
| 3000 push(@convertArguments, "Clamp"); |
| 3001 } elsif (IsIntegerType($attribute->type)) { |
| 3002 push(@convertArguments, "NormalConversion"); |
| 3003 } elsif ($attribute->type eq "boolean" || $attribute->type eq "d
ouble") { |
| 3004 ; |
| 3005 } elsif ($attribute->type eq "DOMString" || IsEnumType($attribut
e->type) || IsCallbackFunctionType($attribute->type)) { |
| 3006 ; |
| 3007 } elsif ($attribute->type ne "object") { |
| 3008 push(@convertArguments, "\"" . $attribute->type . "\""); |
| 3009 } |
| 3010 |
| 3011 my $withPropertyAttributes = ""; |
| 3012 if (@convertArguments || $attribute->isNullable) { |
| 3013 unshift(@convertArguments, $attribute->isNullable ? "true" :
"false"); |
| 3014 $withPropertyAttributes = ".withAttributes(" . join(", ", @c
onvertArguments) . ")"; |
| 3015 } |
| 3016 |
| 3017 my $dictionaryGetter = "options.convert(conversionContext${withP
ropertyAttributes}, \"$attributeName\", eventInit.$attributeImplName)"; |
2962 if ($attribute->extendedAttributes->{"DeprecateAs"}) { | 3018 if ($attribute->extendedAttributes->{"DeprecateAs"}) { |
2963 $code .= " if ($dictionaryGetter)\n"; | 3019 $code .= " if ($dictionaryGetter) {\n"; |
2964 $code .= " " . GenerateDeprecationNotification($attribute
->extendedAttributes->{"DeprecateAs"}); | 3020 $code .= " if (options.hasProperty(\"$attributeName\"
))\n"; |
| 3021 $code .= " " . GenerateDeprecationNotification($attri
bute->extendedAttributes->{"DeprecateAs"}); |
| 3022 $code .= " } else {\n"; |
| 3023 $code .= " return false;\n"; |
| 3024 $code .= " }\n"; |
2965 } else { | 3025 } else { |
2966 $code .= " $dictionaryGetter;\n"; | 3026 $code .= " if (!$dictionaryGetter)\n"; |
| 3027 $code .= " return false;\n"; |
2967 } | 3028 } |
2968 } | 3029 } |
2969 } | 3030 } |
2970 } | 3031 } |
2971 | 3032 |
2972 $code .= <<END; | 3033 $code .= <<END; |
2973 return true; | 3034 return true; |
2974 } | 3035 } |
2975 | 3036 |
2976 END | 3037 END |
(...skipping 2958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5935 } | 5996 } |
5936 | 5997 |
5937 sub IsPrimitiveType | 5998 sub IsPrimitiveType |
5938 { | 5999 { |
5939 my $type = shift; | 6000 my $type = shift; |
5940 | 6001 |
5941 return 1 if $primitiveTypeHash{$type}; | 6002 return 1 if $primitiveTypeHash{$type}; |
5942 return 0; | 6003 return 0; |
5943 } | 6004 } |
5944 | 6005 |
| 6006 sub IsIntegerType |
| 6007 { |
| 6008 my $type = shift; |
| 6009 |
| 6010 return 1 if $integerTypeHash{$type}; |
| 6011 return 0; |
| 6012 } |
| 6013 |
5945 sub IsCallbackFunctionType | 6014 sub IsCallbackFunctionType |
5946 { | 6015 { |
5947 my $type = shift; | 6016 my $type = shift; |
5948 | 6017 |
5949 return 1 if $callbackFunctionTypeHash{$type}; | 6018 return 1 if $callbackFunctionTypeHash{$type}; |
5950 return 0; | 6019 return 0; |
5951 } | 6020 } |
5952 | 6021 |
5953 sub IsEnumType | 6022 sub IsEnumType |
5954 { | 6023 { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6336 | 6405 |
6337 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6406 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
6338 return 1 if $interface->extendedAttributes->{"CustomWrap"}; | 6407 return 1 if $interface->extendedAttributes->{"CustomWrap"}; |
6339 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6408 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6340 return 1 if InheritsInterface($interface, "Document"); | 6409 return 1 if InheritsInterface($interface, "Document"); |
6341 | 6410 |
6342 return 0; | 6411 return 0; |
6343 } | 6412 } |
6344 | 6413 |
6345 1; | 6414 1; |
OLD | NEW |