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