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 11 matching lines...) Expand all Loading... | |
22 # You should have received a copy of the GNU Library General Public License | 22 # You should have received a copy of the GNU Library General Public License |
23 # along with this library; see the file COPYING.LIB. If not, write to | 23 # along with this library; see the file COPYING.LIB. If not, write to |
24 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 24 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
25 # Boston, MA 02111-1307, USA. | 25 # Boston, MA 02111-1307, USA. |
26 # | 26 # |
27 | 27 |
28 package CodeGeneratorV8; | 28 package CodeGeneratorV8; |
29 | 29 |
30 use strict; | 30 use strict; |
31 | 31 |
32 use idltopath; | |
33 | |
32 my $codeGenerator; | 34 my $codeGenerator; |
33 | 35 |
34 | 36 |
35 my @headerContent = (); | 37 my @headerContent = (); |
36 my @implContentHeader = (); | 38 my @implContentHeader = (); |
37 my @implContent = (); | 39 my @implContent = (); |
38 my @implContentInternals = (); | 40 my @implContentInternals = (); |
39 my %implIncludes = (); | 41 my %implIncludes = (); |
40 my %headerIncludes = (); | 42 my %headerIncludes = (); |
41 | 43 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 if ($codeGenerator->IsTypedArrayType($type)) { | 140 if ($codeGenerator->IsTypedArrayType($type)) { |
139 AddToImplIncludes("wtf/${type}.h"); | 141 AddToImplIncludes("wtf/${type}.h"); |
140 } | 142 } |
141 if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->IsStringTyp e($type) and !$codeGenerator->SkipIncludeHeader($type) and $type ne "Date") { | 143 if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->IsStringTyp e($type) and !$codeGenerator->SkipIncludeHeader($type) and $type ne "Date") { |
142 # default, include the same named file | 144 # default, include the same named file |
143 AddToImplIncludes(GetV8HeaderName(${type})); | 145 AddToImplIncludes(GetV8HeaderName(${type})); |
144 | 146 |
145 if ($type =~ /SVGPathSeg/) { | 147 if ($type =~ /SVGPathSeg/) { |
146 my $joinedName = $type; | 148 my $joinedName = $type; |
147 $joinedName =~ s/Abs|Rel//; | 149 $joinedName =~ s/Abs|Rel//; |
148 AddToImplIncludes("${joinedName}.h"); | 150 AddToImplIncludes("core/svg/${joinedName}.h"); |
149 } | 151 } |
150 } | 152 } |
151 | 153 |
152 # additional includes (things needed to compile the bindings but not the hea der) | 154 # additional includes (things needed to compile the bindings but not the hea der) |
153 | 155 |
154 if ($type eq "CanvasRenderingContext2D") { | 156 if ($type eq "CanvasRenderingContext2D") { |
155 AddToImplIncludes("CanvasGradient.h"); | 157 AddToImplIncludes("core/html/canvas/CanvasGradient.h"); |
156 AddToImplIncludes("CanvasPattern.h"); | 158 AddToImplIncludes("core/html/canvas/CanvasPattern.h"); |
157 AddToImplIncludes("CanvasStyle.h"); | 159 AddToImplIncludes("core/html/canvas/CanvasStyle.h"); |
158 } | 160 } |
159 | 161 |
160 if ($type eq "CanvasGradient" or $type eq "XPathNSResolver") { | 162 if ($type eq "CanvasGradient" or $type eq "XPathNSResolver") { |
161 AddToImplIncludes("wtf/text/WTFString.h"); | 163 AddToImplIncludes("wtf/text/WTFString.h"); |
162 } | 164 } |
163 | 165 |
164 if ($type eq "CSSStyleSheet" or $type eq "StyleSheet") { | 166 if ($type eq "CSSStyleSheet" or $type eq "StyleSheet") { |
165 AddToImplIncludes("CSSImportRule.h"); | 167 AddToImplIncludes("core/css/CSSImportRule.h"); |
166 } | 168 } |
167 | 169 |
168 if ($type eq "CSSStyleDeclaration") { | 170 if ($type eq "CSSStyleDeclaration") { |
169 AddToImplIncludes("StylePropertySet.h"); | 171 AddToImplIncludes("core/css/StylePropertySet.h"); |
170 } | 172 } |
171 | 173 |
172 if ($type eq "Plugin" or $type eq "PluginArray" or $type eq "MimeTypeArray") { | 174 if ($type eq "Plugin" or $type eq "PluginArray" or $type eq "MimeTypeArray") { |
173 # So we can get String -> AtomicString conversion for namedItem(). | 175 # So we can get String -> AtomicString conversion for namedItem(). |
174 AddToImplIncludes("wtf/text/AtomicString.h"); | 176 AddToImplIncludes("wtf/text/AtomicString.h"); |
175 } | 177 } |
176 } | 178 } |
177 | 179 |
178 sub NeedsCustomOpaqueRootForGC | 180 sub NeedsCustomOpaqueRootForGC |
179 { | 181 { |
(...skipping 26 matching lines...) Expand all Loading... | |
206 void* V8${interfaceName}::opaqueRootForGC(void* object, v8::Persistent<v8::Objec t> wrapper, v8::Isolate* isolate) | 208 void* V8${interfaceName}::opaqueRootForGC(void* object, v8::Persistent<v8::Objec t> wrapper, v8::Isolate* isolate) |
207 { | 209 { |
208 ASSERT(!wrapper.IsIndependent(isolate)); | 210 ASSERT(!wrapper.IsIndependent(isolate)); |
209 ${interfaceName}* impl = static_cast<${interfaceName}*>(object); | 211 ${interfaceName}* impl = static_cast<${interfaceName}*>(object); |
210 END | 212 END |
211 if (GetGenerateIsReachable($interface) eq "ImplDocument" || | 213 if (GetGenerateIsReachable($interface) eq "ImplDocument" || |
212 GetGenerateIsReachable($interface) eq "ImplElementRoot" || | 214 GetGenerateIsReachable($interface) eq "ImplElementRoot" || |
213 GetGenerateIsReachable($interface) eq "ImplOwnerRoot" || | 215 GetGenerateIsReachable($interface) eq "ImplOwnerRoot" || |
214 GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") { | 216 GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") { |
215 | 217 |
216 $implIncludes{"V8GCController.h"} = 1; | 218 $implIncludes{"bindings/v8/V8GCController.h"} = 1; |
abarth-chromium
2013/04/25 14:14:24
Why not use the header map for these headers as we
Daniel Bratell
2013/04/25 21:24:26
This is not an IDL interface name so these are not
| |
217 | 219 |
218 my $methodName; | 220 my $methodName; |
219 $methodName = "document" if (GetGenerateIsReachable($interface) eq "Impl Document"); | 221 $methodName = "document" if (GetGenerateIsReachable($interface) eq "Impl Document"); |
220 $methodName = "element" if (GetGenerateIsReachable($interface) eq "ImplE lementRoot"); | 222 $methodName = "element" if (GetGenerateIsReachable($interface) eq "ImplE lementRoot"); |
221 $methodName = "owner" if (GetGenerateIsReachable($interface) eq "ImplOwn erRoot"); | 223 $methodName = "owner" if (GetGenerateIsReachable($interface) eq "ImplOwn erRoot"); |
222 $methodName = "ownerNode" if (GetGenerateIsReachable($interface) eq "Imp lOwnerNodeRoot"); | 224 $methodName = "ownerNode" if (GetGenerateIsReachable($interface) eq "Imp lOwnerNodeRoot"); |
223 | 225 |
224 $code .= <<END; | 226 $code .= <<END; |
225 if (Node* owner = impl->${methodName}()) | 227 if (Node* owner = impl->${methodName}()) |
226 return V8GCController::opaqueRootForGC(owner, isolate); | 228 return V8GCController::opaqueRootForGC(owner, isolate); |
(...skipping 20 matching lines...) Expand all Loading... | |
247 | 249 |
248 $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implType); | 250 $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implType); |
249 return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $svgN ativeType; | 251 return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $svgN ativeType; |
250 | 252 |
251 # Append space to avoid compilation errors when using PassRefPtr<$svgNative Type> | 253 # Append space to avoid compilation errors when using PassRefPtr<$svgNative Type> |
252 $svgNativeType = "$svgNativeType "; | 254 $svgNativeType = "$svgNativeType "; |
253 | 255 |
254 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($ implType); | 256 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($ implType); |
255 if ($svgNativeType =~ /SVGPropertyTearOff/) { | 257 if ($svgNativeType =~ /SVGPropertyTearOff/) { |
256 $svgPropertyType = $svgWrappedNativeType; | 258 $svgPropertyType = $svgWrappedNativeType; |
257 AddToImplIncludes("SVGAnimatedPropertyTearOff.h"); | 259 AddToImplIncludes("core/svg/properties/SVGAnimatedPropertyTearOff.h"); |
258 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SV GStaticListPropertyTearOff/) { | 260 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SV GStaticListPropertyTearOff/) { |
259 $svgListPropertyType = $svgWrappedNativeType; | 261 $svgListPropertyType = $svgWrappedNativeType; |
260 $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; | 262 $headerIncludes{"core/svg/properties/SVGAnimatedListPropertyTearOff.h"} = 1; |
261 $headerIncludes{"SVGStaticListPropertyTearOff.h"} = 1; | 263 $headerIncludes{"core/svg/properties/SVGStaticListPropertyTearOff.h"} = 1; |
262 } elsif ($svgNativeType =~ /SVGTransformListPropertyTearOff/) { | 264 } elsif ($svgNativeType =~ /SVGTransformListPropertyTearOff/) { |
263 $svgListPropertyType = $svgWrappedNativeType; | 265 $svgListPropertyType = $svgWrappedNativeType; |
264 $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; | 266 $headerIncludes{"core/svg/properties/SVGAnimatedListPropertyTearOff.h"} = 1; |
265 $headerIncludes{"SVGTransformListPropertyTearOff.h"} = 1; | 267 $headerIncludes{"core/svg/properties/SVGTransformListPropertyTearOff.h"} = 1; |
266 } elsif ($svgNativeType =~ /SVGPathSegListPropertyTearOff/) { | 268 } elsif ($svgNativeType =~ /SVGPathSegListPropertyTearOff/) { |
267 $svgListPropertyType = $svgWrappedNativeType; | 269 $svgListPropertyType = $svgWrappedNativeType; |
268 $headerIncludes{"SVGPathSegListPropertyTearOff.h"} = 1; | 270 $headerIncludes{"core/svg/properties/SVGPathSegListPropertyTearOff.h"} = 1; |
269 } | 271 } |
270 | 272 |
271 if ($svgPropertyType) { | 273 if ($svgPropertyType) { |
272 $svgPropertyType = "SVGPoint" if $svgPropertyType eq "FloatPoint"; | 274 $svgPropertyType = "SVGPoint" if $svgPropertyType eq "FloatPoint"; |
273 } | 275 } |
274 | 276 |
275 return ($svgPropertyType, $svgListPropertyType, $svgNativeType); | 277 return ($svgPropertyType, $svgListPropertyType, $svgNativeType); |
276 } | 278 } |
277 | 279 |
278 sub GenerateHeader | 280 sub GenerateHeader |
(...skipping 17 matching lines...) Expand all Loading... | |
296 foreach (@{$interface->parents}) { | 298 foreach (@{$interface->parents}) { |
297 my $parent = $_; | 299 my $parent = $_; |
298 $headerIncludes{"V8${parent}.h"} = 1; | 300 $headerIncludes{"V8${parent}.h"} = 1; |
299 } | 301 } |
300 } | 302 } |
301 | 303 |
302 # - Add default header template | 304 # - Add default header template |
303 AddToHeader(GenerateHeaderContentHeader($interface)); | 305 AddToHeader(GenerateHeaderContentHeader($interface)); |
304 | 306 |
305 $headerIncludes{"wtf/text/StringHash.h"} = 1; | 307 $headerIncludes{"wtf/text/StringHash.h"} = 1; |
306 $headerIncludes{"WrapperTypeInfo.h"} = 1; | 308 $headerIncludes{"bindings/v8/WrapperTypeInfo.h"} = 1; |
307 $headerIncludes{"V8Binding.h"} = 1; | 309 $headerIncludes{"bindings/v8/V8Binding.h"} = 1; |
308 $headerIncludes{"V8DOMWrapper.h"} = 1; | 310 $headerIncludes{"bindings/v8/V8DOMWrapper.h"} = 1; |
309 $headerIncludes{"wtf/HashMap.h"} = 1; | 311 $headerIncludes{"wtf/HashMap.h"} = 1; |
310 $headerIncludes{"v8.h"} = 1; | 312 $headerIncludes{"v8.h"} = 1; |
311 | 313 |
312 my $headerClassInclude = GetHeaderClassInclude($interfaceName); | 314 my $headerClassInclude = GetHeaderClassInclude($interfaceName); |
313 $headerIncludes{$headerClassInclude} = 1 if $headerClassInclude ne ""; | 315 $headerIncludes{$headerClassInclude} = 1 if $headerClassInclude ne ""; |
314 | 316 |
315 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); | 317 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); |
316 | 318 |
317 foreach my $headerInclude (sort keys(%headerIncludes)) { | 319 foreach my $headerInclude (sort keys(%headerIncludes)) { |
318 if ($headerInclude =~ /wtf|v8\.h/) { | 320 if ($headerInclude =~ /wtf|v8\.h/) { |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 | 674 |
673 my @customInternalFields = (); | 675 my @customInternalFields = (); |
674 # Event listeners on DOM nodes are explicitly supported in the GC controller . | 676 # Event listeners on DOM nodes are explicitly supported in the GC controller . |
675 if (!$codeGenerator->InheritsInterface($interface, "Node") && | 677 if (!$codeGenerator->InheritsInterface($interface, "Node") && |
676 $codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { | 678 $codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { |
677 push(@customInternalFields, "eventListenerCacheIndex"); | 679 push(@customInternalFields, "eventListenerCacheIndex"); |
678 } | 680 } |
679 return @customInternalFields; | 681 return @customInternalFields; |
680 } | 682 } |
681 | 683 |
684 sub mapInterfaceToIncludePath | |
685 { | |
686 my $interface = shift; | |
687 | |
688 return idlToPath($interface); | |
689 } | |
690 | |
682 sub GetHeaderClassInclude | 691 sub GetHeaderClassInclude |
683 { | 692 { |
684 my $v8InterfaceName = shift; | 693 my $v8InterfaceName = shift; |
685 if ($v8InterfaceName =~ /SVGPathSeg/) { | 694 if ($v8InterfaceName =~ /SVGPathSeg/) { |
686 $v8InterfaceName =~ s/Abs|Rel//; | 695 $v8InterfaceName =~ s/Abs|Rel//; |
687 } | 696 } |
688 return "wtf/${v8InterfaceName}.h" if $codeGenerator->IsTypedArrayType($v8Int erfaceName); | 697 return "wtf/${v8InterfaceName}.h" if $codeGenerator->IsTypedArrayType($v8Int erfaceName); |
689 return "" if ($codeGenerator->SkipIncludeHeader($v8InterfaceName)); | 698 return "" if ($codeGenerator->SkipIncludeHeader($v8InterfaceName)); |
690 return "${v8InterfaceName}.h"; | 699 my $interfacepath = mapInterfaceToIncludePath($v8InterfaceName); |
700 return "${interfacepath}${v8InterfaceName}.h"; | |
691 } | 701 } |
692 | 702 |
693 sub GenerateHeaderCustomInternalFieldIndices | 703 sub GenerateHeaderCustomInternalFieldIndices |
694 { | 704 { |
695 my $interface = shift; | 705 my $interface = shift; |
696 my @customInternalFields = GetInternalFields($interface); | 706 my @customInternalFields = GetInternalFields($interface); |
697 my $customFieldCounter = 0; | 707 my $customFieldCounter = 0; |
698 foreach my $customInternalField (@customInternalFields) { | 708 foreach my $customInternalField (@customInternalFields) { |
699 AddToHeader(<<END); | 709 AddToHeader(<<END); |
700 static const int ${customInternalField} = v8DefaultWrapperInternalFieldCount + ${customFieldCounter}; | 710 static const int ${customInternalField} = v8DefaultWrapperInternalFieldCount + ${customFieldCounter}; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
865 my $v8InterfaceName = "V8" . $interfaceName; | 875 my $v8InterfaceName = "V8" . $interfaceName; |
866 my $funcName = $function->signature->name; | 876 my $funcName = $function->signature->name; |
867 | 877 |
868 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8InterfaceName . "::info, currentWorldType))"; | 878 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8InterfaceName . "::info, currentWorldType))"; |
869 if ($function->signature->extendedAttributes->{"DoNotCheckSignature"}) { | 879 if ($function->signature->extendedAttributes->{"DoNotCheckSignature"}) { |
870 $signature = "v8::Local<v8::Signature>()"; | 880 $signature = "v8::Local<v8::Signature>()"; |
871 } | 881 } |
872 | 882 |
873 my $newTemplateParams = "${interfaceName}V8Internal::${funcName}MethodCallba ck, v8Undefined(), $signature"; | 883 my $newTemplateParams = "${interfaceName}V8Internal::${funcName}MethodCallba ck, v8Undefined(), $signature"; |
874 | 884 |
875 AddToImplIncludes("Frame.h"); | 885 AddToImplIncludes("core/page/Frame.h"); |
876 AddToImplContentInternals(<<END); | 886 AddToImplContentInternals(<<END); |
877 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, c onst v8::AccessorInfo& info) | 887 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, c onst v8::AccessorInfo& info) |
878 { | 888 { |
879 // This is only for getting a unique pointer which we can pass to privateTem plate. | 889 // This is only for getting a unique pointer which we can pass to privateTem plate. |
880 static const char* privateTemplateUniqueKey = "${funcName}PrivateTemplate"; | 890 static const char* privateTemplateUniqueKey = "${funcName}PrivateTemplate"; |
881 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); | 891 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); |
882 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); | 892 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); |
883 v8::Persistent<v8::FunctionTemplate> privateTemplate = data->privateTemplate (currentWorldType, &privateTemplateUniqueKey, $newTemplateParams); | 893 v8::Persistent<v8::FunctionTemplate> privateTemplate = data->privateTemplate (currentWorldType, &privateTemplateUniqueKey, $newTemplateParams); |
884 | 894 |
885 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), currentWorldType)); | 895 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), currentWorldType)); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1128 } | 1138 } |
1129 | 1139 |
1130 # Generate security checks if necessary | 1140 # Generate security checks if necessary |
1131 if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { | 1141 if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { |
1132 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(BindingState ::instance(), imp->" . $attribute->signature->name . "()))\n return v8::H andle<v8::Value>(v8Null(info.GetIsolate()));\n\n"; | 1142 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(BindingState ::instance(), imp->" . $attribute->signature->name . "()))\n return v8::H andle<v8::Value>(v8Null(info.GetIsolate()));\n\n"; |
1133 } | 1143 } |
1134 | 1144 |
1135 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Getter RaisesException"}; | 1145 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Getter RaisesException"}; |
1136 my $isNullable = $attribute->signature->isNullable; | 1146 my $isNullable = $attribute->signature->isNullable; |
1137 if ($useExceptions) { | 1147 if ($useExceptions) { |
1138 AddToImplIncludes("ExceptionCode.h"); | 1148 AddToImplIncludes("core/dom/ExceptionCode.h"); |
1139 $code .= " ExceptionCode ec = 0;\n"; | 1149 $code .= " ExceptionCode ec = 0;\n"; |
1140 } | 1150 } |
1141 | 1151 |
1142 if ($isNullable) { | 1152 if ($isNullable) { |
1143 $code .= " bool isNull = false;\n"; | 1153 $code .= " bool isNull = false;\n"; |
1144 } | 1154 } |
1145 | 1155 |
1146 my $returnType = $attribute->signature->type; | 1156 my $returnType = $attribute->signature->type; |
1147 my $getterString; | 1157 my $getterString; |
1148 | 1158 |
1149 if ($getterStringUsesImp) { | 1159 if ($getterStringUsesImp) { |
1150 my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%impl Includes, $interfaceName, $attribute); | 1160 my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%impl Includes, $interfaceName, $attribute); |
1151 push(@arguments, "isNull") if $isNullable; | 1161 push(@arguments, "isNull") if $isNullable; |
1152 push(@arguments, "ec") if $useExceptions; | 1162 push(@arguments, "ec") if $useExceptions; |
1153 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { | 1163 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { |
1154 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp lementedBy"}; | 1164 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp lementedBy"}; |
1155 AddToImplIncludes("${implementedBy}.h"); | 1165 my $implementedByPath = idlToPath($implementedBy); |
1166 AddToImplIncludes("${implementedByPath}${implementedBy}.h"); | |
1156 unshift(@arguments, "imp") if !$attribute->isStatic; | 1167 unshift(@arguments, "imp") if !$attribute->isStatic; |
1157 $functionName = "${implementedBy}::${functionName}"; | 1168 $functionName = "${implementedBy}::${functionName}"; |
1158 } elsif ($attribute->isStatic) { | 1169 } elsif ($attribute->isStatic) { |
1159 $functionName = "${interfaceName}::${functionName}"; | 1170 $functionName = "${interfaceName}::${functionName}"; |
1160 } else { | 1171 } else { |
1161 $functionName = "imp->${functionName}"; | 1172 $functionName = "imp->${functionName}"; |
1162 } | 1173 } |
1163 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extendedAt tributes->{"CallWith"}, " ", 0); | 1174 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extendedAt tributes->{"CallWith"}, " ", 0); |
1164 $code .= $subCode; | 1175 $code .= $subCode; |
1165 unshift(@arguments, @$arg); | 1176 unshift(@arguments, @$arg); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1211 if ((!$codeGenerator->InheritsInterface($interface, "Node") && $attrName ne "self" && IsWrapperType($returnType) && (IsReadonly($attribute) || $attribute->s ignature->extendedAttributes->{"Replaceable"} || $attrName eq "location") | 1222 if ((!$codeGenerator->InheritsInterface($interface, "Node") && $attrName ne "self" && IsWrapperType($returnType) && (IsReadonly($attribute) || $attribute->s ignature->extendedAttributes->{"Replaceable"} || $attrName eq "location") |
1212 && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValu e" && $returnType ne "DOMWindow" | 1223 && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValu e" && $returnType ne "DOMWindow" |
1213 && $returnType ne "MessagePortArray" | 1224 && $returnType ne "MessagePortArray" |
1214 && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($ret urnType)) | 1225 && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($ret urnType)) |
1215 || $attribute->signature->extendedAttributes->{"CacheAttributeForGC"}) { | 1226 || $attribute->signature->extendedAttributes->{"CacheAttributeForGC"}) { |
1216 | 1227 |
1217 my $arrayType = $codeGenerator->GetArrayType($returnType); | 1228 my $arrayType = $codeGenerator->GetArrayType($returnType); |
1218 if ($arrayType) { | 1229 if ($arrayType) { |
1219 if (!$codeGenerator->SkipIncludeHeader($arrayType)) { | 1230 if (!$codeGenerator->SkipIncludeHeader($arrayType)) { |
1220 AddToImplIncludes("V8$arrayType.h"); | 1231 AddToImplIncludes("V8$arrayType.h"); |
1221 AddToImplIncludes("$arrayType.h"); | 1232 AddToImplIncludes("bindings/v8/$arrayType.h"); |
1222 } | 1233 } |
1223 $code .= " return v8Array(${getterString}, info.GetIsolate());\n" ; | 1234 $code .= " return v8Array(${getterString}, info.GetIsolate());\n" ; |
1224 $code .= "}\n\n"; | 1235 $code .= "}\n\n"; |
1225 AddToImplContentInternals($code); | 1236 AddToImplContentInternals($code); |
1226 return; | 1237 return; |
1227 } | 1238 } |
1228 | 1239 |
1229 AddIncludesForType($returnType); | 1240 AddIncludesForType($returnType); |
1230 # Check for a wrapper in the wrapper cache. If there is one, we know tha t a hidden reference has already | 1241 # Check for a wrapper in the wrapper cache. If there is one, we know tha t a hidden reference has already |
1231 # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference. | 1242 # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference. |
(...skipping 15 matching lines...) Expand all Loading... | |
1247 return; | 1258 return; |
1248 } | 1259 } |
1249 | 1260 |
1250 if (($codeGenerator->IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") and $codeGenerator->IsSVGTypeNeedingTearOff($attrType)) { | 1261 if (($codeGenerator->IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") and $codeGenerator->IsSVGTypeNeedingTearOff($attrType)) { |
1251 AddToImplIncludes("V8$attrType.h"); | 1262 AddToImplIncludes("V8$attrType.h"); |
1252 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); | 1263 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); |
1253 # Convert from abstract SVGProperty to real type, so the right toJS() me thod can be invoked. | 1264 # Convert from abstract SVGProperty to real type, so the right toJS() me thod can be invoked. |
1254 $code .= " return toV8Fast$forMainWorldSuffix(static_cast<$svgNativeT ype*>($expression), info, imp);\n"; | 1265 $code .= " return toV8Fast$forMainWorldSuffix(static_cast<$svgNativeT ype*>($expression), info, imp);\n"; |
1255 } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($attrType) and not $interfa ceName =~ /List$/) { | 1266 } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($attrType) and not $interfa ceName =~ /List$/) { |
1256 AddToImplIncludes("V8$attrType.h"); | 1267 AddToImplIncludes("V8$attrType.h"); |
1257 AddToImplIncludes("SVGPropertyTearOff.h"); | 1268 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); |
1258 my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); | 1269 my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); |
1259 my $wrappedValue; | 1270 my $wrappedValue; |
1260 if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($attrT ype) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { | 1271 if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($attrT ype) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { |
1261 my $getter = $expression; | 1272 my $getter = $expression; |
1262 $getter =~ s/imp->//; | 1273 $getter =~ s/imp->//; |
1263 $getter =~ s/\(\)//; | 1274 $getter =~ s/\(\)//; |
1264 | 1275 |
1265 my $updateMethod = "&${interfaceName}::update" . $codeGenerator->WK_ ucfirst($getter); | 1276 my $updateMethod = "&${interfaceName}::update" . $codeGenerator->WK_ ucfirst($getter); |
1266 | 1277 |
1267 my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff($int erfaceName); | 1278 my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff($int erfaceName); |
1268 if ($selfIsTearOffType) { | 1279 if ($selfIsTearOffType) { |
1269 AddToImplIncludes("SVGStaticPropertyWithParentTearOff.h"); | 1280 AddToImplIncludes("core/svg/properties/SVGStaticPropertyWithPare ntTearOff.h"); |
1270 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParen tTearOff<$interfaceName, /; | 1281 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParen tTearOff<$interfaceName, /; |
1271 | 1282 |
1272 if ($expression =~ /matrix/ and $interfaceName eq "SVGTransform" ) { | 1283 if ($expression =~ /matrix/ and $interfaceName eq "SVGTransform" ) { |
1273 # SVGTransform offers a matrix() method for internal usage t hat returns an AffineTransform | 1284 # SVGTransform offers a matrix() method for internal usage t hat returns an AffineTransform |
1274 # and a svgMatrix() method returning a SVGMatrix, used for t he bindings. | 1285 # and a svgMatrix() method returning a SVGMatrix, used for t he bindings. |
1275 $expression =~ s/matrix/svgMatrix/; | 1286 $expression =~ s/matrix/svgMatrix/; |
1276 } | 1287 } |
1277 | 1288 |
1278 $wrappedValue = "WTF::getPtr(${tearOffType}::create(wrapper, $ex pression, $updateMethod))"; | 1289 $wrappedValue = "WTF::getPtr(${tearOffType}::create(wrapper, $ex pression, $updateMethod))"; |
1279 } else { | 1290 } else { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1342 { | 1353 { |
1343 my $interface = shift; | 1354 my $interface = shift; |
1344 my $interfaceName = $interface->name; | 1355 my $interfaceName = $interface->name; |
1345 | 1356 |
1346 my $code = ""; | 1357 my $code = ""; |
1347 $code .= <<END; | 1358 $code .= <<END; |
1348 static void ${interfaceName}ReplaceableAttrSetter(v8::Local<v8::String> name, v8 ::Local<v8::Value> value, const v8::AccessorInfo& info) | 1359 static void ${interfaceName}ReplaceableAttrSetter(v8::Local<v8::String> name, v8 ::Local<v8::Value> value, const v8::AccessorInfo& info) |
1349 { | 1360 { |
1350 END | 1361 END |
1351 if ($interface->extendedAttributes->{"CheckSecurity"}) { | 1362 if ($interface->extendedAttributes->{"CheckSecurity"}) { |
1352 AddToImplIncludes("Frame.h"); | 1363 AddToImplIncludes("core/page/Frame.h"); |
1353 $code .= <<END; | 1364 $code .= <<END; |
1354 ${interfaceName}* imp = V8${interfaceName}::toNative(info.Holder()); | 1365 ${interfaceName}* imp = V8${interfaceName}::toNative(info.Holder()); |
1355 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) | 1366 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) |
1356 return; | 1367 return; |
1357 END | 1368 END |
1358 } | 1369 } |
1359 | 1370 |
1360 $code .= <<END; | 1371 $code .= <<END; |
1361 info.This()->ForceSet(name, value); | 1372 info.This()->ForceSet(name, value); |
1362 } | 1373 } |
1363 | 1374 |
1364 END | 1375 END |
1365 AddToImplContentInternals($code); | 1376 AddToImplContentInternals($code); |
1366 } | 1377 } |
1367 | 1378 |
1368 sub GenerateCustomElementInvocationScopeIfNeeded | 1379 sub GenerateCustomElementInvocationScopeIfNeeded |
1369 { | 1380 { |
1370 my $code = ""; | 1381 my $code = ""; |
1371 my $ext = shift; | 1382 my $ext = shift; |
1372 | 1383 |
1373 if ($ext->{"DeliverCustomElementCallbacks"}) { | 1384 if ($ext->{"DeliverCustomElementCallbacks"}) { |
1374 if ($ext->{"Reflect"}) { | 1385 if ($ext->{"Reflect"}) { |
1375 die "IDL error: [Reflect] and [DeliverCustomElementCallbacks] cannot coexist yet"; | 1386 die "IDL error: [Reflect] and [DeliverCustomElementCallbacks] cannot coexist yet"; |
1376 } | 1387 } |
1377 | 1388 |
1378 AddToImplIncludes("CustomElementRegistry.h", "CUSTOM_ELEMENTS"); | 1389 AddToImplIncludes("core/dom/CustomElementRegistry.h", "CUSTOM_ELEMENTS") ; |
1379 $code .= <<END; | 1390 $code .= <<END; |
1380 #if ENABLE(CUSTOM_ELEMENTS) | 1391 #if ENABLE(CUSTOM_ELEMENTS) |
1381 CustomElementRegistry::CallbackDeliveryScope deliveryScope; | 1392 CustomElementRegistry::CallbackDeliveryScope deliveryScope; |
1382 #endif | 1393 #endif |
1383 END | 1394 END |
1384 } | 1395 } |
1385 return $code; | 1396 return $code; |
1386 } | 1397 } |
1387 | 1398 |
1388 sub GenerateNormalAttrSetterCallback | 1399 sub GenerateNormalAttrSetterCallback |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1454 } | 1465 } |
1455 | 1466 |
1456 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) ; | 1467 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) ; |
1457 if ($svgNativeType) { | 1468 if ($svgNativeType) { |
1458 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearO ff($interfaceName); | 1469 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearO ff($interfaceName); |
1459 if ($svgWrappedNativeType =~ /List$/) { | 1470 if ($svgWrappedNativeType =~ /List$/) { |
1460 $code .= <<END; | 1471 $code .= <<END; |
1461 $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1472 $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); |
1462 END | 1473 END |
1463 } else { | 1474 } else { |
1464 AddToImplIncludes("ExceptionCode.h"); | 1475 AddToImplIncludes("core/dom/ExceptionCode.h"); |
1465 $code .= " $svgNativeType* wrapper = ${v8InterfaceName}::toNative (info.Holder());\n"; | 1476 $code .= " $svgNativeType* wrapper = ${v8InterfaceName}::toNative (info.Holder());\n"; |
1466 $code .= " if (wrapper->isReadOnly()) {\n"; | 1477 $code .= " if (wrapper->isReadOnly()) {\n"; |
1467 $code .= " setDOMException(NO_MODIFICATION_ALLOWED_ERR, info. GetIsolate());\n"; | 1478 $code .= " setDOMException(NO_MODIFICATION_ALLOWED_ERR, info. GetIsolate());\n"; |
1468 $code .= " return;\n"; | 1479 $code .= " return;\n"; |
1469 $code .= " }\n"; | 1480 $code .= " }\n"; |
1470 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; | 1481 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; |
1471 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; | 1482 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
1472 } | 1483 } |
1473 } elsif ($attrExt->{"OnProto"}) { | 1484 } elsif ($attrExt->{"OnProto"}) { |
1474 $code .= <<END; | 1485 $code .= <<END; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1538 my $returnType = $attribute->signature->type; | 1549 my $returnType = $attribute->signature->type; |
1539 if ($codeGenerator->IsRefPtrType($returnType) && !$codeGenerator->GetArrayTy pe($returnType)) { | 1550 if ($codeGenerator->IsRefPtrType($returnType) && !$codeGenerator->GetArrayTy pe($returnType)) { |
1540 $expression = "WTF::getPtr(" . $expression . ")"; | 1551 $expression = "WTF::getPtr(" . $expression . ")"; |
1541 } | 1552 } |
1542 | 1553 |
1543 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->signature- >extendedAttributes); | 1554 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->signature- >extendedAttributes); |
1544 | 1555 |
1545 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Setter RaisesException"}; | 1556 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Setter RaisesException"}; |
1546 | 1557 |
1547 if ($useExceptions) { | 1558 if ($useExceptions) { |
1548 AddToImplIncludes("ExceptionCode.h"); | 1559 AddToImplIncludes("core/dom/ExceptionCode.h"); |
1549 $code .= " ExceptionCode ec = 0;\n"; | 1560 $code .= " ExceptionCode ec = 0;\n"; |
1550 } | 1561 } |
1551 | 1562 |
1552 if ($interfaceName eq "SVGNumber") { | 1563 if ($interfaceName eq "SVGNumber") { |
1553 $code .= " *imp = $expression;\n"; | 1564 $code .= " *imp = $expression;\n"; |
1554 } else { | 1565 } else { |
1555 if ($attribute->signature->type eq "EventListener") { | 1566 if ($attribute->signature->type eq "EventListener") { |
1556 my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName); | 1567 my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName); |
1557 AddToImplIncludes("V8AbstractEventListener.h"); | 1568 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); |
1558 if (!$codeGenerator->InheritsInterface($interface, "Node")) { | 1569 if (!$codeGenerator->InheritsInterface($interface, "Node")) { |
1559 $code .= " transferHiddenDependency(info.Holder(), imp->$attr Name(), value, ${v8InterfaceName}::eventListenerCacheIndex, info.GetIsolate());\ n"; | 1570 $code .= " transferHiddenDependency(info.Holder(), imp->$attr Name(), value, ${v8InterfaceName}::eventListenerCacheIndex, info.GetIsolate());\ n"; |
1560 } | 1571 } |
1561 AddToImplIncludes("V8EventListenerList.h"); | 1572 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); |
1562 if ($interfaceName eq "WorkerContext" and $attribute->signature->nam e eq "onerror") { | 1573 if ($interfaceName eq "WorkerContext" and $attribute->signature->nam e eq "onerror") { |
1563 AddToImplIncludes("V8WorkerContextErrorHandler.h"); | 1574 AddToImplIncludes("bindings/v8/V8WorkerContextErrorHandler.h"); |
1564 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)"; | 1575 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)"; |
1565 } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->na me eq "onerror") { | 1576 } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->na me eq "onerror") { |
1566 AddToImplIncludes("V8WindowErrorHandler.h"); | 1577 AddToImplIncludes("bindings/v8/V8WindowErrorHandler.h"); |
1567 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8WindowErrorHandler>(value, true)"; | 1578 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8WindowErrorHandler>(value, true)"; |
1568 } else { | 1579 } else { |
1569 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate)"; | 1580 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate)"; |
1570 } | 1581 } |
1571 $code .= ", ec" if $useExceptions; | 1582 $code .= ", ec" if $useExceptions; |
1572 $code .= ");\n"; | 1583 $code .= ");\n"; |
1573 } else { | 1584 } else { |
1574 my ($functionName, @arguments) = $codeGenerator->SetterExpression(\% implIncludes, $interfaceName, $attribute); | 1585 my ($functionName, @arguments) = $codeGenerator->SetterExpression(\% implIncludes, $interfaceName, $attribute); |
1575 push(@arguments, $expression); | 1586 push(@arguments, $expression); |
1576 push(@arguments, "ec") if $useExceptions; | 1587 push(@arguments, "ec") if $useExceptions; |
1577 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { | 1588 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { |
1578 my $implementedBy = $attribute->signature->extendedAttributes->{ "ImplementedBy"}; | 1589 my $implementedBy = $attribute->signature->extendedAttributes->{ "ImplementedBy"}; |
1579 AddToImplIncludes("${implementedBy}.h"); | 1590 my $implementedByPath = idlToPath($implementedBy); |
1591 AddToImplIncludes("$implementedByPath${implementedBy}.h"); | |
1580 unshift(@arguments, "imp") if !$attribute->isStatic; | 1592 unshift(@arguments, "imp") if !$attribute->isStatic; |
1581 $functionName = "${implementedBy}::${functionName}"; | 1593 $functionName = "${implementedBy}::${functionName}"; |
1582 } elsif ($attribute->isStatic) { | 1594 } elsif ($attribute->isStatic) { |
1583 $functionName = "${interfaceName}::${functionName}"; | 1595 $functionName = "${interfaceName}::${functionName}"; |
1584 } else { | 1596 } else { |
1585 $functionName = "imp->${functionName}"; | 1597 $functionName = "imp->${functionName}"; |
1586 } | 1598 } |
1587 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extend edAttributes->{"CallWith"}, " ", 1); | 1599 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extend edAttributes->{"CallWith"}, " ", 1); |
1588 $code .= $subCode; | 1600 $code .= $subCode; |
1589 unshift(@arguments, @$arg); | 1601 unshift(@arguments, @$arg); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1818 | 1830 |
1819 END | 1831 END |
1820 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1832 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
1821 AddToImplContentInternals($code); | 1833 AddToImplContentInternals($code); |
1822 return; | 1834 return; |
1823 } | 1835 } |
1824 | 1836 |
1825 $code .= GenerateArgumentsCountCheck($function, $interface); | 1837 $code .= GenerateArgumentsCountCheck($function, $interface); |
1826 | 1838 |
1827 if ($name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { | 1839 if ($name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { |
1828 AddToImplIncludes("V8ArrayBufferViewCustom.h"); | 1840 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); |
1829 $code .= <<END; | 1841 $code .= <<END; |
1830 return setWebGLArrayHelper<$interfaceName, ${v8InterfaceName}>(args); | 1842 return setWebGLArrayHelper<$interfaceName, ${v8InterfaceName}>(args); |
1831 } | 1843 } |
1832 | 1844 |
1833 END | 1845 END |
1834 AddToImplContentInternals($code); | 1846 AddToImplContentInternals($code); |
1835 return; | 1847 return; |
1836 } | 1848 } |
1837 | 1849 |
1838 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); | 1850 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); |
1839 | 1851 |
1840 if ($svgNativeType) { | 1852 if ($svgNativeType) { |
1841 my $nativeClassName = GetNativeType($interfaceName); | 1853 my $nativeClassName = GetNativeType($interfaceName); |
1842 if ($interfaceName =~ /List$/) { | 1854 if ($interfaceName =~ /List$/) { |
1843 $code .= " $nativeClassName imp = ${v8InterfaceName}::toNative(ar gs.Holder());\n"; | 1855 $code .= " $nativeClassName imp = ${v8InterfaceName}::toNative(ar gs.Holder());\n"; |
1844 } else { | 1856 } else { |
1845 AddToImplIncludes("ExceptionCode.h"); | 1857 AddToImplIncludes("core/dom/ExceptionCode.h"); |
1846 $code .= " $nativeClassName wrapper = ${v8InterfaceName}::toNativ e(args.Holder());\n"; | 1858 $code .= " $nativeClassName wrapper = ${v8InterfaceName}::toNativ e(args.Holder());\n"; |
1847 $code .= " if (wrapper->isReadOnly())\n"; | 1859 $code .= " if (wrapper->isReadOnly())\n"; |
1848 $code .= " return setDOMException(NO_MODIFICATION_ALLOWED_ERR , args.GetIsolate());\n"; | 1860 $code .= " return setDOMException(NO_MODIFICATION_ALLOWED_ERR , args.GetIsolate());\n"; |
1849 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingT earOff($interfaceName); | 1861 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingT earOff($interfaceName); |
1850 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; | 1862 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; |
1851 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; | 1863 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
1852 } | 1864 } |
1853 } elsif (!$function->isStatic) { | 1865 } elsif (!$function->isStatic) { |
1854 $code .= <<END; | 1866 $code .= <<END; |
1855 ${interfaceName}* imp = ${v8InterfaceName}::toNative(args.Holder()); | 1867 ${interfaceName}* imp = ${v8InterfaceName}::toNative(args.Holder()); |
1856 END | 1868 END |
1857 } | 1869 } |
1858 | 1870 |
1859 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); | 1871 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); |
1860 | 1872 |
1861 # Check domain security if needed | 1873 # Check domain security if needed |
1862 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->signatu re->extendedAttributes->{"DoNotCheckSecurity"}) { | 1874 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->signatu re->extendedAttributes->{"DoNotCheckSecurity"}) { |
1863 # We have not find real use cases yet. | 1875 # We have not find real use cases yet. |
1864 AddToImplIncludes("Frame.h"); | 1876 AddToImplIncludes("core/page/Frame.h"); |
1865 $code .= <<END; | 1877 $code .= <<END; |
1866 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) | 1878 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) |
1867 return v8Undefined(); | 1879 return v8Undefined(); |
1868 END | 1880 END |
1869 } | 1881 } |
1870 | 1882 |
1871 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"}; | 1883 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"}; |
1872 if (!$raisesExceptions) { | 1884 if (!$raisesExceptions) { |
1873 foreach my $parameter (@{$function->parameters}) { | 1885 foreach my $parameter (@{$function->parameters}) { |
1874 if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailCo nversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { | 1886 if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailCo nversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { |
1875 $raisesExceptions = 1; | 1887 $raisesExceptions = 1; |
1876 } | 1888 } |
1877 } | 1889 } |
1878 } | 1890 } |
1879 | 1891 |
1880 if ($raisesExceptions) { | 1892 if ($raisesExceptions) { |
1881 AddToImplIncludes("ExceptionCode.h"); | 1893 AddToImplIncludes("core/dom/ExceptionCode.h"); |
1882 $code .= " ExceptionCode ec = 0;\n"; | 1894 $code .= " ExceptionCode ec = 0;\n"; |
1883 $code .= " {\n"; | 1895 $code .= " {\n"; |
1884 # The brace here is needed to prevent the ensuing 'goto fail's from jump ing past constructors | 1896 # The brace here is needed to prevent the ensuing 'goto fail's from jump ing past constructors |
1885 # of objects (like Strings) declared later, causing compile errors. The block scope ends | 1897 # of objects (like Strings) declared later, causing compile errors. The block scope ends |
1886 # right before the label 'fail:'. | 1898 # right before the label 'fail:'. |
1887 } | 1899 } |
1888 | 1900 |
1889 if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { | 1901 if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { |
1890 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(BindingState ::instance(), imp->" . $function->signature->name . "(ec)))\n"; | 1902 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(BindingState ::instance(), imp->" . $function->signature->name . "(ec)))\n"; |
1891 $code .= " return v8::Handle<v8::Value>(v8Null(args.GetIsolate()) );\n"; | 1903 $code .= " return v8::Handle<v8::Value>(v8Null(args.GetIsolate()) );\n"; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1926 $code .= $indent . "ScriptState& state = *currentState;\n"; | 1938 $code .= $indent . "ScriptState& state = *currentState;\n"; |
1927 push(@callWithArgs, "&state"); | 1939 push(@callWithArgs, "&state"); |
1928 } | 1940 } |
1929 if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionCon text")) { | 1941 if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionCon text")) { |
1930 $code .= $indent . "ScriptExecutionContext* scriptContext = getScriptExe cutionContext();\n"; | 1942 $code .= $indent . "ScriptExecutionContext* scriptContext = getScriptExe cutionContext();\n"; |
1931 push(@callWithArgs, "scriptContext"); | 1943 push(@callWithArgs, "scriptContext"); |
1932 } | 1944 } |
1933 if ($function and $codeGenerator->ExtendedAttributeContains($callWith, "Scri ptArguments")) { | 1945 if ($function and $codeGenerator->ExtendedAttributeContains($callWith, "Scri ptArguments")) { |
1934 $code .= $indent . "RefPtr<ScriptArguments> scriptArguments(createScript Arguments(args, " . @{$function->parameters} . "));\n"; | 1946 $code .= $indent . "RefPtr<ScriptArguments> scriptArguments(createScript Arguments(args, " . @{$function->parameters} . "));\n"; |
1935 push(@callWithArgs, "scriptArguments.release()"); | 1947 push(@callWithArgs, "scriptArguments.release()"); |
1936 AddToImplIncludes("ScriptArguments.h"); | 1948 AddToImplIncludes("core/inspector/ScriptArguments.h"); |
1937 AddToImplIncludes("ScriptCallStackFactory.h"); | 1949 AddToImplIncludes("bindings/v8/ScriptCallStackFactory.h"); |
1938 } | 1950 } |
1939 return ([@callWithArgs], $code); | 1951 return ([@callWithArgs], $code); |
1940 } | 1952 } |
1941 | 1953 |
1942 sub GenerateArgumentsCountCheck | 1954 sub GenerateArgumentsCountCheck |
1943 { | 1955 { |
1944 my $function = shift; | 1956 my $function = shift; |
1945 my $interface = shift; | 1957 my $interface = shift; |
1946 | 1958 |
1947 my $numMandatoryParams = 0; | 1959 my $numMandatoryParams = 0; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2007 $parameterDefaultPolicy = "DefaultIsNullString"; | 2019 $parameterDefaultPolicy = "DefaultIsNullString"; |
2008 } | 2020 } |
2009 | 2021 |
2010 my $parameterName = $parameter->name; | 2022 my $parameterName = $parameter->name; |
2011 if (GetIndexOf($parameterName, @paramTransferListNames) != -1) { | 2023 if (GetIndexOf($parameterName, @paramTransferListNames) != -1) { |
2012 $replacements{$parameterName} = "messagePortArray" . ucfirst($parame terName); | 2024 $replacements{$parameterName} = "messagePortArray" . ucfirst($parame terName); |
2013 $paramIndex++; | 2025 $paramIndex++; |
2014 next; | 2026 next; |
2015 } | 2027 } |
2016 | 2028 |
2017 AddToImplIncludes("ExceptionCode.h"); | 2029 AddToImplIncludes("core/dom/ExceptionCode.h"); |
2018 if ($parameter->extendedAttributes->{"Callback"}) { | 2030 if ($parameter->extendedAttributes->{"Callback"}) { |
2019 my $v8InterfaceName = "V8" . $parameter->type; | 2031 my $v8InterfaceName = "V8" . $parameter->type; |
2020 AddToImplIncludes("$v8InterfaceName.h"); | 2032 AddToImplIncludes("$v8InterfaceName.h"); |
2021 if ($parameter->isOptional) { | 2033 if ($parameter->isOptional) { |
2022 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n"; | 2034 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n"; |
2023 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; | 2035 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; |
2024 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion())\n"; | 2036 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion())\n"; |
2025 $parameterCheckString .= " return throwTypeError(0, a rgs.GetIsolate());\n"; | 2037 $parameterCheckString .= " return throwTypeError(0, a rgs.GetIsolate());\n"; |
2026 $parameterCheckString .= " $parameterName = ${v8Interface Name}::create(args[$paramIndex], getScriptExecutionContext());\n"; | 2038 $parameterCheckString .= " $parameterName = ${v8Interface Name}::create(args[$paramIndex], getScriptExecutionContext());\n"; |
2027 $parameterCheckString .= " }\n"; | 2039 $parameterCheckString .= " }\n"; |
2028 } else { | 2040 } else { |
2029 $parameterCheckString .= " if (args.Length() <= $paramIndex | | !args[$paramIndex]->IsFunction())\n"; | 2041 $parameterCheckString .= " if (args.Length() <= $paramIndex | | !args[$paramIndex]->IsFunction())\n"; |
2030 $parameterCheckString .= " return throwTypeError(0, args. GetIsolate());\n"; | 2042 $parameterCheckString .= " return throwTypeError(0, args. GetIsolate());\n"; |
2031 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName = ${v8InterfaceName}::create(args[$paramIndex], getScriptExecution Context());\n"; | 2043 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName = ${v8InterfaceName}::create(args[$paramIndex], getScriptExecution Context());\n"; |
2032 } | 2044 } |
2033 } elsif ($parameter->extendedAttributes->{"Clamp"}) { | 2045 } elsif ($parameter->extendedAttributes->{"Clamp"}) { |
2034 my $nativeValue = "${parameterName}NativeValue"; | 2046 my $nativeValue = "${parameterName}NativeValue"; |
2035 my $paramType = $parameter->type; | 2047 my $paramType = $parameter->type; |
2036 $parameterCheckString .= " $paramType $parameterName = 0;\n"; | 2048 $parameterCheckString .= " $paramType $parameterName = 0;\n"; |
2037 $parameterCheckString .= " V8TRYCATCH(double, $nativeValue, a rgs[$paramIndex]->NumberValue());\n"; | 2049 $parameterCheckString .= " V8TRYCATCH(double, $nativeValue, a rgs[$paramIndex]->NumberValue());\n"; |
2038 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; | 2050 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; |
2039 $parameterCheckString .= " $parameterName = clampTo<$para mType>($nativeValue);\n"; | 2051 $parameterCheckString .= " $parameterName = clampTo<$para mType>($nativeValue);\n"; |
2040 } elsif ($parameter->type eq "SerializedScriptValue") { | 2052 } elsif ($parameter->type eq "SerializedScriptValue") { |
2041 AddToImplIncludes("SerializedScriptValue.h"); | 2053 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
2042 my $useTransferList = 0; | 2054 my $useTransferList = 0; |
2043 my $transferListName = ""; | 2055 my $transferListName = ""; |
2044 my $TransferListName = ""; | 2056 my $TransferListName = ""; |
2045 if ($parameter->extendedAttributes->{"TransferList"}) { | 2057 if ($parameter->extendedAttributes->{"TransferList"}) { |
2046 $transferListName = $parameter->extendedAttributes->{"TransferLi st"}; | 2058 $transferListName = $parameter->extendedAttributes->{"TransferLi st"}; |
2047 push(@paramTransferListNames, $transferListName); | 2059 push(@paramTransferListNames, $transferListName); |
2048 | 2060 |
2049 my @allParameterNames = (); | 2061 my @allParameterNames = (); |
2050 foreach my $parameter (@{$function->parameters}) { | 2062 foreach my $parameter (@{$function->parameters}) { |
2051 push(@allParameterNames, $parameter->name); | 2063 push(@allParameterNames, $parameter->name); |
2052 } | 2064 } |
2053 my $transferListIndex = GetIndexOf($transferListName, @allParame terNames); | 2065 my $transferListIndex = GetIndexOf($transferListName, @allParame terNames); |
2054 if ($transferListIndex == -1) { | 2066 if ($transferListIndex == -1) { |
2055 die "IDL error: TransferList refers to a nonexistent argumen t"; | 2067 die "IDL error: TransferList refers to a nonexistent argumen t"; |
2056 } | 2068 } |
2057 | 2069 |
2058 AddToImplIncludes("wtf/ArrayBuffer.h"); | 2070 AddToImplIncludes("wtf/ArrayBuffer.h"); |
2059 AddToImplIncludes("MessagePort.h"); | 2071 AddToImplIncludes("core/dom/MessagePort.h"); |
2060 $TransferListName = ucfirst($transferListName); | 2072 $TransferListName = ucfirst($transferListName); |
2061 $parameterCheckString .= " MessagePortArray messagePortArray$ TransferListName;\n"; | 2073 $parameterCheckString .= " MessagePortArray messagePortArray$ TransferListName;\n"; |
2062 $parameterCheckString .= " ArrayBufferArray arrayBufferArray$ TransferListName;\n"; | 2074 $parameterCheckString .= " ArrayBufferArray arrayBufferArray$ TransferListName;\n"; |
2063 $parameterCheckString .= " if (args.Length() > $transferListI ndex) {\n"; | 2075 $parameterCheckString .= " if (args.Length() > $transferListI ndex) {\n"; |
2064 $parameterCheckString .= " if (!extractTransferables(args [$transferListIndex], messagePortArray$TransferListName, arrayBufferArray$Transf erListName, args.GetIsolate()))\n"; | 2076 $parameterCheckString .= " if (!extractTransferables(args [$transferListIndex], messagePortArray$TransferListName, arrayBufferArray$Transf erListName, args.GetIsolate()))\n"; |
2065 $parameterCheckString .= " return throwTypeError(\"Co uld not extract transferables\", args.GetIsolate());\n"; | 2077 $parameterCheckString .= " return throwTypeError(\"Co uld not extract transferables\", args.GetIsolate());\n"; |
2066 $parameterCheckString .= " }\n"; | 2078 $parameterCheckString .= " }\n"; |
2067 $useTransferList = 1; | 2079 $useTransferList = 1; |
2068 } | 2080 } |
2069 $parameterCheckString .= " bool ${parameterName}DidThrow = false; \n"; | 2081 $parameterCheckString .= " bool ${parameterName}DidThrow = false; \n"; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2211 $code .= <<END; | 2223 $code .= <<END; |
2212 static v8::Handle<v8::Value> constructor${overloadedIndexString}(const v8::Argum ents& args) | 2224 static v8::Handle<v8::Value> constructor${overloadedIndexString}(const v8::Argum ents& args) |
2213 { | 2225 { |
2214 END | 2226 END |
2215 | 2227 |
2216 if ($function->{overloadedIndex} == 0) { | 2228 if ($function->{overloadedIndex} == 0) { |
2217 $code .= GenerateArgumentsCountCheck($function, $interface); | 2229 $code .= GenerateArgumentsCountCheck($function, $interface); |
2218 } | 2230 } |
2219 | 2231 |
2220 if ($raisesExceptions) { | 2232 if ($raisesExceptions) { |
2221 AddToImplIncludes("ExceptionCode.h"); | 2233 AddToImplIncludes("core/dom/ExceptionCode.h"); |
2222 $code .= "\n"; | 2234 $code .= "\n"; |
2223 $code .= " ExceptionCode ec = 0;\n"; | 2235 $code .= " ExceptionCode ec = 0;\n"; |
2224 } | 2236 } |
2225 | 2237 |
2226 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] | 2238 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] |
2227 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName, ""); | 2239 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName, ""); |
2228 $code .= $parameterCheckString; | 2240 $code .= $parameterCheckString; |
2229 | 2241 |
2230 if ($interface->extendedAttributes->{"CallWith"} && $interface->extendedAttr ibutes->{"CallWith"} eq "ScriptExecutionContext") { | 2242 if ($interface->extendedAttributes->{"CallWith"} && $interface->extendedAttr ibutes->{"CallWith"} eq "ScriptExecutionContext") { |
2231 push(@beforeArgumentList, "context"); | 2243 push(@beforeArgumentList, "context"); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2333 } | 2345 } |
2334 GenerateOverloadedConstructorCallback($interface); | 2346 GenerateOverloadedConstructorCallback($interface); |
2335 } | 2347 } |
2336 } | 2348 } |
2337 | 2349 |
2338 sub GenerateEventConstructor | 2350 sub GenerateEventConstructor |
2339 { | 2351 { |
2340 my $interface = shift; | 2352 my $interface = shift; |
2341 my $interfaceName = $interface->name; | 2353 my $interfaceName = $interface->name; |
2342 | 2354 |
2343 AddToImplIncludes("Dictionary.h"); | 2355 AddToImplIncludes("bindings/v8/Dictionary.h"); |
2344 AddToImplContentInternals(<<END); | 2356 AddToImplContentInternals(<<END); |
2345 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2357 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) |
2346 { | 2358 { |
2347 if (args.Length() < 1) | 2359 if (args.Length() < 1) |
2348 return throwNotEnoughArgumentsError(args.GetIsolate()); | 2360 return throwNotEnoughArgumentsError(args.GetIsolate()); |
2349 | 2361 |
2350 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]); | 2362 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]); |
2351 ${interfaceName}Init eventInit; | 2363 ${interfaceName}Init eventInit; |
2352 if (args.Length() >= 2) { | 2364 if (args.Length() >= 2) { |
2353 V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate())); | 2365 V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate())); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2392 END | 2404 END |
2393 AddToImplContent($code); | 2405 AddToImplContent($code); |
2394 } | 2406 } |
2395 | 2407 |
2396 sub GenerateTypedArrayConstructor | 2408 sub GenerateTypedArrayConstructor |
2397 { | 2409 { |
2398 my $interface = shift; | 2410 my $interface = shift; |
2399 my $interfaceName = $interface->name; | 2411 my $interfaceName = $interface->name; |
2400 my $viewType = GetTypeNameOfExternalTypedArray($interface); | 2412 my $viewType = GetTypeNameOfExternalTypedArray($interface); |
2401 my $type = $interface->extendedAttributes->{"TypedArray"}; | 2413 my $type = $interface->extendedAttributes->{"TypedArray"}; |
2402 AddToImplIncludes("V8ArrayBufferViewCustom.h"); | 2414 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); |
2403 | 2415 |
2404 AddToImplContentInternals(<<END); | 2416 AddToImplContentInternals(<<END); |
2405 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2417 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) |
2406 { | 2418 { |
2407 return constructWebGLArray<$interfaceName, V8${interfaceName}, $type>(args, &V8${interfaceName}::info, $viewType); | 2419 return constructWebGLArray<$interfaceName, V8${interfaceName}, $type>(args, &V8${interfaceName}::info, $viewType); |
2408 } | 2420 } |
2409 | 2421 |
2410 END | 2422 END |
2411 } | 2423 } |
2412 | 2424 |
(...skipping 24 matching lines...) Expand all Loading... | |
2437 my $toActiveDOMObject = "0"; | 2449 my $toActiveDOMObject = "0"; |
2438 if ($codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") ) { | 2450 if ($codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") ) { |
2439 $toActiveDOMObject = "${v8InterfaceName}::toActiveDOMObject"; | 2451 $toActiveDOMObject = "${v8InterfaceName}::toActiveDOMObject"; |
2440 } | 2452 } |
2441 | 2453 |
2442 my $toEventTarget = "0"; | 2454 my $toEventTarget = "0"; |
2443 if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { | 2455 if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { |
2444 $toEventTarget = "${v8InterfaceName}::toEventTarget"; | 2456 $toEventTarget = "${v8InterfaceName}::toEventTarget"; |
2445 } | 2457 } |
2446 | 2458 |
2447 AddToImplIncludes("Frame.h"); | 2459 AddToImplIncludes("core/page/Frame.h"); |
2448 AddToImplContent(<<END); | 2460 AddToImplContent(<<END); |
2449 WrapperTypeInfo ${v8InterfaceName}Constructor::info = { ${v8InterfaceName}Constr uctor::GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObject, $toEven tTarget, 0, ${v8InterfaceName}::installPerContextPrototypeProperties, 0, Wrapper TypeObjectPrototype }; | 2461 WrapperTypeInfo ${v8InterfaceName}Constructor::info = { ${v8InterfaceName}Constr uctor::GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObject, $toEven tTarget, 0, ${v8InterfaceName}::installPerContextPrototypeProperties, 0, Wrapper TypeObjectPrototype }; |
2450 | 2462 |
2451 END | 2463 END |
2452 | 2464 |
2453 my $code = ""; | 2465 my $code = ""; |
2454 $code .= <<END; | 2466 $code .= <<END; |
2455 static v8::Handle<v8::Value> ${v8InterfaceName}ConstructorCallback(const v8::Arg uments& args) | 2467 static v8::Handle<v8::Value> ${v8InterfaceName}ConstructorCallback(const v8::Arg uments& args) |
2456 { | 2468 { |
2457 ${maybeObserveFeature} | 2469 ${maybeObserveFeature} |
2458 END | 2470 END |
2459 $code .= GenerateConstructorHeader(); | 2471 $code .= GenerateConstructorHeader(); |
2460 AddToImplIncludes("V8Document.h"); | 2472 AddToImplIncludes("V8Document.h"); |
2461 $code .= <<END; | 2473 $code .= <<END; |
2462 Document* document = currentDocument(BindingState::instance()); | 2474 Document* document = currentDocument(BindingState::instance()); |
2463 | 2475 |
2464 // Make sure the document is added to the DOM Node map. Otherwise, the ${int erfaceName} instance | 2476 // Make sure the document is added to the DOM Node map. Otherwise, the ${int erfaceName} instance |
2465 // may end up being the only node in the map and get garbage-collected prema turely. | 2477 // may end up being the only node in the map and get garbage-collected prema turely. |
2466 toV8(document, args.Holder(), args.GetIsolate()); | 2478 toV8(document, args.Holder(), args.GetIsolate()); |
2467 | 2479 |
2468 END | 2480 END |
2469 | 2481 |
2470 $code .= GenerateArgumentsCountCheck($function, $interface); | 2482 $code .= GenerateArgumentsCountCheck($function, $interface); |
2471 | 2483 |
2472 if ($raisesExceptions) { | 2484 if ($raisesExceptions) { |
2473 AddToImplIncludes("ExceptionCode.h"); | 2485 AddToImplIncludes("core/dom/ExceptionCode.h"); |
2474 $code .= "\n"; | 2486 $code .= "\n"; |
2475 $code .= " ExceptionCode ec = 0;\n"; | 2487 $code .= " ExceptionCode ec = 0;\n"; |
2476 } | 2488 } |
2477 | 2489 |
2478 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName); | 2490 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName); |
2479 $code .= $parameterCheckString; | 2491 $code .= $parameterCheckString; |
2480 | 2492 |
2481 push(@beforeArgumentList, "document"); | 2493 push(@beforeArgumentList, "document"); |
2482 | 2494 |
2483 if ($interface->extendedAttributes->{"RaisesException"}) { | 2495 if ($interface->extendedAttributes->{"RaisesException"}) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2625 my $data = "0 /* no data */"; | 2637 my $data = "0 /* no data */"; |
2626 | 2638 |
2627 # Constructor | 2639 # Constructor |
2628 if ($attribute->signature->type =~ /Constructor$/) { | 2640 if ($attribute->signature->type =~ /Constructor$/) { |
2629 my $constructorType = $attribute->signature->type; | 2641 my $constructorType = $attribute->signature->type; |
2630 $constructorType =~ s/Constructor$//; | 2642 $constructorType =~ s/Constructor$//; |
2631 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct or. | 2643 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct or. |
2632 # We do not generate the header file for NamedConstructor of class XXXX, | 2644 # We do not generate the header file for NamedConstructor of class XXXX, |
2633 # since we generate the NamedConstructor declaration into the header fil e of class XXXX. | 2645 # since we generate the NamedConstructor declaration into the header fil e of class XXXX. |
2634 if ($constructorType !~ /Constructor$/ || $attribute->signature->extende dAttributes->{"CustomConstructor"}) { | 2646 if ($constructorType !~ /Constructor$/ || $attribute->signature->extende dAttributes->{"CustomConstructor"}) { |
2635 AddToImplIncludes("V8${constructorType}.h", $attribute->signature->e xtendedAttributes->{"Conditional"}); | 2647 my $includepath = ""; |
2648 if ($constructorType eq "HTMLImageElementConstructor") { | |
2649 $includepath = "bindings/v8/custom/"; | |
2650 } | |
2651 AddToImplIncludes("${includepath}V8${constructorType}.h", $attribute ->signature->extendedAttributes->{"Conditional"}); | |
2636 } | 2652 } |
2637 $data = "&V8${constructorType}::info"; | 2653 $data = "&V8${constructorType}::info"; |
2638 $getter = "${interfaceName}V8Internal::${interfaceName}ConstructorGetter "; | 2654 $getter = "${interfaceName}V8Internal::${interfaceName}ConstructorGetter "; |
2639 $setter = "${interfaceName}V8Internal::${interfaceName}ReplaceableAttrSe tterCallback"; | 2655 $setter = "${interfaceName}V8Internal::${interfaceName}ReplaceableAttrSe tterCallback"; |
2640 $getterForMainWorld = "0"; | 2656 $getterForMainWorld = "0"; |
2641 $setterForMainWorld = "0"; | 2657 $setterForMainWorld = "0"; |
2642 } else { | 2658 } else { |
2643 # Default Getter and Setter | 2659 # Default Getter and Setter |
2644 $getter = "${interfaceName}V8Internal::${attrName}AttrGetterCallback"; | 2660 $getter = "${interfaceName}V8Internal::${attrName}AttrGetterCallback"; |
2645 $setter = "${interfaceName}V8Internal::${attrName}AttrSetterCallback"; | 2661 $setter = "${interfaceName}V8Internal::${attrName}AttrSetterCallback"; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2810 # FIXME: Find a way to not have to special-case HTMLOptionsCollection. | 2826 # FIXME: Find a way to not have to special-case HTMLOptionsCollection. |
2811 if ($interfaceName eq "HTMLOptionsCollection") { | 2827 if ($interfaceName eq "HTMLOptionsCollection") { |
2812 $hasEnumerator = 1; | 2828 $hasEnumerator = 1; |
2813 $hasIndexedGetter = 1; | 2829 $hasIndexedGetter = 1; |
2814 } | 2830 } |
2815 | 2831 |
2816 if (!$hasIndexedGetter) { | 2832 if (!$hasIndexedGetter) { |
2817 return ""; | 2833 return ""; |
2818 } | 2834 } |
2819 | 2835 |
2820 AddToImplIncludes("V8Collection.h"); | 2836 AddToImplIncludes("bindings/v8/V8Collection.h"); |
2821 | 2837 |
2822 if (!$indexer) { | 2838 if (!$indexer) { |
2823 $indexer = $codeGenerator->FindSuperMethod($interface, "item"); | 2839 $indexer = $codeGenerator->FindSuperMethod($interface, "item"); |
2824 } | 2840 } |
2825 | 2841 |
2826 my $indexerType = $indexer ? $indexer->type : 0; | 2842 my $indexerType = $indexer ? $indexer->type : 0; |
2827 | 2843 |
2828 if ($indexerType && !$hasCustomIndexedSetter) { | 2844 if ($indexerType && !$hasCustomIndexedSetter) { |
2829 $hasEnumerator = 1; | 2845 $hasEnumerator = 1; |
2830 } | 2846 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2898 | 2914 |
2899 my $interfaceName = $interface->name; | 2915 my $interfaceName = $interface->name; |
2900 my $v8InterfaceName = "V8$interfaceName"; | 2916 my $v8InterfaceName = "V8$interfaceName"; |
2901 | 2917 |
2902 if (!$namedPropertyGetter) { | 2918 if (!$namedPropertyGetter) { |
2903 $namedPropertyGetter = $codeGenerator->FindSuperMethod($interface, "name dItem"); | 2919 $namedPropertyGetter = $codeGenerator->FindSuperMethod($interface, "name dItem"); |
2904 } | 2920 } |
2905 | 2921 |
2906 if ($interface->extendedAttributes->{"NamedGetter"}) { | 2922 if ($interface->extendedAttributes->{"NamedGetter"}) { |
2907 die "$interfaceName: [NamedGetter] but no namedItem() method." if (!$nam edPropertyGetter); | 2923 die "$interfaceName: [NamedGetter] but no namedItem() method." if (!$nam edPropertyGetter); |
2908 AddToImplIncludes("V8Collection.h"); | 2924 AddToImplIncludes("bindings/v8/V8Collection.h"); |
2909 my $type = $namedPropertyGetter->type; | 2925 my $type = $namedPropertyGetter->type; |
2910 $subCode .= <<END; | 2926 $subCode .= <<END; |
2911 desc->InstanceTemplate()->SetNamedPropertyHandler(${v8InterfaceName}::namedP ropertyGetter, 0, 0, 0, 0); | 2927 desc->InstanceTemplate()->SetNamedPropertyHandler(${v8InterfaceName}::namedP ropertyGetter, 0, 0, 0, 0); |
2912 END | 2928 END |
2913 | 2929 |
2914 my $code .= <<END; | 2930 my $code .= <<END; |
2915 v8::Handle<v8::Value> ${v8InterfaceName}::namedPropertyGetter(v8::Local<v8::Stri ng> name, const v8::AccessorInfo& info) | 2931 v8::Handle<v8::Value> ${v8InterfaceName}::namedPropertyGetter(v8::Local<v8::Stri ng> name, const v8::AccessorInfo& info) |
2916 { | 2932 { |
2917 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 2933 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
2918 return v8Undefined(); | 2934 return v8Undefined(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3009 my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interfac e); | 3025 my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interfac e); |
3010 my $v8InterfaceName = "V8$interfaceName"; | 3026 my $v8InterfaceName = "V8$interfaceName"; |
3011 my $nativeType = GetNativeTypeForConversions($interface); | 3027 my $nativeType = GetNativeTypeForConversions($interface); |
3012 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); | 3028 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); |
3013 my $vtableRefGnu = GetGnuVTableRefForInterface($interface); | 3029 my $vtableRefGnu = GetGnuVTableRefForInterface($interface); |
3014 my $vtableRefWin = GetWinVTableRefForInterface($interface); | 3030 my $vtableRefWin = GetWinVTableRefForInterface($interface); |
3015 | 3031 |
3016 # - Add default header template | 3032 # - Add default header template |
3017 push(@implContentHeader, GenerateImplementationContentHeader($interface)); | 3033 push(@implContentHeader, GenerateImplementationContentHeader($interface)); |
3018 | 3034 |
3019 AddToImplIncludes("BindingState.h"); | 3035 AddToImplIncludes("bindings/v8/BindingState.h"); |
3020 AddToImplIncludes("ContextFeatures.h"); | 3036 AddToImplIncludes("core/dom/ContextFeatures.h"); |
3021 AddToImplIncludes("RuntimeEnabledFeatures.h"); | 3037 AddToImplIncludes("core/page/RuntimeEnabledFeatures.h"); |
3022 AddToImplIncludes("V8Binding.h"); | 3038 AddToImplIncludes("bindings/v8/V8Binding.h"); |
3023 AddToImplIncludes("V8DOMWrapper.h"); | 3039 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); |
3024 | 3040 |
3025 AddIncludesForType($interfaceName); | 3041 AddIncludesForType($interfaceName); |
3026 | 3042 |
3027 my $toActiveDOMObject = $codeGenerator->InheritsExtendedAttribute($interface , "ActiveDOMObject") ? "${v8InterfaceName}::toActiveDOMObject" : "0"; | 3043 my $toActiveDOMObject = $codeGenerator->InheritsExtendedAttribute($interface , "ActiveDOMObject") ? "${v8InterfaceName}::toActiveDOMObject" : "0"; |
3028 my $toEventTarget = $codeGenerator->InheritsExtendedAttribute($interface, "E ventTarget") ? "${v8InterfaceName}::toEventTarget" : "0"; | 3044 my $toEventTarget = $codeGenerator->InheritsExtendedAttribute($interface, "E ventTarget") ? "${v8InterfaceName}::toEventTarget" : "0"; |
3029 my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8InterfaceName} ::opaqueRootForGC" : "0"; | 3045 my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8InterfaceName} ::opaqueRootForGC" : "0"; |
3030 | 3046 |
3031 # Find the super descriptor. | 3047 # Find the super descriptor. |
3032 my $parentClass = ""; | 3048 my $parentClass = ""; |
3033 my $parentClassTemplate = ""; | 3049 my $parentClassTemplate = ""; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3129 $hasConstructors = 1; | 3145 $hasConstructors = 1; |
3130 } | 3146 } |
3131 next; | 3147 next; |
3132 } | 3148 } |
3133 | 3149 |
3134 if ($attrType eq "EventListener" && $interfaceName eq "DOMWindow") { | 3150 if ($attrType eq "EventListener" && $interfaceName eq "DOMWindow") { |
3135 $attrExt->{"OnProto"} = 1; | 3151 $attrExt->{"OnProto"} = 1; |
3136 } | 3152 } |
3137 | 3153 |
3138 if ($attrType eq "SerializedScriptValue") { | 3154 if ($attrType eq "SerializedScriptValue") { |
3139 AddToImplIncludes("SerializedScriptValue.h"); | 3155 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
3140 } | 3156 } |
3141 | 3157 |
3142 GenerateNormalAttrGetter($attribute, $interface, ""); | 3158 GenerateNormalAttrGetter($attribute, $interface, ""); |
3143 GenerateNormalAttrGetterCallback($attribute, $interface, ""); | 3159 GenerateNormalAttrGetterCallback($attribute, $interface, ""); |
3144 if ($attrExt->{"PerWorldBindings"}) { | 3160 if ($attrExt->{"PerWorldBindings"}) { |
3145 GenerateNormalAttrGetter($attribute, $interface, "ForMainWorld"); | 3161 GenerateNormalAttrGetter($attribute, $interface, "ForMainWorld"); |
3146 GenerateNormalAttrGetterCallback($attribute, $interface, "ForMainWor ld"); | 3162 GenerateNormalAttrGetterCallback($attribute, $interface, "ForMainWor ld"); |
3147 } | 3163 } |
3148 if (!HasCustomSetter($attrExt) && $attrExt->{"Replaceable"}) { | 3164 if (!HasCustomSetter($attrExt) && $attrExt->{"Replaceable"}) { |
3149 $hasReplaceable = 1; | 3165 $hasReplaceable = 1; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3322 $has_constants = 1; | 3338 $has_constants = 1; |
3323 $code .= "static const V8DOMConfiguration::BatchedConstant ${v8Interface Name}Consts[] = {\n"; | 3339 $code .= "static const V8DOMConfiguration::BatchedConstant ${v8Interface Name}Consts[] = {\n"; |
3324 } | 3340 } |
3325 foreach my $constant (@{$interface->constants}) { | 3341 foreach my $constant (@{$interface->constants}) { |
3326 my $name = $constant->name; | 3342 my $name = $constant->name; |
3327 my $value = $constant->value; | 3343 my $value = $constant->value; |
3328 my $attrExt = $constant->extendedAttributes; | 3344 my $attrExt = $constant->extendedAttributes; |
3329 my $conditional = $attrExt->{"Conditional"}; | 3345 my $conditional = $attrExt->{"Conditional"}; |
3330 my $implementedBy = $attrExt->{"ImplementedBy"}; | 3346 my $implementedBy = $attrExt->{"ImplementedBy"}; |
3331 if ($implementedBy) { | 3347 if ($implementedBy) { |
3332 AddToImplIncludes("${implementedBy}.h"); | 3348 my $implementedByPath = idlToPath($implementedBy); |
3349 AddToImplIncludes("${implementedByPath}${implementedBy}.h"); | |
3333 } | 3350 } |
3334 if ($attrExt->{"EnabledAtRuntime"}) { | 3351 if ($attrExt->{"EnabledAtRuntime"}) { |
3335 push(@constantsEnabledAtRuntime, $constant); | 3352 push(@constantsEnabledAtRuntime, $constant); |
3336 } else { | 3353 } else { |
3337 if ($conditional) { | 3354 if ($conditional) { |
3338 my $conditionalString = $codeGenerator->GenerateConditionalStrin gFromAttributeValue($conditional); | 3355 my $conditionalString = $codeGenerator->GenerateConditionalStrin gFromAttributeValue($conditional); |
3339 $code .= "#if ${conditionalString}\n"; | 3356 $code .= "#if ${conditionalString}\n"; |
3340 } | 3357 } |
3341 # If the value we're dealing with is a hex number, preprocess it int o a signed integer | 3358 # If the value we're dealing with is a hex number, preprocess it int o a signed integer |
3342 # here, rather than running static_cast<signed int> in the generated code. | 3359 # here, rather than running static_cast<signed int> in the generated code. |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3757 my $interface = shift; | 3774 my $interface = shift; |
3758 | 3775 |
3759 my $interfaceName = $interface->name; | 3776 my $interfaceName = $interface->name; |
3760 my $v8InterfaceName = "V8$interfaceName"; | 3777 my $v8InterfaceName = "V8$interfaceName"; |
3761 | 3778 |
3762 | 3779 |
3763 # - Add default header template | 3780 # - Add default header template |
3764 AddToHeader(GenerateHeaderContentHeader($interface)); | 3781 AddToHeader(GenerateHeaderContentHeader($interface)); |
3765 | 3782 |
3766 my @unsortedIncludes = (); | 3783 my @unsortedIncludes = (); |
3767 push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\""); | 3784 push(@unsortedIncludes, "#include \"bindings/v8/ActiveDOMCallback.h\""); |
3768 push(@unsortedIncludes, "#include \"DOMWrapperWorld.h\""); | 3785 push(@unsortedIncludes, "#include \"bindings/v8/DOMWrapperWorld.h\""); |
3769 push(@unsortedIncludes, "#include \"$interfaceName.h\""); | 3786 my $interfacePath = idlToPath($interfaceName); |
3770 push(@unsortedIncludes, "#include \"ScopedPersistent.h\""); | 3787 push(@unsortedIncludes, "#include \"$interfacePath$interfaceName.h\""); |
3788 push(@unsortedIncludes, "#include \"bindings/v8/ScopedPersistent.h\""); | |
3771 push(@unsortedIncludes, "#include <v8.h>"); | 3789 push(@unsortedIncludes, "#include <v8.h>"); |
3772 push(@unsortedIncludes, "#include <wtf/Forward.h>"); | 3790 push(@unsortedIncludes, "#include <wtf/Forward.h>"); |
3773 AddToHeader(join("\n", sort @unsortedIncludes)); | 3791 AddToHeader(join("\n", sort @unsortedIncludes)); |
3774 | 3792 |
3775 AddToHeader("\n\nnamespace WebCore {\n\n"); | 3793 AddToHeader("\n\nnamespace WebCore {\n\n"); |
3776 AddToHeader("class ScriptExecutionContext;\n\n"); | 3794 AddToHeader("class ScriptExecutionContext;\n\n"); |
3777 AddToHeader("class $v8InterfaceName : public $interfaceName, public ActiveDO MCallback {\n"); | 3795 AddToHeader("class $v8InterfaceName : public $interfaceName, public ActiveDO MCallback {\n"); |
3778 | 3796 |
3779 AddToHeader(<<END); | 3797 AddToHeader(<<END); |
3780 public: | 3798 public: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3834 sub GenerateCallbackImplementation | 3852 sub GenerateCallbackImplementation |
3835 { | 3853 { |
3836 my $object = shift; | 3854 my $object = shift; |
3837 my $interface = shift; | 3855 my $interface = shift; |
3838 my $interfaceName = $interface->name; | 3856 my $interfaceName = $interface->name; |
3839 my $v8InterfaceName = "V8$interfaceName"; | 3857 my $v8InterfaceName = "V8$interfaceName"; |
3840 | 3858 |
3841 # - Add default header template | 3859 # - Add default header template |
3842 push(@implContentHeader, GenerateImplementationContentHeader($interface)); | 3860 push(@implContentHeader, GenerateImplementationContentHeader($interface)); |
3843 | 3861 |
3844 AddToImplIncludes("ScriptExecutionContext.h"); | 3862 AddToImplIncludes("core/dom/ScriptExecutionContext.h"); |
3845 AddToImplIncludes("V8Binding.h"); | 3863 AddToImplIncludes("bindings/v8/V8Binding.h"); |
3846 AddToImplIncludes("V8Callback.h"); | 3864 AddToImplIncludes("bindings/v8/V8Callback.h"); |
3847 | 3865 |
3848 AddToImplContent("#include <wtf/Assertions.h>\n\n"); | 3866 AddToImplContent("#include <wtf/Assertions.h>\n\n"); |
3849 AddToImplContent("namespace WebCore {\n\n"); | 3867 AddToImplContent("namespace WebCore {\n\n"); |
3850 | 3868 |
3851 AddToImplContent(<<END); | 3869 AddToImplContent(<<END); |
3852 ${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptEx ecutionContext* context) | 3870 ${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptEx ecutionContext* context) |
3853 : ActiveDOMCallback(context) | 3871 : ActiveDOMCallback(context) |
3854 , m_callback(callback) | 3872 , m_callback(callback) |
3855 , m_world(DOMWrapperWorld::current()) | 3873 , m_world(DOMWrapperWorld::current()) |
3856 { | 3874 { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3947 { | 3965 { |
3948 my $interface = shift; | 3966 my $interface = shift; |
3949 my $v8InterfaceName = shift; | 3967 my $v8InterfaceName = shift; |
3950 my $nativeType = shift; | 3968 my $nativeType = shift; |
3951 my $interfaceName = $interface->name; | 3969 my $interfaceName = $interface->name; |
3952 | 3970 |
3953 if ($interface->extendedAttributes->{"NoWrapperCache"} || $interface->extend edAttributes->{"SuppressToJSObject"}) { | 3971 if ($interface->extendedAttributes->{"NoWrapperCache"} || $interface->extend edAttributes->{"SuppressToJSObject"}) { |
3954 return; | 3972 return; |
3955 } | 3973 } |
3956 | 3974 |
3957 AddToImplIncludes("Frame.h"); | 3975 AddToImplIncludes("core/page/Frame.h"); |
3958 AddToImplIncludes("ScriptController.h"); | 3976 AddToImplIncludes("ScriptController.h"); |
3959 | 3977 |
3960 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); | 3978 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); |
3961 my $baseType = BaseInterfaceName($interface); | 3979 my $baseType = BaseInterfaceName($interface); |
3962 | 3980 |
3963 my $code = ""; | 3981 my $code = ""; |
3964 $code .= <<END; | 3982 $code .= <<END; |
3965 | 3983 |
3966 v8::Handle<v8::Object> ${v8InterfaceName}::createWrapper(${createWrapperArgument Type} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 3984 v8::Handle<v8::Object> ${v8InterfaceName}::createWrapper(${createWrapperArgument Type} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
3967 { | 3985 { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4173 if ($function->signature->extendedAttributes->{"ImplementedAs"}) { | 4191 if ($function->signature->extendedAttributes->{"ImplementedAs"}) { |
4174 $name = $function->signature->extendedAttributes->{"ImplementedAs"}; | 4192 $name = $function->signature->extendedAttributes->{"ImplementedAs"}; |
4175 } | 4193 } |
4176 | 4194 |
4177 my $index = 0; | 4195 my $index = 0; |
4178 | 4196 |
4179 my @arguments; | 4197 my @arguments; |
4180 my $functionName; | 4198 my $functionName; |
4181 my $implementedBy = $function->signature->extendedAttributes->{"ImplementedB y"}; | 4199 my $implementedBy = $function->signature->extendedAttributes->{"ImplementedB y"}; |
4182 if ($implementedBy) { | 4200 if ($implementedBy) { |
4183 AddToImplIncludes("${implementedBy}.h"); | 4201 my $implementedByPath = idlToPath($implementedBy); |
4202 AddToImplIncludes("${implementedByPath}${implementedBy}.h"); | |
4184 unshift(@arguments, "imp") if !$function->isStatic; | 4203 unshift(@arguments, "imp") if !$function->isStatic; |
4185 $functionName = "${implementedBy}::${name}"; | 4204 $functionName = "${implementedBy}::${name}"; |
4186 } elsif ($function->isStatic) { | 4205 } elsif ($function->isStatic) { |
4187 $functionName = "${interfaceName}::${name}"; | 4206 $functionName = "${interfaceName}::${name}"; |
4188 } else { | 4207 } else { |
4189 $functionName = "imp->${name}"; | 4208 $functionName = "imp->${name}"; |
4190 } | 4209 } |
4191 | 4210 |
4192 my $callWith = $function->signature->extendedAttributes->{"CallWith"}; | 4211 my $callWith = $function->signature->extendedAttributes->{"CallWith"}; |
4193 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 0, $func tion); | 4212 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 0, $func tion); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4250 if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) { | 4269 if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) { |
4251 $code .= $indent . "if (state.hadException()) {\n"; | 4270 $code .= $indent . "if (state.hadException()) {\n"; |
4252 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n"; | 4271 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n"; |
4253 $code .= $indent . " state.clearException();\n"; | 4272 $code .= $indent . " state.clearException();\n"; |
4254 $code .= $indent . " return throwError(exception, args.GetIsolate()); \n"; | 4273 $code .= $indent . " return throwError(exception, args.GetIsolate()); \n"; |
4255 $code .= $indent . "}\n"; | 4274 $code .= $indent . "}\n"; |
4256 } | 4275 } |
4257 | 4276 |
4258 if ($isSVGTearOffType) { | 4277 if ($isSVGTearOffType) { |
4259 AddToImplIncludes("V8$returnType.h"); | 4278 AddToImplIncludes("V8$returnType.h"); |
4260 AddToImplIncludes("SVGPropertyTearOff.h"); | 4279 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); |
4261 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($returnType ); | 4280 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($returnType ); |
4262 # FIXME: Update for all ScriptWrappables. | 4281 # FIXME: Update for all ScriptWrappables. |
4263 if (IsDOMNodeType($interfaceName)) { | 4282 if (IsDOMNodeType($interfaceName)) { |
4264 $code .= $indent . "return toV8Fast${forMainWorldSuffix}(WTF::getPtr (${svgNativeType}::create($return)), args, imp);\n"; | 4283 $code .= $indent . "return toV8Fast${forMainWorldSuffix}(WTF::getPtr (${svgNativeType}::create($return)), args, imp);\n"; |
4265 } else { | 4284 } else { |
4266 $code .= $indent . "return toV8${forMainWorldSuffix}(WTF::getPtr(${s vgNativeType}::create($return)), args.Holder(), args.GetIsolate());\n"; | 4285 $code .= $indent . "return toV8${forMainWorldSuffix}(WTF::getPtr(${s vgNativeType}::create($return)), args.Holder(), args.GetIsolate());\n"; |
4267 } | 4286 } |
4268 return $code; | 4287 return $code; |
4269 } | 4288 } |
4270 | 4289 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4378 | 4397 |
4379 # Callbacks use raw pointers, so pass isParameter = 1 | 4398 # Callbacks use raw pointers, so pass isParameter = 1 |
4380 return GetNativeType($type, 1); | 4399 return GetNativeType($type, 1); |
4381 } | 4400 } |
4382 | 4401 |
4383 sub TypeCanFailConversion | 4402 sub TypeCanFailConversion |
4384 { | 4403 { |
4385 my $signature = shift; | 4404 my $signature = shift; |
4386 my $type = $signature->type; | 4405 my $type = $signature->type; |
4387 | 4406 |
4388 AddToImplIncludes("ExceptionCode.h") if $type eq "Attr"; | 4407 AddToImplIncludes("core/dom/ExceptionCode.h") if $type eq "Attr"; |
4389 return 1 if $type eq "Attr"; | 4408 return 1 if $type eq "Attr"; |
4390 return 0; | 4409 return 0; |
4391 } | 4410 } |
4392 | 4411 |
4393 sub JSValueToNative | 4412 sub JSValueToNative |
4394 { | 4413 { |
4395 my $signature = shift; | 4414 my $signature = shift; |
4396 my $value = shift; | 4415 my $value = shift; |
4397 my $getIsolate = shift; | 4416 my $getIsolate = shift; |
4398 | 4417 |
(...skipping 21 matching lines...) Expand all Loading... | |
4420 | 4439 |
4421 if ($type eq "DOMString") { | 4440 if ($type eq "DOMString") { |
4422 return $value; | 4441 return $value; |
4423 } | 4442 } |
4424 | 4443 |
4425 if ($codeGenerator->IsEnumType($type)) { | 4444 if ($codeGenerator->IsEnumType($type)) { |
4426 return $value; | 4445 return $value; |
4427 } | 4446 } |
4428 | 4447 |
4429 if ($type eq "SerializedScriptValue") { | 4448 if ($type eq "SerializedScriptValue") { |
4430 AddToImplIncludes("SerializedScriptValue.h"); | 4449 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
4431 return "SerializedScriptValue::create($value, $getIsolate)"; | 4450 return "SerializedScriptValue::create($value, $getIsolate)"; |
4432 } | 4451 } |
4433 | 4452 |
4434 if ($type eq "Dictionary") { | 4453 if ($type eq "Dictionary") { |
4435 AddToImplIncludes("Dictionary.h"); | 4454 AddToImplIncludes("bindings/v8/Dictionary.h"); |
4436 return "Dictionary($value, $getIsolate)"; | 4455 return "Dictionary($value, $getIsolate)"; |
4437 } | 4456 } |
4438 | 4457 |
4439 if ($type eq "any") { | 4458 if ($type eq "any") { |
4440 AddToImplIncludes("ScriptValue.h"); | 4459 AddToImplIncludes("bindings/v8/ScriptValue.h"); |
4441 return "ScriptValue($value)"; | 4460 return "ScriptValue($value)"; |
4442 } | 4461 } |
4443 | 4462 |
4444 if ($type eq "NodeFilter") { | 4463 if ($type eq "NodeFilter") { |
4445 return "toNodeFilter($value)"; | 4464 return "toNodeFilter($value)"; |
4446 } | 4465 } |
4447 | 4466 |
4448 if ($type eq "MediaQueryListListener") { | 4467 if ($type eq "MediaQueryListListener") { |
4449 AddToImplIncludes("MediaQueryListListener.h"); | 4468 AddToImplIncludes("core/css/MediaQueryListListener.h"); |
4450 return "MediaQueryListListener::create(" . $value . ")"; | 4469 return "MediaQueryListListener::create(" . $value . ")"; |
4451 } | 4470 } |
4452 | 4471 |
4453 if ($type eq "EventTarget") { | 4472 if ($type eq "EventTarget") { |
4454 return "V8DOMWrapper::isDOMWrapper($value) ? toWrapperTypeInfo(v8::Handl e<v8::Object>::Cast($value))->toEventTarget(v8::Handle<v8::Object>::Cast($value) ) : 0"; | 4473 return "V8DOMWrapper::isDOMWrapper($value) ? toWrapperTypeInfo(v8::Handl e<v8::Object>::Cast($value))->toEventTarget(v8::Handle<v8::Object>::Cast($value) ) : 0"; |
4455 } | 4474 } |
4456 | 4475 |
4457 if ($type eq "XPathNSResolver") { | 4476 if ($type eq "XPathNSResolver") { |
4458 return "toXPathNSResolver($value, $getIsolate)"; | 4477 return "toXPathNSResolver($value, $getIsolate)"; |
4459 } | 4478 } |
(...skipping 13 matching lines...) Expand all Loading... | |
4473 AddIncludesForType($type); | 4492 AddIncludesForType($type); |
4474 | 4493 |
4475 AddToImplIncludes("V8${type}.h"); | 4494 AddToImplIncludes("V8${type}.h"); |
4476 return "V8${type}::HasInstance($value, $getIsolate, worldType($getIsolate)) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; | 4495 return "V8${type}::HasInstance($value, $getIsolate, worldType($getIsolate)) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; |
4477 } | 4496 } |
4478 | 4497 |
4479 sub GetV8HeaderName | 4498 sub GetV8HeaderName |
4480 { | 4499 { |
4481 my $type = shift; | 4500 my $type = shift; |
4482 return "V8Event.h" if $type eq "DOMTimeStamp"; | 4501 return "V8Event.h" if $type eq "DOMTimeStamp"; |
4483 return "EventListener.h" if $type eq "EventListener"; | 4502 return "core/dom/EventListener.h" if $type eq "EventListener"; |
4484 return "SerializedScriptValue.h" if $type eq "SerializedScriptValue"; | 4503 return "bindings/v8/SerializedScriptValue.h" if $type eq "SerializedScriptVa lue"; |
4485 return "ScriptValue.h" if $type eq "any"; | 4504 return "bindings/v8/ScriptValue.h" if $type eq "any"; |
4505 return "bindings/v8/V8GCController.h" if $type eq "GCController"; | |
4486 return "V8${type}.h"; | 4506 return "V8${type}.h"; |
4487 } | 4507 } |
4488 | 4508 |
4489 sub CreateCustomSignature | 4509 sub CreateCustomSignature |
4490 { | 4510 { |
4491 my $function = shift; | 4511 my $function = shift; |
4492 my $count = @{$function->parameters}; | 4512 my $count = @{$function->parameters}; |
4493 my $name = $function->signature->name; | 4513 my $name = $function->signature->name; |
4494 my $code = " const int ${name}Argc = ${count};\n" . | 4514 my $code = " const int ${name}Argc = ${count};\n" . |
4495 " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { "; | 4515 " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { "; |
4496 my $first = 1; | 4516 my $first = 1; |
4497 foreach my $parameter (@{$function->parameters}) { | 4517 foreach my $parameter (@{$function->parameters}) { |
4498 if ($first) { $first = 0; } | 4518 if ($first) { $first = 0; } |
4499 else { $code .= ", "; } | 4519 else { $code .= ", "; } |
4500 if (IsWrapperType($parameter->type)) { | 4520 if (IsWrapperType($parameter->type)) { |
4501 if ($parameter->type eq "XPathNSResolver") { | 4521 if ($parameter->type eq "XPathNSResolver") { |
4502 # Special case for XPathNSResolver. All other browsers accepts a callable, | 4522 # Special case for XPathNSResolver. All other browsers accepts a callable, |
4503 # so, even though it's against IDL, accept objects here. | 4523 # so, even though it's against IDL, accept objects here. |
4504 $code .= "v8::Handle<v8::FunctionTemplate>()"; | 4524 $code .= "v8::Handle<v8::FunctionTemplate>()"; |
4505 } else { | 4525 } else { |
4506 my $type = $parameter->type; | 4526 my $type = $parameter->type; |
4507 | 4527 |
4508 my $arrayType = $codeGenerator->GetArrayType($type); | 4528 my $arrayType = $codeGenerator->GetArrayType($type); |
4509 my $sequenceType = $codeGenerator->GetSequenceType($type); | 4529 my $sequenceType = $codeGenerator->GetSequenceType($type); |
4510 my $arrayOrSequenceType = $arrayType || $sequenceType; | 4530 my $arrayOrSequenceType = $arrayType || $sequenceType; |
4511 | 4531 |
4512 if ($arrayOrSequenceType) { | 4532 if ($arrayOrSequenceType) { |
4513 if ($arrayType eq "DOMString") { | 4533 if ($arrayType eq "DOMString") { |
4514 AddToImplIncludes("V8DOMStringList.h"); | 4534 AddToImplIncludes("V8DOMStringList.h"); |
4515 AddToImplIncludes("DOMStringList.h"); | 4535 AddToImplIncludes("core/dom/DOMStringList.h"); |
4516 | 4536 |
4517 } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) { | 4537 } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) { |
4518 AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType)) ; | 4538 AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType)) ; |
4519 AddToImplIncludes("${arrayOrSequenceType}.h"); | 4539 AddToImplIncludes("${arrayOrSequenceType}.h"); |
4520 } else { | 4540 } else { |
4521 $code .= "v8::Handle<v8::FunctionTemplate>()"; | 4541 $code .= "v8::Handle<v8::FunctionTemplate>()"; |
4522 next; | 4542 next; |
4523 } | 4543 } |
4524 } else { | 4544 } else { |
4525 AddToImplIncludes(GetV8HeaderName($type)); | 4545 AddToImplIncludes(GetV8HeaderName($type)); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4706 return "v8String($value, $getIsolate$returnHandleTypeArg)"; | 4726 return "v8String($value, $getIsolate$returnHandleTypeArg)"; |
4707 } | 4727 } |
4708 | 4728 |
4709 my $arrayType = $codeGenerator->GetArrayType($type); | 4729 my $arrayType = $codeGenerator->GetArrayType($type); |
4710 my $sequenceType = $codeGenerator->GetSequenceType($type); | 4730 my $sequenceType = $codeGenerator->GetSequenceType($type); |
4711 my $arrayOrSequenceType = $arrayType || $sequenceType; | 4731 my $arrayOrSequenceType = $arrayType || $sequenceType; |
4712 | 4732 |
4713 if ($arrayOrSequenceType) { | 4733 if ($arrayOrSequenceType) { |
4714 if ($arrayType eq "DOMString") { | 4734 if ($arrayType eq "DOMString") { |
4715 AddToImplIncludes("V8DOMStringList.h"); | 4735 AddToImplIncludes("V8DOMStringList.h"); |
4716 AddToImplIncludes("DOMStringList.h"); | 4736 AddToImplIncludes("core/dom/DOMStringList.h"); |
4717 | 4737 |
4718 } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) { | 4738 } elsif ($codeGenerator->IsRefPtrType($arrayOrSequenceType)) { |
4719 AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType)); | 4739 AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType)); |
4720 AddToImplIncludes("${arrayOrSequenceType}.h"); | 4740 my $includepath = idlToPath($arrayOrSequenceType); # This is not an arraytype (always?). It's things like ScriptProfileNode, MediaStreamTream, Media StreamTream, MediaStream. |
4741 AddToImplIncludes("${includepath}${arrayOrSequenceType}.h"); | |
4721 } | 4742 } |
4722 return "v8Array($value, $getIsolate)"; | 4743 return "v8Array($value, $getIsolate)"; |
4723 } | 4744 } |
4724 | 4745 |
4725 AddIncludesForType($type); | 4746 AddIncludesForType($type); |
4726 | 4747 |
4727 if (IsDOMNodeType($type) || $type eq "EventTarget") { | 4748 if (IsDOMNodeType($type) || $type eq "EventTarget") { |
4728 if ($getScriptWrappable) { | 4749 if ($getScriptWrappable) { |
4729 return "toV8Fast${forMainWorldSuffix}($value$getHolderContainerArg$get ScriptWrappableArg)"; | 4750 return "toV8Fast${forMainWorldSuffix}($value$getHolderContainerArg$get ScriptWrappableArg)"; |
4730 } | 4751 } |
4731 return "toV8($value, $getCreationContext, $getIsolate)"; | 4752 return "toV8($value, $getCreationContext, $getIsolate)"; |
4732 } | 4753 } |
4733 | 4754 |
4734 if ($type eq "EventListener") { | 4755 if ($type eq "EventListener") { |
4735 AddToImplIncludes("V8AbstractEventListener.h"); | 4756 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); |
4736 return "${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventList ener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle <v8::Value>(v8Null($getIsolate))"; | 4757 return "${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventList ener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle <v8::Value>(v8Null($getIsolate))"; |
4737 } | 4758 } |
4738 | 4759 |
4739 if ($type eq "SerializedScriptValue") { | 4760 if ($type eq "SerializedScriptValue") { |
4740 AddToImplIncludes("$type.h"); | 4761 AddToImplIncludes("$type.h"); |
4741 return "$value ? $value->deserialize() : v8::Handle<v8::Value>(v8Null($g etIsolate))"; | 4762 return "$value ? $value->deserialize() : v8::Handle<v8::Value>(v8Null($g etIsolate))"; |
4742 } | 4763 } |
4743 | 4764 |
4744 AddToImplIncludes("wtf/RefCounted.h"); | 4765 AddToImplIncludes("wtf/RefCounted.h"); |
4745 AddToImplIncludes("wtf/RefPtr.h"); | 4766 AddToImplIncludes("wtf/RefPtr.h"); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4857 | 4878 |
4858 sub GetPassRefPtrType | 4879 sub GetPassRefPtrType |
4859 { | 4880 { |
4860 my $v8InterfaceName = shift; | 4881 my $v8InterfaceName = shift; |
4861 | 4882 |
4862 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; | 4883 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; |
4863 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; | 4884 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; |
4864 } | 4885 } |
4865 | 4886 |
4866 1; | 4887 1; |
OLD | NEW |