Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 package CodeGeneratorV8; | 28 package CodeGeneratorV8; |
| 29 | 29 |
| 30 use strict; | 30 use strict; |
| 31 | 31 |
| 32 my $codeGenerator; | 32 my $codeGenerator; |
| 33 | 33 |
| 34 | 34 |
| 35 my @headerContent = (); | 35 my @headerContent = (); |
| 36 my @implContentHeader = (); | 36 my @implContentHeader = (); |
| 37 my @implContent = (); | 37 my @implStuff = (); |
|
haraken
2013/04/16 09:40:36
Shall we rename it to @implContent ? Stuff sounds
| |
| 38 my @implContentInternals = (); | 38 my @implInternalStuff = (); |
|
haraken
2013/04/16 09:40:36
@implContentInternals ?
| |
| 39 my %implIncludes = (); | 39 my %implIncludes = (); |
| 40 my %headerIncludes = (); | 40 my %headerIncludes = (); |
| 41 | 41 |
| 42 # Default .h template | 42 # Default .h template |
| 43 my $headerTemplate = << "EOF"; | 43 my $headerTemplate = << "EOF"; |
| 44 /* | 44 /* |
| 45 This file is part of the WebKit open source project. | 45 This file is part of the WebKit open source project. |
| 46 This file has been generated by generate-bindings.pl. DO NOT MODIFY! | 46 This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 47 | 47 |
| 48 This library is free software; you can redistribute it and/or | 48 This library is free software; you can redistribute it and/or |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 my %newValue = (); | 104 my %newValue = (); |
| 105 $newValue{$conditional} = 1; | 105 $newValue{$conditional} = 1; |
| 106 foreach my $condition (split(/\|/, $oldValue)) { | 106 foreach my $condition (split(/\|/, $oldValue)) { |
| 107 $newValue{$condition} = 1; | 107 $newValue{$condition} = 1; |
| 108 } | 108 } |
| 109 $implIncludes{$header} = join("|", sort keys %newValue); | 109 $implIncludes{$header} = join("|", sort keys %newValue); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 sub AddToHeader | |
| 115 { | |
| 116 my @code = @_; | |
| 117 push(@headerContent, @code); | |
| 118 } | |
| 119 | |
| 120 sub AddToImplStuffInternal | |
|
haraken
2013/04/16 09:40:36
AddToImplContentInternals ?
| |
| 121 { | |
| 122 my $code = shift; | |
| 123 push(@implInternalStuff, $code); | |
| 124 } | |
| 125 | |
| 126 sub AddToImplFunctionInternal | |
|
haraken
2013/04/16 09:40:36
Maybe this helper method is not needed, because we
| |
| 127 { | |
| 128 my $func = shift; | |
| 129 AddToImplStuffInternal($func); | |
| 130 } | |
| 131 | |
| 132 sub AddToImplStuff | |
|
haraken
2013/04/16 09:40:36
AddToImplContent ?
| |
| 133 { | |
| 134 my $code = shift; | |
| 135 push(@implStuff, $code); | |
| 136 } | |
| 137 | |
| 138 sub AddToImplFunction | |
|
haraken
2013/04/16 09:40:36
Ditto. We might not need this helper method.
| |
| 139 { | |
| 140 my $func = shift; | |
| 141 AddToImplStuff($func); | |
| 142 } | |
| 143 | |
| 144 | |
| 114 sub AddIncludesForType | 145 sub AddIncludesForType |
| 115 { | 146 { |
| 116 my $type = shift; | 147 my $type = shift; |
| 117 | 148 |
| 118 # When we're finished with the one-file-per-class | 149 # When we're finished with the one-file-per-class |
| 119 # reorganization, we won't need these special cases. | 150 # reorganization, we won't need these special cases. |
| 120 if ($codeGenerator->IsTypedArrayType($type)) { | 151 if ($codeGenerator->IsTypedArrayType($type)) { |
| 121 AddToImplIncludes("wtf/${type}.h"); | 152 AddToImplIncludes("wtf/${type}.h"); |
| 122 } | 153 } |
| 123 if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->IsStringTyp e($type) and !$codeGenerator->SkipIncludeHeader($type) and $type ne "Date") { | 154 if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->IsStringTyp e($type) and !$codeGenerator->SkipIncludeHeader($type) and $type ne "Date") { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 | 208 |
| 178 sub GenerateOpaqueRootForGC | 209 sub GenerateOpaqueRootForGC |
| 179 { | 210 { |
| 180 my $interface = shift; | 211 my $interface = shift; |
| 181 my $interfaceName = $interface->name; | 212 my $interfaceName = $interface->name; |
| 182 | 213 |
| 183 if (GetCustomIsReachable($interface)) { | 214 if (GetCustomIsReachable($interface)) { |
| 184 return; | 215 return; |
| 185 } | 216 } |
| 186 | 217 |
| 187 push(@implContent, <<END); | 218 my $func = <<END; |
|
haraken
2013/04/16 09:40:36
The Blink coding style prefers a full word for a v
| |
| 188 void* V8${interfaceName}::opaqueRootForGC(void* object, v8::Persistent<v8::Objec t> wrapper, v8::Isolate* isolate) | 219 void* V8${interfaceName}::opaqueRootForGC(void* object, v8::Persistent<v8::Objec t> wrapper, v8::Isolate* isolate) |
| 189 { | 220 { |
| 190 ASSERT(!wrapper.IsIndependent(isolate)); | 221 ASSERT(!wrapper.IsIndependent(isolate)); |
| 191 ${interfaceName}* impl = static_cast<${interfaceName}*>(object); | 222 ${interfaceName}* impl = static_cast<${interfaceName}*>(object); |
| 192 END | 223 END |
| 193 if (GetGenerateIsReachable($interface) eq "ImplDocument" || | 224 if (GetGenerateIsReachable($interface) eq "ImplDocument" || |
| 194 GetGenerateIsReachable($interface) eq "ImplElementRoot" || | 225 GetGenerateIsReachable($interface) eq "ImplElementRoot" || |
| 195 GetGenerateIsReachable($interface) eq "ImplOwnerRoot" || | 226 GetGenerateIsReachable($interface) eq "ImplOwnerRoot" || |
| 196 GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") { | 227 GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") { |
| 197 | 228 |
| 198 $implIncludes{"V8GCController.h"} = 1; | 229 $implIncludes{"V8GCController.h"} = 1; |
| 199 | 230 |
| 200 my $methodName; | 231 my $methodName; |
| 201 $methodName = "document" if (GetGenerateIsReachable($interface) eq "Impl Document"); | 232 $methodName = "document" if (GetGenerateIsReachable($interface) eq "Impl Document"); |
| 202 $methodName = "element" if (GetGenerateIsReachable($interface) eq "ImplE lementRoot"); | 233 $methodName = "element" if (GetGenerateIsReachable($interface) eq "ImplE lementRoot"); |
| 203 $methodName = "owner" if (GetGenerateIsReachable($interface) eq "ImplOwn erRoot"); | 234 $methodName = "owner" if (GetGenerateIsReachable($interface) eq "ImplOwn erRoot"); |
| 204 $methodName = "ownerNode" if (GetGenerateIsReachable($interface) eq "Imp lOwnerNodeRoot"); | 235 $methodName = "ownerNode" if (GetGenerateIsReachable($interface) eq "Imp lOwnerNodeRoot"); |
| 205 | 236 |
| 206 push(@implContent, <<END); | 237 $func .= <<END; |
| 207 if (Node* owner = impl->${methodName}()) | 238 if (Node* owner = impl->${methodName}()) |
| 208 return V8GCController::opaqueRootForGC(owner, isolate); | 239 return V8GCController::opaqueRootForGC(owner, isolate); |
| 209 END | 240 END |
| 210 } | 241 } |
| 211 | 242 |
| 212 push(@implContent, <<END); | 243 $func .= <<END; |
| 213 return object; | 244 return object; |
| 214 } | 245 } |
| 215 | 246 |
| 216 END | 247 END |
| 248 AddToImplFunction($func); | |
| 217 } | 249 } |
| 218 | 250 |
| 219 sub GetSVGPropertyTypes | 251 sub GetSVGPropertyTypes |
| 220 { | 252 { |
| 221 my $implType = shift; | 253 my $implType = shift; |
| 222 | 254 |
| 223 my $svgPropertyType; | 255 my $svgPropertyType; |
| 224 my $svgListPropertyType; | 256 my $svgListPropertyType; |
| 225 my $svgNativeType; | 257 my $svgNativeType; |
| 226 | 258 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 | 306 |
| 275 my $hasDependentLifetime = $interface->extendedAttributes->{"DependentLifeti me"} || $codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") || GetGenerateIsReachable($interface) || $v8InterfaceName =~ /SVG/; | 307 my $hasDependentLifetime = $interface->extendedAttributes->{"DependentLifeti me"} || $codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") || GetGenerateIsReachable($interface) || $v8InterfaceName =~ /SVG/; |
| 276 if (!$hasDependentLifetime) { | 308 if (!$hasDependentLifetime) { |
| 277 foreach (@{$interface->parents}) { | 309 foreach (@{$interface->parents}) { |
| 278 my $parent = $_; | 310 my $parent = $_; |
| 279 $headerIncludes{"V8${parent}.h"} = 1; | 311 $headerIncludes{"V8${parent}.h"} = 1; |
| 280 } | 312 } |
| 281 } | 313 } |
| 282 | 314 |
| 283 # - Add default header template | 315 # - Add default header template |
| 284 push(@headerContent, GenerateHeaderContentHeader($interface)); | 316 AddToHeader(GenerateHeaderContentHeader($interface)); |
| 285 | 317 |
| 286 $headerIncludes{"wtf/text/StringHash.h"} = 1; | 318 $headerIncludes{"wtf/text/StringHash.h"} = 1; |
| 287 $headerIncludes{"WrapperTypeInfo.h"} = 1; | 319 $headerIncludes{"WrapperTypeInfo.h"} = 1; |
| 288 $headerIncludes{"V8Binding.h"} = 1; | 320 $headerIncludes{"V8Binding.h"} = 1; |
| 289 $headerIncludes{"V8DOMWrapper.h"} = 1; | 321 $headerIncludes{"V8DOMWrapper.h"} = 1; |
| 290 $headerIncludes{"wtf/HashMap.h"} = 1; | 322 $headerIncludes{"wtf/HashMap.h"} = 1; |
| 291 $headerIncludes{"v8.h"} = 1; | 323 $headerIncludes{"v8.h"} = 1; |
| 292 | 324 |
| 293 my $headerClassInclude = GetHeaderClassInclude($interfaceName); | 325 my $headerClassInclude = GetHeaderClassInclude($interfaceName); |
| 294 $headerIncludes{$headerClassInclude} = 1 if $headerClassInclude ne ""; | 326 $headerIncludes{$headerClassInclude} = 1 if $headerClassInclude ne ""; |
| 295 | 327 |
| 296 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); | 328 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); |
| 297 | 329 |
| 298 foreach my $headerInclude (sort keys(%headerIncludes)) { | 330 foreach my $headerInclude (sort keys(%headerIncludes)) { |
| 299 if ($headerInclude =~ /wtf|v8\.h/) { | 331 if ($headerInclude =~ /wtf|v8\.h/) { |
| 300 push(@headerContent, "#include \<${headerInclude}\>\n"); | 332 AddToHeader("#include \<${headerInclude}\>\n"); |
| 301 } else { | 333 } else { |
| 302 push(@headerContent, "#include \"${headerInclude}\"\n"); | 334 AddToHeader("#include \"${headerInclude}\"\n"); |
| 303 } | 335 } |
| 304 } | 336 } |
| 305 | 337 |
| 306 push(@headerContent, "\nnamespace WebCore {\n"); | 338 AddToHeader("\nnamespace WebCore {\n"); |
| 307 push(@headerContent, "\ntemplate<typename PropertyType> class SVGPropertyTea rOff;\n") if $svgPropertyType; | 339 AddToHeader("\ntemplate<typename PropertyType> class SVGPropertyTearOff;\n") if $svgPropertyType; |
| 308 if ($svgNativeType) { | 340 if ($svgNativeType) { |
| 309 if ($svgNativeType =~ /SVGStaticListPropertyTearOff/) { | 341 if ($svgNativeType =~ /SVGStaticListPropertyTearOff/) { |
| 310 push(@headerContent, "\ntemplate<typename PropertyType> class SVGSta ticListPropertyTearOff;\n"); | 342 AddToHeader("\ntemplate<typename PropertyType> class SVGStaticListPr opertyTearOff;\n"); |
| 311 } else { | 343 } else { |
| 312 push(@headerContent, "\ntemplate<typename PropertyType> class SVGLis tPropertyTearOff;\n"); | 344 AddToHeader("\ntemplate<typename PropertyType> class SVGListProperty TearOff;\n"); |
| 313 } | 345 } |
| 314 } | 346 } |
| 315 | 347 |
| 316 push(@headerContent, "\n"); | 348 AddToHeader("\n"); |
| 317 push(@headerContent, "class FloatRect;\n") if $svgPropertyType && $svgProper tyType eq "FloatRect"; | 349 AddToHeader("class FloatRect;\n") if $svgPropertyType && $svgPropertyType eq "FloatRect"; |
| 318 push(@headerContent, "class Dictionary;\n") if $codeGenerator->IsConstructor Template($interface, "Event"); | 350 AddToHeader("class Dictionary;\n") if $codeGenerator->IsConstructorTemplate( $interface, "Event"); |
| 319 | 351 |
| 320 my $nativeType = GetNativeTypeForConversions($interface); | 352 my $nativeType = GetNativeTypeForConversions($interface); |
| 321 if ($interface->extendedAttributes->{"NamedConstructor"}) { | 353 if ($interface->extendedAttributes->{"NamedConstructor"}) { |
| 322 push(@headerContent, <<END); | 354 AddToHeader(<<END); |
| 323 class V8${nativeType}Constructor { | 355 class V8${nativeType}Constructor { |
| 324 public: | 356 public: |
| 325 static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, Wrappe rWorldType); | 357 static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, Wrappe rWorldType); |
| 326 static WrapperTypeInfo info; | 358 static WrapperTypeInfo info; |
| 327 }; | 359 }; |
| 328 | 360 |
| 329 END | 361 END |
| 330 } | 362 } |
| 331 | 363 |
| 332 push(@headerContent, "class $v8InterfaceName {\n"); | 364 AddToHeader("class $v8InterfaceName {\n"); |
| 333 push(@headerContent, "public:\n"); | 365 AddToHeader("public:\n"); |
| 334 | 366 |
| 335 push(@headerContent, " static const bool hasDependentLifetime = "); | 367 AddToHeader(" static const bool hasDependentLifetime = "); |
| 336 if ($hasDependentLifetime) { | 368 if ($hasDependentLifetime) { |
| 337 push(@headerContent, "true;\n"); | 369 AddToHeader("true;\n"); |
| 338 } elsif (@{$interface->parents}) { | 370 } elsif (@{$interface->parents}) { |
| 339 # Even if this type doesn't have the [DependentLifetime] attribute its p arents may. | 371 # Even if this type doesn't have the [DependentLifetime] attribute its p arents may. |
| 340 # Let the compiler statically determine this for us. | 372 # Let the compiler statically determine this for us. |
| 341 my $separator = ""; | 373 my $separator = ""; |
| 342 foreach (@{$interface->parents}) { | 374 foreach (@{$interface->parents}) { |
| 343 my $parent = $_; | 375 my $parent = $_; |
| 344 $headerIncludes{"V8${parent}.h"} = 1; | 376 $headerIncludes{"V8${parent}.h"} = 1; |
| 345 push(@headerContent, "${separator}V8${parent}::hasDependentLifetime" ); | 377 AddToHeader("${separator}V8${parent}::hasDependentLifetime"); |
| 346 $separator = " || "; | 378 $separator = " || "; |
| 347 } | 379 } |
| 348 push(@headerContent, ";\n"); | 380 AddToHeader(";\n"); |
| 349 } else { | 381 } else { |
| 350 push(@headerContent, "false;\n"); | 382 AddToHeader("false;\n"); |
| 351 } | 383 } |
| 352 | 384 |
| 353 my $fromFunctionOpening = ""; | 385 my $fromFunctionOpening = ""; |
| 354 my $fromFunctionClosing = ""; | 386 my $fromFunctionClosing = ""; |
| 355 if ($interface->extendedAttributes->{"WrapAsFunction"}) { | 387 if ($interface->extendedAttributes->{"WrapAsFunction"}) { |
| 356 $fromFunctionOpening = "V8DOMWrapper::fromFunction("; | 388 $fromFunctionOpening = "V8DOMWrapper::fromFunction("; |
| 357 $fromFunctionClosing = ")"; | 389 $fromFunctionClosing = ")"; |
| 358 } | 390 } |
| 359 | 391 |
| 360 push(@headerContent, <<END); | 392 AddToHeader(<<END); |
| 361 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp e); | 393 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp e); |
| 362 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); | 394 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); |
| 363 static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, Wrappe rWorldType); | 395 static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, Wrappe rWorldType); |
| 364 static ${nativeType}* toNative(v8::Handle<v8::Object> object) | 396 static ${nativeType}* toNative(v8::Handle<v8::Object> object) |
| 365 { | 397 { |
| 366 return reinterpret_cast<${nativeType}*>(${fromFunctionOpening}object${fr omFunctionClosing}->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) ; | 398 return reinterpret_cast<${nativeType}*>(${fromFunctionOpening}object${fr omFunctionClosing}->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) ; |
| 367 } | 399 } |
| 368 static void derefObject(void*); | 400 static void derefObject(void*); |
| 369 static WrapperTypeInfo info; | 401 static WrapperTypeInfo info; |
| 370 END | 402 END |
| 371 | 403 |
| 372 if (NeedsCustomOpaqueRootForGC($interface)) { | 404 if (NeedsCustomOpaqueRootForGC($interface)) { |
| 373 push(@headerContent, " static void* opaqueRootForGC(void*, v8::Persis tent<v8::Object>, v8::Isolate*);\n"); | 405 AddToHeader(" static void* opaqueRootForGC(void*, v8::Persistent<v8:: Object>, v8::Isolate*);\n"); |
| 374 } | 406 } |
| 375 | 407 |
| 376 if ($codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") ) { | 408 if ($codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") ) { |
| 377 push(@headerContent, " static ActiveDOMObject* toActiveDOMObject(v8:: Handle<v8::Object>);\n"); | 409 AddToHeader(" static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8 ::Object>);\n"); |
| 378 } | 410 } |
| 379 | 411 |
| 380 if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { | 412 if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { |
| 381 push(@headerContent, " static EventTarget* toEventTarget(v8::Handle<v 8::Object>);\n"); | 413 AddToHeader(" static EventTarget* toEventTarget(v8::Handle<v8::Object >);\n"); |
| 382 } | 414 } |
| 383 | 415 |
| 384 if ($interfaceName eq "DOMWindow") { | 416 if ($interfaceName eq "DOMWindow") { |
| 385 push(@headerContent, <<END); | 417 AddToHeader(<<END); |
| 386 static v8::Persistent<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolat e*, WrapperWorldType); | 418 static v8::Persistent<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolat e*, WrapperWorldType); |
| 387 END | 419 END |
| 388 } | 420 } |
| 389 | 421 |
| 390 if ($interfaceName eq "HTMLDocument") { | 422 if ($interfaceName eq "HTMLDocument") { |
| 391 push(@headerContent, <<END); | 423 AddToHeader(<<END); |
| 392 static v8::Local<v8::Object> wrapInShadowObject(v8::Local<v8::Object> wrappe r, Node* impl, v8::Isolate*); | 424 static v8::Local<v8::Object> wrapInShadowObject(v8::Local<v8::Object> wrappe r, Node* impl, v8::Isolate*); |
| 393 END | 425 END |
| 394 } | 426 } |
| 395 | 427 |
| 396 my @enabledPerContextFunctions; | 428 my @enabledPerContextFunctions; |
| 397 foreach my $function (@{$interface->functions}) { | 429 foreach my $function (@{$interface->functions}) { |
| 398 my $name = $function->signature->name; | 430 my $name = $function->signature->name; |
| 399 my $attrExt = $function->signature->extendedAttributes; | 431 my $attrExt = $function->signature->extendedAttributes; |
| 400 | 432 |
| 401 if (HasCustomMethod($attrExt) && !$attrExt->{"ImplementedBy"} && $functi on->{overloadIndex} == 1) { | 433 if (HasCustomMethod($attrExt) && !$attrExt->{"ImplementedBy"} && $functi on->{overloadIndex} == 1) { |
| 402 my $conditionalString = $codeGenerator->GenerateConditionalString($f unction->signature); | 434 my $conditionalString = $codeGenerator->GenerateConditionalString($f unction->signature); |
| 403 push(@headerContent, "#if ${conditionalString}\n") if $conditionalSt ring; | 435 AddToHeader("#if ${conditionalString}\n") if $conditionalString; |
| 404 push(@headerContent, <<END); | 436 AddToHeader(<<END); |
| 405 static v8::Handle<v8::Value> ${name}MethodCustom(const v8::Arguments&); | 437 static v8::Handle<v8::Value> ${name}MethodCustom(const v8::Arguments&); |
| 406 END | 438 END |
| 407 push(@headerContent, "#endif // ${conditionalString}\n") if $conditi onalString; | 439 AddToHeader("#endif // ${conditionalString}\n") if $conditionalStrin g; |
| 408 } | 440 } |
| 409 if ($attrExt->{"EnabledPerContext"}) { | 441 if ($attrExt->{"EnabledPerContext"}) { |
| 410 push(@enabledPerContextFunctions, $function); | 442 push(@enabledPerContextFunctions, $function); |
| 411 } | 443 } |
| 412 } | 444 } |
| 413 | 445 |
| 414 if (IsConstructable($interface)) { | 446 if (IsConstructable($interface)) { |
| 415 push(@headerContent, " static v8::Handle<v8::Value> constructorCallba ck(const v8::Arguments&);\n"); | 447 AddToHeader(" static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);\n"); |
| 416 END | 448 END |
| 417 } | 449 } |
| 418 if (HasCustomConstructor($interface)) { | 450 if (HasCustomConstructor($interface)) { |
| 419 push(@headerContent, " static v8::Handle<v8::Value> constructorCustom (const v8::Arguments&);\n"); | 451 AddToHeader(" static v8::Handle<v8::Value> constructorCustom(const v8 ::Arguments&);\n"); |
| 420 } | 452 } |
| 421 | 453 |
| 422 my @enabledPerContextAttributes; | 454 my @enabledPerContextAttributes; |
| 423 foreach my $attribute (@{$interface->attributes}) { | 455 foreach my $attribute (@{$interface->attributes}) { |
| 424 my $name = $attribute->signature->name; | 456 my $name = $attribute->signature->name; |
| 425 my $attrExt = $attribute->signature->extendedAttributes; | 457 my $attrExt = $attribute->signature->extendedAttributes; |
| 426 my $conditionalString = $codeGenerator->GenerateConditionalString($attri bute->signature); | 458 my $conditionalString = $codeGenerator->GenerateConditionalString($attri bute->signature); |
| 427 if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) { | 459 if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) { |
| 428 push(@headerContent, "#if ${conditionalString}\n") if $conditionalSt ring; | 460 AddToHeader("#if ${conditionalString}\n") if $conditionalString; |
| 429 push(@headerContent, <<END); | 461 AddToHeader(<<END); |
| 430 static v8::Handle<v8::Value> ${name}AttrGetterCustom(v8::Local<v8::String> n ame, const v8::AccessorInfo&); | 462 static v8::Handle<v8::Value> ${name}AttrGetterCustom(v8::Local<v8::String> n ame, const v8::AccessorInfo&); |
| 431 END | 463 END |
| 432 push(@headerContent, "#endif // ${conditionalString}\n") if $conditi onalString; | 464 AddToHeader("#endif // ${conditionalString}\n") if $conditionalStrin g; |
| 433 } | 465 } |
| 434 if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) { | 466 if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) { |
| 435 push(@headerContent, "#if ${conditionalString}\n") if $conditionalSt ring; | 467 AddToHeader("#if ${conditionalString}\n") if $conditionalString; |
| 436 push(@headerContent, <<END); | 468 AddToHeader(<<END); |
| 437 static void ${name}AttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8 ::Value>, const v8::AccessorInfo&); | 469 static void ${name}AttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8 ::Value>, const v8::AccessorInfo&); |
| 438 END | 470 END |
| 439 push(@headerContent, "#endif // ${conditionalString}\n") if $conditi onalString; | 471 AddToHeader("#endif // ${conditionalString}\n") if $conditionalStrin g; |
| 440 } | 472 } |
| 441 if ($attrExt->{"EnabledPerContext"}) { | 473 if ($attrExt->{"EnabledPerContext"}) { |
| 442 push(@enabledPerContextAttributes, $attribute); | 474 push(@enabledPerContextAttributes, $attribute); |
| 443 } | 475 } |
| 444 } | 476 } |
| 445 | 477 |
| 446 GenerateHeaderNamedAndIndexedPropertyAccessors($interface); | 478 GenerateHeaderNamedAndIndexedPropertyAccessors($interface); |
| 447 GenerateHeaderCustomCall($interface); | 479 GenerateHeaderCustomCall($interface); |
| 448 GenerateHeaderCustomInternalFieldIndices($interface); | 480 GenerateHeaderCustomInternalFieldIndices($interface); |
| 449 | 481 |
| 450 if ($interface->name eq "DOMWindow") { | 482 if ($interface->name eq "DOMWindow") { |
| 451 push(@headerContent, <<END); | 483 AddToHeader(<<END); |
| 452 static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v 8::Value> key, v8::AccessType, v8::Local<v8::Value> data); | 484 static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v 8::Value> key, v8::AccessType, v8::Local<v8::Value> data); |
| 453 static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data); | 485 static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data); |
| 454 END | 486 END |
| 455 } | 487 } |
| 456 | 488 |
| 457 if (@enabledPerContextAttributes) { | 489 if (@enabledPerContextAttributes) { |
| 458 push(@headerContent, <<END); | 490 AddToHeader(<<END); |
| 459 static void installPerContextProperties(v8::Handle<v8::Object>, ${nativeType }*, v8::Isolate*); | 491 static void installPerContextProperties(v8::Handle<v8::Object>, ${nativeType }*, v8::Isolate*); |
| 460 END | 492 END |
| 461 } else { | 493 } else { |
| 462 push(@headerContent, <<END); | 494 AddToHeader(<<END); |
| 463 static void installPerContextProperties(v8::Handle<v8::Object>, ${nativeType }*, v8::Isolate*) { } | 495 static void installPerContextProperties(v8::Handle<v8::Object>, ${nativeType }*, v8::Isolate*) { } |
| 464 END | 496 END |
| 465 } | 497 } |
| 466 | 498 |
| 467 if (@enabledPerContextFunctions) { | 499 if (@enabledPerContextFunctions) { |
| 468 push(@headerContent, <<END); | 500 AddToHeader(<<END); |
| 469 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8: :Isolate*); | 501 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8: :Isolate*); |
| 470 END | 502 END |
| 471 } else { | 503 } else { |
| 472 push(@headerContent, <<END); | 504 AddToHeader(<<END); |
| 473 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8: :Isolate*) { } | 505 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8: :Isolate*) { } |
| 474 END | 506 END |
| 475 } | 507 } |
| 476 | 508 |
| 477 if ($interfaceName eq "HTMLElement") { | 509 if ($interfaceName eq "HTMLElement") { |
| 478 push(@headerContent, <<END); | 510 AddToHeader(<<END); |
| 479 friend v8::Handle<v8::Object> createV8HTMLWrapper(HTMLElement*, v8::Handle<v 8::Object> creationContext, v8::Isolate*); | 511 friend v8::Handle<v8::Object> createV8HTMLWrapper(HTMLElement*, v8::Handle<v 8::Object> creationContext, v8::Isolate*); |
| 480 friend v8::Handle<v8::Object> createV8HTMLDirectWrapper(HTMLElement*, v8::Ha ndle<v8::Object> creationContext, v8::Isolate*); | 512 friend v8::Handle<v8::Object> createV8HTMLDirectWrapper(HTMLElement*, v8::Ha ndle<v8::Object> creationContext, v8::Isolate*); |
| 481 END | 513 END |
| 482 } elsif ($interfaceName eq "SVGElement") { | 514 } elsif ($interfaceName eq "SVGElement") { |
| 483 push(@headerContent, <<END); | 515 AddToHeader(<<END); |
| 484 friend v8::Handle<v8::Object> createV8SVGWrapper(SVGElement*, v8::Handle<v8: :Object> creationContext, v8::Isolate*); | 516 friend v8::Handle<v8::Object> createV8SVGWrapper(SVGElement*, v8::Handle<v8: :Object> creationContext, v8::Isolate*); |
| 485 friend v8::Handle<v8::Object> createV8SVGDirectWrapper(SVGElement*, v8::Hand le<v8::Object> creationContext, v8::Isolate*); | 517 friend v8::Handle<v8::Object> createV8SVGDirectWrapper(SVGElement*, v8::Hand le<v8::Object> creationContext, v8::Isolate*); |
| 486 friend v8::Handle<v8::Object> createV8SVGFallbackWrapper(SVGElement*, v8::Ha ndle<v8::Object> creationContext, v8::Isolate*); | 518 friend v8::Handle<v8::Object> createV8SVGFallbackWrapper(SVGElement*, v8::Ha ndle<v8::Object> creationContext, v8::Isolate*); |
| 487 END | 519 END |
| 488 } elsif ($interfaceName eq "HTMLUnknownElement") { | 520 } elsif ($interfaceName eq "HTMLUnknownElement") { |
| 489 push(@headerContent, <<END); | 521 AddToHeader(<<END); |
| 490 friend v8::Handle<v8::Object> createV8HTMLFallbackWrapper(HTMLUnknownElement *, v8::Handle<v8::Object> creationContext, v8::Isolate*); | 522 friend v8::Handle<v8::Object> createV8HTMLFallbackWrapper(HTMLUnknownElement *, v8::Handle<v8::Object> creationContext, v8::Isolate*); |
| 491 END | 523 END |
| 492 } elsif ($interfaceName eq "Element") { | 524 } elsif ($interfaceName eq "Element") { |
| 493 push(@headerContent, <<END); | 525 AddToHeader(<<END); |
| 494 // This is a performance optimization hack. See V8Element::wrap. | 526 // This is a performance optimization hack. See V8Element::wrap. |
| 495 friend v8::Handle<v8::Object> wrap(Node*, v8::Handle<v8::Object> creationCon text, v8::Isolate*); | 527 friend v8::Handle<v8::Object> wrap(Node*, v8::Handle<v8::Object> creationCon text, v8::Isolate*); |
| 496 END | 528 END |
| 497 } | 529 } |
| 498 | 530 |
| 499 push(@headerContent, <<END); | 531 AddToHeader(<<END); |
| 500 private: | 532 private: |
| 501 END | 533 END |
| 502 | 534 |
| 503 my $noToV8 = $interface->extendedAttributes->{"SuppressToJSObject"}; | 535 my $noToV8 = $interface->extendedAttributes->{"SuppressToJSObject"}; |
| 504 my $noWrap = $interface->extendedAttributes->{"NoWrapperCache"} || $noToV8; | 536 my $noWrap = $interface->extendedAttributes->{"NoWrapperCache"} || $noToV8; |
| 505 if (!$noWrap) { | 537 if (!$noWrap) { |
| 506 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); | 538 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); |
| 507 push(@headerContent, <<END); | 539 AddToHeader(<<END); |
| 508 friend v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> cr eationContext, v8::Isolate*); | 540 friend v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> cr eationContext, v8::Isolate*); |
| 509 static v8::Handle<v8::Object> createWrapper(${createWrapperArgumentType}, v8 ::Handle<v8::Object> creationContext, v8::Isolate*); | 541 static v8::Handle<v8::Object> createWrapper(${createWrapperArgumentType}, v8 ::Handle<v8::Object> creationContext, v8::Isolate*); |
| 510 END | 542 END |
| 511 } | 543 } |
| 512 | 544 |
| 513 push(@headerContent, <<END); | 545 AddToHeader(<<END); |
| 514 }; | 546 }; |
| 515 | 547 |
| 516 template<> | 548 template<> |
| 517 class WrapperTypeTraits<${nativeType} > { | 549 class WrapperTypeTraits<${nativeType} > { |
| 518 public: | 550 public: |
| 519 static WrapperTypeInfo* info() { return &${v8InterfaceName}::info; } | 551 static WrapperTypeInfo* info() { return &${v8InterfaceName}::info; } |
| 520 }; | 552 }; |
| 521 | 553 |
| 522 END | 554 END |
| 523 | 555 |
| 524 my $customWrap = !!($interface->extendedAttributes->{"CustomToJSObject"}); | 556 my $customWrap = !!($interface->extendedAttributes->{"CustomToJSObject"}); |
| 525 if ($noToV8) { | 557 if ($noToV8) { |
| 526 die "Can't suppress toV8 for subclass\n" if @parents; | 558 die "Can't suppress toV8 for subclass\n" if @parents; |
| 527 } elsif ($noWrap) { | 559 } elsif ($noWrap) { |
| 528 die "Must have custom toV8\n" if !$customWrap; | 560 die "Must have custom toV8\n" if !$customWrap; |
| 529 push(@headerContent, <<END); | 561 AddToHeader(<<END); |
| 530 class ${nativeType}; | 562 class ${nativeType}; |
| 531 v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContex t, v8::Isolate*); | 563 v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContex t, v8::Isolate*); |
| 532 v8::Handle<v8::Value> toV8ForMainWorld(${nativeType}*, v8::Handle<v8::Object> cr eationContext, v8::Isolate*); | 564 v8::Handle<v8::Value> toV8ForMainWorld(${nativeType}*, v8::Handle<v8::Object> cr eationContext, v8::Isolate*); |
| 533 | 565 |
| 534 template<class HolderContainer, class Wrappable> | 566 template<class HolderContainer, class Wrappable> |
| 535 inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer & container, Wrappable*) | 567 inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer & container, Wrappable*) |
| 536 { | 568 { |
| 537 return toV8(impl, container.Holder(), container.GetIsolate()); | 569 return toV8(impl, container.Holder(), container.GetIsolate()); |
| 538 } | 570 } |
| 539 | 571 |
| 540 template<class HolderContainer, class Wrappable> | 572 template<class HolderContainer, class Wrappable> |
| 541 inline v8::Handle<v8::Value> toV8FastForMainWorld(${nativeType}* impl, const Hol derContainer& container, Wrappable*) | 573 inline v8::Handle<v8::Value> toV8FastForMainWorld(${nativeType}* impl, const Hol derContainer& container, Wrappable*) |
| 542 { | 574 { |
| 543 return toV8ForMainWorld(impl, container.Holder(), container.GetIsolate()); | 575 return toV8ForMainWorld(impl, container.Holder(), container.GetIsolate()); |
| 544 } | 576 } |
| 545 END | 577 END |
| 546 } else { | 578 } else { |
| 547 | 579 |
| 548 my $createWrapperCall = $customWrap ? "${v8InterfaceName}::wrap" : "${v8 InterfaceName}::createWrapper"; | 580 my $createWrapperCall = $customWrap ? "${v8InterfaceName}::wrap" : "${v8 InterfaceName}::createWrapper"; |
| 549 my $returningWrapper = $interface->extendedAttributes->{"WrapAsFunction" } ? "V8DOMWrapper::toFunction(wrapper)" : "wrapper"; | 581 my $returningWrapper = $interface->extendedAttributes->{"WrapAsFunction" } ? "V8DOMWrapper::toFunction(wrapper)" : "wrapper"; |
| 550 my $returningCreatedWrapperOpening = $interface->extendedAttributes->{"W rapAsFunction"} ? "V8DOMWrapper::toFunction(" : ""; | 582 my $returningCreatedWrapperOpening = $interface->extendedAttributes->{"W rapAsFunction"} ? "V8DOMWrapper::toFunction(" : ""; |
| 551 my $returningCreatedWrapperClosing = $interface->extendedAttributes->{"W rapAsFunction"} ? ", \"${interfaceName}\", isolate)" : ""; | 583 my $returningCreatedWrapperClosing = $interface->extendedAttributes->{"W rapAsFunction"} ? ", \"${interfaceName}\", isolate)" : ""; |
| 552 | 584 |
| 553 if ($customWrap) { | 585 if ($customWrap) { |
| 554 push(@headerContent, <<END); | 586 AddToHeader(<<END); |
| 555 | 587 |
| 556 v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> creation Context, v8::Isolate*); | 588 v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> creation Context, v8::Isolate*); |
| 557 END | 589 END |
| 558 } else { | 590 } else { |
| 559 push(@headerContent, <<END); | 591 AddToHeader(<<END); |
| 560 | 592 |
| 561 inline v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) | 593 inline v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) |
| 562 { | 594 { |
| 563 ASSERT(impl); | 595 ASSERT(impl); |
| 564 ASSERT(DOMDataStore::getWrapper(impl, isolate).IsEmpty()); | 596 ASSERT(DOMDataStore::getWrapper(impl, isolate).IsEmpty()); |
| 565 return ${returningCreatedWrapperOpening}$createWrapperCall(impl, creationCon text, isolate)${returningCreatedWrapperClosing}; | 597 return ${returningCreatedWrapperOpening}$createWrapperCall(impl, creationCon text, isolate)${returningCreatedWrapperClosing}; |
| 566 } | 598 } |
| 567 END | 599 END |
| 568 } | 600 } |
| 569 | 601 |
| 570 push(@headerContent, <<END); | 602 AddToHeader(<<END); |
| 571 | 603 |
| 572 inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Handle<v8::Object> cr eationContext, v8::Isolate* isolate) | 604 inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Handle<v8::Object> cr eationContext, v8::Isolate* isolate) |
| 573 { | 605 { |
| 574 if (UNLIKELY(!impl)) | 606 if (UNLIKELY(!impl)) |
| 575 return v8NullWithCheck(isolate); | 607 return v8NullWithCheck(isolate); |
| 576 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); | 608 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); |
| 577 if (!wrapper.IsEmpty()) | 609 if (!wrapper.IsEmpty()) |
| 578 return $returningWrapper; | 610 return $returningWrapper; |
| 579 return wrap(impl, creationContext, isolate); | 611 return wrap(impl, creationContext, isolate); |
| 580 } | 612 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 | 647 |
| 616 template<class HolderContainer, class Wrappable> | 648 template<class HolderContainer, class Wrappable> |
| 617 inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< ${nativeType} > im pl, const HolderContainer& container, Wrappable* wrappable) | 649 inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< ${nativeType} > im pl, const HolderContainer& container, Wrappable* wrappable) |
| 618 { | 650 { |
| 619 return toV8FastForMainWorld(impl.get(), container, wrappable); | 651 return toV8FastForMainWorld(impl.get(), container, wrappable); |
| 620 } | 652 } |
| 621 | 653 |
| 622 END | 654 END |
| 623 } | 655 } |
| 624 | 656 |
| 625 push(@headerContent, <<END); | 657 AddToHeader(<<END); |
| 626 | 658 |
| 627 template<class HolderContainer, class Wrappable> | 659 template<class HolderContainer, class Wrappable> |
| 628 inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< ${nativeType} > impl, const Ho lderContainer& container, Wrappable* wrappable) | 660 inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< ${nativeType} > impl, const Ho lderContainer& container, Wrappable* wrappable) |
| 629 { | 661 { |
| 630 return toV8Fast(impl.get(), container, wrappable); | 662 return toV8Fast(impl.get(), container, wrappable); |
| 631 } | 663 } |
| 632 | 664 |
| 633 inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl, v8::Handle<v 8::Object> creationContext, v8::Isolate* isolate) | 665 inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl, v8::Handle<v 8::Object> creationContext, v8::Isolate* isolate) |
| 634 { | 666 { |
| 635 return toV8(impl.get(), creationContext, isolate); | 667 return toV8(impl.get(), creationContext, isolate); |
| 636 } | 668 } |
| 637 END | 669 END |
| 638 | 670 |
| 639 if ($codeGenerator->IsConstructorTemplate($interface, "Event")) { | 671 if ($codeGenerator->IsConstructorTemplate($interface, "Event")) { |
| 640 push(@headerContent, "\nbool fill${interfaceName}Init(${interfaceName}In it&, const Dictionary&);\n"); | 672 AddToHeader("\nbool fill${interfaceName}Init(${interfaceName}Init&, cons t Dictionary&);\n"); |
| 641 } | 673 } |
| 642 | 674 |
| 643 push(@headerContent, "\n}\n\n"); | 675 AddToHeader("\n}\n\n"); |
| 644 push(@headerContent, "#endif // $v8InterfaceName" . "_h\n"); | 676 AddToHeader("#endif // $v8InterfaceName" . "_h\n"); |
| 645 | 677 |
| 646 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); | 678 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); |
| 647 push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalSt ring; | 679 AddToHeader("#endif // ${conditionalString}\n\n") if $conditionalString; |
| 648 } | 680 } |
| 649 | 681 |
| 650 sub GetInternalFields | 682 sub GetInternalFields |
| 651 { | 683 { |
| 652 my $interface = shift; | 684 my $interface = shift; |
| 653 | 685 |
| 654 my @customInternalFields = (); | 686 my @customInternalFields = (); |
| 655 # Event listeners on DOM nodes are explicitly supported in the GC controller . | 687 # Event listeners on DOM nodes are explicitly supported in the GC controller . |
| 656 if (!$codeGenerator->InheritsInterface($interface, "Node") && | 688 if (!$codeGenerator->InheritsInterface($interface, "Node") && |
| 657 $codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { | 689 $codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 670 return "" if ($codeGenerator->SkipIncludeHeader($v8InterfaceName)); | 702 return "" if ($codeGenerator->SkipIncludeHeader($v8InterfaceName)); |
| 671 return "${v8InterfaceName}.h"; | 703 return "${v8InterfaceName}.h"; |
| 672 } | 704 } |
| 673 | 705 |
| 674 sub GenerateHeaderCustomInternalFieldIndices | 706 sub GenerateHeaderCustomInternalFieldIndices |
| 675 { | 707 { |
| 676 my $interface = shift; | 708 my $interface = shift; |
| 677 my @customInternalFields = GetInternalFields($interface); | 709 my @customInternalFields = GetInternalFields($interface); |
| 678 my $customFieldCounter = 0; | 710 my $customFieldCounter = 0; |
| 679 foreach my $customInternalField (@customInternalFields) { | 711 foreach my $customInternalField (@customInternalFields) { |
| 680 push(@headerContent, <<END); | 712 AddToHeader(<<END); |
| 681 static const int ${customInternalField} = v8DefaultWrapperInternalFieldCount + ${customFieldCounter}; | 713 static const int ${customInternalField} = v8DefaultWrapperInternalFieldCount + ${customFieldCounter}; |
| 682 END | 714 END |
| 683 $customFieldCounter++; | 715 $customFieldCounter++; |
| 684 } | 716 } |
| 685 push(@headerContent, <<END); | 717 AddToHeader(<<END); |
| 686 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + $ {customFieldCounter}; | 718 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + $ {customFieldCounter}; |
| 687 END | 719 END |
| 688 } | 720 } |
| 689 | 721 |
| 690 my %indexerSpecialCases = ( | 722 my %indexerSpecialCases = ( |
| 691 "Storage" => 1, | 723 "Storage" => 1, |
| 692 "HTMLAppletElement" => 1, | 724 "HTMLAppletElement" => 1, |
| 693 "HTMLEmbedElement" => 1, | 725 "HTMLEmbedElement" => 1, |
| 694 "HTMLObjectElement" => 1 | 726 "HTMLObjectElement" => 1 |
| 695 ); | 727 ); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 716 if ($interfaceName eq "HTMLAppletElement" || $interfaceName eq "HTMLEmbedEle ment" || $interfaceName eq "HTMLObjectElement") { | 748 if ($interfaceName eq "HTMLAppletElement" || $interfaceName eq "HTMLEmbedEle ment" || $interfaceName eq "HTMLObjectElement") { |
| 717 $hasCustomNamedGetter = 1; | 749 $hasCustomNamedGetter = 1; |
| 718 } | 750 } |
| 719 if ($interfaceName eq "HTMLDocument") { | 751 if ($interfaceName eq "HTMLDocument") { |
| 720 $hasCustomNamedGetter = 0; | 752 $hasCustomNamedGetter = 0; |
| 721 $hasCustomIndexedGetter = 0; | 753 $hasCustomIndexedGetter = 0; |
| 722 } | 754 } |
| 723 my $isIndexerSpecialCase = exists $indexerSpecialCases{$interfaceName}; | 755 my $isIndexerSpecialCase = exists $indexerSpecialCases{$interfaceName}; |
| 724 | 756 |
| 725 if ($hasCustomIndexedGetter || $isIndexerSpecialCase) { | 757 if ($hasCustomIndexedGetter || $isIndexerSpecialCase) { |
| 726 push(@headerContent, <<END); | 758 AddToHeader(<<END); |
| 727 static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::Acces sorInfo&); | 759 static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::Acces sorInfo&); |
| 728 END | 760 END |
| 729 } | 761 } |
| 730 | 762 |
| 731 if ($isIndexerSpecialCase || $hasCustomIndexedSetter) { | 763 if ($isIndexerSpecialCase || $hasCustomIndexedSetter) { |
| 732 push(@headerContent, <<END); | 764 AddToHeader(<<END); |
| 733 static v8::Handle<v8::Value> indexedPropertySetter(uint32_t, v8::Local<v8::V alue>, const v8::AccessorInfo&); | 765 static v8::Handle<v8::Value> indexedPropertySetter(uint32_t, v8::Local<v8::V alue>, const v8::AccessorInfo&); |
| 734 END | 766 END |
| 735 } | 767 } |
| 736 if ($hasCustomDeleters) { | 768 if ($hasCustomDeleters) { |
| 737 push(@headerContent, <<END); | 769 AddToHeader(<<END); |
| 738 static v8::Handle<v8::Boolean> indexedPropertyDeleter(uint32_t, const v8::Ac cessorInfo&); | 770 static v8::Handle<v8::Boolean> indexedPropertyDeleter(uint32_t, const v8::Ac cessorInfo&); |
| 739 END | 771 END |
| 740 } | 772 } |
| 741 if ($hasCustomNamedGetter) { | 773 if ($hasCustomNamedGetter) { |
| 742 push(@headerContent, <<END); | 774 AddToHeader(<<END); |
| 743 static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String>, cons t v8::AccessorInfo&); | 775 static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String>, cons t v8::AccessorInfo&); |
| 744 END | 776 END |
| 745 } | 777 } |
| 746 if ($hasCustomNamedSetter) { | 778 if ($hasCustomNamedSetter) { |
| 747 push(@headerContent, <<END); | 779 AddToHeader(<<END); |
| 748 static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String>, v8:: Local<v8::Value>, const v8::AccessorInfo&); | 780 static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String>, v8:: Local<v8::Value>, const v8::AccessorInfo&); |
| 749 END | 781 END |
| 750 } | 782 } |
| 751 if ($hasCustomDeleters) { | 783 if ($hasCustomDeleters) { |
| 752 push(@headerContent, <<END); | 784 AddToHeader(<<END); |
| 753 static v8::Handle<v8::Boolean> namedPropertyDeleter(v8::Local<v8::String>, c onst v8::AccessorInfo&); | 785 static v8::Handle<v8::Boolean> namedPropertyDeleter(v8::Local<v8::String>, c onst v8::AccessorInfo&); |
| 754 END | 786 END |
| 755 } | 787 } |
| 756 if ($hasCustomEnumerator) { | 788 if ($hasCustomEnumerator) { |
| 757 push(@headerContent, <<END); | 789 AddToHeader(<<END); |
| 758 static v8::Handle<v8::Array> namedPropertyEnumerator(const v8::AccessorInfo& ); | 790 static v8::Handle<v8::Array> namedPropertyEnumerator(const v8::AccessorInfo& ); |
| 759 static v8::Handle<v8::Integer> namedPropertyQuery(v8::Local<v8::String>, con st v8::AccessorInfo&); | 791 static v8::Handle<v8::Integer> namedPropertyQuery(v8::Local<v8::String>, con st v8::AccessorInfo&); |
| 760 END | 792 END |
| 761 } | 793 } |
| 762 } | 794 } |
| 763 | 795 |
| 764 sub GenerateHeaderCustomCall | 796 sub GenerateHeaderCustomCall |
| 765 { | 797 { |
| 766 my $interface = shift; | 798 my $interface = shift; |
| 767 | 799 |
| 768 if ($interface->extendedAttributes->{"CustomCall"}) { | 800 if ($interface->extendedAttributes->{"CustomCall"}) { |
| 769 push(@headerContent, " static v8::Handle<v8::Value> callAsFunctionCal lback(const v8::Arguments&);\n"); | 801 AddToHeader(" static v8::Handle<v8::Value> callAsFunctionCallback(con st v8::Arguments&);\n"); |
| 770 } | 802 } |
| 771 if ($interface->name eq "Location") { | 803 if ($interface->name eq "Location") { |
| 772 push(@headerContent, " static v8::Handle<v8::Value> assignAttrGetterC ustom(v8::Local<v8::String> name, const v8::AccessorInfo&);\n"); | 804 AddToHeader(" static v8::Handle<v8::Value> assignAttrGetterCustom(v8: :Local<v8::String> name, const v8::AccessorInfo&);\n"); |
| 773 push(@headerContent, " static v8::Handle<v8::Value> reloadAttrGetterC ustom(v8::Local<v8::String> name, const v8::AccessorInfo&);\n"); | 805 AddToHeader(" static v8::Handle<v8::Value> reloadAttrGetterCustom(v8: :Local<v8::String> name, const v8::AccessorInfo&);\n"); |
| 774 push(@headerContent, " static v8::Handle<v8::Value> replaceAttrGetter Custom(v8::Local<v8::String> name, const v8::AccessorInfo&);\n"); | 806 AddToHeader(" static v8::Handle<v8::Value> replaceAttrGetterCustom(v8 ::Local<v8::String> name, const v8::AccessorInfo&);\n"); |
| 775 } | 807 } |
| 776 } | 808 } |
| 777 | 809 |
| 778 sub IsConstructable | 810 sub IsConstructable |
| 779 { | 811 { |
| 780 my $interface = shift; | 812 my $interface = shift; |
| 781 | 813 |
| 782 return $interface->extendedAttributes->{"CustomConstructor"} || $interface-> extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"Constru ctorTemplate"}; | 814 return $interface->extendedAttributes->{"CustomConstructor"} || $interface-> extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"Constru ctorTemplate"}; |
| 783 } | 815 } |
| 784 | 816 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 823 my $funcName = $function->signature->name; | 855 my $funcName = $function->signature->name; |
| 824 | 856 |
| 825 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8InterfaceName . "::info, currentWorldType))"; | 857 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8InterfaceName . "::info, currentWorldType))"; |
| 826 if ($function->signature->extendedAttributes->{"DoNotCheckSignature"}) { | 858 if ($function->signature->extendedAttributes->{"DoNotCheckSignature"}) { |
| 827 $signature = "v8::Local<v8::Signature>()"; | 859 $signature = "v8::Local<v8::Signature>()"; |
| 828 } | 860 } |
| 829 | 861 |
| 830 my $newTemplateParams = "${interfaceName}V8Internal::${funcName}MethodCallba ck, v8Undefined(), $signature"; | 862 my $newTemplateParams = "${interfaceName}V8Internal::${funcName}MethodCallba ck, v8Undefined(), $signature"; |
| 831 | 863 |
| 832 AddToImplIncludes("Frame.h"); | 864 AddToImplIncludes("Frame.h"); |
| 833 push(@implContentInternals, <<END); | 865 AddToImplFunctionInternal(<<END); |
| 834 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, c onst v8::AccessorInfo& info) | 866 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, c onst v8::AccessorInfo& info) |
| 835 { | 867 { |
| 836 // This is only for getting a unique pointer which we can pass to privateTem plate. | 868 // This is only for getting a unique pointer which we can pass to privateTem plate. |
| 837 static const char* privateTemplateUniqueKey = "${funcName}PrivateTemplate"; | 869 static const char* privateTemplateUniqueKey = "${funcName}PrivateTemplate"; |
| 838 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); | 870 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); |
| 839 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); | 871 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); |
| 840 v8::Persistent<v8::FunctionTemplate> privateTemplate = data->privateTemplate (currentWorldType, &privateTemplateUniqueKey, $newTemplateParams); | 872 v8::Persistent<v8::FunctionTemplate> privateTemplate = data->privateTemplate (currentWorldType, &privateTemplateUniqueKey, $newTemplateParams); |
| 841 | 873 |
| 842 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), currentWorldType)); | 874 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), currentWorldType)); |
| 843 if (holder.IsEmpty()) { | 875 if (holder.IsEmpty()) { |
| 844 // can only reach here by 'object.__proto__.func', and it should passed | 876 // can only reach here by 'object.__proto__.func', and it should passed |
| 845 // domain security check already | 877 // domain security check already |
| 846 return privateTemplate->GetFunction(); | 878 return privateTemplate->GetFunction(); |
| 847 } | 879 } |
| 848 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); | 880 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); |
| 849 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame(), DoNotReportSecurityError)) { | 881 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame(), DoNotReportSecurityError)) { |
| 850 static const char* sharedTemplateUniqueKey = "${funcName}SharedTemplate" ; | 882 static const char* sharedTemplateUniqueKey = "${funcName}SharedTemplate" ; |
| 851 v8::Persistent<v8::FunctionTemplate> sharedTemplate = data->privateTempl ate(currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams); | 883 v8::Persistent<v8::FunctionTemplate> sharedTemplate = data->privateTempl ate(currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams); |
| 852 return sharedTemplate->GetFunction(); | 884 return sharedTemplate->GetFunction(); |
| 853 } | 885 } |
| 854 | 886 |
| 855 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(name); | 887 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(name); |
| 856 if (!hiddenValue.IsEmpty()) | 888 if (!hiddenValue.IsEmpty()) |
| 857 return hiddenValue; | 889 return hiddenValue; |
| 858 | 890 |
| 859 return privateTemplate->GetFunction(); | 891 return privateTemplate->GetFunction(); |
| 860 } | 892 } |
| 861 | 893 |
| 894 END | |
| 895 AddToImplFunctionInternal(<<END); | |
| 862 static v8::Handle<v8::Value> ${funcName}AttrGetterCallback(v8::Local<v8::String> name, const v8::AccessorInfo& info) | 896 static v8::Handle<v8::Value> ${funcName}AttrGetterCallback(v8::Local<v8::String> name, const v8::AccessorInfo& info) |
| 863 { | 897 { |
| 864 return ${interfaceName}V8Internal::${funcName}AttrGetter(name, info); | 898 return ${interfaceName}V8Internal::${funcName}AttrGetter(name, info); |
| 865 } | 899 } |
| 866 | 900 |
|
haraken
2013/04/16 09:40:36
Nit: You might want to remove the trailing empty l
kojih
2013/04/16 11:00:07
OK.
| |
| 867 END | 901 END |
| 868 } | 902 } |
| 869 | 903 |
| 870 sub GenerateDomainSafeFunctionSetter | 904 sub GenerateDomainSafeFunctionSetter |
| 871 { | 905 { |
| 872 my $interfaceName = shift; | 906 my $interfaceName = shift; |
| 873 my $v8InterfaceName = "V8" . $interfaceName; | 907 my $v8InterfaceName = "V8" . $interfaceName; |
| 874 | 908 |
| 875 push(@implContentInternals, <<END); | 909 AddToImplFunctionInternal(<<END); |
| 876 static void ${interfaceName}DomainSafeFunctionSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) | 910 static void ${interfaceName}DomainSafeFunctionSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) |
| 877 { | 911 { |
| 878 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); | 912 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); |
| 879 if (holder.IsEmpty()) | 913 if (holder.IsEmpty()) |
| 880 return; | 914 return; |
| 881 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); | 915 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); |
| 882 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) | 916 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) |
| 883 return; | 917 return; |
| 884 | 918 |
| 885 info.This()->SetHiddenValue(name, value); | 919 info.This()->SetHiddenValue(name, value); |
| 886 } | 920 } |
| 887 | 921 |
| 888 END | 922 END |
| 889 } | 923 } |
| 890 | 924 |
| 891 sub GenerateConstructorGetter | 925 sub GenerateConstructorGetter |
| 892 { | 926 { |
| 893 my $interface = shift; | 927 my $interface = shift; |
| 894 my $interfaceName = $interface->name; | 928 my $interfaceName = $interface->name; |
| 895 | 929 |
| 896 push(@implContentInternals, <<END); | 930 AddToImplFunctionInternal(<<END); |
| 897 static v8::Handle<v8::Value> ${interfaceName}ConstructorGetter(v8::Local<v8::Str ing> name, const v8::AccessorInfo& info) | 931 static v8::Handle<v8::Value> ${interfaceName}ConstructorGetter(v8::Local<v8::Str ing> name, const v8::AccessorInfo& info) |
| 898 { | 932 { |
| 899 v8::Handle<v8::Value> data = info.Data(); | 933 v8::Handle<v8::Value> data = info.Data(); |
| 900 ASSERT(data->IsExternal()); | 934 ASSERT(data->IsExternal()); |
| 901 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext()); | 935 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext()); |
| 902 if (!perContextData) | 936 if (!perContextData) |
| 903 return v8Undefined(); | 937 return v8Undefined(); |
| 904 return perContextData->constructorForType(WrapperTypeInfo::unwrap(data)); | 938 return perContextData->constructorForType(WrapperTypeInfo::unwrap(data)); |
| 905 } | 939 } |
| 906 END | 940 END |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 923 my $attribute = shift; | 957 my $attribute = shift; |
| 924 my $interface = shift; | 958 my $interface = shift; |
| 925 my $forMainWorldSuffix = shift; | 959 my $forMainWorldSuffix = shift; |
| 926 | 960 |
| 927 my $interfaceName = $interface->name; | 961 my $interfaceName = $interface->name; |
| 928 my $v8InterfaceName = "V8$interfaceName"; | 962 my $v8InterfaceName = "V8$interfaceName"; |
| 929 my $attrExt = $attribute->signature->extendedAttributes; | 963 my $attrExt = $attribute->signature->extendedAttributes; |
| 930 my $attrName = $attribute->signature->name; | 964 my $attrName = $attribute->signature->name; |
| 931 | 965 |
| 932 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute ->signature); | 966 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute ->signature); |
| 933 push(@implContentInternals, "#if ${conditionalString}\n\n") if $conditionalS tring; | 967 my $func = ""; |
| 968 $func .= "#if ${conditionalString}\n\n" if $conditionalString; | |
| 934 | 969 |
| 935 push(@implContentInternals, "static v8::Handle<v8::Value> ${attrName}AttrGet terCallback${forMainWorldSuffix}(v8::Local<v8::String> name, const v8::AccessorI nfo& info)\n"); | 970 $func .= "static v8::Handle<v8::Value> ${attrName}AttrGetterCallback${forMai nWorldSuffix}(v8::Local<v8::String> name, const v8::AccessorInfo& info)\n"; |
| 936 push(@implContentInternals, "{\n"); | 971 $func .= "{\n"; |
| 937 push(@implContentInternals, GenerateFeatureObservation($attrExt->{"MeasureAs "})); | 972 $func .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
| 938 if (HasCustomGetter($attrExt)) { | 973 if (HasCustomGetter($attrExt)) { |
| 939 push(@implContentInternals, " return ${v8InterfaceName}::${attrName}A ttrGetterCustom(name, info);\n"); | 974 $func .= " return ${v8InterfaceName}::${attrName}AttrGetterCustom(nam e, info);\n"; |
| 940 } else { | 975 } else { |
| 941 push(@implContentInternals, " return ${interfaceName}V8Internal::${at trName}AttrGetter${forMainWorldSuffix}(name, info);\n"); | 976 $func .= " return ${interfaceName}V8Internal::${attrName}AttrGetter${ forMainWorldSuffix}(name, info);\n"; |
| 942 } | 977 } |
| 943 push(@implContentInternals, "}\n\n"); | 978 $func .= "}\n\n"; |
| 944 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $condit ionalString; | 979 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 980 | |
| 981 AddToImplFunctionInternal($func); | |
| 945 } | 982 } |
| 946 | 983 |
| 947 sub GenerateNormalAttrGetter | 984 sub GenerateNormalAttrGetter |
| 948 { | 985 { |
| 949 my $attribute = shift; | 986 my $attribute = shift; |
| 950 my $interface = shift; | 987 my $interface = shift; |
| 951 my $forMainWorldSuffix = shift; | 988 my $forMainWorldSuffix = shift; |
| 952 | 989 |
| 953 my $interfaceName = $interface->name; | 990 my $interfaceName = $interface->name; |
| 954 my $v8InterfaceName = "V8$interfaceName"; | 991 my $v8InterfaceName = "V8$interfaceName"; |
| 955 my $attrExt = $attribute->signature->extendedAttributes; | 992 my $attrExt = $attribute->signature->extendedAttributes; |
| 956 my $attrName = $attribute->signature->name; | 993 my $attrName = $attribute->signature->name; |
| 957 my $attrType = $attribute->signature->type; | 994 my $attrType = $attribute->signature->type; |
| 958 | 995 |
| 959 if (HasCustomGetter($attrExt)) { | 996 if (HasCustomGetter($attrExt)) { |
| 960 return; | 997 return; |
| 961 } | 998 } |
| 962 | 999 |
| 963 $codeGenerator->AssertNotSequenceType($attrType); | 1000 $codeGenerator->AssertNotSequenceType($attrType); |
| 964 my $getterStringUsesImp = $interfaceName ne "SVGNumber"; | 1001 my $getterStringUsesImp = $interfaceName ne "SVGNumber"; |
| 965 my $nativeType = GetNativeTypeFromSignature($attribute->signature, -1); | 1002 my $nativeType = GetNativeTypeFromSignature($attribute->signature, -1); |
| 966 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) ; | 1003 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) ; |
| 967 | 1004 |
| 968 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute ->signature); | 1005 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute ->signature); |
| 969 push(@implContentInternals, "#if ${conditionalString}\n\n") if $conditionalS tring; | 1006 my $func = ""; |
| 970 push(@implContentInternals, <<END); | 1007 $func .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 1008 $func .= <<END; | |
| 971 static v8::Handle<v8::Value> ${attrName}AttrGetter${forMainWorldSuffix}(v8::Loca l<v8::String> name, const v8::AccessorInfo& info) | 1009 static v8::Handle<v8::Value> ${attrName}AttrGetter${forMainWorldSuffix}(v8::Loca l<v8::String> name, const v8::AccessorInfo& info) |
| 972 { | 1010 { |
| 973 END | 1011 END |
| 974 if ($svgNativeType) { | 1012 if ($svgNativeType) { |
| 975 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearO ff($interfaceName); | 1013 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearO ff($interfaceName); |
| 976 if ($svgWrappedNativeType =~ /List/) { | 1014 if ($svgWrappedNativeType =~ /List/) { |
| 977 push(@implContentInternals, <<END); | 1015 $func .= <<END; |
| 978 $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1016 $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); |
| 979 END | 1017 END |
| 980 } else { | 1018 } else { |
| 981 push(@implContentInternals, <<END); | 1019 $func .= <<END; |
| 982 $svgNativeType* wrapper = ${v8InterfaceName}::toNative(info.Holder()); | 1020 $svgNativeType* wrapper = ${v8InterfaceName}::toNative(info.Holder()); |
| 983 $svgWrappedNativeType& impInstance = wrapper->propertyReference(); | 1021 $svgWrappedNativeType& impInstance = wrapper->propertyReference(); |
| 984 END | 1022 END |
| 985 if ($getterStringUsesImp) { | 1023 if ($getterStringUsesImp) { |
| 986 push(@implContentInternals, <<END); | 1024 $func .= <<END; |
| 987 $svgWrappedNativeType* imp = &impInstance; | 1025 $svgWrappedNativeType* imp = &impInstance; |
| 988 END | 1026 END |
| 989 } | 1027 } |
| 990 } | 1028 } |
| 991 } elsif ($attrExt->{"OnProto"} || $attrExt->{"Unforgeable"}) { | 1029 } elsif ($attrExt->{"OnProto"} || $attrExt->{"Unforgeable"}) { |
| 992 if ($interfaceName eq "DOMWindow") { | 1030 if ($interfaceName eq "DOMWindow") { |
| 993 push(@implContentInternals, <<END); | 1031 $func .= <<END; |
| 994 v8::Handle<v8::Object> holder = info.Holder(); | 1032 v8::Handle<v8::Object> holder = info.Holder(); |
| 995 END | 1033 END |
| 996 } else { | 1034 } else { |
| 997 # perform lookup first | 1035 # perform lookup first |
| 998 push(@implContentInternals, <<END); | 1036 $func .= <<END; |
| 999 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); | 1037 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); |
| 1000 if (holder.IsEmpty()) | 1038 if (holder.IsEmpty()) |
| 1001 return v8Undefined(); | 1039 return v8Undefined(); |
| 1002 END | 1040 END |
| 1003 } | 1041 } |
| 1004 push(@implContentInternals, <<END); | 1042 $func .= <<END; |
| 1005 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); | 1043 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); |
| 1006 END | 1044 END |
| 1007 } else { | 1045 } else { |
| 1008 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; | 1046 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; |
| 1009 my $url = $attribute->signature->extendedAttributes->{"URL"}; | 1047 my $url = $attribute->signature->extendedAttributes->{"URL"}; |
| 1010 if ($getterStringUsesImp && $reflect && !$url && $codeGenerator->Inherit sInterface($interface, "Node") && $codeGenerator->IsStringType($attrType)) { | 1048 if ($getterStringUsesImp && $reflect && !$url && $codeGenerator->Inherit sInterface($interface, "Node") && $codeGenerator->IsStringType($attrType)) { |
| 1011 # Generate super-compact call for regular attribute getter: | 1049 # Generate super-compact call for regular attribute getter: |
| 1012 my ($functionName, @arguments) = $codeGenerator->GetterExpression(\% implIncludes, $interfaceName, $attribute); | 1050 my ($functionName, @arguments) = $codeGenerator->GetterExpression(\% implIncludes, $interfaceName, $attribute); |
| 1013 push(@implContentInternals, " Element* imp = V8Element::toNative( info.Holder());\n"); | 1051 $func .= " Element* imp = V8Element::toNative(info.Holder());\n"; |
| 1014 push(@implContentInternals, " return v8String(imp->${functionName }(" . join(", ", @arguments) . "), info.GetIsolate(), ReturnUnsafeHandle);\n"); | 1052 $func .= " return v8String(imp->${functionName}(" . join(", ", @a rguments) . "), info.GetIsolate(), ReturnUnsafeHandle);\n"; |
| 1015 push(@implContentInternals, "}\n\n"); | 1053 $func .= "}\n\n"; |
| 1016 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $conditionalString; | 1054 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1055 AddToImplFunctionInternal($func); | |
| 1017 return; | 1056 return; |
| 1018 # Skip the rest of the function! | 1057 # Skip the rest of the function! |
| 1019 } | 1058 } |
| 1020 if ($attribute->signature->type eq "SerializedScriptValue" && $attrExt-> {"CachedAttribute"}) { | 1059 if ($attribute->signature->type eq "SerializedScriptValue" && $attrExt-> {"CachedAttribute"}) { |
| 1021 push(@implContentInternals, <<END); | 1060 $func .= <<END; |
| 1022 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); | 1061 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); |
| 1023 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); | 1062 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); |
| 1024 if (!value.IsEmpty()) | 1063 if (!value.IsEmpty()) |
| 1025 return value; | 1064 return value; |
| 1026 END | 1065 END |
| 1027 } | 1066 } |
| 1028 if (!$attribute->isStatic) { | 1067 if (!$attribute->isStatic) { |
| 1029 push(@implContentInternals, <<END); | 1068 $func .= <<END; |
| 1030 ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1069 ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); |
| 1031 END | 1070 END |
| 1032 } | 1071 } |
| 1033 } | 1072 } |
| 1034 | 1073 |
| 1035 # Generate security checks if necessary | 1074 # Generate security checks if necessary |
| 1036 if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { | 1075 if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { |
| 1037 push(@implContentInternals, " if (!BindingSecurity::shouldAllowAccess ToNode(BindingState::instance(), imp->" . $attribute->signature->name . "()))\n return v8::Handle<v8::Value>(v8Null(info.GetIsolate()));\n\n"); | 1076 $func .= " if (!BindingSecurity::shouldAllowAccessToNode(BindingState ::instance(), imp->" . $attribute->signature->name . "()))\n return v8::H andle<v8::Value>(v8Null(info.GetIsolate()));\n\n"; |
| 1038 } | 1077 } |
| 1039 | 1078 |
| 1040 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Getter RaisesException"}; | 1079 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Getter RaisesException"}; |
| 1041 my $isNullable = $attribute->signature->isNullable; | 1080 my $isNullable = $attribute->signature->isNullable; |
| 1042 if ($useExceptions) { | 1081 if ($useExceptions) { |
| 1043 AddToImplIncludes("ExceptionCode.h"); | 1082 AddToImplIncludes("ExceptionCode.h"); |
| 1044 push(@implContentInternals, " ExceptionCode ec = 0;\n"); | 1083 $func .= " ExceptionCode ec = 0;\n"; |
| 1045 } | 1084 } |
| 1046 | 1085 |
| 1047 if ($isNullable) { | 1086 if ($isNullable) { |
| 1048 push(@implContentInternals, " bool isNull = false;\n"); | 1087 $func .= " bool isNull = false;\n"; |
| 1049 } | 1088 } |
| 1050 | 1089 |
| 1051 my $returnType = $attribute->signature->type; | 1090 my $returnType = $attribute->signature->type; |
| 1052 my $getterString; | 1091 my $getterString; |
| 1053 | 1092 |
| 1054 if ($getterStringUsesImp) { | 1093 if ($getterStringUsesImp) { |
| 1055 my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%impl Includes, $interfaceName, $attribute); | 1094 my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%impl Includes, $interfaceName, $attribute); |
| 1056 push(@arguments, "isNull") if $isNullable; | 1095 push(@arguments, "isNull") if $isNullable; |
| 1057 push(@arguments, "ec") if $useExceptions; | 1096 push(@arguments, "ec") if $useExceptions; |
| 1058 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { | 1097 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { |
| 1059 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp lementedBy"}; | 1098 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp lementedBy"}; |
| 1060 AddToImplIncludes("${implementedBy}.h"); | 1099 AddToImplIncludes("${implementedBy}.h"); |
| 1061 unshift(@arguments, "imp") if !$attribute->isStatic; | 1100 unshift(@arguments, "imp") if !$attribute->isStatic; |
| 1062 $functionName = "${implementedBy}::${functionName}"; | 1101 $functionName = "${implementedBy}::${functionName}"; |
| 1063 } elsif ($attribute->isStatic) { | 1102 } elsif ($attribute->isStatic) { |
| 1064 $functionName = "${interfaceName}::${functionName}"; | 1103 $functionName = "${interfaceName}::${functionName}"; |
| 1065 } else { | 1104 } else { |
| 1066 $functionName = "imp->${functionName}"; | 1105 $functionName = "imp->${functionName}"; |
| 1067 } | 1106 } |
| 1068 unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttr ibutes->{"CallWith"}, \@implContentInternals, " ", 0)); | 1107 my ($arg, $code) = GenerateCallWith($attribute->signature->extendedAttri butes->{"CallWith"}, " ", 0); |
| 1108 $func .= $code; | |
| 1109 unshift(@arguments, @$arg); | |
| 1069 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; | 1110 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; |
| 1070 } else { | 1111 } else { |
| 1071 $getterString = "impInstance"; | 1112 $getterString = "impInstance"; |
| 1072 } | 1113 } |
| 1073 | 1114 |
| 1074 my $result; | 1115 my $result; |
| 1075 if ($attribute->signature->type eq "EventListener" && $interface->name eq "D OMWindow") { | 1116 if ($attribute->signature->type eq "EventListener" && $interface->name eq "D OMWindow") { |
| 1076 push(@implContentInternals, " if (!imp->document())\n"); | 1117 $func .= " if (!imp->document())\n"; |
| 1077 push(@implContentInternals, " return v8Undefined();\n"); | 1118 $func .= " return v8Undefined();\n"; |
| 1078 } | 1119 } |
| 1079 | 1120 |
| 1080 if ($useExceptions || $isNullable) { | 1121 if ($useExceptions || $isNullable) { |
| 1081 if ($nativeType =~ /^V8StringResource/) { | 1122 if ($nativeType =~ /^V8StringResource/) { |
| 1082 push(@implContentInternals, " " . ConvertToV8StringResource($attr ibute->signature, $nativeType, "v", $getterString) . ";\n"); | 1123 $func .= " " . ConvertToV8StringResource($attribute->signature, $ nativeType, "v", $getterString) . ";\n"; |
| 1083 } else { | 1124 } else { |
| 1084 push(@implContentInternals, " $nativeType v = $getterString;\n"); | 1125 $func .= " $nativeType v = $getterString;\n"; |
| 1085 } | 1126 } |
| 1086 | 1127 |
| 1087 if ($isNullable) { | 1128 if ($isNullable) { |
| 1088 push(@implContentInternals, " if (isNull)\n"); | 1129 $func .= " if (isNull)\n"; |
| 1089 push(@implContentInternals, " return v8Null(info.GetIsolate() );\n"); | 1130 $func .= " return v8Null(info.GetIsolate());\n"; |
| 1090 } | 1131 } |
| 1091 | 1132 |
| 1092 if ($useExceptions) { | 1133 if ($useExceptions) { |
| 1093 push(@implContentInternals, " if (UNLIKELY(ec))\n"); | 1134 $func .= " if (UNLIKELY(ec))\n"; |
| 1094 push(@implContentInternals, " return setDOMException(ec, info .GetIsolate());\n"); | 1135 $func .= " return setDOMException(ec, info.GetIsolate());\n"; |
| 1095 | 1136 |
| 1096 if ($codeGenerator->ExtendedAttributeContains($attribute->signature- >extendedAttributes->{"CallWith"}, "ScriptState")) { | 1137 if ($codeGenerator->ExtendedAttributeContains($attribute->signature- >extendedAttributes->{"CallWith"}, "ScriptState")) { |
| 1097 push(@implContentInternals, " if (state.hadException())\n"); | 1138 $func .= " if (state.hadException())\n"; |
| 1098 push(@implContentInternals, " return throwError(state.exc eption(), info.GetIsolate());\n"); | 1139 $func .= " return throwError(state.exception(), info.GetI solate());\n"; |
| 1099 } | 1140 } |
| 1100 } | 1141 } |
| 1101 | 1142 |
| 1102 $result = "v"; | 1143 $result = "v"; |
| 1103 $result .= ".release()" if ($codeGenerator->IsRefPtrType($returnType)); | 1144 $result .= ".release()" if ($codeGenerator->IsRefPtrType($returnType)); |
| 1104 } else { | 1145 } else { |
| 1105 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary | 1146 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary |
| 1106 $result = $getterString; | 1147 $result = $getterString; |
| 1107 # Fix amigious conversion problem, by casting to the base type first ($g etterString returns a type that inherits from SVGAnimatedEnumeration, not the ba se class directly). | 1148 # Fix amigious conversion problem, by casting to the base type first ($g etterString returns a type that inherits from SVGAnimatedEnumeration, not the ba se class directly). |
| 1108 $result = "static_pointer_cast<SVGAnimatedEnumeration>($result)" if $ret urnType eq "SVGAnimatedEnumeration"; | 1149 $result = "static_pointer_cast<SVGAnimatedEnumeration>($result)" if $ret urnType eq "SVGAnimatedEnumeration"; |
| 1109 } | 1150 } |
| 1110 | 1151 |
| 1111 # Special case for readonly or Replaceable attributes (with a few exceptions ). This attempts to ensure that JS wrappers don't get | 1152 # Special case for readonly or Replaceable attributes (with a few exceptions ). This attempts to ensure that JS wrappers don't get |
| 1112 # garbage-collected prematurely when their lifetime is strongly tied to thei r owner. We accomplish this by inserting a reference to | 1153 # garbage-collected prematurely when their lifetime is strongly tied to thei r owner. We accomplish this by inserting a reference to |
| 1113 # the newly created wrapper into an internal field of the holder object. | 1154 # the newly created wrapper into an internal field of the holder object. |
| 1114 if ((!$codeGenerator->InheritsInterface($interface, "Node") && $attrName ne "self" && IsWrapperType($returnType) && (IsReadonly($attribute) || $attribute->s ignature->extendedAttributes->{"Replaceable"} || $attrName eq "location") | 1155 if ((!$codeGenerator->InheritsInterface($interface, "Node") && $attrName ne "self" && IsWrapperType($returnType) && (IsReadonly($attribute) || $attribute->s ignature->extendedAttributes->{"Replaceable"} || $attrName eq "location") |
| 1115 && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValu e" && $returnType ne "DOMWindow" | 1156 && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValu e" && $returnType ne "DOMWindow" |
| 1116 && $returnType ne "MessagePortArray" | 1157 && $returnType ne "MessagePortArray" |
| 1117 && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($ret urnType)) | 1158 && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($ret urnType)) |
| 1118 || $attribute->signature->extendedAttributes->{"CacheAttributeForGC"}) { | 1159 || $attribute->signature->extendedAttributes->{"CacheAttributeForGC"}) { |
| 1119 | 1160 |
| 1120 my $arrayType = $codeGenerator->GetArrayType($returnType); | 1161 my $arrayType = $codeGenerator->GetArrayType($returnType); |
| 1121 if ($arrayType) { | 1162 if ($arrayType) { |
| 1122 if (!$codeGenerator->SkipIncludeHeader($arrayType)) { | 1163 if (!$codeGenerator->SkipIncludeHeader($arrayType)) { |
| 1123 AddToImplIncludes("V8$arrayType.h"); | 1164 AddToImplIncludes("V8$arrayType.h"); |
| 1124 AddToImplIncludes("$arrayType.h"); | 1165 AddToImplIncludes("$arrayType.h"); |
| 1125 } | 1166 } |
| 1126 push(@implContentInternals, " return v8Array(${getterString}, inf o.GetIsolate());\n"); | 1167 $func .= " return v8Array(${getterString}, info.GetIsolate());\n" ; |
| 1127 push(@implContentInternals, "}\n\n"); | 1168 $func .= "}\n\n"; |
| 1169 AddToImplFunctionInternal($func); | |
| 1128 return; | 1170 return; |
| 1129 } | 1171 } |
| 1130 | 1172 |
| 1131 AddIncludesForType($returnType); | 1173 AddIncludesForType($returnType); |
| 1132 # Check for a wrapper in the wrapper cache. If there is one, we know tha t a hidden reference has already | 1174 # Check for a wrapper in the wrapper cache. If there is one, we know tha t a hidden reference has already |
| 1133 # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference. | 1175 # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference. |
| 1134 push(@implContentInternals, " RefPtr<$returnType> result = ${getterSt ring};\n"); | 1176 $func .= " RefPtr<$returnType> result = ${getterString};\n"; |
| 1135 if ($forMainWorldSuffix) { | 1177 if ($forMainWorldSuffix) { |
| 1136 push(@implContentInternals, " v8::Handle<v8::Value> wrapper = resul t.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper${forMainWorldSuffix}(re sult.get())) : v8Undefined();\n"); | 1178 $func .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper${forMainWorldSuffix}(result.get())) : v8Un defined();\n"; |
| 1137 } else { | 1179 } else { |
| 1138 push(@implContentInternals, " v8::Handle<v8::Value> wrapper = resul t.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetI solate())) : v8Undefined();\n"); | 1180 $func .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetIsolate())) : v8Unde fined();\n"; |
| 1139 } | 1181 } |
| 1140 push(@implContentInternals, " if (wrapper.IsEmpty()) {\n"); | 1182 $func .= " if (wrapper.IsEmpty()) {\n"; |
| 1141 push(@implContentInternals, " wrapper = toV8(result.get(), info.H older(), info.GetIsolate());\n"); # FIXME: Could use wrap here since the wrapper is empty. | 1183 $func .= " wrapper = toV8(result.get(), info.Holder(), info.GetIs olate());\n"; # FIXME: Could use wrap here since the wrapper is empty. |
| 1142 push(@implContentInternals, " if (!wrapper.IsEmpty())\n"); | 1184 $func .= " if (!wrapper.IsEmpty())\n"; |
| 1143 push(@implContentInternals, " V8HiddenPropertyName::setNamedH iddenReference(info.Holder(), \"${attrName}\", wrapper);\n"); | 1185 $func .= " V8HiddenPropertyName::setNamedHiddenReference(info .Holder(), \"${attrName}\", wrapper);\n"; |
| 1144 push(@implContentInternals, " }\n"); | 1186 $func .= " }\n"; |
| 1145 push(@implContentInternals, " return wrapper;\n"); | 1187 $func .= " return wrapper;\n"; |
| 1146 push(@implContentInternals, "}\n\n"); | 1188 $func .= "}\n\n"; |
| 1147 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $co nditionalString; | 1189 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1190 AddToImplFunctionInternal($func); | |
| 1148 return; | 1191 return; |
| 1149 } | 1192 } |
| 1150 | 1193 |
| 1151 if (($codeGenerator->IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") and $codeGenerator->IsSVGTypeNeedingTearOff($attrType)) { | 1194 if (($codeGenerator->IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") and $codeGenerator->IsSVGTypeNeedingTearOff($attrType)) { |
| 1152 AddToImplIncludes("V8$attrType.h"); | 1195 AddToImplIncludes("V8$attrType.h"); |
| 1153 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); | 1196 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); |
| 1154 # Convert from abstract SVGProperty to real type, so the right toJS() me thod can be invoked. | 1197 # Convert from abstract SVGProperty to real type, so the right toJS() me thod can be invoked. |
| 1155 push(@implContentInternals, " return toV8Fast$forMainWorldSuffix(stat ic_cast<$svgNativeType*>($result), info, imp);\n"); | 1198 $func .= " return toV8Fast$forMainWorldSuffix(static_cast<$svgNativeT ype*>($result), info, imp);\n"; |
| 1156 } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($attrType) and not $interfa ceName =~ /List$/) { | 1199 } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($attrType) and not $interfa ceName =~ /List$/) { |
| 1157 AddToImplIncludes("V8$attrType.h"); | 1200 AddToImplIncludes("V8$attrType.h"); |
| 1158 AddToImplIncludes("SVGPropertyTearOff.h"); | 1201 AddToImplIncludes("SVGPropertyTearOff.h"); |
| 1159 my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); | 1202 my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); |
| 1160 my $wrappedValue; | 1203 my $wrappedValue; |
| 1161 if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($attrT ype) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { | 1204 if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($attrT ype) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { |
| 1162 my $getter = $result; | 1205 my $getter = $result; |
| 1163 $getter =~ s/imp->//; | 1206 $getter =~ s/imp->//; |
| 1164 $getter =~ s/\(\)//; | 1207 $getter =~ s/\(\)//; |
| 1165 | 1208 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1183 | 1226 |
| 1184 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $result , $updateMethod))"; | 1227 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $result , $updateMethod))"; |
| 1185 } | 1228 } |
| 1186 } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { | 1229 } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { |
| 1187 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $result ))"; | 1230 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $result ))"; |
| 1188 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { | 1231 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { |
| 1189 $wrappedValue = "WTF::getPtr($result)"; | 1232 $wrappedValue = "WTF::getPtr($result)"; |
| 1190 } else { | 1233 } else { |
| 1191 $wrappedValue = "WTF::getPtr(${tearOffType}::create($result))"; | 1234 $wrappedValue = "WTF::getPtr(${tearOffType}::create($result))"; |
| 1192 } | 1235 } |
| 1193 push(@implContentInternals, " return toV8Fast$forMainWorldSuffix($wra ppedValue, info, imp);\n"); | 1236 $func .= " return toV8Fast$forMainWorldSuffix($wrappedValue, info, im p);\n"; |
| 1194 } elsif ($attribute->signature->type eq "MessagePortArray") { | 1237 } elsif ($attribute->signature->type eq "MessagePortArray") { |
| 1195 AddToImplIncludes("MessagePort.h"); | 1238 AddToImplIncludes("MessagePort.h"); |
| 1196 AddToImplIncludes("V8MessagePort.h"); | 1239 AddToImplIncludes("V8MessagePort.h"); |
| 1197 my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name) ; | 1240 my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name) ; |
| 1198 push(@implContentInternals, <<END); | 1241 $func .= <<END; |
| 1199 MessagePortArray* ports = imp->${getterFunc}(); | 1242 MessagePortArray* ports = imp->${getterFunc}(); |
| 1200 if (!ports) | 1243 if (!ports) |
| 1201 return v8::Array::New(0); | 1244 return v8::Array::New(0); |
| 1202 MessagePortArray portsCopy(*ports); | 1245 MessagePortArray portsCopy(*ports); |
| 1203 v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size()); | 1246 v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size()); |
| 1204 for (size_t i = 0; i < portsCopy.size(); ++i) | 1247 for (size_t i = 0; i < portsCopy.size(); ++i) |
| 1205 portArray->Set(v8Integer(i, info.GetIsolate()), toV8Fast$forMainWorldSuf fix(portsCopy[i].get(), info, imp)); | 1248 portArray->Set(v8Integer(i, info.GetIsolate()), toV8Fast$forMainWorldSuf fix(portsCopy[i].get(), info, imp)); |
| 1206 return portArray; | 1249 return portArray; |
| 1207 END | 1250 END |
| 1208 } elsif ($attribute->signature->type eq "SerializedScriptValue" && $attrExt- >{"CachedAttribute"}) { | 1251 } elsif ($attribute->signature->type eq "SerializedScriptValue" && $attrExt- >{"CachedAttribute"}) { |
| 1209 my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name) ; | 1252 my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name) ; |
| 1210 push(@implContentInternals, <<END); | 1253 $func .= <<END; |
| 1211 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}(); | 1254 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}(); |
| 1212 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Nul l(info.GetIsolate())); | 1255 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Nul l(info.GetIsolate())); |
| 1213 info.Holder()->SetHiddenValue(propertyName, value); | 1256 info.Holder()->SetHiddenValue(propertyName, value); |
| 1214 return value; | 1257 return value; |
| 1215 END | 1258 END |
| 1216 } else { | 1259 } else { |
| 1217 push(@implContentInternals, " return " . NativeToJSValue($attribute-> signature, $result, "info.Holder()", "info.GetIsolate()", "info", "imp", "Return UnsafeHandle", $forMainWorldSuffix).";\n"); | 1260 $func .= " return " . NativeToJSValue($attribute->signature, $result, "info.Holder()", "info.GetIsolate()", "info", "imp", "ReturnUnsafeHandle", $for MainWorldSuffix).";\n"; |
| 1218 } | 1261 } |
| 1219 | 1262 |
| 1220 push(@implContentInternals, "}\n\n"); # end of getter | 1263 $func .= "}\n\n"; # end of getter |
| 1221 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $condit ionalString; | 1264 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1265 AddToImplFunctionInternal($func); | |
| 1222 } | 1266 } |
| 1223 | 1267 |
| 1224 sub GenerateReplaceableAttrSetterCallback | 1268 sub GenerateReplaceableAttrSetterCallback |
| 1225 { | 1269 { |
| 1226 my $interface = shift; | 1270 my $interface = shift; |
| 1227 my $interfaceName = $interface->name; | 1271 my $interfaceName = $interface->name; |
| 1228 | 1272 |
| 1229 push(@implContentInternals, "static void ${interfaceName}ReplaceableAttrSett erCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::Acc essorInfo& info)\n"); | 1273 my $func = ""; |
| 1230 push(@implContentInternals, "{\n"); | 1274 $func .= "static void ${interfaceName}ReplaceableAttrSetterCallback(v8::Loca l<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n" ; |
| 1231 push(@implContentInternals, GenerateFeatureObservation($interface->extendedA ttributes->{"MeasureAs"})); | 1275 $func .= "{\n"; |
| 1232 push(@implContentInternals, " return ${interfaceName}V8Internal::${interf aceName}ReplaceableAttrSetter(name, value, info);\n"); | 1276 $func .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"}); |
| 1233 push(@implContentInternals, "}\n\n"); | 1277 $func .= " return ${interfaceName}V8Internal::${interfaceName}Replaceable AttrSetter(name, value, info);\n"; |
| 1278 $func .= "}\n\n"; | |
| 1279 AddToImplFunctionInternal($func); | |
| 1234 } | 1280 } |
| 1235 | 1281 |
| 1236 sub GenerateReplaceableAttrSetter | 1282 sub GenerateReplaceableAttrSetter |
| 1237 { | 1283 { |
| 1238 my $interface = shift; | 1284 my $interface = shift; |
| 1239 my $interfaceName = $interface->name; | 1285 my $interfaceName = $interface->name; |
| 1240 | 1286 |
| 1241 push(@implContentInternals, <<END); | 1287 my $func = ""; |
| 1288 $func .= <<END; | |
| 1242 static void ${interfaceName}ReplaceableAttrSetter(v8::Local<v8::String> name, v8 ::Local<v8::Value> value, const v8::AccessorInfo& info) | 1289 static void ${interfaceName}ReplaceableAttrSetter(v8::Local<v8::String> name, v8 ::Local<v8::Value> value, const v8::AccessorInfo& info) |
| 1243 { | 1290 { |
| 1244 END | 1291 END |
| 1245 if ($interface->extendedAttributes->{"CheckSecurity"}) { | 1292 if ($interface->extendedAttributes->{"CheckSecurity"}) { |
| 1246 AddToImplIncludes("Frame.h"); | 1293 AddToImplIncludes("Frame.h"); |
| 1247 push(@implContentInternals, <<END); | 1294 $func .= <<END; |
| 1248 ${interfaceName}* imp = V8${interfaceName}::toNative(info.Holder()); | 1295 ${interfaceName}* imp = V8${interfaceName}::toNative(info.Holder()); |
| 1249 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) | 1296 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) |
| 1250 return; | 1297 return; |
| 1251 END | 1298 END |
| 1252 } | 1299 } |
| 1253 | 1300 |
| 1254 push(@implContentInternals, <<END); | 1301 $func .= <<END; |
| 1255 info.This()->ForceSet(name, value); | 1302 info.This()->ForceSet(name, value); |
| 1256 } | 1303 } |
| 1257 | 1304 |
| 1258 END | 1305 END |
| 1306 AddToImplFunctionInternal($func); | |
| 1259 } | 1307 } |
| 1260 | 1308 |
| 1261 sub GenerateCustomElementInvocationScopeIfNeeded | 1309 sub GenerateCustomElementInvocationScopeIfNeeded |
| 1262 { | 1310 { |
| 1263 my $out = shift; | 1311 my $out = ""; |
|
haraken
2013/04/16 09:40:36
Maybe $code is a better name?
Either way, let's m
kojih
2013/04/16 11:00:07
as discussed offline:
basically use $code
use $sub
| |
| 1264 my $ext = shift; | 1312 my $ext = shift; |
| 1265 | 1313 |
| 1266 if ($ext->{"DeliverCustomElementCallbacks"}) { | 1314 if ($ext->{"DeliverCustomElementCallbacks"}) { |
| 1267 if ($ext->{"Reflect"}) { | 1315 if ($ext->{"Reflect"}) { |
| 1268 die "IDL error: [Reflect] and [DeliverCustomElementCallbacks] cannot coexist yet"; | 1316 die "IDL error: [Reflect] and [DeliverCustomElementCallbacks] cannot coexist yet"; |
| 1269 } | 1317 } |
| 1270 | 1318 |
| 1271 AddToImplIncludes("CustomElementRegistry.h", "CUSTOM_ELEMENTS"); | 1319 AddToImplIncludes("CustomElementRegistry.h", "CUSTOM_ELEMENTS"); |
| 1272 push(@$out, <<END); | 1320 $out .= <<END; |
| 1273 #if ENABLE(CUSTOM_ELEMENTS) | 1321 #if ENABLE(CUSTOM_ELEMENTS) |
| 1274 CustomElementRegistry::CallbackDeliveryScope deliveryScope; | 1322 CustomElementRegistry::CallbackDeliveryScope deliveryScope; |
| 1275 #endif | 1323 #endif |
| 1276 END | 1324 END |
| 1277 } | 1325 } |
| 1326 return $out; | |
| 1278 } | 1327 } |
| 1279 | 1328 |
| 1280 sub GenerateNormalAttrSetterCallback | 1329 sub GenerateNormalAttrSetterCallback |
| 1281 { | 1330 { |
| 1282 my $attribute = shift; | 1331 my $attribute = shift; |
| 1283 my $interface = shift; | 1332 my $interface = shift; |
| 1284 my $forMainWorldSuffix = shift; | 1333 my $forMainWorldSuffix = shift; |
| 1285 | 1334 |
| 1286 my $interfaceName = $interface->name; | 1335 my $interfaceName = $interface->name; |
| 1287 my $v8InterfaceName = "V8$interfaceName"; | 1336 my $v8InterfaceName = "V8$interfaceName"; |
| 1288 my $attrExt = $attribute->signature->extendedAttributes; | 1337 my $attrExt = $attribute->signature->extendedAttributes; |
| 1289 my $attrName = $attribute->signature->name; | 1338 my $attrName = $attribute->signature->name; |
| 1290 | 1339 |
| 1291 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute ->signature); | 1340 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute ->signature); |
| 1292 push(@implContentInternals, "#if ${conditionalString}\n\n") if $conditionalS tring; | 1341 my $func = ""; |
| 1342 $func .= "#if ${conditionalString}\n\n" if $conditionalString; | |
| 1293 | 1343 |
| 1294 push(@implContentInternals, "static void ${attrName}AttrSetterCallback${forM ainWorldSuffix}(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8 ::AccessorInfo& info)\n"); | 1344 $func .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8: :Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& inf o)\n"; |
| 1295 push(@implContentInternals, "{\n"); | 1345 $func .= "{\n"; |
| 1296 push(@implContentInternals, GenerateFeatureObservation($attrExt->{"MeasureAs "})); | 1346 $func .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
| 1297 if (HasCustomSetter($attrExt)) { | 1347 if (HasCustomSetter($attrExt)) { |
| 1298 push(@implContentInternals, " ${v8InterfaceName}::${attrName}AttrSett erCustom(name, value, info);\n"); | 1348 $func .= " ${v8InterfaceName}::${attrName}AttrSetterCustom(name, valu e, info);\n"; |
| 1299 } else { | 1349 } else { |
| 1300 push(@implContentInternals, " ${interfaceName}V8Internal::${attrName} AttrSetter${forMainWorldSuffix}(name, value, info);\n"); | 1350 $func .= " ${interfaceName}V8Internal::${attrName}AttrSetter${forMain WorldSuffix}(name, value, info);\n"; |
| 1301 } | 1351 } |
| 1302 push(@implContentInternals, "}\n\n"); | 1352 $func .= "}\n\n"; |
| 1303 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $condit ionalString; | 1353 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1354 AddToImplFunctionInternal($func); | |
| 1304 } | 1355 } |
| 1305 | 1356 |
| 1306 sub GenerateNormalAttrSetter | 1357 sub GenerateNormalAttrSetter |
| 1307 { | 1358 { |
| 1308 my $attribute = shift; | 1359 my $attribute = shift; |
| 1309 my $interface = shift; | 1360 my $interface = shift; |
| 1310 my $forMainWorldSuffix = shift; | 1361 my $forMainWorldSuffix = shift; |
| 1311 | 1362 |
| 1312 my $interfaceName = $interface->name; | 1363 my $interfaceName = $interface->name; |
| 1313 my $v8InterfaceName = "V8$interfaceName"; | 1364 my $v8InterfaceName = "V8$interfaceName"; |
| 1314 my $attrName = $attribute->signature->name; | 1365 my $attrName = $attribute->signature->name; |
| 1315 my $attrExt = $attribute->signature->extendedAttributes; | 1366 my $attrExt = $attribute->signature->extendedAttributes; |
| 1316 my $attrType = $attribute->signature->type; | 1367 my $attrType = $attribute->signature->type; |
| 1317 | 1368 |
| 1318 if (HasCustomSetter($attrExt)) { | 1369 if (HasCustomSetter($attrExt)) { |
| 1319 return; | 1370 return; |
| 1320 } | 1371 } |
| 1321 | 1372 |
| 1322 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute ->signature); | 1373 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute ->signature); |
| 1323 push(@implContentInternals, "#if ${conditionalString}\n\n") if $conditionalS tring; | 1374 my $func = ""; |
| 1324 push(@implContentInternals, "static void ${attrName}AttrSetter${forMainWorld Suffix}(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::Access orInfo& info)\n"); | 1375 $func .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 1325 push(@implContentInternals, "{\n"); | 1376 $func .= "static void ${attrName}AttrSetter${forMainWorldSuffix}(v8::Local<v 8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n"; |
| 1377 $func .= "{\n"; | |
| 1326 | 1378 |
| 1327 # If the "StrictTypeChecking" extended attribute is present, and the attribu te's type is an | 1379 # If the "StrictTypeChecking" extended attribute is present, and the attribu te's type is an |
| 1328 # interface type, then if the incoming value does not implement that interfa ce, a TypeError is | 1380 # interface type, then if the incoming value does not implement that interfa ce, a TypeError is |
| 1329 # thrown rather than silently passing NULL to the C++ code. | 1381 # thrown rather than silently passing NULL to the C++ code. |
| 1330 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to both | 1382 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to both |
| 1331 # strings and numbers, so do not throw TypeError if the attribute is of thes e types. | 1383 # strings and numbers, so do not throw TypeError if the attribute is of thes e types. |
| 1332 if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) { | 1384 if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) { |
| 1333 my $argType = $attribute->signature->type; | 1385 my $argType = $attribute->signature->type; |
| 1334 if (IsWrapperType($argType)) { | 1386 if (IsWrapperType($argType)) { |
| 1335 push(@implContentInternals, " if (!isUndefinedOrNull(value) && !V 8${argType}::HasInstance(value, info.GetIsolate(), worldType(info.GetIsolate())) ) {\n"); | 1387 $func .= " if (!isUndefinedOrNull(value) && !V8${argType}::HasIns tance(value, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; |
| 1336 push(@implContentInternals, " throwTypeError(0, info.GetIsola te());\n"); | 1388 $func .= " throwTypeError(0, info.GetIsolate());\n"; |
| 1337 push(@implContentInternals, " return;\n"); | 1389 $func .= " return;\n"; |
| 1338 push(@implContentInternals, " }\n"); | 1390 $func .= " }\n"; |
| 1339 } | 1391 } |
| 1340 } | 1392 } |
| 1341 | 1393 |
| 1342 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) ; | 1394 my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) ; |
| 1343 if ($svgNativeType) { | 1395 if ($svgNativeType) { |
| 1344 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearO ff($interfaceName); | 1396 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearO ff($interfaceName); |
| 1345 if ($svgWrappedNativeType =~ /List$/) { | 1397 if ($svgWrappedNativeType =~ /List$/) { |
| 1346 push(@implContentInternals, <<END); | 1398 $func .= <<END; |
| 1347 $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1399 $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); |
| 1348 END | 1400 END |
| 1349 } else { | 1401 } else { |
| 1350 AddToImplIncludes("ExceptionCode.h"); | 1402 AddToImplIncludes("ExceptionCode.h"); |
| 1351 push(@implContentInternals, " $svgNativeType* wrapper = ${v8Inter faceName}::toNative(info.Holder());\n"); | 1403 $func .= " $svgNativeType* wrapper = ${v8InterfaceName}::toNative (info.Holder());\n"; |
| 1352 push(@implContentInternals, " if (wrapper->isReadOnly()) {\n"); | 1404 $func .= " if (wrapper->isReadOnly()) {\n"; |
| 1353 push(@implContentInternals, " setDOMException(NO_MODIFICATION _ALLOWED_ERR, info.GetIsolate());\n"); | 1405 $func .= " setDOMException(NO_MODIFICATION_ALLOWED_ERR, info. GetIsolate());\n"; |
| 1354 push(@implContentInternals, " return;\n"); | 1406 $func .= " return;\n"; |
| 1355 push(@implContentInternals, " }\n"); | 1407 $func .= " }\n"; |
| 1356 push(@implContentInternals, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n"); | 1408 $func .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; |
| 1357 push(@implContentInternals, " $svgWrappedNativeType* imp = &impIn stance;\n"); | 1409 $func .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
| 1358 } | 1410 } |
| 1359 } elsif ($attrExt->{"OnProto"}) { | 1411 } elsif ($attrExt->{"OnProto"}) { |
| 1360 push(@implContentInternals, <<END); | 1412 $func .= <<END; |
| 1361 ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1413 ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); |
| 1362 END | 1414 END |
| 1363 } else { | 1415 } else { |
| 1364 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; | 1416 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; |
| 1365 if ($reflect && $codeGenerator->InheritsInterface($interface, "Node") && $codeGenerator->IsStringType($attrType)) { | 1417 if ($reflect && $codeGenerator->InheritsInterface($interface, "Node") && $codeGenerator->IsStringType($attrType)) { |
| 1366 # Generate super-compact call for regular attribute setter: | 1418 # Generate super-compact call for regular attribute setter: |
| 1367 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr Name : $reflect; | 1419 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr Name : $reflect; |
| 1368 my $namespace = $codeGenerator->NamespaceForAttributeName($interface Name, $contentAttributeName); | 1420 my $namespace = $codeGenerator->NamespaceForAttributeName($interface Name, $contentAttributeName); |
| 1369 AddToImplIncludes("${namespace}.h"); | 1421 AddToImplIncludes("${namespace}.h"); |
| 1370 push(@implContentInternals, " Element* imp = V8Element::toNative( info.Holder());\n"); | 1422 $func .= " Element* imp = V8Element::toNative(info.Holder());\n"; |
| 1371 push(@implContentInternals, " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOI D(V8StringResource<WithNullCheck>, stringResource, value);\n"); | 1423 $func .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource< WithNullCheck>, stringResource, value);\n"; |
| 1372 push(@implContentInternals, " imp->setAttribute(${namespace}::${c ontentAttributeName}Attr, stringResource);\n"); | 1424 $func .= " imp->setAttribute(${namespace}::${contentAttributeName }Attr, stringResource);\n"; |
| 1373 push(@implContentInternals, "}\n\n"); | 1425 $func .= "}\n\n"; |
| 1374 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $conditionalString; | 1426 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1427 AddToImplFunctionInternal($func); | |
| 1375 return; | 1428 return; |
| 1376 # Skip the rest of the function! | 1429 # Skip the rest of the function! |
| 1377 } | 1430 } |
| 1378 | 1431 |
| 1379 if (!$attribute->isStatic) { | 1432 if (!$attribute->isStatic) { |
| 1380 push(@implContentInternals, <<END); | 1433 $func .= <<END; |
| 1381 ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1434 ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); |
| 1382 END | 1435 END |
| 1383 } | 1436 } |
| 1384 } | 1437 } |
| 1385 | 1438 |
| 1386 my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); | 1439 my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); |
| 1387 if ($attribute->signature->type eq "EventListener") { | 1440 if ($attribute->signature->type eq "EventListener") { |
| 1388 if ($interface->name eq "DOMWindow") { | 1441 if ($interface->name eq "DOMWindow") { |
| 1389 push(@implContentInternals, " if (!imp->document())\n"); | 1442 $func .= " if (!imp->document())\n"; |
| 1390 push(@implContentInternals, " return;\n"); | 1443 $func .= " return;\n"; |
| 1391 } | 1444 } |
| 1392 } else { | 1445 } else { |
| 1393 my $value = JSValueToNative($attribute->signature, "value", "info.GetIso late()"); | 1446 my $value = JSValueToNative($attribute->signature, "value", "info.GetIso late()"); |
| 1394 my $arrayType = $codeGenerator->GetArrayType($nativeType); | 1447 my $arrayType = $codeGenerator->GetArrayType($nativeType); |
| 1395 | 1448 |
| 1396 if ($nativeType =~ /^V8StringResource/) { | 1449 if ($nativeType =~ /^V8StringResource/) { |
| 1397 push(@implContentInternals, " " . ConvertToV8StringResource($attr ibute->signature, $nativeType, "v", $value, "VOID") . "\n"); | 1450 $func .= " " . ConvertToV8StringResource($attribute->signature, $ nativeType, "v", $value, "VOID") . "\n"; |
| 1398 } elsif ($arrayType) { | 1451 } elsif ($arrayType) { |
| 1399 push(@implContentInternals, " Vector<$arrayType> v = $value;\n"); | 1452 $func .= " Vector<$arrayType> v = $value;\n"; |
| 1400 } elsif ($attribute->signature->extendedAttributes->{"EnforceRange"}) { | 1453 } elsif ($attribute->signature->extendedAttributes->{"EnforceRange"}) { |
| 1401 push(@implContentInternals, " V8TRYCATCH_WITH_TYPECHECK_VOID($nat iveType, v, $value, info.GetIsolate());\n"); | 1454 $func .= " V8TRYCATCH_WITH_TYPECHECK_VOID($nativeType, v, $value, info.GetIsolate());\n"; |
| 1402 } else { | 1455 } else { |
| 1403 push(@implContentInternals, " V8TRYCATCH_VOID($nativeType, v, $va lue);\n"); | 1456 $func .= " V8TRYCATCH_VOID($nativeType, v, $value);\n"; |
| 1404 } | 1457 } |
| 1405 } | 1458 } |
| 1406 | 1459 |
| 1407 if ($codeGenerator->IsEnumType($attrType)) { | 1460 if ($codeGenerator->IsEnumType($attrType)) { |
| 1408 # setter ignores invalid enumeration values | 1461 # setter ignores invalid enumeration values |
| 1409 my @enumValues = $codeGenerator->ValidEnumValues($attrType); | 1462 my @enumValues = $codeGenerator->ValidEnumValues($attrType); |
| 1410 my @validEqualities = (); | 1463 my @validEqualities = (); |
| 1411 foreach my $enumValue (@enumValues) { | 1464 foreach my $enumValue (@enumValues) { |
| 1412 push(@validEqualities, "string == \"$enumValue\""); | 1465 push(@validEqualities, "string == \"$enumValue\""); |
| 1413 } | 1466 } |
| 1414 my $enumValidationExpression = join(" || ", @validEqualities); | 1467 my $enumValidationExpression = join(" || ", @validEqualities); |
| 1415 push(@implContentInternals, <<END); | 1468 $func .= <<END; |
| 1416 String string = v; | 1469 String string = v; |
| 1417 if (!($enumValidationExpression)) | 1470 if (!($enumValidationExpression)) |
| 1418 return; | 1471 return; |
| 1419 END | 1472 END |
| 1420 } | 1473 } |
| 1421 | 1474 |
| 1422 my $result = "v"; | 1475 my $result = "v"; |
| 1423 my $returnType = $attribute->signature->type; | 1476 my $returnType = $attribute->signature->type; |
| 1424 if ($codeGenerator->IsRefPtrType($returnType) && !$codeGenerator->GetArrayTy pe($returnType)) { | 1477 if ($codeGenerator->IsRefPtrType($returnType) && !$codeGenerator->GetArrayTy pe($returnType)) { |
| 1425 $result = "WTF::getPtr(" . $result . ")"; | 1478 $result = "WTF::getPtr(" . $result . ")"; |
| 1426 } | 1479 } |
| 1427 | 1480 |
| 1428 GenerateCustomElementInvocationScopeIfNeeded(\@implContentInternals, $attrib ute->signature->extendedAttributes); | 1481 $func .= GenerateCustomElementInvocationScopeIfNeeded($attribute->signature- >extendedAttributes); |
| 1429 | 1482 |
| 1430 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Setter RaisesException"}; | 1483 my $useExceptions = 1 if $attribute->signature->extendedAttributes->{"Setter RaisesException"}; |
| 1431 | 1484 |
| 1432 if ($useExceptions) { | 1485 if ($useExceptions) { |
| 1433 AddToImplIncludes("ExceptionCode.h"); | 1486 AddToImplIncludes("ExceptionCode.h"); |
| 1434 push(@implContentInternals, " ExceptionCode ec = 0;\n"); | 1487 $func .= " ExceptionCode ec = 0;\n"; |
| 1435 } | 1488 } |
| 1436 | 1489 |
| 1437 if ($interfaceName eq "SVGNumber") { | 1490 if ($interfaceName eq "SVGNumber") { |
| 1438 push(@implContentInternals, " *imp = $result;\n"); | 1491 $func .= " *imp = $result;\n"; |
| 1439 } else { | 1492 } else { |
| 1440 if ($attribute->signature->type eq "EventListener") { | 1493 if ($attribute->signature->type eq "EventListener") { |
| 1441 my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName); | 1494 my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName); |
| 1442 AddToImplIncludes("V8AbstractEventListener.h"); | 1495 AddToImplIncludes("V8AbstractEventListener.h"); |
| 1443 if (!$codeGenerator->InheritsInterface($interface, "Node")) { | 1496 if (!$codeGenerator->InheritsInterface($interface, "Node")) { |
| 1444 push(@implContentInternals, " transferHiddenDependency(info.H older(), imp->$attrName(), value, ${v8InterfaceName}::eventListenerCacheIndex, i nfo.GetIsolate());\n"); | 1497 $func .= " transferHiddenDependency(info.Holder(), imp->$attr Name(), value, ${v8InterfaceName}::eventListenerCacheIndex, info.GetIsolate());\ n"; |
| 1445 } | 1498 } |
| 1446 AddToImplIncludes("V8EventListenerList.h"); | 1499 AddToImplIncludes("V8EventListenerList.h"); |
| 1447 if ($interfaceName eq "WorkerContext" and $attribute->signature->nam e eq "onerror") { | 1500 if ($interfaceName eq "WorkerContext" and $attribute->signature->nam e eq "onerror") { |
| 1448 AddToImplIncludes("V8WorkerContextErrorHandler.h"); | 1501 AddToImplIncludes("V8WorkerContextErrorHandler.h"); |
| 1449 push(@implContentInternals, " imp->set$implSetterFunctionName (V8EventListenerList::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, tr ue)"); | 1502 $func .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)"; |
| 1450 } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->na me eq "onerror") { | 1503 } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->na me eq "onerror") { |
| 1451 AddToImplIncludes("V8WindowErrorHandler.h"); | 1504 AddToImplIncludes("V8WindowErrorHandler.h"); |
| 1452 push(@implContentInternals, " imp->set$implSetterFunctionName (V8EventListenerList::findOrCreateWrapper<V8WindowErrorHandler>(value, true)"); | 1505 $func .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8WindowErrorHandler>(value, true)"; |
| 1453 } else { | 1506 } else { |
| 1454 push(@implContentInternals, " imp->set$implSetterFunctionName (V8EventListenerList::getEventListener(value, true, ListenerFindOrCreate)"); | 1507 $func .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate)"; |
| 1455 } | 1508 } |
| 1456 push(@implContentInternals, ", ec") if $useExceptions; | 1509 $func .= ", ec" if $useExceptions; |
| 1457 push(@implContentInternals, ");\n"); | 1510 $func .= ");\n"; |
| 1458 } else { | 1511 } else { |
| 1459 my ($functionName, @arguments) = $codeGenerator->SetterExpression(\% implIncludes, $interfaceName, $attribute); | 1512 my ($functionName, @arguments) = $codeGenerator->SetterExpression(\% implIncludes, $interfaceName, $attribute); |
| 1460 push(@arguments, $result); | 1513 push(@arguments, $result); |
| 1461 push(@arguments, "ec") if $useExceptions; | 1514 push(@arguments, "ec") if $useExceptions; |
| 1462 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { | 1515 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { |
| 1463 my $implementedBy = $attribute->signature->extendedAttributes->{ "ImplementedBy"}; | 1516 my $implementedBy = $attribute->signature->extendedAttributes->{ "ImplementedBy"}; |
| 1464 AddToImplIncludes("${implementedBy}.h"); | 1517 AddToImplIncludes("${implementedBy}.h"); |
| 1465 unshift(@arguments, "imp") if !$attribute->isStatic; | 1518 unshift(@arguments, "imp") if !$attribute->isStatic; |
| 1466 $functionName = "${implementedBy}::${functionName}"; | 1519 $functionName = "${implementedBy}::${functionName}"; |
| 1467 } elsif ($attribute->isStatic) { | 1520 } elsif ($attribute->isStatic) { |
| 1468 $functionName = "${interfaceName}::${functionName}"; | 1521 $functionName = "${interfaceName}::${functionName}"; |
| 1469 } else { | 1522 } else { |
| 1470 $functionName = "imp->${functionName}"; | 1523 $functionName = "imp->${functionName}"; |
| 1471 } | 1524 } |
| 1472 unshift(@arguments, GenerateCallWith($attribute->signature->extended Attributes->{"CallWith"}, \@implContentInternals, " ", 1)); | 1525 my ($arg, $code) = GenerateCallWith($attribute->signature->extendedA ttributes->{"CallWith"}, " ", 1); |
| 1473 push(@implContentInternals, " ${functionName}(" . join(", ", @arg uments) . ");\n"); | 1526 $func .= $code; |
| 1527 unshift(@arguments, @$arg); | |
| 1528 $func .= " ${functionName}(" . join(", ", @arguments) . ");\n"; | |
| 1474 } | 1529 } |
| 1475 } | 1530 } |
| 1476 | 1531 |
| 1477 if ($useExceptions) { | 1532 if ($useExceptions) { |
| 1478 push(@implContentInternals, " if (UNLIKELY(ec))\n"); | 1533 $func .= " if (UNLIKELY(ec))\n"; |
| 1479 push(@implContentInternals, " setDOMException(ec, info.GetIsolate ());\n"); | 1534 $func .= " setDOMException(ec, info.GetIsolate());\n"; |
| 1480 } | 1535 } |
| 1481 | 1536 |
| 1482 if ($codeGenerator->ExtendedAttributeContains($attribute->signature->extende dAttributes->{"CallWith"}, "ScriptState")) { | 1537 if ($codeGenerator->ExtendedAttributeContains($attribute->signature->extende dAttributes->{"CallWith"}, "ScriptState")) { |
| 1483 push(@implContentInternals, " if (state.hadException())\n"); | 1538 $func .= " if (state.hadException())\n"; |
| 1484 push(@implContentInternals, " throwError(state.exception(), info. GetIsolate());\n"); | 1539 $func .= " throwError(state.exception(), info.GetIsolate());\n"; |
| 1485 } | 1540 } |
| 1486 | 1541 |
| 1487 if ($svgNativeType) { | 1542 if ($svgNativeType) { |
| 1488 if ($useExceptions) { | 1543 if ($useExceptions) { |
| 1489 push(@implContentInternals, " if (!ec)\n"); | 1544 $func .= " if (!ec)\n"; |
| 1490 push(@implContentInternals, " wrapper->commitChange();\n"); | 1545 $func .= " wrapper->commitChange();\n"; |
| 1491 } else { | 1546 } else { |
| 1492 push(@implContentInternals, " wrapper->commitChange();\n"); | 1547 $func .= " wrapper->commitChange();\n"; |
| 1493 } | 1548 } |
| 1494 } | 1549 } |
| 1495 | 1550 |
| 1496 if ($attribute->signature->type eq "SerializedScriptValue" && $attribute->si gnature->extendedAttributes->{"CachedAttribute"}) { | 1551 if ($attribute->signature->type eq "SerializedScriptValue" && $attribute->si gnature->extendedAttributes->{"CachedAttribute"}) { |
| 1497 push(@implContentInternals, <<END); | 1552 $func .= <<END; |
| 1498 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value. | 1553 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value. |
| 1499 END | 1554 END |
| 1500 } | 1555 } |
| 1501 | 1556 |
| 1502 push(@implContentInternals, " return;\n"); | 1557 $func .= " return;\n"; |
| 1503 push(@implContentInternals, "}\n\n"); # end of setter | 1558 $func .= "}\n\n"; # end of setter |
| 1504 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $condit ionalString; | 1559 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1560 AddToImplFunctionInternal($func); | |
| 1505 } | 1561 } |
| 1506 | 1562 |
| 1507 sub GenerateParametersCheckExpression | 1563 sub GenerateParametersCheckExpression |
| 1508 { | 1564 { |
| 1509 my $numParameters = shift; | 1565 my $numParameters = shift; |
| 1510 my $function = shift; | 1566 my $function = shift; |
| 1511 | 1567 |
| 1512 my @andExpression = (); | 1568 my @andExpression = (); |
| 1513 push(@andExpression, "args.Length() == $numParameters"); | 1569 push(@andExpression, "args.Length() == $numParameters"); |
| 1514 my $parameterIndex = 0; | 1570 my $parameterIndex = 0; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1585 # Generate code for choosing the correct overload to call. Overloads are | 1641 # Generate code for choosing the correct overload to call. Overloads are |
| 1586 # chosen based on the total number of arguments passed and the type of | 1642 # chosen based on the total number of arguments passed and the type of |
| 1587 # values passed in non-primitive argument slots. When more than a single | 1643 # values passed in non-primitive argument slots. When more than a single |
| 1588 # overload is applicable, precedence is given according to the order of | 1644 # overload is applicable, precedence is given according to the order of |
| 1589 # declaration in the IDL. | 1645 # declaration in the IDL. |
| 1590 | 1646 |
| 1591 my $name = $function->signature->name; | 1647 my $name = $function->signature->name; |
| 1592 | 1648 |
| 1593 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature); | 1649 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature); |
| 1594 my $leastNumMandatoryParams = 255; | 1650 my $leastNumMandatoryParams = 255; |
| 1595 push(@implContentInternals, "#if ${conditionalString}\n\n") if $conditionalS tring; | 1651 my $func = ""; |
| 1596 push(@implContentInternals, <<END); | 1652 $func .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 1653 $func .= <<END; | |
| 1597 static v8::Handle<v8::Value> ${name}Method${forMainWorldSuffix}(const v8::Argume nts& args) | 1654 static v8::Handle<v8::Value> ${name}Method${forMainWorldSuffix}(const v8::Argume nts& args) |
| 1598 { | 1655 { |
| 1599 END | 1656 END |
| 1600 push(@implContentInternals, GenerateFeatureObservation($function->signature- >extendedAttributes->{"MeasureAs"})); | 1657 $func .= GenerateFeatureObservation($function->signature->extendedAttributes ->{"MeasureAs"}); |
| 1601 | 1658 |
| 1602 foreach my $overload (@{$function->{overloads}}) { | 1659 foreach my $overload (@{$function->{overloads}}) { |
| 1603 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC heck($overload); | 1660 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC heck($overload); |
| 1604 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); | 1661 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); |
| 1605 push(@implContentInternals, " if ($parametersCheck)\n"); | 1662 $func .= " if ($parametersCheck)\n"; |
| 1606 my $overloadedIndexString = $overload->{overloadIndex}; | 1663 my $overloadedIndexString = $overload->{overloadIndex}; |
| 1607 push(@implContentInternals, " return ${name}${overloadedIndexStri ng}Method${forMainWorldSuffix}(args);\n"); | 1664 $func .= " return ${name}${overloadedIndexString}Method${forMainW orldSuffix}(args);\n"; |
| 1608 } | 1665 } |
| 1609 if ($leastNumMandatoryParams >= 1) { | 1666 if ($leastNumMandatoryParams >= 1) { |
| 1610 push(@implContentInternals, " if (args.Length() < $leastNumMandatoryP arams)\n"); | 1667 $func .= " if (args.Length() < $leastNumMandatoryParams)\n"; |
| 1611 push(@implContentInternals, " return throwNotEnoughArgumentsError (args.GetIsolate());\n"); | 1668 $func .= " return throwNotEnoughArgumentsError(args.GetIsolate()) ;\n"; |
| 1612 } | 1669 } |
| 1613 push(@implContentInternals, <<END); | 1670 $func .= <<END; |
| 1614 return throwTypeError(0, args.GetIsolate()); | 1671 return throwTypeError(0, args.GetIsolate()); |
| 1615 END | 1672 END |
| 1616 push(@implContentInternals, "}\n\n"); | 1673 $func .= "}\n\n"; |
| 1617 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $condit ionalString; | 1674 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1675 AddToImplFunctionInternal($func); | |
| 1618 } | 1676 } |
| 1619 | 1677 |
| 1620 sub GenerateFunctionCallback | 1678 sub GenerateFunctionCallback |
| 1621 { | 1679 { |
| 1622 my $function = shift; | 1680 my $function = shift; |
| 1623 my $interface = shift; | 1681 my $interface = shift; |
| 1624 my $forMainWorldSuffix = shift; | 1682 my $forMainWorldSuffix = shift; |
| 1625 | 1683 |
| 1626 my $interfaceName = $interface->name; | 1684 my $interfaceName = $interface->name; |
| 1627 my $v8InterfaceName = "V8$interfaceName"; | 1685 my $v8InterfaceName = "V8$interfaceName"; |
| 1628 my $name = $function->signature->name; | 1686 my $name = $function->signature->name; |
| 1629 | 1687 |
| 1630 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature); | 1688 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature); |
| 1631 push(@implContentInternals, "#if ${conditionalString}\n\n") if $conditionalS tring; | 1689 my $func = ""; |
| 1632 push(@implContentInternals, <<END); | 1690 $func .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 1691 $func .= <<END; | |
| 1633 static v8::Handle<v8::Value> ${name}MethodCallback${forMainWorldSuffix}(const v8 ::Arguments& args) | 1692 static v8::Handle<v8::Value> ${name}MethodCallback${forMainWorldSuffix}(const v8 ::Arguments& args) |
| 1634 { | 1693 { |
| 1635 END | 1694 END |
| 1636 push(@implContentInternals, GenerateFeatureObservation($function->signature- >extendedAttributes->{"MeasureAs"})); | 1695 $func .= GenerateFeatureObservation($function->signature->extendedAttributes ->{"MeasureAs"}); |
| 1637 if (HasCustomMethod($function->signature->extendedAttributes)) { | 1696 if (HasCustomMethod($function->signature->extendedAttributes)) { |
| 1638 push(@implContentInternals, " return ${v8InterfaceName}::${name}Metho dCustom(args);\n"); | 1697 $func .= " return ${v8InterfaceName}::${name}MethodCustom(args);\n"; |
| 1639 } else { | 1698 } else { |
| 1640 push(@implContentInternals, " return ${interfaceName}V8Internal::${na me}Method${forMainWorldSuffix}(args);\n"); | 1699 $func .= " return ${interfaceName}V8Internal::${name}Method${forMainW orldSuffix}(args);\n"; |
| 1641 } | 1700 } |
| 1642 push(@implContentInternals, "}\n\n"); | 1701 $func .= "}\n\n"; |
| 1643 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $condit ionalString; | 1702 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1703 AddToImplFunctionInternal($func); | |
| 1644 } | 1704 } |
| 1645 | 1705 |
| 1646 sub GenerateFunction | 1706 sub GenerateFunction |
| 1647 { | 1707 { |
| 1648 my $function = shift; | 1708 my $function = shift; |
| 1649 my $interface = shift; | 1709 my $interface = shift; |
| 1650 my $forMainWorldSuffix = shift; | 1710 my $forMainWorldSuffix = shift; |
| 1651 | 1711 |
| 1652 my $interfaceName = $interface->name; | 1712 my $interfaceName = $interface->name; |
| 1653 my $v8InterfaceName = "V8$interfaceName"; | 1713 my $v8InterfaceName = "V8$interfaceName"; |
| 1654 my $name = $function->signature->name; | 1714 my $name = $function->signature->name; |
| 1655 my $funcExt = $function->signature->extendedAttributes; | 1715 my $funcExt = $function->signature->extendedAttributes; |
| 1656 | 1716 |
| 1657 if (HasCustomMethod($funcExt)) { | 1717 if (HasCustomMethod($funcExt)) { |
| 1658 return; | 1718 return; |
| 1659 } | 1719 } |
| 1660 | 1720 |
| 1661 if (@{$function->{overloads}} > 1) { | 1721 if (@{$function->{overloads}} > 1) { |
| 1662 # Append a number to an overloaded method's name to make it unique: | 1722 # Append a number to an overloaded method's name to make it unique: |
| 1663 $name = $name . $function->{overloadIndex}; | 1723 $name = $name . $function->{overloadIndex}; |
| 1664 } | 1724 } |
| 1665 | 1725 |
| 1666 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature); | 1726 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature); |
| 1667 push(@implContentInternals, "#if ${conditionalString}\n\n") if $conditionalS tring; | 1727 my $func = ""; |
| 1668 push(@implContentInternals, "static v8::Handle<v8::Value> ${name}Method${for MainWorldSuffix}(const v8::Arguments& args)\n"); | 1728 $func .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 1669 push(@implContentInternals, "{\n"); | 1729 $func .= "static v8::Handle<v8::Value> ${name}Method${forMainWorldSuffix}(co nst v8::Arguments& args)\n"; |
| 1730 $func .= "{\n"; | |
| 1670 | 1731 |
| 1671 if ($name eq "addEventListener" || $name eq "removeEventListener") { | 1732 if ($name eq "addEventListener" || $name eq "removeEventListener") { |
| 1672 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; | 1733 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; |
| 1673 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; | 1734 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; |
| 1674 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove"; | 1735 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove"; |
| 1675 | 1736 |
| 1676 AddToImplIncludes("V8EventListenerList.h"); | 1737 AddToImplIncludes("V8EventListenerList.h"); |
| 1677 push(@implContentInternals, <<END); | 1738 $func .= <<END; |
| 1678 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(args[ 1], false, ListenerFind${lookupType}); | 1739 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(args[ 1], false, ListenerFind${lookupType}); |
| 1679 if (listener) { | 1740 if (listener) { |
| 1680 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<WithNullCheck>, stringR esource, args[0]); | 1741 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<WithNullCheck>, stringR esource, args[0]); |
| 1681 V8${interfaceName}::toNative(args.Holder())->${name}(stringResource, lis tener${passRefPtrHandling}, args[2]->BooleanValue()); | 1742 V8${interfaceName}::toNative(args.Holder())->${name}(stringResource, lis tener${passRefPtrHandling}, args[2]->BooleanValue()); |
| 1682 END | 1743 END |
| 1683 if (!$codeGenerator->InheritsInterface($interface, "Node")) { | 1744 if (!$codeGenerator->InheritsInterface($interface, "Node")) { |
| 1684 push(@implContentInternals, <<END); | 1745 $func .= <<END; |
| 1685 ${hiddenDependencyAction}HiddenDependency(args.Holder(), args[1], V8${in terfaceName}::eventListenerCacheIndex, args.GetIsolate()); | 1746 ${hiddenDependencyAction}HiddenDependency(args.Holder(), args[1], V8${in terfaceName}::eventListenerCacheIndex, args.GetIsolate()); |
| 1686 END | 1747 END |
| 1687 } | 1748 } |
| 1688 push(@implContentInternals, <<END); | 1749 $func .= <<END; |
| 1689 } | 1750 } |
| 1690 return v8Undefined(); | 1751 return v8Undefined(); |
| 1691 } | 1752 } |
| 1692 | 1753 |
| 1693 END | 1754 END |
| 1694 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $co nditionalString; | 1755 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1756 AddToImplFunctionInternal($func); | |
| 1695 return; | 1757 return; |
| 1696 } | 1758 } |
| 1697 | 1759 |
| 1698 push(@implContentInternals, GenerateArgumentsCountCheck($function, $interfac e)); | 1760 $func .= GenerateArgumentsCountCheck($function, $interface); |
| 1699 | 1761 |
| 1700 if ($name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { | 1762 if ($name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { |
| 1701 AddToImplIncludes("V8ArrayBufferViewCustom.h"); | 1763 AddToImplIncludes("V8ArrayBufferViewCustom.h"); |
| 1702 push(@implContentInternals, <<END); | 1764 $func .= <<END; |
| 1703 return setWebGLArrayHelper<$interfaceName, ${v8InterfaceName}>(args); | 1765 return setWebGLArrayHelper<$interfaceName, ${v8InterfaceName}>(args); |
| 1704 } | 1766 } |
| 1705 | 1767 |
| 1706 END | 1768 END |
| 1769 AddToImplFunctionInternal($func); | |
| 1707 return; | 1770 return; |
| 1708 } | 1771 } |
| 1709 | 1772 |
| 1710 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); | 1773 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); |
| 1711 | 1774 |
| 1712 if ($svgNativeType) { | 1775 if ($svgNativeType) { |
| 1713 my $nativeClassName = GetNativeType($interfaceName); | 1776 my $nativeClassName = GetNativeType($interfaceName); |
| 1714 if ($interfaceName =~ /List$/) { | 1777 if ($interfaceName =~ /List$/) { |
| 1715 push(@implContentInternals, " $nativeClassName imp = ${v8Interfac eName}::toNative(args.Holder());\n"); | 1778 $func .= " $nativeClassName imp = ${v8InterfaceName}::toNative(ar gs.Holder());\n"; |
| 1716 } else { | 1779 } else { |
| 1717 AddToImplIncludes("ExceptionCode.h"); | 1780 AddToImplIncludes("ExceptionCode.h"); |
| 1718 push(@implContentInternals, " $nativeClassName wrapper = ${v8Inte rfaceName}::toNative(args.Holder());\n"); | 1781 $func .= " $nativeClassName wrapper = ${v8InterfaceName}::toNativ e(args.Holder());\n"; |
| 1719 push(@implContentInternals, " if (wrapper->isReadOnly())\n"); | 1782 $func .= " if (wrapper->isReadOnly())\n"; |
| 1720 push(@implContentInternals, " return setDOMException(NO_MODIF ICATION_ALLOWED_ERR, args.GetIsolate());\n"); | 1783 $func .= " return setDOMException(NO_MODIFICATION_ALLOWED_ERR , args.GetIsolate());\n"; |
| 1721 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingT earOff($interfaceName); | 1784 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingT earOff($interfaceName); |
| 1722 push(@implContentInternals, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n"); | 1785 $func .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; |
| 1723 push(@implContentInternals, " $svgWrappedNativeType* imp = &impIn stance;\n"); | 1786 $func .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
| 1724 } | 1787 } |
| 1725 } elsif (!$function->isStatic) { | 1788 } elsif (!$function->isStatic) { |
| 1726 push(@implContentInternals, <<END); | 1789 $func .= <<END; |
| 1727 ${interfaceName}* imp = ${v8InterfaceName}::toNative(args.Holder()); | 1790 ${interfaceName}* imp = ${v8InterfaceName}::toNative(args.Holder()); |
| 1728 END | 1791 END |
| 1729 } | 1792 } |
| 1730 | 1793 |
| 1731 GenerateCustomElementInvocationScopeIfNeeded(\@implContentInternals, $funcEx t); | 1794 $func .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); |
| 1732 | 1795 |
| 1733 # Check domain security if needed | 1796 # Check domain security if needed |
| 1734 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->signatu re->extendedAttributes->{"DoNotCheckSecurity"}) { | 1797 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->signatu re->extendedAttributes->{"DoNotCheckSecurity"}) { |
| 1735 # We have not find real use cases yet. | 1798 # We have not find real use cases yet. |
| 1736 AddToImplIncludes("Frame.h"); | 1799 AddToImplIncludes("Frame.h"); |
| 1737 push(@implContentInternals, <<END); | 1800 $func .= <<END; |
| 1738 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) | 1801 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame())) |
| 1739 return v8Undefined(); | 1802 return v8Undefined(); |
| 1740 END | 1803 END |
| 1741 } | 1804 } |
| 1742 | 1805 |
| 1743 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"}; | 1806 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"}; |
| 1744 if (!$raisesExceptions) { | 1807 if (!$raisesExceptions) { |
| 1745 foreach my $parameter (@{$function->parameters}) { | 1808 foreach my $parameter (@{$function->parameters}) { |
| 1746 if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailCo nversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { | 1809 if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailCo nversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { |
| 1747 $raisesExceptions = 1; | 1810 $raisesExceptions = 1; |
| 1748 } | 1811 } |
| 1749 } | 1812 } |
| 1750 } | 1813 } |
| 1751 | 1814 |
| 1752 if ($raisesExceptions) { | 1815 if ($raisesExceptions) { |
| 1753 AddToImplIncludes("ExceptionCode.h"); | 1816 AddToImplIncludes("ExceptionCode.h"); |
| 1754 push(@implContentInternals, " ExceptionCode ec = 0;\n"); | 1817 $func .= " ExceptionCode ec = 0;\n"; |
| 1755 push(@implContentInternals, " {\n"); | 1818 $func .= " {\n"; |
| 1756 # The brace here is needed to prevent the ensuing 'goto fail's from jump ing past constructors | 1819 # The brace here is needed to prevent the ensuing 'goto fail's from jump ing past constructors |
| 1757 # of objects (like Strings) declared later, causing compile errors. The block scope ends | 1820 # of objects (like Strings) declared later, causing compile errors. The block scope ends |
| 1758 # right before the label 'fail:'. | 1821 # right before the label 'fail:'. |
| 1759 } | 1822 } |
| 1760 | 1823 |
| 1761 if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { | 1824 if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { |
| 1762 push(@implContentInternals, " if (!BindingSecurity::shouldAllowAccess ToNode(BindingState::instance(), imp->" . $function->signature->name . "(ec)))\n "); | 1825 $func .= " if (!BindingSecurity::shouldAllowAccessToNode(BindingState ::instance(), imp->" . $function->signature->name . "(ec)))\n"; |
| 1763 push(@implContentInternals, " return v8::Handle<v8::Value>(v8Null (args.GetIsolate()));\n"); | 1826 $func .= " return v8::Handle<v8::Value>(v8Null(args.GetIsolate()) );\n"; |
| 1764 END | 1827 END |
| 1765 } | 1828 } |
| 1766 | 1829 |
| 1767 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName, $forMainWorldSuffix); | 1830 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName, $forMainWorldSuffix); |
| 1768 push(@implContentInternals, $parameterCheckString); | 1831 $func .= $parameterCheckString; |
| 1769 | 1832 |
| 1770 # Build the function call string. | 1833 # Build the function call string. |
| 1771 push(@implContentInternals, GenerateFunctionCallString($function, $paramInde x, " ", $interfaceName, $forMainWorldSuffix, %replacements)); | 1834 $func .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ceName, $forMainWorldSuffix, %replacements); |
| 1772 | 1835 |
| 1773 if ($raisesExceptions) { | 1836 if ($raisesExceptions) { |
| 1774 push(@implContentInternals, " }\n"); | 1837 $func .= " }\n"; |
| 1775 push(@implContentInternals, " fail:\n"); | 1838 $func .= " fail:\n"; |
| 1776 push(@implContentInternals, " return setDOMException(ec, args.GetIsol ate());\n"); | 1839 $func .= " return setDOMException(ec, args.GetIsolate());\n"; |
| 1777 } | 1840 } |
| 1778 | 1841 |
| 1779 push(@implContentInternals, "}\n\n"); | 1842 $func .= "}\n\n"; |
| 1780 push(@implContentInternals, "#endif // ${conditionalString}\n\n") if $condit ionalString; | 1843 $func .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 1844 AddToImplFunctionInternal($func); | |
| 1781 } | 1845 } |
| 1782 | 1846 |
| 1783 sub GenerateCallWith | 1847 sub GenerateCallWith |
| 1784 { | 1848 { |
| 1785 my $callWith = shift; | 1849 my $callWith = shift; |
| 1786 return () unless $callWith; | 1850 return ([], "") unless $callWith; |
| 1787 my $outputArray = shift; | |
| 1788 my $indent = shift; | 1851 my $indent = shift; |
| 1789 my $returnVoid = shift; | 1852 my $returnVoid = shift; |
| 1790 my $function = shift; | 1853 my $function = shift; |
| 1854 my $code = ""; | |
| 1791 | 1855 |
| 1792 my @callWithArgs; | 1856 my @callWithArgs; |
| 1793 if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) { | 1857 if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) { |
| 1794 push(@$outputArray, $indent . "ScriptState* currentState = ScriptState:: current();\n"); | 1858 $code .= $indent . "ScriptState* currentState = ScriptState::current();\ n"; |
| 1795 push(@$outputArray, $indent . "if (!currentState)\n"); | 1859 $code .= $indent . "if (!currentState)\n"; |
| 1796 push(@$outputArray, $indent . " return" . ($returnVoid ? "" : " v8Und efined()") . ";\n"); | 1860 $code .= $indent . " return" . ($returnVoid ? "" : " v8Undefined()") . ";\n"; |
| 1797 push(@$outputArray, $indent . "ScriptState& state = *currentState;\n"); | 1861 $code .= $indent . "ScriptState& state = *currentState;\n"; |
| 1798 push(@callWithArgs, "&state"); | 1862 push(@callWithArgs, "&state"); |
| 1799 } | 1863 } |
| 1800 if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionCon text")) { | 1864 if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionCon text")) { |
| 1801 push(@$outputArray, $indent . "ScriptExecutionContext* scriptContext = g etScriptExecutionContext();\n"); | 1865 $code .= $indent . "ScriptExecutionContext* scriptContext = getScriptExe cutionContext();\n"; |
| 1802 push(@callWithArgs, "scriptContext"); | 1866 push(@callWithArgs, "scriptContext"); |
| 1803 } | 1867 } |
| 1804 if ($function and $codeGenerator->ExtendedAttributeContains($callWith, "Scri ptArguments")) { | 1868 if ($function and $codeGenerator->ExtendedAttributeContains($callWith, "Scri ptArguments")) { |
| 1805 push(@$outputArray, $indent . "RefPtr<ScriptArguments> scriptArguments(c reateScriptArguments(args, " . @{$function->parameters} . "));\n"); | 1869 $code .= $indent . "RefPtr<ScriptArguments> scriptArguments(createScript Arguments(args, " . @{$function->parameters} . "));\n"; |
| 1806 push(@callWithArgs, "scriptArguments.release()"); | 1870 push(@callWithArgs, "scriptArguments.release()"); |
| 1807 AddToImplIncludes("ScriptArguments.h"); | 1871 AddToImplIncludes("ScriptArguments.h"); |
| 1808 AddToImplIncludes("ScriptCallStackFactory.h"); | 1872 AddToImplIncludes("ScriptCallStackFactory.h"); |
| 1809 } | 1873 } |
| 1810 return @callWithArgs; | 1874 return ([@callWithArgs], $code); |
| 1811 } | 1875 } |
| 1812 | 1876 |
| 1813 sub GenerateArgumentsCountCheck | 1877 sub GenerateArgumentsCountCheck |
| 1814 { | 1878 { |
| 1815 my $function = shift; | 1879 my $function = shift; |
| 1816 my $interface = shift; | 1880 my $interface = shift; |
| 1817 | 1881 |
| 1818 my $numMandatoryParams = 0; | 1882 my $numMandatoryParams = 0; |
| 1819 my $allowNonOptional = 1; | 1883 my $allowNonOptional = 1; |
| 1820 foreach my $param (@{$function->parameters}) { | 1884 foreach my $param (@{$function->parameters}) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2022 $paramIndex++; | 2086 $paramIndex++; |
| 2023 } | 2087 } |
| 2024 return ($parameterCheckString, $paramIndex, %replacements); | 2088 return ($parameterCheckString, $paramIndex, %replacements); |
| 2025 } | 2089 } |
| 2026 | 2090 |
| 2027 sub GenerateOverloadedConstructorCallback | 2091 sub GenerateOverloadedConstructorCallback |
| 2028 { | 2092 { |
| 2029 my $interface = shift; | 2093 my $interface = shift; |
| 2030 my $interfaceName = $interface->name; | 2094 my $interfaceName = $interface->name; |
| 2031 | 2095 |
| 2032 push(@implContentInternals, <<END); | 2096 my $func = ""; |
| 2097 $func .= <<END; | |
| 2033 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2098 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) |
| 2034 { | 2099 { |
| 2035 END | 2100 END |
| 2036 my $leastNumMandatoryParams = 255; | 2101 my $leastNumMandatoryParams = 255; |
| 2037 foreach my $constructor (@{$interface->constructors}) { | 2102 foreach my $constructor (@{$interface->constructors}) { |
| 2038 my $name = "constructor" . $constructor->{overloadedIndex}; | 2103 my $name = "constructor" . $constructor->{overloadedIndex}; |
| 2039 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC heck($constructor); | 2104 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC heck($constructor); |
| 2040 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); | 2105 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams); |
| 2041 push(@implContentInternals, " if ($parametersCheck)\n"); | 2106 $func .= " if ($parametersCheck)\n"; |
| 2042 push(@implContentInternals, " return ${interfaceName}V8Internal:: ${name}(args);\n"); | 2107 $func .= " return ${interfaceName}V8Internal::${name}(args);\n"; |
| 2043 } | 2108 } |
| 2044 if ($leastNumMandatoryParams >= 1) { | 2109 if ($leastNumMandatoryParams >= 1) { |
| 2045 push(@implContentInternals, " if (args.Length() < $leastNumMandatoryP arams)\n"); | 2110 $func .= " if (args.Length() < $leastNumMandatoryParams)\n"; |
| 2046 push(@implContentInternals, " return throwNotEnoughArgumentsError (args.GetIsolate());\n"); | 2111 $func .= " return throwNotEnoughArgumentsError(args.GetIsolate()) ;\n"; |
| 2047 } | 2112 } |
| 2048 push(@implContentInternals, <<END); | 2113 $func .= <<END; |
| 2049 return throwTypeError(0, args.GetIsolate()); | 2114 return throwTypeError(0, args.GetIsolate()); |
| 2050 END | 2115 END |
| 2051 push(@implContentInternals, "}\n\n"); | 2116 $func .= "}\n\n"; |
| 2117 AddToImplFunctionInternal($func); | |
| 2052 } | 2118 } |
| 2053 | 2119 |
| 2054 sub GenerateSingleConstructorCallback | 2120 sub GenerateSingleConstructorCallback |
| 2055 { | 2121 { |
| 2056 my $interface = shift; | 2122 my $interface = shift; |
| 2057 my $function = shift; | 2123 my $function = shift; |
| 2058 | 2124 |
| 2059 my $interfaceName = $interface->name; | 2125 my $interfaceName = $interface->name; |
| 2060 my $overloadedIndexString = ""; | 2126 my $overloadedIndexString = ""; |
| 2061 if ($function->{overloadedIndex} > 0) { | 2127 if ($function->{overloadedIndex} > 0) { |
| 2062 $overloadedIndexString .= $function->{overloadedIndex}; | 2128 $overloadedIndexString .= $function->{overloadedIndex}; |
| 2063 } | 2129 } |
| 2064 | 2130 |
| 2065 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"}; | 2131 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"}; |
| 2066 if ($interface->extendedAttributes->{"RaisesException"}) { | 2132 if ($interface->extendedAttributes->{"RaisesException"}) { |
| 2067 $raisesExceptions = 1; | 2133 $raisesExceptions = 1; |
| 2068 } | 2134 } |
| 2069 if (!$raisesExceptions) { | 2135 if (!$raisesExceptions) { |
| 2070 foreach my $parameter (@{$function->parameters}) { | 2136 foreach my $parameter (@{$function->parameters}) { |
| 2071 if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailCo nversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { | 2137 if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailCo nversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { |
| 2072 $raisesExceptions = 1; | 2138 $raisesExceptions = 1; |
| 2073 } | 2139 } |
| 2074 } | 2140 } |
| 2075 } | 2141 } |
| 2076 | 2142 |
| 2077 my @beforeArgumentList; | 2143 my @beforeArgumentList; |
| 2078 my @afterArgumentList; | 2144 my @afterArgumentList; |
| 2079 push(@implContentInternals, <<END); | 2145 my $func = ""; |
| 2146 $func .= <<END; | |
| 2080 static v8::Handle<v8::Value> constructor${overloadedIndexString}(const v8::Argum ents& args) | 2147 static v8::Handle<v8::Value> constructor${overloadedIndexString}(const v8::Argum ents& args) |
| 2081 { | 2148 { |
| 2082 END | 2149 END |
| 2083 | 2150 |
| 2084 if ($function->{overloadedIndex} == 0) { | 2151 if ($function->{overloadedIndex} == 0) { |
| 2085 push(@implContentInternals, GenerateArgumentsCountCheck($function, $inte rface)); | 2152 $func .= GenerateArgumentsCountCheck($function, $interface); |
| 2086 } | 2153 } |
| 2087 | 2154 |
| 2088 if ($raisesExceptions) { | 2155 if ($raisesExceptions) { |
| 2089 AddToImplIncludes("ExceptionCode.h"); | 2156 AddToImplIncludes("ExceptionCode.h"); |
| 2090 push(@implContentInternals, "\n"); | 2157 $func .= "\n"; |
| 2091 push(@implContentInternals, " ExceptionCode ec = 0;\n"); | 2158 $func .= " ExceptionCode ec = 0;\n"; |
| 2092 } | 2159 } |
| 2093 | 2160 |
| 2094 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] | 2161 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] |
| 2095 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName, ""); | 2162 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName, ""); |
| 2096 push(@implContentInternals, $parameterCheckString); | 2163 $func .= $parameterCheckString; |
| 2097 | 2164 |
| 2098 if ($interface->extendedAttributes->{"CallWith"} && $interface->extendedAttr ibutes->{"CallWith"} eq "ScriptExecutionContext") { | 2165 if ($interface->extendedAttributes->{"CallWith"} && $interface->extendedAttr ibutes->{"CallWith"} eq "ScriptExecutionContext") { |
| 2099 push(@beforeArgumentList, "context"); | 2166 push(@beforeArgumentList, "context"); |
| 2100 push(@implContentInternals, <<END); | 2167 $func .= <<END; |
| 2101 | 2168 |
| 2102 ScriptExecutionContext* context = getScriptExecutionContext(); | 2169 ScriptExecutionContext* context = getScriptExecutionContext(); |
| 2103 END | 2170 END |
| 2104 } | 2171 } |
| 2105 | 2172 |
| 2106 if ($interface->extendedAttributes->{"RaisesException"}) { | 2173 if ($interface->extendedAttributes->{"RaisesException"}) { |
| 2107 push(@afterArgumentList, "ec"); | 2174 push(@afterArgumentList, "ec"); |
| 2108 } | 2175 } |
| 2109 | 2176 |
| 2110 my @argumentList; | 2177 my @argumentList; |
| 2111 my $index = 0; | 2178 my $index = 0; |
| 2112 foreach my $parameter (@{$function->parameters}) { | 2179 foreach my $parameter (@{$function->parameters}) { |
| 2113 last if $index eq $paramIndex; | 2180 last if $index eq $paramIndex; |
| 2114 if ($replacements{$parameter->name}) { | 2181 if ($replacements{$parameter->name}) { |
| 2115 push(@argumentList, $replacements{$parameter->name}); | 2182 push(@argumentList, $replacements{$parameter->name}); |
| 2116 } else { | 2183 } else { |
| 2117 push(@argumentList, $parameter->name); | 2184 push(@argumentList, $parameter->name); |
| 2118 } | 2185 } |
| 2119 $index++; | 2186 $index++; |
| 2120 } | 2187 } |
| 2121 | 2188 |
| 2122 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); | 2189 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); |
| 2123 push(@implContentInternals, "\n"); | 2190 $func .= "\n"; |
| 2124 push(@implContentInternals, " RefPtr<${interfaceName}> impl = ${interface Name}::create(${argumentString});\n"); | 2191 $func .= " RefPtr<${interfaceName}> impl = ${interfaceName}::create(${arg umentString});\n"; |
| 2125 push(@implContentInternals, " v8::Handle<v8::Object> wrapper = args.Holde r();\n"); | 2192 $func .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; |
| 2126 | 2193 |
| 2127 if ($interface->extendedAttributes->{"RaisesException"}) { | 2194 if ($interface->extendedAttributes->{"RaisesException"}) { |
| 2128 push(@implContentInternals, " if (ec)\n"); | 2195 $func .= " if (ec)\n"; |
| 2129 push(@implContentInternals, " goto fail;\n"); | 2196 $func .= " goto fail;\n"; |
| 2130 } | 2197 } |
| 2131 | 2198 |
| 2132 push(@implContentInternals, <<END); | 2199 $func .= <<END; |
| 2133 | 2200 |
| 2134 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &V8${interfaceName} ::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); | 2201 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &V8${interfaceName} ::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); |
| 2135 return wrapper; | 2202 return wrapper; |
| 2136 END | 2203 END |
| 2137 | 2204 |
| 2138 if ($raisesExceptions) { | 2205 if ($raisesExceptions) { |
| 2139 push(@implContentInternals, " fail:\n"); | 2206 $func .= " fail:\n"; |
| 2140 push(@implContentInternals, " return setDOMException(ec, args.GetIsol ate());\n"); | 2207 $func .= " return setDOMException(ec, args.GetIsolate());\n"; |
| 2141 } | 2208 } |
| 2142 | 2209 |
| 2143 push(@implContentInternals, "}\n"); | 2210 $func .= "}\n"; |
| 2144 push(@implContentInternals, "\n"); | 2211 $func .= "\n"; |
| 2212 AddToImplFunctionInternal($func); | |
| 2145 } | 2213 } |
| 2146 | 2214 |
| 2147 sub GenerateConstructorCallback | 2215 sub GenerateConstructorCallback |
| 2148 { | 2216 { |
| 2149 my $interface = shift; | 2217 my $interface = shift; |
| 2150 | 2218 |
| 2151 my $interfaceName = $interface->name; | 2219 my $interfaceName = $interface->name; |
| 2152 push(@implContent, "v8::Handle<v8::Value> V8${interfaceName}::constructorCal lback(const v8::Arguments& args)\n"); | 2220 my $func = ""; |
| 2153 push(@implContent, "{\n"); | 2221 $func .= "v8::Handle<v8::Value> V8${interfaceName}::constructorCallback(cons t v8::Arguments& args)\n"; |
| 2154 push(@implContent, GenerateFeatureObservation($interface->extendedAttributes ->{"MeasureAs"})); | 2222 $func .= "{\n"; |
| 2155 push(@implContent, GenerateConstructorHeader()); | 2223 $func .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"}); |
| 2224 $func .= GenerateConstructorHeader(); | |
| 2156 if (HasCustomConstructor($interface)) { | 2225 if (HasCustomConstructor($interface)) { |
| 2157 push(@implContent, " return V8${interfaceName}::constructorCustom(arg s);\n"); | 2226 $func .= " return V8${interfaceName}::constructorCustom(args);\n"; |
| 2158 } else { | 2227 } else { |
| 2159 push(@implContent, " return ${interfaceName}V8Internal::constructor(a rgs);\n"); | 2228 $func .= " return ${interfaceName}V8Internal::constructor(args);\n"; |
| 2160 } | 2229 } |
| 2161 push(@implContent, "}\n\n"); | 2230 $func .= "}\n\n"; |
| 2231 AddToImplFunction($func); | |
| 2162 } | 2232 } |
| 2163 | 2233 |
| 2164 sub GenerateConstructor | 2234 sub GenerateConstructor |
| 2165 { | 2235 { |
| 2166 my $interface = shift; | 2236 my $interface = shift; |
| 2167 my $interfaceName = $interface->name; | 2237 my $interfaceName = $interface->name; |
| 2168 | 2238 |
| 2169 if (@{$interface->constructors} == 1) { | 2239 if (@{$interface->constructors} == 1) { |
| 2170 GenerateSingleConstructorCallback($interface, @{$interface->constructors }[0]); | 2240 GenerateSingleConstructorCallback($interface, @{$interface->constructors }[0]); |
| 2171 } else { | 2241 } else { |
| 2172 foreach my $constructor (@{$interface->constructors}) { | 2242 foreach my $constructor (@{$interface->constructors}) { |
| 2173 GenerateSingleConstructorCallback($interface, $constructor); | 2243 GenerateSingleConstructorCallback($interface, $constructor); |
| 2174 } | 2244 } |
| 2175 GenerateOverloadedConstructorCallback($interface); | 2245 GenerateOverloadedConstructorCallback($interface); |
| 2176 } | 2246 } |
| 2177 } | 2247 } |
| 2178 | 2248 |
| 2179 sub GenerateEventConstructor | 2249 sub GenerateEventConstructor |
| 2180 { | 2250 { |
| 2181 my $interface = shift; | 2251 my $interface = shift; |
| 2182 my $interfaceName = $interface->name; | 2252 my $interfaceName = $interface->name; |
| 2183 | 2253 |
| 2184 AddToImplIncludes("Dictionary.h"); | 2254 AddToImplIncludes("Dictionary.h"); |
| 2185 push(@implContentInternals, <<END); | 2255 AddToImplFunctionInternal(<<END); |
| 2186 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2256 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) |
| 2187 { | 2257 { |
| 2188 END | |
| 2189 push(@implContentInternals, <<END); | |
| 2190 if (args.Length() < 1) | 2258 if (args.Length() < 1) |
| 2191 return throwNotEnoughArgumentsError(args.GetIsolate()); | 2259 return throwNotEnoughArgumentsError(args.GetIsolate()); |
| 2192 | 2260 |
| 2193 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]); | 2261 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]); |
| 2194 ${interfaceName}Init eventInit; | 2262 ${interfaceName}Init eventInit; |
| 2195 if (args.Length() >= 2) { | 2263 if (args.Length() >= 2) { |
| 2196 V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate())); | 2264 V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate())); |
| 2197 if (!fill${interfaceName}Init(eventInit, options)) | 2265 if (!fill${interfaceName}Init(eventInit, options)) |
| 2198 return v8Undefined(); | 2266 return v8Undefined(); |
| 2199 } | 2267 } |
| 2200 | 2268 |
| 2201 RefPtr<${interfaceName}> event = ${interfaceName}::create(type, eventInit); | 2269 RefPtr<${interfaceName}> event = ${interfaceName}::create(type, eventInit); |
| 2202 | 2270 |
| 2203 v8::Handle<v8::Object> wrapper = args.Holder(); | 2271 v8::Handle<v8::Object> wrapper = args.Holder(); |
| 2204 V8DOMWrapper::associateObjectWithWrapper(event.release(), &V8${interfaceName }::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); | 2272 V8DOMWrapper::associateObjectWithWrapper(event.release(), &V8${interfaceName }::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); |
| 2205 return wrapper; | 2273 return wrapper; |
| 2206 } | 2274 } |
| 2207 END | 2275 END |
| 2208 | 2276 |
| 2209 push(@implContent, <<END); | 2277 my $func = ""; |
| 2278 $func .= <<END; | |
| 2210 bool fill${interfaceName}Init(${interfaceName}Init& eventInit, const Dictionary& options) | 2279 bool fill${interfaceName}Init(${interfaceName}Init& eventInit, const Dictionary& options) |
| 2211 { | 2280 { |
| 2212 END | 2281 END |
| 2213 | 2282 |
| 2214 foreach my $interfaceBase (@{$interface->parents}) { | 2283 foreach my $interfaceBase (@{$interface->parents}) { |
| 2215 push(@implContent, <<END); | 2284 $func .= <<END; |
| 2216 if (!fill${interfaceBase}Init(eventInit, options)) | 2285 if (!fill${interfaceBase}Init(eventInit, options)) |
| 2217 return false; | 2286 return false; |
| 2218 | 2287 |
| 2219 END | 2288 END |
| 2220 } | 2289 } |
| 2221 | 2290 |
| 2222 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 2291 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
| 2223 my $attribute = @{$interface->attributes}[$index]; | 2292 my $attribute = @{$interface->attributes}[$index]; |
| 2224 if ($attribute->signature->extendedAttributes->{"InitializedByEventConst ructor"}) { | 2293 if ($attribute->signature->extendedAttributes->{"InitializedByEventConst ructor"}) { |
| 2225 my $attributeName = $attribute->signature->name; | 2294 my $attributeName = $attribute->signature->name; |
| 2226 push(@implContent, " options.get(\"$attributeName\", eventInit.$a ttributeName);\n"); | 2295 $func .= " options.get(\"$attributeName\", eventInit.$attributeNa me);\n"; |
| 2227 } | 2296 } |
| 2228 } | 2297 } |
| 2229 | 2298 |
| 2230 push(@implContent, <<END); | 2299 $func .= <<END; |
| 2231 return true; | 2300 return true; |
| 2232 } | 2301 } |
| 2233 | 2302 |
| 2234 END | 2303 END |
| 2304 AddToImplFunction($func); | |
| 2235 } | 2305 } |
| 2236 | 2306 |
| 2237 sub GenerateTypedArrayConstructor | 2307 sub GenerateTypedArrayConstructor |
| 2238 { | 2308 { |
| 2239 my $interface = shift; | 2309 my $interface = shift; |
| 2240 my $interfaceName = $interface->name; | 2310 my $interfaceName = $interface->name; |
| 2241 my $viewType = GetTypeNameOfExternalTypedArray($interface); | 2311 my $viewType = GetTypeNameOfExternalTypedArray($interface); |
| 2242 my $type = $interface->extendedAttributes->{"TypedArray"}; | 2312 my $type = $interface->extendedAttributes->{"TypedArray"}; |
| 2243 AddToImplIncludes("V8ArrayBufferViewCustom.h"); | 2313 AddToImplIncludes("V8ArrayBufferViewCustom.h"); |
| 2244 | 2314 |
| 2245 push(@implContentInternals, <<END); | 2315 AddToImplFunctionInternal(<<END); |
| 2246 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2316 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) |
| 2247 { | 2317 { |
| 2248 return constructWebGLArray<$interfaceName, V8${interfaceName}, $type>(args, &V8${interfaceName}::info, $viewType); | 2318 return constructWebGLArray<$interfaceName, V8${interfaceName}, $type>(args, &V8${interfaceName}::info, $viewType); |
| 2249 } | 2319 } |
| 2250 | 2320 |
| 2251 END | 2321 END |
| 2252 } | 2322 } |
| 2253 | 2323 |
| 2254 sub GenerateNamedConstructor | 2324 sub GenerateNamedConstructor |
| 2255 { | 2325 { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2279 if ($codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") ) { | 2349 if ($codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") ) { |
| 2280 $toActiveDOMObject = "${v8InterfaceName}::toActiveDOMObject"; | 2350 $toActiveDOMObject = "${v8InterfaceName}::toActiveDOMObject"; |
| 2281 } | 2351 } |
| 2282 | 2352 |
| 2283 my $toEventTarget = "0"; | 2353 my $toEventTarget = "0"; |
| 2284 if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { | 2354 if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { |
| 2285 $toEventTarget = "${v8InterfaceName}::toEventTarget"; | 2355 $toEventTarget = "${v8InterfaceName}::toEventTarget"; |
| 2286 } | 2356 } |
| 2287 | 2357 |
| 2288 AddToImplIncludes("Frame.h"); | 2358 AddToImplIncludes("Frame.h"); |
| 2289 push(@implContent, <<END); | 2359 AddToImplStuff(<<END); |
| 2290 WrapperTypeInfo ${v8InterfaceName}Constructor::info = { ${v8InterfaceName}Constr uctor::GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObject, $toEven tTarget, 0, ${v8InterfaceName}::installPerContextPrototypeProperties, 0, Wrapper TypeObjectPrototype }; | 2360 WrapperTypeInfo ${v8InterfaceName}Constructor::info = { ${v8InterfaceName}Constr uctor::GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObject, $toEven tTarget, 0, ${v8InterfaceName}::installPerContextPrototypeProperties, 0, Wrapper TypeObjectPrototype }; |
| 2291 | 2361 |
| 2362 END | |
| 2363 | |
| 2364 my $func = ""; | |
| 2365 $func .= <<END; | |
| 2292 static v8::Handle<v8::Value> ${v8InterfaceName}ConstructorCallback(const v8::Arg uments& args) | 2366 static v8::Handle<v8::Value> ${v8InterfaceName}ConstructorCallback(const v8::Arg uments& args) |
| 2293 { | 2367 { |
| 2294 ${maybeObserveFeature} | 2368 ${maybeObserveFeature} |
| 2295 END | 2369 END |
| 2296 push(@implContent, GenerateConstructorHeader()); | 2370 $func .= GenerateConstructorHeader(); |
| 2297 AddToImplIncludes("V8Document.h"); | 2371 AddToImplIncludes("V8Document.h"); |
| 2298 push(@implContent, <<END); | 2372 $func .= <<END; |
| 2299 Document* document = currentDocument(BindingState::instance()); | 2373 Document* document = currentDocument(BindingState::instance()); |
| 2300 | 2374 |
| 2301 // Make sure the document is added to the DOM Node map. Otherwise, the ${int erfaceName} instance | 2375 // Make sure the document is added to the DOM Node map. Otherwise, the ${int erfaceName} instance |
| 2302 // may end up being the only node in the map and get garbage-collected prema turely. | 2376 // may end up being the only node in the map and get garbage-collected prema turely. |
| 2303 toV8(document, args.Holder(), args.GetIsolate()); | 2377 toV8(document, args.Holder(), args.GetIsolate()); |
| 2304 | 2378 |
| 2305 END | 2379 END |
| 2306 | 2380 |
| 2307 push(@implContent, GenerateArgumentsCountCheck($function, $interface)); | 2381 $func .= GenerateArgumentsCountCheck($function, $interface); |
| 2308 | 2382 |
| 2309 if ($raisesExceptions) { | 2383 if ($raisesExceptions) { |
| 2310 AddToImplIncludes("ExceptionCode.h"); | 2384 AddToImplIncludes("ExceptionCode.h"); |
| 2311 push(@implContent, "\n"); | 2385 $func .= "\n"; |
| 2312 push(@implContent, " ExceptionCode ec = 0;\n"); | 2386 $func .= " ExceptionCode ec = 0;\n"; |
| 2313 } | 2387 } |
| 2314 | 2388 |
| 2315 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName); | 2389 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interfaceName); |
| 2316 push(@implContent, $parameterCheckString); | 2390 $func .= $parameterCheckString; |
| 2317 | 2391 |
| 2318 push(@beforeArgumentList, "document"); | 2392 push(@beforeArgumentList, "document"); |
| 2319 | 2393 |
| 2320 if ($interface->extendedAttributes->{"RaisesException"}) { | 2394 if ($interface->extendedAttributes->{"RaisesException"}) { |
| 2321 push(@afterArgumentList, "ec"); | 2395 push(@afterArgumentList, "ec"); |
| 2322 } | 2396 } |
| 2323 | 2397 |
| 2324 my @argumentList; | 2398 my @argumentList; |
| 2325 my $index = 0; | 2399 my $index = 0; |
| 2326 foreach my $parameter (@{$function->parameters}) { | 2400 foreach my $parameter (@{$function->parameters}) { |
| 2327 last if $index eq $paramIndex; | 2401 last if $index eq $paramIndex; |
| 2328 if ($replacements{$parameter->name}) { | 2402 if ($replacements{$parameter->name}) { |
| 2329 push(@argumentList, $replacements{$parameter->name}); | 2403 push(@argumentList, $replacements{$parameter->name}); |
| 2330 } else { | 2404 } else { |
| 2331 push(@argumentList, $parameter->name); | 2405 push(@argumentList, $parameter->name); |
| 2332 } | 2406 } |
| 2333 $index++; | 2407 $index++; |
| 2334 } | 2408 } |
| 2335 | 2409 |
| 2336 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); | 2410 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); |
| 2337 push(@implContent, "\n"); | 2411 $func .= "\n"; |
| 2338 push(@implContent, " RefPtr<${interfaceName}> impl = ${interfaceName}::cr eateForJSConstructor(${argumentString});\n"); | 2412 $func .= " RefPtr<${interfaceName}> impl = ${interfaceName}::createForJSC onstructor(${argumentString});\n"; |
| 2339 push(@implContent, " v8::Handle<v8::Object> wrapper = args.Holder();\n"); | 2413 $func .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; |
| 2340 | 2414 |
| 2341 if ($interface->extendedAttributes->{"RaisesException"}) { | 2415 if ($interface->extendedAttributes->{"RaisesException"}) { |
| 2342 push(@implContent, " if (ec)\n"); | 2416 $func .= " if (ec)\n"; |
| 2343 push(@implContent, " goto fail;\n"); | 2417 $func .= " goto fail;\n"; |
| 2344 } | 2418 } |
| 2345 | 2419 |
| 2346 push(@implContent, <<END); | 2420 $func .= <<END; |
| 2347 | 2421 |
| 2348 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8InterfaceName} Constructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); | 2422 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8InterfaceName} Constructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); |
| 2349 return wrapper; | 2423 return wrapper; |
| 2350 END | 2424 END |
| 2351 | 2425 |
| 2352 if ($raisesExceptions) { | 2426 if ($raisesExceptions) { |
| 2353 push(@implContent, " fail:\n"); | 2427 $func .= " fail:\n"; |
| 2354 push(@implContent, " return setDOMException(ec, args.GetIsolate());\n "); | 2428 $func .= " return setDOMException(ec, args.GetIsolate());\n"; |
| 2355 } | 2429 } |
| 2356 | 2430 |
| 2357 push(@implContent, "}\n"); | 2431 $func .= "}\n"; |
| 2432 AddToImplFunction($func); | |
| 2358 | 2433 |
| 2359 push(@implContent, <<END); | 2434 $func = <<END; |
| 2360 | 2435 |
| 2361 v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}Constructor::GetTemplate( v8::Isolate* isolate, WrapperWorldType currentWorldType) | 2436 v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}Constructor::GetTemplate( v8::Isolate* isolate, WrapperWorldType currentWorldType) |
| 2362 { | 2437 { |
| 2363 static v8::Persistent<v8::FunctionTemplate> cachedTemplate; | 2438 static v8::Persistent<v8::FunctionTemplate> cachedTemplate; |
| 2364 if (!cachedTemplate.IsEmpty()) | 2439 if (!cachedTemplate.IsEmpty()) |
| 2365 return cachedTemplate; | 2440 return cachedTemplate; |
| 2366 | 2441 |
| 2367 v8::HandleScope scope; | 2442 v8::HandleScope scope; |
| 2368 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(${v8Inter faceName}ConstructorCallback); | 2443 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(${v8Inter faceName}ConstructorCallback); |
| 2369 | 2444 |
| 2370 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate(); | 2445 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate(); |
| 2371 instance->SetInternalFieldCount(${v8InterfaceName}::internalFieldCount); | 2446 instance->SetInternalFieldCount(${v8InterfaceName}::internalFieldCount); |
| 2372 result->SetClassName(v8::String::NewSymbol("${interfaceName}")); | 2447 result->SetClassName(v8::String::NewSymbol("${interfaceName}")); |
| 2373 result->Inherit(${v8InterfaceName}::GetTemplate(isolate, currentWorldType)); | 2448 result->Inherit(${v8InterfaceName}::GetTemplate(isolate, currentWorldType)); |
| 2374 | 2449 |
| 2375 cachedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, result); | 2450 cachedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, result); |
| 2376 return cachedTemplate; | 2451 return cachedTemplate; |
| 2377 } | 2452 } |
| 2378 | 2453 |
| 2379 END | 2454 END |
| 2455 AddToImplFunction($func); | |
| 2380 } | 2456 } |
| 2381 | 2457 |
| 2382 sub GenerateConstructorHeader | 2458 sub GenerateConstructorHeader |
| 2383 { | 2459 { |
| 2384 my $content = <<END; | 2460 my $content = <<END; |
| 2385 if (!args.IsConstructCall()) | 2461 if (!args.IsConstructCall()) |
| 2386 return throwTypeError("DOM object constructor cannot be called as a func tion.", args.GetIsolate()); | 2462 return throwTypeError("DOM object constructor cannot be called as a func tion.", args.GetIsolate()); |
| 2387 | 2463 |
| 2388 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) | 2464 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) |
| 2389 return args.Holder(); | 2465 return args.Holder(); |
| 2390 | 2466 |
| 2391 END | 2467 END |
| 2392 return $content; | 2468 return $content; |
| 2393 } | 2469 } |
| 2394 | 2470 |
| 2395 sub GenerateBatchedAttributeData | 2471 sub GenerateBatchedAttributeData |
| 2396 { | 2472 { |
| 2397 my $interface = shift; | 2473 my $interface = shift; |
| 2398 my $attributes = shift; | 2474 my $attributes = shift; |
| 2475 my $out = ""; | |
| 2399 my $interfaceName = $interface->name; | 2476 my $interfaceName = $interface->name; |
| 2400 | 2477 |
| 2401 foreach my $attribute (@$attributes) { | 2478 foreach my $attribute (@$attributes) { |
| 2402 my $conditionalString = $codeGenerator->GenerateConditionalString($attri bute->signature); | 2479 my $conditionalString = $codeGenerator->GenerateConditionalString($attri bute->signature); |
| 2403 push(@implContent, "#if ${conditionalString}\n") if $conditionalString; | 2480 my $code = ""; |
| 2404 GenerateSingleBatchedAttribute($interfaceName, $attribute, ",", ""); | 2481 $code .= "#if ${conditionalString}\n" if $conditionalString; |
| 2405 push(@implContent, "#endif // ${conditionalString}\n") if $conditionalSt ring; | 2482 $code .= GenerateSingleBatchedAttribute($interfaceName, $attribute, ",", ""); |
| 2483 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | |
| 2484 $out .= $code; | |
| 2406 } | 2485 } |
| 2486 return $out; | |
| 2407 } | 2487 } |
| 2408 | 2488 |
| 2409 sub GenerateSingleBatchedAttribute | 2489 sub GenerateSingleBatchedAttribute |
| 2410 { | 2490 { |
| 2411 my $interfaceName = shift; | 2491 my $interfaceName = shift; |
| 2412 my $attribute = shift; | 2492 my $attribute = shift; |
| 2413 my $delimiter = shift; | 2493 my $delimiter = shift; |
| 2414 my $indent = shift; | 2494 my $indent = shift; |
| 2495 my $out = ""; | |
| 2415 my $attrName = $attribute->signature->name; | 2496 my $attrName = $attribute->signature->name; |
| 2416 my $attrExt = $attribute->signature->extendedAttributes; | 2497 my $attrExt = $attribute->signature->extendedAttributes; |
| 2417 | 2498 |
| 2418 my $accessControl = "v8::DEFAULT"; | 2499 my $accessControl = "v8::DEFAULT"; |
| 2419 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { | 2500 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { |
| 2420 $accessControl = "v8::ALL_CAN_READ"; | 2501 $accessControl = "v8::ALL_CAN_READ"; |
| 2421 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { | 2502 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { |
| 2422 $accessControl = "v8::ALL_CAN_WRITE"; | 2503 $accessControl = "v8::ALL_CAN_WRITE"; |
| 2423 } elsif ($attrExt->{"DoNotCheckSecurity"}) { | 2504 } elsif ($attrExt->{"DoNotCheckSecurity"}) { |
| 2424 $accessControl = "v8::ALL_CAN_READ"; | 2505 $accessControl = "v8::ALL_CAN_READ"; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2494 } | 2575 } |
| 2495 | 2576 |
| 2496 if (!$attrExt->{"PerWorldBindings"}) { | 2577 if (!$attrExt->{"PerWorldBindings"}) { |
| 2497 $getterForMainWorld = "0"; | 2578 $getterForMainWorld = "0"; |
| 2498 $setterForMainWorld = "0"; | 2579 $setterForMainWorld = "0"; |
| 2499 } | 2580 } |
| 2500 | 2581 |
| 2501 my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type . | 2582 my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type . |
| 2502 "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')"; | 2583 "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')"; |
| 2503 | 2584 |
| 2504 push(@implContent, $indent . " \/\/ $commentInfo\n"); | 2585 $out .= $indent . " \/\/ $commentInfo\n"; |
| 2505 push(@implContent, $indent . " {\"$attrName\", $getter, $setter, $getterF orMainWorld, $setterForMainWorld, $data, $accessControl, static_cast<v8::Propert yAttribute>($propAttr), $on_proto}" . $delimiter . "\n"); | 2586 $out .= $indent . " {\"$attrName\", $getter, $setter, $getterForMainWorld , $setterForMainWorld, $data, $accessControl, static_cast<v8::PropertyAttribute> ($propAttr), $on_proto}" . $delimiter . "\n"; |
| 2587 return $out; | |
| 2506 } | 2588 } |
| 2507 | 2589 |
| 2508 sub IsStandardFunction | 2590 sub IsStandardFunction |
| 2509 { | 2591 { |
| 2510 my $interface = shift; | 2592 my $interface = shift; |
| 2511 my $function = shift; | 2593 my $function = shift; |
| 2512 | 2594 |
| 2513 my $interfaceName = $interface->name; | 2595 my $interfaceName = $interface->name; |
| 2514 my $attrExt = $function->signature->extendedAttributes; | 2596 my $attrExt = $function->signature->extendedAttributes; |
| 2515 return 0 if $attrExt->{"Unforgeable"}; | 2597 return 0 if $attrExt->{"Unforgeable"}; |
| 2516 return 0 if $function->isStatic; | 2598 return 0 if $function->isStatic; |
| 2517 return 0 if $attrExt->{"EnabledAtRuntime"}; | 2599 return 0 if $attrExt->{"EnabledAtRuntime"}; |
| 2518 return 0 if $attrExt->{"EnabledPerContext"}; | 2600 return 0 if $attrExt->{"EnabledPerContext"}; |
| 2519 return 0 if RequiresCustomSignature($function); | 2601 return 0 if RequiresCustomSignature($function); |
| 2520 return 0 if $attrExt->{"DoNotCheckSignature"}; | 2602 return 0 if $attrExt->{"DoNotCheckSignature"}; |
| 2521 return 0 if ($attrExt->{"DoNotCheckSecurity"} && ($interface->extendedAttrib utes->{"CheckSecurity"} || $interfaceName eq "DOMWindow")); | 2603 return 0 if ($attrExt->{"DoNotCheckSecurity"} && ($interface->extendedAttrib utes->{"CheckSecurity"} || $interfaceName eq "DOMWindow")); |
| 2522 return 0 if $attrExt->{"NotEnumerable"}; | 2604 return 0 if $attrExt->{"NotEnumerable"}; |
| 2523 return 0 if $attrExt->{"ReadOnly"}; | 2605 return 0 if $attrExt->{"ReadOnly"}; |
| 2524 return 1; | 2606 return 1; |
| 2525 } | 2607 } |
| 2526 | 2608 |
| 2527 sub GenerateNonStandardFunction | 2609 sub GenerateNonStandardFunction |
| 2528 { | 2610 { |
| 2529 my $interface = shift; | 2611 my $interface = shift; |
| 2530 my $function = shift; | 2612 my $function = shift; |
| 2613 my $out = ""; | |
| 2531 | 2614 |
| 2532 my $interfaceName = $interface->name; | 2615 my $interfaceName = $interface->name; |
| 2533 my $attrExt = $function->signature->extendedAttributes; | 2616 my $attrExt = $function->signature->extendedAttributes; |
| 2534 my $name = $function->signature->name; | 2617 my $name = $function->signature->name; |
| 2535 | 2618 |
| 2536 my $property_attributes = "v8::DontDelete"; | 2619 my $property_attributes = "v8::DontDelete"; |
| 2537 if ($attrExt->{"NotEnumerable"}) { | 2620 if ($attrExt->{"NotEnumerable"}) { |
| 2538 $property_attributes .= " | v8::DontEnum"; | 2621 $property_attributes .= " | v8::DontEnum"; |
| 2539 } | 2622 } |
| 2540 if ($attrExt->{"ReadOnly"}) { | 2623 if ($attrExt->{"ReadOnly"}) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2561 # Only call Set()/SetAccessor() if this method should be enabled | 2644 # Only call Set()/SetAccessor() if this method should be enabled |
| 2562 my $enable_function = GetContextEnableFunction($function->signature); | 2645 my $enable_function = GetContextEnableFunction($function->signature); |
| 2563 $conditional = "if (${enable_function}(impl->document()))\n "; | 2646 $conditional = "if (${enable_function}(impl->document()))\n "; |
| 2564 } | 2647 } |
| 2565 | 2648 |
| 2566 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh eckSecurity"}) { | 2649 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh eckSecurity"}) { |
| 2567 # Functions that are marked DoNotCheckSecurity are always readable but i f they are changed | 2650 # Functions that are marked DoNotCheckSecurity are always readable but i f they are changed |
| 2568 # and then accessed on a different domain we do not return the underlyin g value but instead | 2651 # and then accessed on a different domain we do not return the underlyin g value but instead |
| 2569 # return a new copy of the original function. This is achieved by storin g the changed value | 2652 # return a new copy of the original function. This is achieved by storin g the changed value |
| 2570 # as hidden property. | 2653 # as hidden property. |
| 2571 push(@implContent, <<END); | 2654 $out .= <<END; |
| 2572 | 2655 |
| 2573 // $commentInfo | 2656 // $commentInfo |
| 2574 ${conditional}$template->SetAccessor(v8::String::NewSymbol("$name"), ${inter faceName}V8Internal::${name}AttrGetterCallback, ${interfaceName}V8Internal::${in terfaceName}DomainSafeFunctionSetter, v8Undefined(), v8::ALL_CAN_READ, static_ca st<v8::PropertyAttribute>($property_attributes)); | 2657 ${conditional}$template->SetAccessor(v8::String::NewSymbol("$name"), ${inter faceName}V8Internal::${name}AttrGetterCallback, ${interfaceName}V8Internal::${in terfaceName}DomainSafeFunctionSetter, v8Undefined(), v8::ALL_CAN_READ, static_ca st<v8::PropertyAttribute>($property_attributes)); |
| 2575 END | 2658 END |
| 2576 return; | 2659 return $out; |
| 2577 } | 2660 } |
| 2578 | 2661 |
| 2579 my $signature = "defaultSignature"; | 2662 my $signature = "defaultSignature"; |
| 2580 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { | 2663 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { |
| 2581 $signature = "v8::Local<v8::Signature>()"; | 2664 $signature = "v8::Local<v8::Signature>()"; |
| 2582 } | 2665 } |
| 2583 | 2666 |
| 2584 if (RequiresCustomSignature($function)) { | 2667 if (RequiresCustomSignature($function)) { |
| 2585 $signature = "${name}Signature"; | 2668 $signature = "${name}Signature"; |
| 2586 push(@implContent, "\n // Custom Signature '$name'\n", CreateCustomSi gnature($function)); | 2669 $out .= "\n // Custom Signature '$name'\n" . CreateCustomSignature($f unction); |
| 2587 } | 2670 } |
| 2588 | 2671 |
| 2589 if ($property_attributes eq "v8::DontDelete") { | 2672 if ($property_attributes eq "v8::DontDelete") { |
| 2590 $property_attributes = ""; | 2673 $property_attributes = ""; |
| 2591 } else { | 2674 } else { |
| 2592 $property_attributes = ", static_cast<v8::PropertyAttribute>($property_a ttributes)"; | 2675 $property_attributes = ", static_cast<v8::PropertyAttribute>($property_a ttributes)"; |
| 2593 } | 2676 } |
| 2594 | 2677 |
| 2595 if ($template eq "proto" && $conditional eq "" && $signature eq "defaultSign ature" && $property_attributes eq "") { | 2678 if ($template eq "proto" && $conditional eq "" && $signature eq "defaultSign ature" && $property_attributes eq "") { |
| 2596 die "This shouldn't happen: Intraface '$interfaceName' $commentInfo\n"; | 2679 die "This shouldn't happen: Intraface '$interfaceName' $commentInfo\n"; |
| 2597 } | 2680 } |
| 2598 | 2681 |
| 2599 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature); | 2682 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature); |
| 2600 push(@implContent, "#if ${conditionalString}\n") if $conditionalString; | 2683 $out .= "#if ${conditionalString}\n" if $conditionalString; |
| 2601 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { | 2684 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { |
| 2602 push(@implContent, " if (currentWorldType == MainWorld) {\n"); | 2685 $out .= " if (currentWorldType == MainWorld) {\n"; |
| 2603 push(@implContent, " ${conditional}$template->Set(v8::String::New Symbol(\"$name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name} MethodCallbackForMainWorld, v8Undefined(), ${signature})$property_attributes);\n "); | 2686 $out .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$n ame\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCallb ackForMainWorld, v8Undefined(), ${signature})$property_attributes);\n"; |
| 2604 push(@implContent, " } else {\n"); | 2687 $out .= " } else {\n"; |
| 2605 push(@implContent, " ${conditional}$template->Set(v8::String::New Symbol(\"$name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name} MethodCallback, v8Undefined(), ${signature})$property_attributes);\n"); | 2688 $out .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$n ame\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCallb ack, v8Undefined(), ${signature})$property_attributes);\n"; |
| 2606 push(@implContent, " }\n"); | 2689 $out .= " }\n"; |
| 2607 } else { | 2690 } else { |
| 2608 push(@implContent, " ${conditional}$template->Set(v8::String::NewSymb ol(\"$name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}Meth odCallback, v8Undefined(), ${signature})$property_attributes);\n"); | 2691 $out .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$name\ "), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCallback, v8Undefined(), ${signature})$property_attributes);\n"; |
| 2609 } | 2692 } |
| 2610 push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString ; | 2693 $out .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 2694 return $out; | |
| 2611 } | 2695 } |
| 2612 | 2696 |
| 2613 sub GenerateImplementationIndexer | 2697 sub GenerateImplementationIndexer |
| 2614 { | 2698 { |
| 2615 my $interface = shift; | 2699 my $interface = shift; |
| 2616 my $indexer = shift; | 2700 my $indexer = shift; |
| 2701 my $out = ""; | |
| 2702 | |
| 2617 my $interfaceName = $interface->name; | 2703 my $interfaceName = $interface->name; |
| 2618 my $v8InterfaceName = "V8$interfaceName"; | 2704 my $v8InterfaceName = "V8$interfaceName"; |
| 2619 | 2705 |
| 2620 # FIXME: Figure out what NumericIndexedGetter is really supposed to do. Righ t now, it's only set on WebGL-related files. | 2706 # FIXME: Figure out what NumericIndexedGetter is really supposed to do. Righ t now, it's only set on WebGL-related files. |
| 2621 my $hasCustomSetter = $interface->extendedAttributes->{"CustomIndexedSetter" } && !$interface->extendedAttributes->{"NumericIndexedGetter"}; | 2707 my $hasCustomSetter = $interface->extendedAttributes->{"CustomIndexedSetter" } && !$interface->extendedAttributes->{"NumericIndexedGetter"}; |
| 2622 my $hasGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interf ace->extendedAttributes->{"CustomGetOwnPropertySlot"}; | 2708 my $hasGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interf ace->extendedAttributes->{"CustomGetOwnPropertySlot"}; |
| 2623 | 2709 |
| 2624 # FIXME: Investigate and remove this nastinesss. In V8, named property handl ing and indexer handling are apparently decoupled, | 2710 # FIXME: Investigate and remove this nastinesss. In V8, named property handl ing and indexer handling are apparently decoupled, |
| 2625 # which means that object[X] where X is a number doesn't reach named propert y indexer. So we need to provide | 2711 # which means that object[X] where X is a number doesn't reach named propert y indexer. So we need to provide |
| 2626 # simplistic, mirrored indexer handling in addition to named property handli ng. | 2712 # simplistic, mirrored indexer handling in addition to named property handli ng. |
| 2627 my $isSpecialCase = exists $indexerSpecialCases{$interfaceName}; | 2713 my $isSpecialCase = exists $indexerSpecialCases{$interfaceName}; |
| 2628 if ($isSpecialCase) { | 2714 if ($isSpecialCase) { |
| 2629 $hasGetter = 1; | 2715 $hasGetter = 1; |
| 2630 if ($interface->extendedAttributes->{"CustomNamedSetter"}) { | 2716 if ($interface->extendedAttributes->{"CustomNamedSetter"}) { |
| 2631 $hasCustomSetter = 1; | 2717 $hasCustomSetter = 1; |
| 2632 } | 2718 } |
| 2633 } | 2719 } |
| 2634 | 2720 |
| 2635 my $hasEnumerator = !$isSpecialCase && $codeGenerator->InheritsInterface($in terface, "Node"); | 2721 my $hasEnumerator = !$isSpecialCase && $codeGenerator->InheritsInterface($in terface, "Node"); |
| 2636 | 2722 |
| 2637 # FIXME: Find a way to not have to special-case HTMLOptionsCollection. | 2723 # FIXME: Find a way to not have to special-case HTMLOptionsCollection. |
| 2638 if ($interfaceName eq "HTMLOptionsCollection") { | 2724 if ($interfaceName eq "HTMLOptionsCollection") { |
| 2639 $hasEnumerator = 1; | 2725 $hasEnumerator = 1; |
| 2640 $hasGetter = 1; | 2726 $hasGetter = 1; |
| 2641 } | 2727 } |
| 2642 | 2728 |
| 2643 if (!$hasGetter) { | 2729 if (!$hasGetter) { |
| 2644 return; | 2730 return ""; |
| 2645 } | 2731 } |
| 2646 | 2732 |
| 2647 AddToImplIncludes("V8Collection.h"); | 2733 AddToImplIncludes("V8Collection.h"); |
| 2648 | 2734 |
| 2649 if (!$indexer) { | 2735 if (!$indexer) { |
| 2650 $indexer = $codeGenerator->FindSuperMethod($interface, "item"); | 2736 $indexer = $codeGenerator->FindSuperMethod($interface, "item"); |
| 2651 } | 2737 } |
| 2652 | 2738 |
| 2653 my $indexerType = $indexer ? $indexer->type : 0; | 2739 my $indexerType = $indexer ? $indexer->type : 0; |
| 2654 | 2740 |
| 2655 # FIXME: Remove this once toV8 helper methods are implemented (see https://b ugs.webkit.org/show_bug.cgi?id=32563). | 2741 # FIXME: Remove this once toV8 helper methods are implemented (see https://b ugs.webkit.org/show_bug.cgi?id=32563). |
| 2656 if ($interfaceName eq "WebKitCSSKeyframesRule") { | 2742 if ($interfaceName eq "WebKitCSSKeyframesRule") { |
| 2657 $indexerType = "WebKitCSSKeyframeRule"; | 2743 $indexerType = "WebKitCSSKeyframeRule"; |
| 2658 } | 2744 } |
| 2659 | 2745 |
| 2660 if ($indexerType && !$hasCustomSetter) { | 2746 if ($indexerType && !$hasCustomSetter) { |
| 2661 if ($indexerType eq "DOMString") { | 2747 if ($indexerType eq "DOMString") { |
| 2662 my $conversion = $indexer->extendedAttributes->{"TreatReturnedNullSt ringAs"}; | 2748 my $conversion = $indexer->extendedAttributes->{"TreatReturnedNullSt ringAs"}; |
| 2663 if ($conversion && $conversion eq "Null") { | 2749 if ($conversion && $conversion eq "Null") { |
| 2664 push(@implContent, <<END); | 2750 $out .= <<END; |
| 2665 setCollectionStringOrUndefinedIndexedGetter<${interfaceName}>(desc); | 2751 setCollectionStringOrUndefinedIndexedGetter<${interfaceName}>(desc); |
| 2666 END | 2752 END |
| 2667 } else { | 2753 } else { |
| 2668 push(@implContent, <<END); | 2754 $out .= <<END; |
| 2669 setCollectionStringIndexedGetter<${interfaceName}>(desc); | 2755 setCollectionStringIndexedGetter<${interfaceName}>(desc); |
| 2670 END | 2756 END |
| 2671 } | 2757 } |
| 2672 } else { | 2758 } else { |
| 2673 push(@implContent, <<END); | 2759 $out .= <<END; |
| 2674 setCollectionIndexedGetter<${interfaceName}, ${indexerType}>(desc); | 2760 setCollectionIndexedGetter<${interfaceName}, ${indexerType}>(desc); |
| 2675 END | 2761 END |
| 2676 # Include the header for this indexer type, because setCollectionInd exedGetter() requires toV8() for this type. | 2762 # Include the header for this indexer type, because setCollectionInd exedGetter() requires toV8() for this type. |
| 2677 AddToImplIncludes("V8${indexerType}.h"); | 2763 AddToImplIncludes("V8${indexerType}.h"); |
| 2678 } | 2764 } |
| 2679 | 2765 |
| 2680 return; | 2766 return $out; |
| 2681 } | 2767 } |
| 2682 | 2768 |
| 2683 my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"}; | 2769 my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"}; |
| 2684 my $setOn = "Instance"; | 2770 my $setOn = "Instance"; |
| 2685 | 2771 |
| 2686 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba cks) and it's used on DOMWindow | 2772 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba cks) and it's used on DOMWindow |
| 2687 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to | 2773 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to |
| 2688 # get implementation straight out of the DOMWindow prototype regardless of w hat prototype is actually set | 2774 # get implementation straight out of the DOMWindow prototype regardless of w hat prototype is actually set |
| 2689 # on the object. | 2775 # on the object. |
| 2690 if ($interfaceName eq "DOMWindow") { | 2776 if ($interfaceName eq "DOMWindow") { |
| 2691 $setOn = "Prototype"; | 2777 $setOn = "Prototype"; |
| 2692 $hasDeleter = 0; | 2778 $hasDeleter = 0; |
| 2693 } | 2779 } |
| 2694 | 2780 |
| 2695 push(@implContent, " desc->${setOn}Template()->SetIndexedPropertyHandler( ${v8InterfaceName}::indexedPropertyGetter"); | 2781 $out .= " desc->${setOn}Template()->SetIndexedPropertyHandler(${v8Interfa ceName}::indexedPropertyGetter"; |
| 2696 push(@implContent, $hasCustomSetter ? ", ${v8InterfaceName}::indexedProperty Setter" : ", 0"); | 2782 $out .= $hasCustomSetter ? ", ${v8InterfaceName}::indexedPropertySetter" : " , 0"; |
| 2697 push(@implContent, ", 0"); # IndexedPropertyQuery -- not being used at the m oment. | 2783 $out .= ", 0"; # IndexedPropertyQuery -- not being used at the moment. |
| 2698 push(@implContent, $hasDeleter ? ", ${v8InterfaceName}::indexedPropertyDelet er" : ", 0"); | 2784 $out .= $hasDeleter ? ", ${v8InterfaceName}::indexedPropertyDeleter" : ", 0" ; |
| 2699 push(@implContent, ", nodeCollectionIndexedPropertyEnumerator<${interfaceNam e}>") if $hasEnumerator; | 2785 $out .= ", nodeCollectionIndexedPropertyEnumerator<${interfaceName}>" if $ha sEnumerator; |
| 2700 push(@implContent, ");\n"); | 2786 $out .= ");\n"; |
| 2787 return $out; | |
| 2701 } | 2788 } |
| 2702 | 2789 |
| 2790 # @return (templateConfigCode, name) | |
| 2703 sub GenerateImplementationNamedPropertyGetter | 2791 sub GenerateImplementationNamedPropertyGetter |
| 2704 { | 2792 { |
| 2705 my $interface = shift; | 2793 my $interface = shift; |
| 2706 my $namedPropertyGetter = shift; | 2794 my $namedPropertyGetter = shift; |
| 2795 my $implContentGlobal = shift; | |
| 2796 my $tmplConfig = ""; | |
| 2797 my $namedPropertydGetter = ""; | |
| 2798 | |
| 2707 my $interfaceName = $interface->name; | 2799 my $interfaceName = $interface->name; |
| 2708 my $v8InterfaceName = "V8$interfaceName"; | 2800 my $v8InterfaceName = "V8$interfaceName"; |
| 2709 | 2801 |
| 2802 if (!$namedPropertyGetter) { | |
| 2803 $namedPropertyGetter = $codeGenerator->FindSuperMethod($interface, "name dItem"); | |
| 2804 } | |
| 2805 | |
| 2710 if ($interface->extendedAttributes->{"NamedGetter"}) { | 2806 if ($interface->extendedAttributes->{"NamedGetter"}) { |
| 2711 AddToImplIncludes("V8Collection.h"); | 2807 AddToImplIncludes("V8Collection.h"); |
| 2712 my $type = $namedPropertyGetter->type; | 2808 my $type = $namedPropertyGetter->type; |
| 2713 push(@implContent, <<END); | 2809 $tmplConfig .= <<END; |
| 2714 desc->InstanceTemplate()->SetNamedPropertyHandler(${v8InterfaceName}::namedP ropertyGetter, 0, 0, 0, 0); | 2810 desc->InstanceTemplate()->SetNamedPropertyHandler(${v8InterfaceName}::namedP ropertyGetter, 0, 0, 0, 0); |
| 2715 END | 2811 END |
| 2812 | |
| 2813 $namedPropertydGetter .= <<END; | |
|
haraken
2013/04/16 09:40:36
Can't you do this like AddToImplContent(<<END) ? T
kojih
2013/04/16 11:00:07
Great, I did it.
| |
| 2814 v8::Handle<v8::Value> ${v8InterfaceName}::namedPropertyGetter(v8::Local<v8::Stri ng> name, const v8::AccessorInfo& info) | |
| 2815 { | |
| 2816 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | |
| 2817 return v8Undefined(); | |
| 2818 if (info.Holder()->HasRealNamedCallbackProperty(name)) | |
| 2819 return v8Undefined(); | |
| 2820 | |
| 2821 v8::Local<v8::Object> object = info.Holder(); | |
| 2822 v8::Handle<v8::Object> creationContext = info.Holder(); | |
| 2823 v8::Isolate* isolate = info.GetIsolate(); | |
| 2824 | |
| 2825 ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); | |
| 2826 ASSERT(toWrapperTypeInfo(object) != &V8Node::info); | |
| 2827 $interfaceName* collection = toNative(object); | |
| 2828 | |
| 2829 AtomicString propertyName = toWebCoreAtomicStringWithNullCheck(name); | |
| 2830 RefPtr<$type> element = collection->namedItem(propertyName); | |
| 2831 | |
| 2832 if (!element) | |
| 2833 return v8Undefined(); | |
| 2834 | |
| 2835 return toV8(element.release(), creationContext, isolate); | |
| 2836 } | |
| 2837 | |
| 2838 END | |
| 2716 } | 2839 } |
| 2717 | 2840 |
| 2718 my $hasCustomNamedGetter = $interface->extendedAttributes->{"CustomNamedGett er"}; | 2841 my $hasCustomNamedGetter = $interface->extendedAttributes->{"CustomNamedGett er"}; |
| 2719 # FIXME: make consistent between IDL and implementation. Then remove these s pecial cases. | 2842 # FIXME: make consistent between IDL and implementation. Then remove these s pecial cases. |
| 2720 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLAppletElement"; | 2843 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLAppletElement"; |
| 2721 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLEmbedElement"; | 2844 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLEmbedElement"; |
| 2722 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLObjectElement"; | 2845 $hasCustomNamedGetter = 1 if $interfaceName eq "HTMLObjectElement"; |
| 2723 $hasCustomNamedGetter = 1 if $interfaceName eq "DOMWindow"; | 2846 $hasCustomNamedGetter = 1 if $interfaceName eq "DOMWindow"; |
| 2724 $hasCustomNamedGetter = 0 if $interfaceName eq "HTMLDocument"; | 2847 $hasCustomNamedGetter = 0 if $interfaceName eq "HTMLDocument"; |
| 2725 | 2848 |
| 2726 if ($hasCustomNamedGetter) { | 2849 if ($hasCustomNamedGetter) { |
| 2727 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamed Setter"}; | 2850 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamed Setter"}; |
| 2728 my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty" }; | 2851 my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty" }; |
| 2729 my $hasEnumerator = $interface->extendedAttributes->{"CustomEnumeratePro perty"}; | 2852 my $hasEnumerator = $interface->extendedAttributes->{"CustomEnumeratePro perty"}; |
| 2730 my $setOn = "Instance"; | 2853 my $setOn = "Instance"; |
| 2731 | 2854 |
| 2732 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCa llbacks) and it's used on DOMWindow | 2855 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCa llbacks) and it's used on DOMWindow |
| 2733 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to | 2856 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to |
| 2734 # get implementation straight out of the DOMWindow prototype regardless of what prototype is actually set | 2857 # get implementation straight out of the DOMWindow prototype regardless of what prototype is actually set |
| 2735 # on the object. | 2858 # on the object. |
| 2736 if ($interfaceName eq "DOMWindow") { | 2859 if ($interfaceName eq "DOMWindow") { |
| 2737 $setOn = "Prototype"; | 2860 $setOn = "Prototype"; |
| 2738 $hasDeleter = 0; | 2861 $hasDeleter = 0; |
| 2739 $hasEnumerator = 0; | 2862 $hasEnumerator = 0; |
| 2740 } | 2863 } |
| 2741 | 2864 |
| 2742 push(@implContent, " desc->${setOn}Template()->SetNamedPropertyHandle r(${v8InterfaceName}::namedPropertyGetter, "); | 2865 $tmplConfig .= " desc->${setOn}Template()->SetNamedPropertyHandler(${ v8InterfaceName}::namedPropertyGetter, "; |
| 2743 push(@implContent, $hasCustomNamedSetter ? "${v8InterfaceName}::namedPro pertySetter, " : "0, "); | 2866 $tmplConfig .= $hasCustomNamedSetter ? "${v8InterfaceName}::namedPropert ySetter, " : "0, "; |
| 2744 # If there is a custom enumerator, there MUST be custom query to properl y communicate property attributes. | 2867 # If there is a custom enumerator, there MUST be custom query to properl y communicate property attributes. |
| 2745 push(@implContent, $hasEnumerator ? "${v8InterfaceName}::namedPropertyQu ery, " : "0, "); | 2868 $tmplConfig .= $hasEnumerator ? "${v8InterfaceName}::namedPropertyQuery, " : "0, "; |
| 2746 push(@implContent, $hasDeleter ? "${v8InterfaceName}::namedPropertyDelet er, " : "0, "); | 2869 $tmplConfig .= $hasDeleter ? "${v8InterfaceName}::namedPropertyDeleter, " : "0, "; |
| 2747 push(@implContent, $hasEnumerator ? "${v8InterfaceName}::namedPropertyEn umerator" : "0"); | 2870 $tmplConfig .= $hasEnumerator ? "${v8InterfaceName}::namedPropertyEnumer ator" : "0"; |
| 2748 push(@implContent, ");\n"); | 2871 $tmplConfig .= ");\n"; |
| 2749 } | 2872 } |
| 2873 | |
| 2874 return ($tmplConfig, $namedPropertydGetter); | |
|
haraken
2013/04/16 09:40:36
Ditto. We want to avoid returning $namedPropertydG
| |
| 2750 } | 2875 } |
| 2751 | 2876 |
| 2752 sub GenerateImplementationCustomCall | 2877 sub GenerateImplementationCustomCall |
| 2753 { | 2878 { |
| 2754 my $interface = shift; | 2879 my $interface = shift; |
| 2880 my $out = ""; | |
| 2881 | |
| 2755 my $interfaceName = $interface->name; | 2882 my $interfaceName = $interface->name; |
| 2756 | 2883 |
| 2757 if ($interface->extendedAttributes->{"CustomCall"}) { | 2884 if ($interface->extendedAttributes->{"CustomCall"}) { |
| 2758 push(@implContent, " desc->InstanceTemplate()->SetCallAsFunctionHandl er(V8${interfaceName}::callAsFunctionCallback);\n"); | 2885 $out .= " desc->InstanceTemplate()->SetCallAsFunctionHandler(V8${inte rfaceName}::callAsFunctionCallback);\n"; |
| 2759 } | 2886 } |
| 2887 return $out; | |
| 2760 } | 2888 } |
| 2761 | 2889 |
| 2762 sub GenerateImplementationMasqueradesAsUndefined | 2890 sub GenerateImplementationMasqueradesAsUndefined |
| 2763 { | 2891 { |
| 2764 my $interface = shift; | 2892 my $interface = shift; |
| 2893 my $out = ""; | |
| 2894 | |
| 2765 if ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) | 2895 if ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) |
| 2766 { | 2896 { |
| 2767 push(@implContent, " desc->InstanceTemplate()->MarkAsUndetectable();\ n"); | 2897 $out .= " desc->InstanceTemplate()->MarkAsUndetectable();\n"; |
| 2768 } | 2898 } |
| 2899 return $out; | |
| 2769 } | 2900 } |
| 2770 | 2901 |
| 2771 sub GenerateImplementation | 2902 sub GenerateImplementation |
| 2772 { | 2903 { |
| 2773 my $object = shift; | 2904 my $object = shift; |
| 2774 my $interface = shift; | 2905 my $interface = shift; |
| 2775 my $interfaceName = $interface->name; | 2906 my $interfaceName = $interface->name; |
| 2776 my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interfac e); | 2907 my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interfac e); |
| 2777 my $v8InterfaceName = "V8$interfaceName"; | 2908 my $v8InterfaceName = "V8$interfaceName"; |
| 2778 my $nativeType = GetNativeTypeForConversions($interface); | 2909 my $nativeType = GetNativeTypeForConversions($interface); |
| 2779 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); | 2910 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); |
| 2780 my $vtableRefGnu = GetGnuVTableRefForInterface($interface); | 2911 my $vtableRefGnu = GetGnuVTableRefForInterface($interface); |
| 2781 my $vtableRefWin = GetWinVTableRefForInterface($interface); | 2912 my $vtableRefWin = GetWinVTableRefForInterface($interface); |
| 2782 | 2913 |
| 2783 # - Add default header template | 2914 # - Add default header template |
| 2784 push(@implContentHeader, GenerateImplementationContentHeader($interface)); | 2915 push(@implContentHeader, GenerateImplementationContentHeader($interface)); |
| 2785 | 2916 |
| 2917 my $implContentGlobal = []; | |
|
haraken
2013/04/16 09:40:36
Is this needed?
kojih
2013/04/16 11:00:07
no, removed.
| |
| 2918 | |
| 2786 AddToImplIncludes("BindingState.h"); | 2919 AddToImplIncludes("BindingState.h"); |
| 2787 AddToImplIncludes("ContextFeatures.h"); | 2920 AddToImplIncludes("ContextFeatures.h"); |
| 2788 AddToImplIncludes("RuntimeEnabledFeatures.h"); | 2921 AddToImplIncludes("RuntimeEnabledFeatures.h"); |
| 2789 AddToImplIncludes("V8Binding.h"); | 2922 AddToImplIncludes("V8Binding.h"); |
| 2790 AddToImplIncludes("V8DOMWrapper.h"); | 2923 AddToImplIncludes("V8DOMWrapper.h"); |
| 2791 | 2924 |
| 2792 AddIncludesForType($interfaceName); | 2925 AddIncludesForType($interfaceName); |
| 2793 | 2926 |
| 2794 my $toActiveDOMObject = $codeGenerator->InheritsExtendedAttribute($interface , "ActiveDOMObject") ? "${v8InterfaceName}::toActiveDOMObject" : "0"; | 2927 my $toActiveDOMObject = $codeGenerator->InheritsExtendedAttribute($interface , "ActiveDOMObject") ? "${v8InterfaceName}::toActiveDOMObject" : "0"; |
| 2795 my $toEventTarget = $codeGenerator->InheritsExtendedAttribute($interface, "E ventTarget") ? "${v8InterfaceName}::toEventTarget" : "0"; | 2928 my $toEventTarget = $codeGenerator->InheritsExtendedAttribute($interface, "E ventTarget") ? "${v8InterfaceName}::toEventTarget" : "0"; |
| 2796 my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8InterfaceName} ::opaqueRootForGC" : "0"; | 2929 my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8InterfaceName} ::opaqueRootForGC" : "0"; |
| 2797 | 2930 |
| 2798 # Find the super descriptor. | 2931 # Find the super descriptor. |
| 2799 my $parentClass = ""; | 2932 my $parentClass = ""; |
| 2800 my $parentClassTemplate = ""; | 2933 my $parentClassTemplate = ""; |
| 2801 foreach (@{$interface->parents}) { | 2934 foreach (@{$interface->parents}) { |
| 2802 my $parent = $_; | 2935 my $parent = $_; |
| 2803 AddToImplIncludes("V8${parent}.h"); | 2936 AddToImplIncludes("V8${parent}.h"); |
| 2804 $parentClass = "V8" . $parent; | 2937 $parentClass = "V8" . $parent; |
| 2805 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)"; | 2938 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)"; |
| 2806 last; | 2939 last; |
| 2807 } | 2940 } |
| 2808 | 2941 |
| 2809 push(@implContentInternals, <<END) if $vtableNameGnu; | 2942 AddToImplStuffInternal(<<END) if $vtableNameGnu; |
| 2810 #if ENABLE(BINDING_INTEGRITY) | 2943 #if ENABLE(BINDING_INTEGRITY) |
| 2811 #if defined(OS_WIN) | 2944 #if defined(OS_WIN) |
| 2812 #pragma warning(disable: 4483) | 2945 #pragma warning(disable: 4483) |
| 2813 extern "C" { extern void (*const ${vtableRefWin}[])(); } | 2946 extern "C" { extern void (*const ${vtableRefWin}[])(); } |
| 2814 #else | 2947 #else |
| 2815 extern "C" { extern void* ${vtableNameGnu}[]; } | 2948 extern "C" { extern void* ${vtableNameGnu}[]; } |
| 2816 #endif | 2949 #endif |
| 2817 #endif // ENABLE(BINDING_INTEGRITY) | 2950 #endif // ENABLE(BINDING_INTEGRITY) |
| 2818 | 2951 |
| 2819 END | 2952 END |
| 2820 | 2953 |
| 2821 push(@implContentInternals, "namespace WebCore {\n\n"); | 2954 AddToImplStuffInternal("namespace WebCore {\n\n"); |
| 2822 | 2955 |
| 2823 push(@implContentInternals, <<END) if $vtableNameGnu; | 2956 AddToImplFunctionInternal(<<END) if $vtableNameGnu; |
| 2824 #if ENABLE(BINDING_INTEGRITY) | 2957 #if ENABLE(BINDING_INTEGRITY) |
| 2825 // This checks if a DOM object that is about to be wrapped is valid. | 2958 // This checks if a DOM object that is about to be wrapped is valid. |
| 2826 // Specifically, it checks that a vtable of the DOM object is equal to | 2959 // Specifically, it checks that a vtable of the DOM object is equal to |
| 2827 // a vtable of an expected class. | 2960 // a vtable of an expected class. |
| 2828 // Due to a dangling pointer, the DOM object you are wrapping might be | 2961 // Due to a dangling pointer, the DOM object you are wrapping might be |
| 2829 // already freed or realloced. If freed, the check will fail because | 2962 // already freed or realloced. If freed, the check will fail because |
| 2830 // a free list pointer should be stored at the head of the DOM object. | 2963 // a free list pointer should be stored at the head of the DOM object. |
| 2831 // If realloced, the check will fail because the vtable of the DOM object | 2964 // If realloced, the check will fail because the vtable of the DOM object |
| 2832 // differs from the expected vtable (unless the same class of DOM object | 2965 // differs from the expected vtable (unless the same class of DOM object |
| 2833 // is realloced on the slot). | 2966 // is realloced on the slot). |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2844 } | 2977 } |
| 2845 #endif // ENABLE(BINDING_INTEGRITY) | 2978 #endif // ENABLE(BINDING_INTEGRITY) |
| 2846 | 2979 |
| 2847 END | 2980 END |
| 2848 | 2981 |
| 2849 | 2982 |
| 2850 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; | 2983 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; |
| 2851 | 2984 |
| 2852 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot ype" : "WrapperTypeObjectPrototype"; | 2985 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot ype" : "WrapperTypeObjectPrototype"; |
| 2853 | 2986 |
| 2854 push(@implContentInternals, "WrapperTypeInfo ${v8InterfaceName}::info = { ${ v8InterfaceName}::GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObje ct, $toEventTarget, $rootForGC, ${v8InterfaceName}::installPerContextPrototypePr operties, $parentClassInfo, $WrapperTypePrototype };\n\n"); | 2987 my $code = "WrapperTypeInfo ${v8InterfaceName}::info = { ${v8InterfaceName}: :GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObject, $toEventTarge t, "; |
| 2855 push(@implContentInternals, "namespace ${interfaceName}V8Internal {\n\n"); | 2988 $code .= "$rootForGC, ${v8InterfaceName}::installPerContextPrototypeProperti es, $parentClassInfo, $WrapperTypePrototype };\n\n"; |
| 2989 AddToImplStuffInternal($code); | |
| 2990 AddToImplStuffInternal("namespace ${interfaceName}V8Internal {\n\n"); | |
| 2856 | 2991 |
| 2857 push(@implContentInternals, "template <typename T> void V8_USE(T) { }\n\n"); | 2992 AddToImplStuffInternal("template <typename T> void V8_USE(T) { }\n\n"); |
| 2858 | 2993 |
| 2859 my $hasConstructors = 0; | 2994 my $hasConstructors = 0; |
| 2860 my $hasReplaceable = 0; | 2995 my $hasReplaceable = 0; |
| 2861 | 2996 |
| 2862 # Generate property accessors for attributes. | 2997 # Generate property accessors for attributes. |
| 2863 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 2998 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
| 2864 my $attribute = @{$interface->attributes}[$index]; | 2999 my $attribute = @{$interface->attributes}[$index]; |
| 2865 my $attrType = $attribute->signature->type; | 3000 my $attrType = $attribute->signature->type; |
| 2866 my $attrExt = $attribute->signature->extendedAttributes; | 3001 my $attrExt = $attribute->signature->extendedAttributes; |
| 2867 | 3002 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2911 if (NeedsCustomOpaqueRootForGC($interface)) { | 3046 if (NeedsCustomOpaqueRootForGC($interface)) { |
| 2912 GenerateOpaqueRootForGC($interface); | 3047 GenerateOpaqueRootForGC($interface); |
| 2913 } | 3048 } |
| 2914 | 3049 |
| 2915 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne "DOMWindow") { | 3050 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne "DOMWindow") { |
| 2916 GenerateSecurityCheckFunctions($interface); | 3051 GenerateSecurityCheckFunctions($interface); |
| 2917 } | 3052 } |
| 2918 | 3053 |
| 2919 if ($interface->extendedAttributes->{"TypedArray"}) { | 3054 if ($interface->extendedAttributes->{"TypedArray"}) { |
| 2920 my $viewType = GetTypeNameOfExternalTypedArray($interface); | 3055 my $viewType = GetTypeNameOfExternalTypedArray($interface); |
| 2921 push(@implContent, <<END); | 3056 AddToImplFunction(<<END); |
| 2922 v8::Handle<v8::Object> wrap($interfaceName* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) | 3057 v8::Handle<v8::Object> wrap($interfaceName* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) |
| 2923 { | 3058 { |
| 2924 ASSERT(impl); | 3059 ASSERT(impl); |
| 2925 v8::Handle<v8::Object> wrapper = ${v8InterfaceName}::createWrapper(impl, cre ationContext, isolate); | 3060 v8::Handle<v8::Object> wrapper = ${v8InterfaceName}::createWrapper(impl, cre ationContext, isolate); |
| 2926 if (!wrapper.IsEmpty()) | 3061 if (!wrapper.IsEmpty()) |
| 2927 wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $v iewType, impl->length()); | 3062 wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $v iewType, impl->length()); |
| 2928 return wrapper; | 3063 return wrapper; |
| 2929 } | 3064 } |
| 2930 | 3065 |
| 2931 END | 3066 END |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2971 } | 3106 } |
| 2972 } | 3107 } |
| 2973 | 3108 |
| 2974 # Separate out functions that are enabled per context so we can process them specially. | 3109 # Separate out functions that are enabled per context so we can process them specially. |
| 2975 if ($function->signature->extendedAttributes->{"EnabledPerContext"}) { | 3110 if ($function->signature->extendedAttributes->{"EnabledPerContext"}) { |
| 2976 push(@enabledPerContextFunctions, $function); | 3111 push(@enabledPerContextFunctions, $function); |
| 2977 } else { | 3112 } else { |
| 2978 push(@normalFunctions, $function); | 3113 push(@normalFunctions, $function); |
| 2979 } | 3114 } |
| 2980 } | 3115 } |
| 2981 if (!$namedPropertyGetter) { | |
| 2982 $namedPropertyGetter = $codeGenerator->FindSuperMethod($interface, "name dItem"); | |
| 2983 } | |
| 2984 | 3116 |
| 2985 if ($needsDomainSafeFunctionSetter) { | 3117 if ($needsDomainSafeFunctionSetter) { |
| 2986 GenerateDomainSafeFunctionSetter($interfaceName); | 3118 GenerateDomainSafeFunctionSetter($interfaceName); |
| 2987 } | 3119 } |
| 2988 | 3120 |
| 2989 # Attributes | 3121 # Attributes |
| 2990 my $attributes = $interface->attributes; | 3122 my $attributes = $interface->attributes; |
| 2991 | 3123 |
| 2992 # For the DOMWindow interface we partition the attributes into the | 3124 # For the DOMWindow interface we partition the attributes into the |
| 2993 # ones that disallows shadowing and the rest. | 3125 # ones that disallows shadowing and the rest. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 3004 push(@enabledAtRuntimeAttributes, $attribute); | 3136 push(@enabledAtRuntimeAttributes, $attribute); |
| 3005 } elsif ($attribute->signature->extendedAttributes->{"EnabledPerContext" }) { | 3137 } elsif ($attribute->signature->extendedAttributes->{"EnabledPerContext" }) { |
| 3006 push(@enabledPerContextAttributes, $attribute); | 3138 push(@enabledPerContextAttributes, $attribute); |
| 3007 } else { | 3139 } else { |
| 3008 push(@normalAttributes, $attribute); | 3140 push(@normalAttributes, $attribute); |
| 3009 } | 3141 } |
| 3010 } | 3142 } |
| 3011 $attributes = \@normalAttributes; | 3143 $attributes = \@normalAttributes; |
| 3012 # Put the attributes that disallow shadowing on the shadow object. | 3144 # Put the attributes that disallow shadowing on the shadow object. |
| 3013 if (@disallowsShadowing) { | 3145 if (@disallowsShadowing) { |
| 3014 push(@implContent, "static const V8DOMConfiguration::BatchedAttribute sh adowAttrs[] = {\n"); | 3146 my $stuff = ""; |
|
haraken
2013/04/16 09:40:36
$stuff is too ambiguous. $code ?
| |
| 3015 GenerateBatchedAttributeData($interface, \@disallowsShadowing); | 3147 $stuff .= "static const V8DOMConfiguration::BatchedAttribute shadowAttrs [] = {\n"; |
| 3016 push(@implContent, "};\n\n"); | 3148 $stuff .= GenerateBatchedAttributeData($interface, \@disallowsShadowing) ; |
| 3149 $stuff .= "};\n\n"; | |
| 3150 AddToImplStuff($stuff); | |
| 3017 } | 3151 } |
| 3018 | 3152 |
| 3019 my $has_attributes = 0; | 3153 my $has_attributes = 0; |
| 3020 if (@$attributes) { | 3154 if (@$attributes) { |
| 3021 $has_attributes = 1; | 3155 $has_attributes = 1; |
| 3022 push(@implContent, "static const V8DOMConfiguration::BatchedAttribute ${ v8InterfaceName}Attrs[] = {\n"); | 3156 my $stuff = ""; |
| 3023 GenerateBatchedAttributeData($interface, $attributes); | 3157 $stuff .= "static const V8DOMConfiguration::BatchedAttribute ${v8Interfa ceName}Attrs[] = {\n"; |
| 3024 push(@implContent, "};\n\n"); | 3158 $stuff .= GenerateBatchedAttributeData($interface, $attributes); |
| 3159 $stuff .= "};\n\n"; | |
| 3160 AddToImplStuff($stuff); | |
| 3025 } | 3161 } |
| 3026 | 3162 |
| 3027 # Setup table of standard callback functions | 3163 # Setup table of standard callback functions |
| 3028 my $num_callbacks = 0; | 3164 my $num_callbacks = 0; |
| 3029 my $has_callbacks = 0; | 3165 my $has_callbacks = 0; |
| 3166 my $stuff = ""; | |
| 3030 foreach my $function (@normalFunctions) { | 3167 foreach my $function (@normalFunctions) { |
| 3031 # Only one table entry is needed for overloaded methods: | 3168 # Only one table entry is needed for overloaded methods: |
| 3032 next if $function->{overloadIndex} > 1; | 3169 next if $function->{overloadIndex} > 1; |
| 3033 # Don't put any nonstandard functions into this table: | 3170 # Don't put any nonstandard functions into this table: |
| 3034 next if !IsStandardFunction($interface, $function); | 3171 next if !IsStandardFunction($interface, $function); |
| 3035 if (!$has_callbacks) { | 3172 if (!$has_callbacks) { |
| 3036 $has_callbacks = 1; | 3173 $has_callbacks = 1; |
| 3037 push(@implContent, "static const V8DOMConfiguration::BatchedMethod $ {v8InterfaceName}Methods[] = {\n"); | 3174 $stuff .= "static const V8DOMConfiguration::BatchedMethod ${v8Interf aceName}Methods[] = {\n"; |
| 3038 } | 3175 } |
| 3039 my $name = $function->signature->name; | 3176 my $name = $function->signature->name; |
| 3040 my $methodForMainWorld = "0"; | 3177 my $methodForMainWorld = "0"; |
| 3041 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { | 3178 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { |
| 3042 $methodForMainWorld = "${interfaceName}V8Internal::${name}MethodCall backForMainWorld"; | 3179 $methodForMainWorld = "${interfaceName}V8Internal::${name}MethodCall backForMainWorld"; |
| 3043 } | 3180 } |
| 3044 my $conditionalString = $codeGenerator->GenerateConditionalString($funct ion->signature); | 3181 my $conditionalString = $codeGenerator->GenerateConditionalString($funct ion->signature); |
| 3045 push(@implContent, "#if ${conditionalString}\n") if $conditionalString; | 3182 $stuff .= "#if ${conditionalString}\n" if $conditionalString; |
| 3046 push(@implContent, <<END); | 3183 $stuff .= <<END; |
| 3047 {"$name", ${interfaceName}V8Internal::${name}MethodCallback, ${methodForMain World}}, | 3184 {"$name", ${interfaceName}V8Internal::${name}MethodCallback, ${methodForMain World}}, |
| 3048 END | 3185 END |
| 3049 push(@implContent, "#endif\n") if $conditionalString; | 3186 $stuff .= "#endif\n" if $conditionalString; |
| 3050 $num_callbacks++; | 3187 $num_callbacks++; |
| 3051 } | 3188 } |
| 3052 push(@implContent, "};\n\n") if $has_callbacks; | 3189 $stuff .= "};\n\n" if $has_callbacks; |
| 3190 AddToImplStuff($stuff); | |
| 3053 | 3191 |
| 3054 # Setup constants | 3192 # Setup constants |
| 3055 my $has_constants = 0; | 3193 my $has_constants = 0; |
| 3056 my @constantsEnabledAtRuntime; | 3194 my @constantsEnabledAtRuntime; |
| 3195 $stuff = ""; | |
| 3057 if (@{$interface->constants}) { | 3196 if (@{$interface->constants}) { |
| 3058 $has_constants = 1; | 3197 $has_constants = 1; |
| 3059 push(@implContent, "static const V8DOMConfiguration::BatchedConstant ${v 8InterfaceName}Consts[] = {\n"); | 3198 $stuff .= "static const V8DOMConfiguration::BatchedConstant ${v8Interfac eName}Consts[] = {\n"; |
| 3060 } | 3199 } |
| 3061 foreach my $constant (@{$interface->constants}) { | 3200 foreach my $constant (@{$interface->constants}) { |
| 3062 my $name = $constant->name; | 3201 my $name = $constant->name; |
| 3063 my $value = $constant->value; | 3202 my $value = $constant->value; |
| 3064 my $attrExt = $constant->extendedAttributes; | 3203 my $attrExt = $constant->extendedAttributes; |
| 3065 my $conditional = $attrExt->{"Conditional"}; | 3204 my $conditional = $attrExt->{"Conditional"}; |
| 3066 my $implementedBy = $attrExt->{"ImplementedBy"}; | 3205 my $implementedBy = $attrExt->{"ImplementedBy"}; |
| 3067 if ($implementedBy) { | 3206 if ($implementedBy) { |
| 3068 AddToImplIncludes("${implementedBy}.h"); | 3207 AddToImplIncludes("${implementedBy}.h"); |
| 3069 } | 3208 } |
| 3070 if ($attrExt->{"EnabledAtRuntime"}) { | 3209 if ($attrExt->{"EnabledAtRuntime"}) { |
| 3071 push(@constantsEnabledAtRuntime, $constant); | 3210 push(@constantsEnabledAtRuntime, $constant); |
| 3072 } else { | 3211 } else { |
| 3073 if ($conditional) { | 3212 if ($conditional) { |
| 3074 my $conditionalString = $codeGenerator->GenerateConditionalStrin gFromAttributeValue($conditional); | 3213 my $conditionalString = $codeGenerator->GenerateConditionalStrin gFromAttributeValue($conditional); |
| 3075 push(@implContent, "#if ${conditionalString}\n"); | 3214 $stuff .= "#if ${conditionalString}\n"; |
| 3076 } | 3215 } |
| 3077 # If the value we're dealing with is a hex number, preprocess it int o a signed integer | 3216 # If the value we're dealing with is a hex number, preprocess it int o a signed integer |
| 3078 # here, rather than running static_cast<signed int> in the generated code. | 3217 # here, rather than running static_cast<signed int> in the generated code. |
| 3079 if (substr($value, 0, 2) eq "0x") { | 3218 if (substr($value, 0, 2) eq "0x") { |
| 3080 $value = unpack('i', pack('I', hex($value))); | 3219 $value = unpack('i', pack('I', hex($value))); |
| 3081 } | 3220 } |
| 3082 push(@implContent, <<END); | 3221 $stuff .= <<END; |
| 3083 {"${name}", $value}, | 3222 {"${name}", $value}, |
| 3084 END | 3223 END |
| 3085 push(@implContent, "#endif\n") if $conditional; | 3224 $stuff .= "#endif\n" if $conditional; |
| 3086 } | 3225 } |
| 3087 } | 3226 } |
| 3088 if ($has_constants) { | 3227 if ($has_constants) { |
| 3089 push(@implContent, "};\n\n"); | 3228 $stuff .= "};\n\n"; |
| 3090 push(@implContent, $codeGenerator->GenerateCompileTimeCheckForEnumsIfNee ded($interface)); | 3229 $stuff .= join "", $codeGenerator->GenerateCompileTimeCheckForEnumsIfNee ded($interface); |
| 3230 AddToImplStuff($stuff); | |
| 3091 } | 3231 } |
| 3092 | 3232 |
| 3093 if (!HasCustomConstructor($interface)) { | 3233 if (!HasCustomConstructor($interface)) { |
| 3094 if ($interface->extendedAttributes->{"NamedConstructor"}) { | 3234 if ($interface->extendedAttributes->{"NamedConstructor"}) { |
| 3095 GenerateNamedConstructor(@{$interface->constructors}[0], $interface) ; | 3235 GenerateNamedConstructor(@{$interface->constructors}[0], $interface) ; |
| 3096 } elsif ($interface->extendedAttributes->{"Constructor"}) { | 3236 } elsif ($interface->extendedAttributes->{"Constructor"}) { |
| 3097 GenerateConstructor($interface); | 3237 GenerateConstructor($interface); |
| 3098 } elsif ($codeGenerator->IsConstructorTemplate($interface, "Event")) { | 3238 } elsif ($codeGenerator->IsConstructorTemplate($interface, "Event")) { |
| 3099 GenerateEventConstructor($interface); | 3239 GenerateEventConstructor($interface); |
| 3100 } elsif ($codeGenerator->IsConstructorTemplate($interface, "TypedArray") ) { | 3240 } elsif ($codeGenerator->IsConstructorTemplate($interface, "TypedArray") ) { |
| 3101 GenerateTypedArrayConstructor($interface); | 3241 GenerateTypedArrayConstructor($interface); |
| 3102 } | 3242 } |
| 3103 } | 3243 } |
| 3104 if (IsConstructable($interface)) { | 3244 if (IsConstructable($interface)) { |
| 3105 GenerateConstructorCallback($interface); | 3245 GenerateConstructorCallback($interface); |
| 3106 } | 3246 } |
| 3107 | 3247 |
| 3108 push(@implContentInternals, "} // namespace ${interfaceName}V8Internal\n\n") ; | 3248 AddToImplStuffInternal("} // namespace ${interfaceName}V8Internal\n\n"); |
| 3109 | 3249 |
| 3110 my $access_check = ""; | 3250 my $access_check = ""; |
| 3111 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne " DOMWindow") { | 3251 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne " DOMWindow") { |
| 3112 $access_check = "instance->SetAccessCheckCallbacks(${interfaceName}V8Int ernal::namedSecurityCheck, ${interfaceName}V8Internal::indexedSecurityCheck, v8: :External::New(&${v8InterfaceName}::info));"; | 3252 $access_check = "instance->SetAccessCheckCallbacks(${interfaceName}V8Int ernal::namedSecurityCheck, ${interfaceName}V8Internal::indexedSecurityCheck, v8: :External::New(&${v8InterfaceName}::info));"; |
| 3113 } | 3253 } |
| 3114 | 3254 |
| 3115 # For the DOMWindow interface, generate the shadow object template | 3255 # For the DOMWindow interface, generate the shadow object template |
| 3116 # configuration method. | 3256 # configuration method. |
| 3117 if ($interfaceName eq "DOMWindow") { | 3257 if ($interfaceName eq "DOMWindow") { |
| 3118 push(@implContent, <<END); | 3258 AddToImplFunction(<<END); |
| 3119 static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Pers istent<v8::ObjectTemplate> templ, v8::Isolate* isolate, WrapperWorldType current WorldType) | 3259 static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Pers istent<v8::ObjectTemplate> templ, v8::Isolate* isolate, WrapperWorldType current WorldType) |
| 3120 { | 3260 { |
| 3121 V8DOMConfiguration::batchConfigureAttributes(templ, v8::Handle<v8::ObjectTem plate>(), shadowAttrs, WTF_ARRAY_LENGTH(shadowAttrs), isolate, currentWorldType) ; | 3261 V8DOMConfiguration::batchConfigureAttributes(templ, v8::Handle<v8::ObjectTem plate>(), shadowAttrs, WTF_ARRAY_LENGTH(shadowAttrs), isolate, currentWorldType) ; |
| 3122 | 3262 |
| 3123 // Install a security handler with V8. | 3263 // Install a security handler with V8. |
| 3124 templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheckCustom, V8DOMW indow::indexedSecurityCheckCustom, v8::External::New(&V8DOMWindow::info)); | 3264 templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheckCustom, V8DOMW indow::indexedSecurityCheckCustom, v8::External::New(&V8DOMWindow::info)); |
| 3125 templ->SetInternalFieldCount(V8DOMWindow::internalFieldCount); | 3265 templ->SetInternalFieldCount(V8DOMWindow::internalFieldCount); |
| 3126 return templ; | 3266 return templ; |
| 3127 } | 3267 } |
| 3128 END | 3268 END |
| 3129 } | 3269 } |
| 3130 | 3270 |
| 3131 if (!$parentClassTemplate) { | 3271 if (!$parentClassTemplate) { |
| 3132 $parentClassTemplate = "v8::Persistent<v8::FunctionTemplate>()"; | 3272 $parentClassTemplate = "v8::Persistent<v8::FunctionTemplate>()"; |
| 3133 } | 3273 } |
| 3134 | 3274 |
| 3135 # Generate the template configuration method | 3275 # Generate the template configuration method |
| 3136 push(@implContent, <<END); | 3276 my $func = ""; |
| 3277 $func .= <<END; | |
| 3137 static v8::Persistent<v8::FunctionTemplate> Configure${v8InterfaceName}Template( v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldTyp e currentWorldType) | 3278 static v8::Persistent<v8::FunctionTemplate> Configure${v8InterfaceName}Template( v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldTyp e currentWorldType) |
| 3138 { | 3279 { |
| 3139 desc->ReadOnlyPrototype(); | 3280 desc->ReadOnlyPrototype(); |
| 3140 | 3281 |
| 3141 v8::Local<v8::Signature> defaultSignature; | 3282 v8::Local<v8::Signature> defaultSignature; |
| 3142 END | 3283 END |
| 3143 if ($interface->extendedAttributes->{"EnabledAtRuntime"}) { | 3284 if ($interface->extendedAttributes->{"EnabledAtRuntime"}) { |
| 3144 my $enable_function = GetRuntimeEnableFunctionName($interface); | 3285 my $enable_function = GetRuntimeEnableFunctionName($interface); |
| 3145 push(@implContent, <<END); | 3286 $func .= <<END; |
| 3146 if (!${enable_function}()) | 3287 if (!${enable_function}()) |
| 3147 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"\", $pa rentClassTemplate, ${v8InterfaceName}::internalFieldCount, 0, 0, 0, 0, isolate, currentWorldType); | 3288 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"\", $pa rentClassTemplate, ${v8InterfaceName}::internalFieldCount, 0, 0, 0, 0, isolate, currentWorldType); |
| 3148 else | 3289 else |
| 3149 END | 3290 END |
| 3150 } | 3291 } |
| 3151 push(@implContent, <<END); | 3292 $func .= <<END; |
| 3152 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"${visibleIn terfaceName}\", $parentClassTemplate, ${v8InterfaceName}::internalFieldCount, | 3293 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"${visibleIn terfaceName}\", $parentClassTemplate, ${v8InterfaceName}::internalFieldCount, |
| 3153 END | 3294 END |
| 3154 # Set up our attributes if we have them | 3295 # Set up our attributes if we have them |
| 3155 if ($has_attributes) { | 3296 if ($has_attributes) { |
| 3156 push(@implContent, <<END); | 3297 $func .= <<END; |
| 3157 ${v8InterfaceName}Attrs, WTF_ARRAY_LENGTH(${v8InterfaceName}Attrs), | 3298 ${v8InterfaceName}Attrs, WTF_ARRAY_LENGTH(${v8InterfaceName}Attrs), |
| 3158 END | 3299 END |
| 3159 } else { | 3300 } else { |
| 3160 push(@implContent, <<END); | 3301 $func .= <<END; |
| 3161 0, 0, | 3302 0, 0, |
| 3162 END | 3303 END |
| 3163 } | 3304 } |
| 3164 | 3305 |
| 3165 if ($has_callbacks) { | 3306 if ($has_callbacks) { |
| 3166 push(@implContent, <<END); | 3307 $func .= <<END; |
| 3167 ${v8InterfaceName}Methods, WTF_ARRAY_LENGTH(${v8InterfaceName}Methods), isolate, currentWorldType); | 3308 ${v8InterfaceName}Methods, WTF_ARRAY_LENGTH(${v8InterfaceName}Methods), isolate, currentWorldType); |
| 3168 END | 3309 END |
| 3169 } else { | 3310 } else { |
| 3170 push(@implContent, <<END); | 3311 $func .= <<END; |
| 3171 0, 0, isolate, currentWorldType); | 3312 0, 0, isolate, currentWorldType); |
| 3172 END | 3313 END |
| 3173 } | 3314 } |
| 3174 | 3315 |
| 3175 AddToImplIncludes("wtf/UnusedParam.h"); | 3316 AddToImplIncludes("wtf/UnusedParam.h"); |
| 3176 push(@implContent, <<END); | 3317 $func .= <<END; |
| 3177 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 3318 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
| 3178 END | 3319 END |
| 3179 | 3320 |
| 3180 if (IsConstructable($interface)) { | 3321 if (IsConstructable($interface)) { |
| 3181 push(@implContent, " desc->SetCallHandler(${v8InterfaceName}::constru ctorCallback);\n"); | 3322 $func .= " desc->SetCallHandler(${v8InterfaceName}::constructorCallba ck);\n"; |
| 3182 } | 3323 } |
| 3183 | 3324 |
| 3184 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has _constants) { | 3325 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has _constants) { |
| 3185 push(@implContent, <<END); | 3326 $func .= <<END; |
| 3186 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 3327 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
| 3187 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 3328 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
| 3188 UNUSED_PARAM(instance); // In some cases, it will not be used. | 3329 UNUSED_PARAM(instance); // In some cases, it will not be used. |
| 3189 UNUSED_PARAM(proto); // In some cases, it will not be used. | 3330 UNUSED_PARAM(proto); // In some cases, it will not be used. |
| 3190 END | 3331 END |
| 3191 } | 3332 } |
| 3192 | 3333 |
| 3193 if ($access_check) { | 3334 if ($access_check) { |
| 3194 push(@implContent, " $access_check\n"); | 3335 $func .= " $access_check\n"; |
| 3195 } | 3336 } |
| 3196 | 3337 |
| 3197 # Setup the enable-at-runtime attrs if we have them | 3338 # Setup the enable-at-runtime attrs if we have them |
| 3198 foreach my $runtime_attr (@enabledAtRuntimeAttributes) { | 3339 foreach my $runtime_attr (@enabledAtRuntimeAttributes) { |
| 3199 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr->signat ure); | 3340 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr->signat ure); |
| 3200 my $conditionalString = $codeGenerator->GenerateConditionalString($runti me_attr->signature); | 3341 my $conditionalString = $codeGenerator->GenerateConditionalString($runti me_attr->signature); |
| 3201 push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString ; | 3342 $func .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 3202 push(@implContent, " if (${enable_function}()) {\n"); | 3343 $func .= " if (${enable_function}()) {\n"; |
| 3203 push(@implContent, " static const V8DOMConfiguration::BatchedAttr ibute attrData =\\\n"); | 3344 $func .= " static const V8DOMConfiguration::BatchedAttribute attr Data =\\\n"; |
| 3204 GenerateSingleBatchedAttribute($interfaceName, $runtime_attr, ";", " "); | 3345 $func .= GenerateSingleBatchedAttribute($interfaceName, $runtime_attr, " ;", " "); |
| 3205 push(@implContent, <<END); | 3346 $func .= <<END; |
| 3206 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e, currentWorldType); | 3347 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e, currentWorldType); |
| 3207 } | 3348 } |
| 3208 END | 3349 END |
| 3209 push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional String; | 3350 $func .= "\n#endif // ${conditionalString}\n" if $conditionalString; |
| 3210 } | 3351 } |
| 3211 | 3352 |
| 3212 # Setup the enable-at-runtime constants if we have them | 3353 # Setup the enable-at-runtime constants if we have them |
| 3213 foreach my $runtime_const (@constantsEnabledAtRuntime) { | 3354 foreach my $runtime_const (@constantsEnabledAtRuntime) { |
| 3214 my $enable_function = GetRuntimeEnableFunctionName($runtime_const); | 3355 my $enable_function = GetRuntimeEnableFunctionName($runtime_const); |
| 3215 my $conditionalString = $codeGenerator->GenerateConditionalString($runti me_const); | 3356 my $conditionalString = $codeGenerator->GenerateConditionalString($runti me_const); |
| 3216 my $name = $runtime_const->name; | 3357 my $name = $runtime_const->name; |
| 3217 my $value = $runtime_const->value; | 3358 my $value = $runtime_const->value; |
| 3218 push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString ; | 3359 $func .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 3219 push(@implContent, " if (${enable_function}()) {\n"); | 3360 $func .= " if (${enable_function}()) {\n"; |
| 3220 push(@implContent, <<END); | 3361 $func .= <<END; |
| 3221 static const V8DOMConfiguration::BatchedConstant constData = {"${name}", static_cast<signed int>(${value})}; | 3362 static const V8DOMConfiguration::BatchedConstant constData = {"${name}", static_cast<signed int>(${value})}; |
| 3222 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1, isolate); | 3363 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1, isolate); |
| 3223 END | 3364 END |
| 3224 push(@implContent, " }\n"); | 3365 $func .= " }\n"; |
| 3225 push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional String; | 3366 $func .= "\n#endif // ${conditionalString}\n" if $conditionalString; |
| 3226 } | 3367 } |
| 3227 | 3368 |
| 3228 GenerateImplementationIndexer($interface, $indexer); | 3369 $func .= GenerateImplementationIndexer($interface, $indexer); |
| 3229 GenerateImplementationNamedPropertyGetter($interface, $namedPropertyGetter); | 3370 |
| 3230 GenerateImplementationCustomCall($interface); | 3371 my ($tmplConfig, $namedPropertydGetter) = GenerateImplementationNamedPropert yGetter($interface, $namedPropertyGetter, $implContentGlobal); |
| 3231 GenerateImplementationMasqueradesAsUndefined($interface); | 3372 $func .= $tmplConfig; |
| 3373 $func .= GenerateImplementationCustomCall($interface); | |
| 3374 $func .= GenerateImplementationMasqueradesAsUndefined($interface); | |
| 3232 | 3375 |
| 3233 # Define our functions with Set() or SetAccessor() | 3376 # Define our functions with Set() or SetAccessor() |
| 3234 my $total_functions = 0; | 3377 my $total_functions = 0; |
| 3235 foreach my $function (@normalFunctions) { | 3378 foreach my $function (@normalFunctions) { |
| 3236 # Only one accessor is needed for overloaded methods: | 3379 # Only one accessor is needed for overloaded methods: |
| 3237 next if $function->{overloadIndex} > 1; | 3380 next if $function->{overloadIndex} > 1; |
| 3238 | 3381 |
| 3239 $total_functions++; | 3382 $total_functions++; |
| 3240 next if IsStandardFunction($interface, $function); | 3383 next if IsStandardFunction($interface, $function); |
| 3241 GenerateNonStandardFunction($interface, $function); | 3384 $func .= GenerateNonStandardFunction($interface, $function); |
| 3242 $num_callbacks++; | 3385 $num_callbacks++; |
| 3243 } | 3386 } |
| 3244 | 3387 |
| 3245 die "Wrong number of callbacks generated for $interfaceName ($num_callbacks, should be $total_functions)" if $num_callbacks != $total_functions; | 3388 die "Wrong number of callbacks generated for $interfaceName ($num_callbacks, should be $total_functions)" if $num_callbacks != $total_functions; |
| 3246 | 3389 |
| 3247 if ($has_constants) { | 3390 if ($has_constants) { |
| 3248 push(@implContent, <<END); | 3391 $func .= <<END; |
| 3249 V8DOMConfiguration::batchConfigureConstants(desc, proto, ${v8InterfaceName}C onsts, WTF_ARRAY_LENGTH(${v8InterfaceName}Consts), isolate); | 3392 V8DOMConfiguration::batchConfigureConstants(desc, proto, ${v8InterfaceName}C onsts, WTF_ARRAY_LENGTH(${v8InterfaceName}Consts), isolate); |
| 3250 END | 3393 END |
| 3251 } | 3394 } |
| 3252 | 3395 |
| 3253 # Special cases | 3396 # Special cases |
| 3254 if ($interfaceName eq "DOMWindow") { | 3397 if ($interfaceName eq "DOMWindow") { |
| 3255 push(@implContent, <<END); | 3398 $func .= <<END; |
| 3256 | 3399 |
| 3257 proto->SetInternalFieldCount(V8DOMWindow::internalFieldCount); | 3400 proto->SetInternalFieldCount(V8DOMWindow::internalFieldCount); |
| 3258 desc->SetHiddenPrototype(true); | 3401 desc->SetHiddenPrototype(true); |
| 3259 instance->SetInternalFieldCount(V8DOMWindow::internalFieldCount); | 3402 instance->SetInternalFieldCount(V8DOMWindow::internalFieldCount); |
| 3260 // Set access check callbacks, but turned off initially. | 3403 // Set access check callbacks, but turned off initially. |
| 3261 // When a context is detached from a frame, turn on the access check. | 3404 // When a context is detached from a frame, turn on the access check. |
| 3262 // Turning on checks also invalidates inline caches of the object. | 3405 // Turning on checks also invalidates inline caches of the object. |
| 3263 instance->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheckCustom, V8D OMWindow::indexedSecurityCheckCustom, v8::External::New(&V8DOMWindow::info), fal se); | 3406 instance->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheckCustom, V8D OMWindow::indexedSecurityCheckCustom, v8::External::New(&V8DOMWindow::info), fal se); |
| 3264 END | 3407 END |
| 3265 } | 3408 } |
| 3266 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerCo ntext" or $interfaceName eq "SharedWorkerContext") { | 3409 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerCo ntext" or $interfaceName eq "SharedWorkerContext") { |
| 3267 push(@implContent, <<END); | 3410 $func .= <<END; |
| 3268 desc->SetHiddenPrototype(true); | 3411 desc->SetHiddenPrototype(true); |
| 3269 END | 3412 END |
| 3270 } | 3413 } |
| 3271 if ($interfaceName eq "Location") { | 3414 if ($interfaceName eq "Location") { |
| 3272 push(@implContent, <<END); | 3415 $func .= <<END; |
| 3273 | 3416 |
| 3274 // For security reasons, these functions are on the instance instead | 3417 // For security reasons, these functions are on the instance instead |
| 3275 // of on the prototype object to ensure that they cannot be overwritten. | 3418 // of on the prototype object to ensure that they cannot be overwritten. |
| 3276 instance->SetAccessor(v8::String::NewSymbol("reload"), V8Location::reloadAtt rGetterCustom, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttri bute>(v8::DontDelete | v8::ReadOnly)); | 3419 instance->SetAccessor(v8::String::NewSymbol("reload"), V8Location::reloadAtt rGetterCustom, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttri bute>(v8::DontDelete | v8::ReadOnly)); |
| 3277 instance->SetAccessor(v8::String::NewSymbol("replace"), V8Location::replaceA ttrGetterCustom, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAtt ribute>(v8::DontDelete | v8::ReadOnly)); | 3420 instance->SetAccessor(v8::String::NewSymbol("replace"), V8Location::replaceA ttrGetterCustom, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAtt ribute>(v8::DontDelete | v8::ReadOnly)); |
| 3278 instance->SetAccessor(v8::String::NewSymbol("assign"), V8Location::assignAtt rGetterCustom, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttri bute>(v8::DontDelete | v8::ReadOnly)); | 3421 instance->SetAccessor(v8::String::NewSymbol("assign"), V8Location::assignAtt rGetterCustom, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttri bute>(v8::DontDelete | v8::ReadOnly)); |
| 3279 END | 3422 END |
| 3280 } | 3423 } |
| 3281 | 3424 |
| 3282 push(@implContent, <<END); | 3425 $func .= <<END; |
| 3283 | 3426 |
| 3284 // Custom toString template | 3427 // Custom toString template |
| 3285 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate()); | 3428 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate()); |
| 3286 return desc; | 3429 return desc; |
| 3287 } | 3430 } |
| 3288 | 3431 |
| 3432 END | |
| 3433 AddToImplFunction($func); | |
| 3434 | |
| 3435 AddToImplFunction(join "", $namedPropertydGetter); | |
|
haraken
2013/04/16 09:40:36
You might want to do it in GenerateImplementationN
| |
| 3436 | |
| 3437 AddToImplFunction(<<END); | |
| 3289 v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}::GetTemplate(v8::Isolate * isolate, WrapperWorldType currentWorldType) | 3438 v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}::GetTemplate(v8::Isolate * isolate, WrapperWorldType currentWorldType) |
| 3290 { | 3439 { |
| 3291 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 3440 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 3292 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info); | 3441 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info); |
| 3293 if (result != data->templateMap(currentWorldType).end()) | 3442 if (result != data->templateMap(currentWorldType).end()) |
| 3294 return result->value; | 3443 return result->value; |
| 3295 | 3444 |
| 3296 v8::HandleScope handleScope; | 3445 v8::HandleScope handleScope; |
| 3297 v8::Persistent<v8::FunctionTemplate> templ = | 3446 v8::Persistent<v8::FunctionTemplate> templ = |
| 3298 Configure${v8InterfaceName}Template(data->rawTemplate(&info, currentWorl dType), isolate, currentWorldType); | 3447 Configure${v8InterfaceName}Template(data->rawTemplate(&info, currentWorl dType), isolate, currentWorldType); |
| 3299 data->templateMap(currentWorldType).add(&info, templ); | 3448 data->templateMap(currentWorldType).add(&info, templ); |
| 3300 return templ; | 3449 return templ; |
| 3301 } | 3450 } |
| 3302 | 3451 |
| 3452 END | |
| 3453 AddToImplFunction(<<END); | |
| 3303 bool ${v8InterfaceName}::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* i solate, WrapperWorldType currentWorldType) | 3454 bool ${v8InterfaceName}::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* i solate, WrapperWorldType currentWorldType) |
| 3304 { | 3455 { |
| 3305 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType); | 3456 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType); |
| 3306 } | 3457 } |
| 3307 | 3458 |
| 3459 END | |
| 3460 AddToImplFunction(<<END); | |
| 3308 bool ${v8InterfaceName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8:: Isolate* isolate) | 3461 bool ${v8InterfaceName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8:: Isolate* isolate) |
| 3309 { | 3462 { |
| 3310 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | 3463 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) |
| 3311 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) | 3464 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) |
| 3312 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); | 3465 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); |
| 3313 } | 3466 } |
| 3314 | 3467 |
| 3315 END | 3468 END |
| 3316 | 3469 |
| 3317 if (@enabledPerContextAttributes) { | 3470 if (@enabledPerContextAttributes) { |
| 3318 push(@implContent, <<END); | 3471 my $func = ""; |
| 3472 $func .= <<END; | |
| 3319 void ${v8InterfaceName}::installPerContextProperties(v8::Handle<v8::Object> inst ance, ${nativeType}* impl, v8::Isolate* isolate) | 3473 void ${v8InterfaceName}::installPerContextProperties(v8::Handle<v8::Object> inst ance, ${nativeType}* impl, v8::Isolate* isolate) |
| 3320 { | 3474 { |
| 3321 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type()); | 3475 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type()); |
| 3322 // When building QtWebkit with V8 this variable is unused when none of the f eatures are enabled. | 3476 // When building QtWebkit with V8 this variable is unused when none of the f eatures are enabled. |
| 3323 UNUSED_PARAM(proto); | 3477 UNUSED_PARAM(proto); |
| 3324 END | 3478 END |
| 3325 | 3479 |
| 3326 # Setup the enable-by-settings attrs if we have them | 3480 # Setup the enable-by-settings attrs if we have them |
| 3327 foreach my $runtimeAttr (@enabledPerContextAttributes) { | 3481 foreach my $runtimeAttr (@enabledPerContextAttributes) { |
| 3328 my $enableFunction = GetContextEnableFunction($runtimeAttr->signatur e); | 3482 my $enableFunction = GetContextEnableFunction($runtimeAttr->signatur e); |
| 3329 my $conditionalString = $codeGenerator->GenerateConditionalString($r untimeAttr->signature); | 3483 my $conditionalString = $codeGenerator->GenerateConditionalString($r untimeAttr->signature); |
| 3330 push(@implContent, "\n#if ${conditionalString}\n") if $conditionalSt ring; | 3484 $func .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 3331 push(@implContent, " if (${enableFunction}(impl->document())) {\n "); | 3485 $func .= " if (${enableFunction}(impl->document())) {\n"; |
| 3332 push(@implContent, " static const V8DOMConfiguration::Batched Attribute attrData =\\\n"); | 3486 $func .= " static const V8DOMConfiguration::BatchedAttribute attrData =\\\n"; |
| 3333 GenerateSingleBatchedAttribute($interfaceName, $runtimeAttr, ";", " "); | 3487 $func .= GenerateSingleBatchedAttribute($interfaceName, $runtimeAttr , ";", " "); |
| 3334 push(@implContent, <<END); | 3488 $func .= <<END; |
| 3335 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e); | 3489 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e); |
| 3336 END | 3490 END |
| 3337 push(@implContent, " }\n"); | 3491 $func .= " }\n"; |
| 3338 push(@implContent, "#endif // ${conditionalString}\n") if $condition alString; | 3492 $func .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 3339 } | 3493 } |
| 3340 push(@implContent, <<END); | 3494 $func .= <<END; |
| 3341 } | 3495 } |
| 3342 | 3496 |
| 3343 END | 3497 END |
| 3498 AddToImplFunction($func); | |
| 3344 } | 3499 } |
| 3345 | 3500 |
| 3346 if (@enabledPerContextFunctions) { | 3501 if (@enabledPerContextFunctions) { |
| 3347 push(@implContent, <<END); | 3502 my $func = ""; |
| 3503 $func .= <<END; | |
| 3348 void ${v8InterfaceName}::installPerContextPrototypeProperties(v8::Handle<v8::Obj ect> proto, v8::Isolate* isolate) | 3504 void ${v8InterfaceName}::installPerContextPrototypeProperties(v8::Handle<v8::Obj ect> proto, v8::Isolate* isolate) |
| 3349 { | 3505 { |
| 3350 UNUSED_PARAM(proto); | 3506 UNUSED_PARAM(proto); |
| 3351 END | 3507 END |
| 3352 # Setup the enable-by-settings functions if we have them | 3508 # Setup the enable-by-settings functions if we have them |
| 3353 push(@implContent, <<END); | 3509 $func .= <<END; |
| 3354 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate))); | 3510 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate))); |
| 3355 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 3511 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
| 3356 | 3512 |
| 3357 ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationCo ntext()); | 3513 ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationCo ntext()); |
| 3358 END | 3514 END |
| 3359 | 3515 |
| 3360 foreach my $runtimeFunc (@enabledPerContextFunctions) { | 3516 foreach my $runtimeFunc (@enabledPerContextFunctions) { |
| 3361 my $enableFunction = GetContextEnableFunction($runtimeFunc->signatur e); | 3517 my $enableFunction = GetContextEnableFunction($runtimeFunc->signatur e); |
| 3362 my $conditionalString = $codeGenerator->GenerateConditionalString($r untimeFunc->signature); | 3518 my $conditionalString = $codeGenerator->GenerateConditionalString($r untimeFunc->signature); |
| 3363 push(@implContent, "\n#if ${conditionalString}\n") if $conditionalSt ring; | 3519 $func .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 3364 push(@implContent, " if (context && context->isDocument() && ${en ableFunction}(toDocument(context))) {\n"); | 3520 $func .= " if (context && context->isDocument() && ${enableFuncti on}(toDocument(context))) {\n"; |
| 3365 my $name = $runtimeFunc->signature->name; | 3521 my $name = $runtimeFunc->signature->name; |
| 3366 push(@implContent, <<END); | 3522 $func .= <<END; |
| 3367 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($ {interfaceName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur e)->GetFunction()); | 3523 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($ {interfaceName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur e)->GetFunction()); |
| 3368 END | 3524 END |
| 3369 push(@implContent, " }\n"); | 3525 $func .= " }\n"; |
| 3370 push(@implContent, "#endif // ${conditionalString}\n") if $condition alString; | 3526 $func .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 3371 } | 3527 } |
| 3372 | 3528 |
| 3373 push(@implContent, <<END); | 3529 $func .= <<END; |
| 3374 } | 3530 } |
| 3375 | 3531 |
| 3376 END | 3532 END |
| 3533 AddToImplFunction($func); | |
| 3377 } | 3534 } |
| 3378 | 3535 |
| 3379 if ($codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") ) { | 3536 if ($codeGenerator->InheritsExtendedAttribute($interface, "ActiveDOMObject") ) { |
| 3380 # MessagePort is handled like an active dom object even though it doesn' t inherit | 3537 # MessagePort is handled like an active dom object even though it doesn' t inherit |
| 3381 # from ActiveDOMObject, so don't try to cast it to ActiveDOMObject. | 3538 # from ActiveDOMObject, so don't try to cast it to ActiveDOMObject. |
| 3382 my $returnValue = $interfaceName eq "MessagePort" ? "0" : "toNative(obje ct)"; | 3539 my $returnValue = $interfaceName eq "MessagePort" ? "0" : "toNative(obje ct)"; |
| 3383 push(@implContent, <<END); | 3540 AddToImplFunction(<<END); |
| 3384 ActiveDOMObject* ${v8InterfaceName}::toActiveDOMObject(v8::Handle<v8::Object> ob ject) | 3541 ActiveDOMObject* ${v8InterfaceName}::toActiveDOMObject(v8::Handle<v8::Object> ob ject) |
| 3385 { | 3542 { |
| 3386 return $returnValue; | 3543 return $returnValue; |
| 3387 } | 3544 } |
| 3388 | 3545 |
| 3389 END | 3546 END |
| 3390 } | 3547 } |
| 3391 | 3548 |
| 3392 if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { | 3549 if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { |
| 3393 push(@implContent, <<END); | 3550 AddToImplFunction(<<END); |
| 3394 EventTarget* ${v8InterfaceName}::toEventTarget(v8::Handle<v8::Object> object) | 3551 EventTarget* ${v8InterfaceName}::toEventTarget(v8::Handle<v8::Object> object) |
| 3395 { | 3552 { |
| 3396 return toNative(object); | 3553 return toNative(object); |
| 3397 } | 3554 } |
| 3398 | 3555 |
| 3399 END | 3556 END |
| 3400 } | 3557 } |
| 3401 | 3558 |
| 3402 if ($interfaceName eq "DOMWindow") { | 3559 if ($interfaceName eq "DOMWindow") { |
| 3403 push(@implContent, <<END); | 3560 AddToImplFunction(<<END); |
| 3404 v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate(v8::Isol ate* isolate, WrapperWorldType currentWorldType) | 3561 v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate(v8::Isol ate* isolate, WrapperWorldType currentWorldType) |
| 3405 { | 3562 { |
| 3406 if (currentWorldType == MainWorld) { | 3563 if (currentWorldType == MainWorld) { |
| 3407 static v8::Persistent<v8::ObjectTemplate> V8DOMWindowShadowObjectCacheFo rMainWorld; | 3564 static v8::Persistent<v8::ObjectTemplate> V8DOMWindowShadowObjectCacheFo rMainWorld; |
| 3408 if (V8DOMWindowShadowObjectCacheForMainWorld.IsEmpty()) { | 3565 if (V8DOMWindowShadowObjectCacheForMainWorld.IsEmpty()) { |
| 3409 V8DOMWindowShadowObjectCacheForMainWorld = v8::Persistent<v8::Object Template>::New(isolate, v8::ObjectTemplate::New()); | 3566 V8DOMWindowShadowObjectCacheForMainWorld = v8::Persistent<v8::Object Template>::New(isolate, v8::ObjectTemplate::New()); |
| 3410 ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCacheForMainWor ld, isolate, currentWorldType); | 3567 ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCacheForMainWor ld, isolate, currentWorldType); |
| 3411 } | 3568 } |
| 3412 return V8DOMWindowShadowObjectCacheForMainWorld; | 3569 return V8DOMWindowShadowObjectCacheForMainWorld; |
| 3413 } else { | 3570 } else { |
| 3414 static v8::Persistent<v8::ObjectTemplate> V8DOMWindowShadowObjectCacheFo rNonMainWorld; | 3571 static v8::Persistent<v8::ObjectTemplate> V8DOMWindowShadowObjectCacheFo rNonMainWorld; |
| 3415 if (V8DOMWindowShadowObjectCacheForNonMainWorld.IsEmpty()) { | 3572 if (V8DOMWindowShadowObjectCacheForNonMainWorld.IsEmpty()) { |
| 3416 V8DOMWindowShadowObjectCacheForNonMainWorld = v8::Persistent<v8::Obj ectTemplate>::New(isolate, v8::ObjectTemplate::New()); | 3573 V8DOMWindowShadowObjectCacheForNonMainWorld = v8::Persistent<v8::Obj ectTemplate>::New(isolate, v8::ObjectTemplate::New()); |
| 3417 ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCacheForNonMain World, isolate, currentWorldType); | 3574 ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCacheForNonMain World, isolate, currentWorldType); |
| 3418 } | 3575 } |
| 3419 return V8DOMWindowShadowObjectCacheForNonMainWorld; | 3576 return V8DOMWindowShadowObjectCacheForNonMainWorld; |
| 3420 } | 3577 } |
| 3421 } | 3578 } |
| 3422 | 3579 |
| 3423 END | 3580 END |
| 3424 } | 3581 } |
| 3425 | 3582 |
| 3426 # FIXME: Separate array for generated code and move this block to GenerateIm plementationNamedPropertyGetter | |
| 3427 if ( $interface->extendedAttributes->{"NamedGetter"} ) { | |
| 3428 my $type = $namedPropertyGetter->type; | |
| 3429 push(@implContent, <<END); | |
| 3430 v8::Handle<v8::Value> ${v8InterfaceName}::namedPropertyGetter(v8::Local<v8::Stri ng> name, const v8::AccessorInfo& info) | |
| 3431 { | |
| 3432 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | |
| 3433 return v8Undefined(); | |
| 3434 if (info.Holder()->HasRealNamedCallbackProperty(name)) | |
| 3435 return v8Undefined(); | |
| 3436 | |
| 3437 v8::Local<v8::Object> object = info.Holder(); | |
| 3438 v8::Handle<v8::Object> creationContext = info.Holder(); | |
| 3439 v8::Isolate* isolate = info.GetIsolate(); | |
| 3440 | |
| 3441 ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); | |
| 3442 ASSERT(toWrapperTypeInfo(object) != &V8Node::info); | |
| 3443 $interfaceName* collection = toNative(object); | |
| 3444 | |
| 3445 AtomicString propertyName = toWebCoreAtomicStringWithNullCheck(name); | |
| 3446 RefPtr<$type> element = collection->namedItem(propertyName); | |
| 3447 | |
| 3448 if (!element) | |
| 3449 return v8Undefined(); | |
| 3450 | |
| 3451 return toV8(element.release(), creationContext, isolate); | |
| 3452 } | |
| 3453 END | |
| 3454 } | |
| 3455 | |
| 3456 GenerateToV8Converters($interface, $v8InterfaceName, $nativeType); | 3583 GenerateToV8Converters($interface, $v8InterfaceName, $nativeType); |
| 3457 | 3584 |
| 3458 push(@implContent, <<END); | 3585 AddToImplFunction(<<END); |
| 3459 void ${v8InterfaceName}::derefObject(void* object) | 3586 void ${v8InterfaceName}::derefObject(void* object) |
| 3460 { | 3587 { |
| 3461 static_cast<${nativeType}*>(object)->deref(); | 3588 static_cast<${nativeType}*>(object)->deref(); |
| 3462 } | 3589 } |
| 3463 | 3590 |
| 3591 END | |
| 3592 AddToImplStuff(<<END); | |
| 3464 } // namespace WebCore | 3593 } // namespace WebCore |
| 3465 END | 3594 END |
| 3466 | 3595 |
| 3467 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); | 3596 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); |
| 3468 push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalStri ng; | 3597 AddToImplStuff("\n#endif // ${conditionalString}\n") if $conditionalString; |
| 3469 | 3598 |
| 3470 # We've already added the header for this file in implContentHeader, so remo ve | 3599 # We've already added the header for this file in implContentHeader, so remo ve |
| 3471 # it from implIncludes to ensure we don't #include it twice. | 3600 # it from implIncludes to ensure we don't #include it twice. |
| 3472 delete $implIncludes{"${v8InterfaceName}.h"}; | 3601 delete $implIncludes{"${v8InterfaceName}.h"}; |
| 3473 } | 3602 } |
| 3474 | 3603 |
| 3604 | |
| 3605 | |
| 3475 sub GenerateHeaderContentHeader | 3606 sub GenerateHeaderContentHeader |
| 3476 { | 3607 { |
| 3477 my $interface = shift; | 3608 my $interface = shift; |
| 3478 my $v8InterfaceName = "V8" . $interface->name; | 3609 my $v8InterfaceName = "V8" . $interface->name; |
| 3479 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); | 3610 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); |
| 3480 | 3611 |
| 3481 my @headerContentHeader = split("\r", $headerTemplate); | 3612 my @headerContentHeader = split("\r", $headerTemplate); |
| 3482 | 3613 |
| 3483 push(@headerContentHeader, "\n#ifndef ${v8InterfaceName}" . "_h\n"); | 3614 push(@headerContentHeader, "\n#ifndef ${v8InterfaceName}" . "_h\n"); |
| 3484 push(@headerContentHeader, "#define ${v8InterfaceName}" . "_h\n\n"); | 3615 push(@headerContentHeader, "#define ${v8InterfaceName}" . "_h\n\n"); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 3503 sub GenerateCallbackHeader | 3634 sub GenerateCallbackHeader |
| 3504 { | 3635 { |
| 3505 my $object = shift; | 3636 my $object = shift; |
| 3506 my $interface = shift; | 3637 my $interface = shift; |
| 3507 | 3638 |
| 3508 my $interfaceName = $interface->name; | 3639 my $interfaceName = $interface->name; |
| 3509 my $v8InterfaceName = "V8$interfaceName"; | 3640 my $v8InterfaceName = "V8$interfaceName"; |
| 3510 | 3641 |
| 3511 | 3642 |
| 3512 # - Add default header template | 3643 # - Add default header template |
| 3513 push(@headerContent, GenerateHeaderContentHeader($interface)); | 3644 AddToHeader(GenerateHeaderContentHeader($interface)); |
| 3514 | 3645 |
| 3515 my @unsortedIncludes = (); | 3646 my @unsortedIncludes = (); |
| 3516 push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\""); | 3647 push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\""); |
| 3517 push(@unsortedIncludes, "#include \"DOMWrapperWorld.h\""); | 3648 push(@unsortedIncludes, "#include \"DOMWrapperWorld.h\""); |
| 3518 push(@unsortedIncludes, "#include \"$interfaceName.h\""); | 3649 push(@unsortedIncludes, "#include \"$interfaceName.h\""); |
| 3519 push(@unsortedIncludes, "#include \"ScopedPersistent.h\""); | 3650 push(@unsortedIncludes, "#include \"ScopedPersistent.h\""); |
| 3520 push(@unsortedIncludes, "#include <v8.h>"); | 3651 push(@unsortedIncludes, "#include <v8.h>"); |
| 3521 push(@unsortedIncludes, "#include <wtf/Forward.h>"); | 3652 push(@unsortedIncludes, "#include <wtf/Forward.h>"); |
| 3522 push(@headerContent, join("\n", sort @unsortedIncludes)); | 3653 AddToHeader(join("\n", sort @unsortedIncludes)); |
| 3523 | 3654 |
| 3524 push(@headerContent, "\n\nnamespace WebCore {\n\n"); | 3655 AddToHeader("\n\nnamespace WebCore {\n\n"); |
| 3525 push(@headerContent, "class ScriptExecutionContext;\n\n"); | 3656 AddToHeader("class ScriptExecutionContext;\n\n"); |
| 3526 push(@headerContent, "class $v8InterfaceName : public $interfaceName, public ActiveDOMCallback {\n"); | 3657 AddToHeader("class $v8InterfaceName : public $interfaceName, public ActiveDO MCallback {\n"); |
| 3527 | 3658 |
| 3528 push(@headerContent, <<END); | 3659 AddToHeader(<<END); |
| 3529 public: | 3660 public: |
| 3530 static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, Sc riptExecutionContext* context) | 3661 static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, Sc riptExecutionContext* context) |
| 3531 { | 3662 { |
| 3532 ASSERT(value->IsObject()); | 3663 ASSERT(value->IsObject()); |
| 3533 ASSERT(context); | 3664 ASSERT(context); |
| 3534 return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(valu e), context)); | 3665 return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(valu e), context)); |
| 3535 } | 3666 } |
| 3536 | 3667 |
| 3537 virtual ~${v8InterfaceName}(); | 3668 virtual ~${v8InterfaceName}(); |
| 3538 | 3669 |
| 3539 END | 3670 END |
| 3540 | 3671 |
| 3541 # Functions | 3672 # Functions |
| 3542 my $numFunctions = @{$interface->functions}; | 3673 my $numFunctions = @{$interface->functions}; |
| 3543 if ($numFunctions > 0) { | 3674 if ($numFunctions > 0) { |
| 3544 push(@headerContent, " // Functions\n"); | 3675 AddToHeader(" // Functions\n"); |
| 3545 foreach my $function (@{$interface->functions}) { | 3676 foreach my $function (@{$interface->functions}) { |
| 3546 my @params = @{$function->parameters}; | 3677 my @params = @{$function->parameters}; |
| 3547 if (!$function->signature->extendedAttributes->{"Custom"} && | 3678 if (!$function->signature->extendedAttributes->{"Custom"} && |
| 3548 !(GetNativeType($function->signature->type) eq "bool")) { | 3679 !(GetNativeType($function->signature->type) eq "bool")) { |
| 3549 push(@headerContent, " COMPILE_ASSERT(false)"); | 3680 AddToHeader(" COMPILE_ASSERT(false)"); |
| 3550 } | 3681 } |
| 3551 | 3682 |
| 3552 push(@headerContent, " virtual " . GetNativeTypeForCallbacks($fun ction->signature->type) . " " . $function->signature->name . "("); | 3683 AddToHeader(" virtual " . GetNativeTypeForCallbacks($function->si gnature->type) . " " . $function->signature->name . "("); |
| 3553 | 3684 |
| 3554 my @args = (); | 3685 my @args = (); |
| 3555 foreach my $param (@params) { | 3686 foreach my $param (@params) { |
| 3556 push(@args, GetNativeTypeForCallbacks($param->type) . " " . $par am->name); | 3687 push(@args, GetNativeTypeForCallbacks($param->type) . " " . $par am->name); |
| 3557 } | 3688 } |
| 3558 push(@headerContent, join(", ", @args)); | 3689 AddToHeader(join(", ", @args)); |
| 3559 push(@headerContent, ");\n"); | 3690 AddToHeader(");\n"); |
| 3560 } | 3691 } |
| 3561 } | 3692 } |
| 3562 | 3693 |
| 3563 push(@headerContent, <<END); | 3694 AddToHeader(<<END); |
| 3564 | 3695 |
| 3565 virtual ScriptExecutionContext* scriptExecutionContext() const { return Cont extDestructionObserver::scriptExecutionContext(); } | 3696 virtual ScriptExecutionContext* scriptExecutionContext() const { return Cont extDestructionObserver::scriptExecutionContext(); } |
| 3566 | 3697 |
| 3567 private: | 3698 private: |
| 3568 ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*); | 3699 ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*); |
| 3569 | 3700 |
| 3570 ScopedPersistent<v8::Object> m_callback; | 3701 ScopedPersistent<v8::Object> m_callback; |
| 3571 RefPtr<DOMWrapperWorld> m_world; | 3702 RefPtr<DOMWrapperWorld> m_world; |
| 3572 }; | 3703 }; |
| 3573 | 3704 |
| 3574 END | 3705 END |
| 3575 | 3706 |
| 3576 push(@headerContent, "}\n\n"); | 3707 AddToHeader("}\n\n"); |
| 3577 push(@headerContent, "#endif // $v8InterfaceName" . "_h\n\n"); | 3708 AddToHeader("#endif // $v8InterfaceName" . "_h\n\n"); |
| 3578 | 3709 |
| 3579 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); | 3710 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); |
| 3580 push(@headerContent, "#endif // ${conditionalString}\n") if $conditionalStri ng; | 3711 AddToHeader("#endif // ${conditionalString}\n") if $conditionalString; |
| 3581 } | 3712 } |
| 3582 | 3713 |
| 3583 sub GenerateCallbackImplementation | 3714 sub GenerateCallbackImplementation |
| 3584 { | 3715 { |
| 3585 my $object = shift; | 3716 my $object = shift; |
| 3586 my $interface = shift; | 3717 my $interface = shift; |
| 3587 my $interfaceName = $interface->name; | 3718 my $interfaceName = $interface->name; |
| 3588 my $v8InterfaceName = "V8$interfaceName"; | 3719 my $v8InterfaceName = "V8$interfaceName"; |
| 3589 | 3720 |
| 3590 # - Add default header template | 3721 # - Add default header template |
| 3591 push(@implContentHeader, GenerateImplementationContentHeader($interface)); | 3722 push(@implContentHeader, GenerateImplementationContentHeader($interface)); |
| 3592 | 3723 |
| 3593 AddToImplIncludes("ScriptExecutionContext.h"); | 3724 AddToImplIncludes("ScriptExecutionContext.h"); |
| 3594 AddToImplIncludes("V8Binding.h"); | 3725 AddToImplIncludes("V8Binding.h"); |
| 3595 AddToImplIncludes("V8Callback.h"); | 3726 AddToImplIncludes("V8Callback.h"); |
| 3596 | 3727 |
| 3597 push(@implContent, "#include <wtf/Assertions.h>\n\n"); | 3728 AddToImplStuff("#include <wtf/Assertions.h>\n\n"); |
| 3598 push(@implContent, "namespace WebCore {\n\n"); | 3729 AddToImplStuff("namespace WebCore {\n\n"); |
| 3599 push(@implContent, <<END); | 3730 |
| 3731 AddToImplFunction(<<END); | |
| 3600 ${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptEx ecutionContext* context) | 3732 ${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptEx ecutionContext* context) |
| 3601 : ActiveDOMCallback(context) | 3733 : ActiveDOMCallback(context) |
| 3602 , m_callback(callback) | 3734 , m_callback(callback) |
| 3603 , m_world(context->isDocument() ? DOMWrapperWorld::isolatedWorld(v8::Context ::GetCurrent()) : 0) | 3735 , m_world(context->isDocument() ? DOMWrapperWorld::isolatedWorld(v8::Context ::GetCurrent()) : 0) |
| 3604 { | 3736 { |
| 3605 } | 3737 } |
| 3606 | 3738 |
| 3739 END | |
| 3740 | |
| 3741 AddToImplFunction(<<END); | |
| 3607 ${v8InterfaceName}::~${v8InterfaceName}() | 3742 ${v8InterfaceName}::~${v8InterfaceName}() |
| 3608 { | 3743 { |
| 3609 } | 3744 } |
| 3610 | 3745 |
| 3611 END | 3746 END |
| 3612 | 3747 |
| 3613 # Functions | 3748 # Functions |
| 3614 my $numFunctions = @{$interface->functions}; | 3749 my $numFunctions = @{$interface->functions}; |
| 3615 if ($numFunctions > 0) { | 3750 if ($numFunctions > 0) { |
| 3616 push(@implContent, "// Functions\n"); | 3751 AddToImplStuff("// Functions\n"); |
| 3617 foreach my $function (@{$interface->functions}) { | 3752 foreach my $function (@{$interface->functions}) { |
| 3753 my $func = ""; | |
| 3618 my @params = @{$function->parameters}; | 3754 my @params = @{$function->parameters}; |
| 3619 if ($function->signature->extendedAttributes->{"Custom"} || | 3755 if ($function->signature->extendedAttributes->{"Custom"} || |
| 3620 !(GetNativeTypeForCallbacks($function->signature->type) eq "bool ")) { | 3756 !(GetNativeTypeForCallbacks($function->signature->type) eq "bool ")) { |
| 3621 next; | 3757 next; |
| 3622 } | 3758 } |
| 3623 | 3759 |
| 3624 AddIncludesForType($function->signature->type); | 3760 AddIncludesForType($function->signature->type); |
| 3625 push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signa ture->type) . " ${v8InterfaceName}::" . $function->signature->name . "("); | 3761 $func .= "\n" . GetNativeTypeForCallbacks($function->signature->type ) . " ${v8InterfaceName}::" . $function->signature->name . "("; |
| 3626 | 3762 |
| 3627 my @args = (); | 3763 my @args = (); |
| 3628 my @argsCheck = (); | 3764 my @argsCheck = (); |
| 3629 my $thisType = $function->signature->extendedAttributes->{"PassThisT oCallback"}; | 3765 my $thisType = $function->signature->extendedAttributes->{"PassThisT oCallback"}; |
| 3630 foreach my $param (@params) { | 3766 foreach my $param (@params) { |
| 3631 my $paramName = $param->name; | 3767 my $paramName = $param->name; |
| 3632 AddIncludesForType($param->type); | 3768 AddIncludesForType($param->type); |
| 3633 push(@args, GetNativeTypeForCallbacks($param->type) . " " . $par amName); | 3769 push(@args, GetNativeTypeForCallbacks($param->type) . " " . $par amName); |
| 3634 if ($thisType and $thisType eq $param->type) { | 3770 if ($thisType and $thisType eq $param->type) { |
| 3635 push(@argsCheck, <<END); | 3771 push(@argsCheck, <<END); |
| 3636 ASSERT(${paramName}); | 3772 ASSERT(${paramName}); |
| 3637 | 3773 |
| 3638 END | 3774 END |
| 3639 } | 3775 } |
| 3640 } | 3776 } |
| 3641 push(@implContent, join(", ", @args)); | 3777 $func .= join(", ", @args); |
| 3642 | 3778 |
| 3643 push(@implContent, ")\n"); | 3779 $func .= ")\n"; |
| 3644 push(@implContent, "{\n"); | 3780 $func .= "{\n"; |
| 3645 push(@implContent, @argsCheck) if @argsCheck; | 3781 $func .= join "", @argsCheck if @argsCheck; |
| 3646 push(@implContent, " if (!canInvokeCallback())\n"); | 3782 $func .= " if (!canInvokeCallback())\n"; |
| 3647 push(@implContent, " return true;\n\n"); | 3783 $func .= " return true;\n\n"; |
| 3648 push(@implContent, " v8::HandleScope handleScope;\n\n"); | 3784 $func .= " v8::HandleScope handleScope;\n\n"; |
| 3649 push(@implContent, " v8::Handle<v8::Context> v8Context = toV8Cont ext(scriptExecutionContext(), m_world.get());\n"); | 3785 $func .= " v8::Handle<v8::Context> v8Context = toV8Context(script ExecutionContext(), m_world.get());\n"; |
| 3650 push(@implContent, " if (v8Context.IsEmpty())\n"); | 3786 $func .= " if (v8Context.IsEmpty())\n"; |
| 3651 push(@implContent, " return true;\n\n"); | 3787 $func .= " return true;\n\n"; |
| 3652 push(@implContent, " v8::Context::Scope scope(v8Context);\n\n"); | 3788 $func .= " v8::Context::Scope scope(v8Context);\n\n"; |
| 3653 | 3789 |
| 3654 @args = (); | 3790 @args = (); |
| 3655 foreach my $param (@params) { | 3791 foreach my $param (@params) { |
| 3656 my $paramName = $param->name; | 3792 my $paramName = $param->name; |
| 3657 push(@implContent, " v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName, "v8::Handle<v8::Object>()", "v8Contex t->GetIsolate()", "") . ";\n"); | 3793 $func .= " v8::Handle<v8::Value> ${paramName}Handle = " . Nat iveToJSValue($param, $paramName, "v8::Handle<v8::Object>()", "v8Context->GetIsol ate()", "") . ";\n"; |
| 3658 push(@implContent, " if (${paramName}Handle.IsEmpty()) {\n"); | 3794 $func .= " if (${paramName}Handle.IsEmpty()) {\n"; |
| 3659 push(@implContent, " if (!isScriptControllerTerminating() )\n"); | 3795 $func .= " if (!isScriptControllerTerminating())\n"; |
| 3660 push(@implContent, " CRASH();\n"); | 3796 $func .= " CRASH();\n"; |
| 3661 push(@implContent, " return true;\n"); | 3797 $func .= " return true;\n"; |
| 3662 push(@implContent, " }\n"); | 3798 $func .= " }\n"; |
| 3663 push(@args, " ${paramName}Handle"); | 3799 push(@args, " ${paramName}Handle"); |
| 3664 } | 3800 } |
| 3665 | 3801 |
| 3666 if (scalar(@args) > 0) { | 3802 if (scalar(@args) > 0) { |
| 3667 push(@implContent, "\n v8::Handle<v8::Value> argv[] = {\n"); | 3803 $func .= "\n v8::Handle<v8::Value> argv[] = {\n"; |
| 3668 push(@implContent, join(",\n", @args)); | 3804 $func .= join(",\n", @args); |
| 3669 push(@implContent, "\n };\n\n"); | 3805 $func .= "\n };\n\n"; |
| 3670 } else { | 3806 } else { |
| 3671 push(@implContent, "\n v8::Handle<v8::Value> *argv = 0;\n\n") ; | 3807 $func .= "\n v8::Handle<v8::Value> *argv = 0;\n\n"; |
| 3672 } | 3808 } |
| 3673 push(@implContent, " bool callbackReturnValue = false;\n"); | 3809 $func .= " bool callbackReturnValue = false;\n"; |
| 3674 if ($thisType) { | 3810 if ($thisType) { |
| 3675 foreach my $param (@params) { | 3811 foreach my $param (@params) { |
| 3676 next if $param->type ne $thisType; | 3812 next if $param->type ne $thisType; |
| 3677 my $paramName = $param->name; | 3813 my $paramName = $param->name; |
| 3678 push(@implContent, " return !invokeCallback(m_callback.ge t(), v8::Handle<v8::Object>::Cast(${paramName}Handle), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); | 3814 $func .= " return !invokeCallback(m_callback.get(), v8::H andle<v8::Object>::Cast(${paramName}Handle), " . scalar(@params) . ", argv, call backReturnValue, scriptExecutionContext());\n"; |
| 3815 AddToImplFunction($func); | |
| 3679 last; | 3816 last; |
| 3680 } | 3817 } |
| 3681 } else { | 3818 } else { |
| 3682 push(@implContent, " return !invokeCallback(m_callback.get(), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\ n"); | 3819 $func .= " return !invokeCallback(m_callback.get(), " . scala r(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"; |
| 3683 } | 3820 } |
| 3684 push(@implContent, "}\n"); | 3821 $func .= "}\n"; |
| 3822 AddToImplFunction($func); | |
| 3685 } | 3823 } |
| 3686 } | 3824 } |
| 3687 | 3825 |
| 3688 push(@implContent, "\n} // namespace WebCore\n\n"); | 3826 AddToImplStuff("\n} // namespace WebCore\n\n"); |
| 3689 | 3827 |
| 3690 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); | 3828 my $conditionalString = $codeGenerator->GenerateConditionalString($interface ); |
| 3691 push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString ; | 3829 AddToImplStuff("#endif // ${conditionalString}\n") if $conditionalString; |
| 3692 } | 3830 } |
| 3693 | 3831 |
| 3694 sub BaseInterfaceName | 3832 sub BaseInterfaceName |
| 3695 { | 3833 { |
| 3696 my $interface = shift; | 3834 my $interface = shift; |
| 3697 | 3835 |
| 3698 while (@{$interface->parents}) { | 3836 while (@{$interface->parents}) { |
| 3699 $interface = $codeGenerator->ParseInterface(@{$interface->parents}[0]); | 3837 $interface = $codeGenerator->ParseInterface(@{$interface->parents}[0]); |
| 3700 } | 3838 } |
| 3701 | 3839 |
| 3702 return $interface->name; | 3840 return $interface->name; |
| 3703 } | 3841 } |
| 3704 | 3842 |
| 3705 sub GenerateToV8Converters | 3843 sub GenerateToV8Converters |
| 3706 { | 3844 { |
| 3707 my $interface = shift; | 3845 my $interface = shift; |
| 3708 my $v8InterfaceName = shift; | 3846 my $v8InterfaceName = shift; |
| 3709 my $nativeType = shift; | 3847 my $nativeType = shift; |
| 3710 my $interfaceName = $interface->name; | 3848 my $interfaceName = $interface->name; |
| 3711 | 3849 |
| 3712 if ($interface->extendedAttributes->{"NoWrapperCache"} || $interface->extend edAttributes->{"SuppressToJSObject"}) { | 3850 if ($interface->extendedAttributes->{"NoWrapperCache"} || $interface->extend edAttributes->{"SuppressToJSObject"}) { |
| 3713 return; | 3851 return; |
| 3714 } | 3852 } |
| 3715 | 3853 |
| 3716 AddToImplIncludes("Frame.h"); | 3854 AddToImplIncludes("Frame.h"); |
| 3717 | 3855 |
| 3718 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); | 3856 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); |
| 3719 my $baseType = BaseInterfaceName($interface); | 3857 my $baseType = BaseInterfaceName($interface); |
| 3720 | 3858 |
| 3721 push(@implContent, <<END); | 3859 my $func = ""; |
| 3860 $func .= <<END; | |
| 3722 | 3861 |
| 3723 v8::Handle<v8::Object> ${v8InterfaceName}::createWrapper(${createWrapperArgument Type} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 3862 v8::Handle<v8::Object> ${v8InterfaceName}::createWrapper(${createWrapperArgument Type} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 3724 { | 3863 { |
| 3725 ASSERT(impl.get()); | 3864 ASSERT(impl.get()); |
| 3726 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); | 3865 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); |
| 3727 END | 3866 END |
| 3728 | 3867 |
| 3729 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); | 3868 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); |
| 3730 push(@implContent, <<END) if $vtableNameGnu; | 3869 $func .= <<END if $vtableNameGnu; |
| 3731 | 3870 |
| 3732 #if ENABLE(BINDING_INTEGRITY) | 3871 #if ENABLE(BINDING_INTEGRITY) |
| 3733 checkTypeOrDieTrying(impl.get()); | 3872 checkTypeOrDieTrying(impl.get()); |
| 3734 #endif | 3873 #endif |
| 3735 END | 3874 END |
| 3736 | 3875 |
| 3737 push(@implContent, <<END) if ($baseType ne $interfaceName); | 3876 $func .= <<END if ($baseType ne $interfaceName); |
| 3738 ASSERT(static_cast<void*>(static_cast<${baseType}*>(impl.get())) == static_c ast<void*>(impl.get())); | 3877 ASSERT(static_cast<void*>(static_cast<${baseType}*>(impl.get())) == static_c ast<void*>(impl.get())); |
| 3739 END | 3878 END |
| 3740 | 3879 |
| 3741 if ($codeGenerator->InheritsInterface($interface, "Document")) { | 3880 if ($codeGenerator->InheritsInterface($interface, "Document")) { |
| 3742 push(@implContent, <<END); | 3881 $func .= <<END; |
| 3743 if (Frame* frame = impl->frame()) { | 3882 if (Frame* frame = impl->frame()) { |
| 3744 if (frame->script()->initializeMainWorld()) { | 3883 if (frame->script()->initializeMainWorld()) { |
| 3745 // initializeMainWorld may have created a wrapper for the object, re try from the start. | 3884 // initializeMainWorld may have created a wrapper for the object, re try from the start. |
| 3746 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper(impl.get() , isolate); | 3885 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper(impl.get() , isolate); |
| 3747 if (!wrapper.IsEmpty()) | 3886 if (!wrapper.IsEmpty()) |
| 3748 return wrapper; | 3887 return wrapper; |
| 3749 } | 3888 } |
| 3750 } | 3889 } |
| 3751 END | 3890 END |
| 3752 } | 3891 } |
| 3753 | 3892 |
| 3754 push(@implContent, <<END); | 3893 $func .= <<END; |
| 3755 | 3894 |
| 3756 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, impl.get(), isolate); | 3895 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, impl.get(), isolate); |
| 3757 if (UNLIKELY(wrapper.IsEmpty())) | 3896 if (UNLIKELY(wrapper.IsEmpty())) |
| 3758 return wrapper; | 3897 return wrapper; |
| 3759 | 3898 |
| 3760 installPerContextProperties(wrapper, impl.get(), isolate); | 3899 installPerContextProperties(wrapper, impl.get(), isolate); |
| 3761 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasD ependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Indep endent); | 3900 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasD ependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Indep endent); |
| 3762 return wrapper; | 3901 return wrapper; |
| 3763 } | 3902 } |
| 3764 END | 3903 END |
| 3904 AddToImplFunction($func); | |
| 3765 } | 3905 } |
| 3766 | 3906 |
| 3767 sub GenerateSecurityCheckFunctions | 3907 sub GenerateSecurityCheckFunctions |
| 3768 { | 3908 { |
| 3769 my $interface = shift; | 3909 my $interface = shift; |
| 3770 my $interfaceName = $interface->name; | 3910 my $interfaceName = $interface->name; |
| 3771 my $v8InterfaceName = "V8$interfaceName"; | 3911 my $v8InterfaceName = "V8$interfaceName"; |
| 3772 | 3912 |
| 3773 push(@implContentInternals, <<END); | 3913 AddToImplFunctionInternal(<<END); |
| 3774 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>) | 3914 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>) |
| 3775 { | 3915 { |
| 3776 $interfaceName* imp = ${v8InterfaceName}::toNative(host); | 3916 $interfaceName* imp = ${v8InterfaceName}::toNative(host); |
| 3777 return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), i mp->frame(), DoNotReportSecurityError); | 3917 return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), i mp->frame(), DoNotReportSecurityError); |
| 3778 } | 3918 } |
| 3779 | 3919 |
| 3920 END | |
| 3921 AddToImplFunctionInternal(<<END); | |
| 3780 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>) | 3922 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>) |
| 3781 { | 3923 { |
| 3782 $interfaceName* imp = ${v8InterfaceName}::toNative(host); | 3924 $interfaceName* imp = ${v8InterfaceName}::toNative(host); |
| 3783 return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), i mp->frame(), DoNotReportSecurityError); | 3925 return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), i mp->frame(), DoNotReportSecurityError); |
| 3784 } | 3926 } |
| 3785 | 3927 |
| 3786 END | 3928 END |
| 3787 } | 3929 } |
| 3788 | 3930 |
| 3789 sub GetNativeTypeForConversions | 3931 sub GetNativeTypeForConversions |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3937 AddToImplIncludes("${implementedBy}.h"); | 4079 AddToImplIncludes("${implementedBy}.h"); |
| 3938 unshift(@arguments, "imp") if !$function->isStatic; | 4080 unshift(@arguments, "imp") if !$function->isStatic; |
| 3939 $functionName = "${implementedBy}::${name}"; | 4081 $functionName = "${implementedBy}::${name}"; |
| 3940 } elsif ($function->isStatic) { | 4082 } elsif ($function->isStatic) { |
| 3941 $functionName = "${interfaceName}::${name}"; | 4083 $functionName = "${interfaceName}::${name}"; |
| 3942 } else { | 4084 } else { |
| 3943 $functionName = "imp->${name}"; | 4085 $functionName = "imp->${name}"; |
| 3944 } | 4086 } |
| 3945 | 4087 |
| 3946 my $callWith = $function->signature->extendedAttributes->{"CallWith"}; | 4088 my $callWith = $function->signature->extendedAttributes->{"CallWith"}; |
| 3947 my @callWithOutput = (); | 4089 my ($callWithArgs, $code) = GenerateCallWith($callWith, $indent, 0, $functio n); |
| 3948 my @callWithArgs = GenerateCallWith($callWith, \@callWithOutput, $indent, 0, $function); | 4090 $result .= $code; |
| 3949 $result .= join("", @callWithOutput); | 4091 unshift(@arguments, @$callWithArgs); |
| 3950 unshift(@arguments, @callWithArgs); | 4092 $index += @$callWithArgs; |
| 3951 $index += @callWithArgs; | 4093 $numberOfParameters += @$callWithArgs; |
| 3952 $numberOfParameters += @callWithArgs; | |
| 3953 | 4094 |
| 3954 foreach my $parameter (@{$function->parameters}) { | 4095 foreach my $parameter (@{$function->parameters}) { |
| 3955 if ($index eq $numberOfParameters) { | 4096 if ($index eq $numberOfParameters) { |
| 3956 last; | 4097 last; |
| 3957 } | 4098 } |
| 3958 my $paramName = $parameter->name; | 4099 my $paramName = $parameter->name; |
| 3959 my $paramType = $parameter->type; | 4100 my $paramType = $parameter->type; |
| 3960 | 4101 |
| 3961 if ($replacements{$paramName}) { | 4102 if ($replacements{$paramName}) { |
| 3962 push @arguments, $replacements{$paramName}; | 4103 push @arguments, $replacements{$paramName}; |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4545 } | 4686 } |
| 4546 foreach my $condition (sort keys %implIncludeConditions) { | 4687 foreach my $condition (sort keys %implIncludeConditions) { |
| 4547 $contents .= "\n#if " . $codeGenerator->GenerateConditionalStringFromAtt ributeValue($condition) . "\n"; | 4688 $contents .= "\n#if " . $codeGenerator->GenerateConditionalStringFromAtt ributeValue($condition) . "\n"; |
| 4548 foreach my $include (sort @{$implIncludeConditions{$condition}}) { | 4689 foreach my $include (sort @{$implIncludeConditions{$condition}}) { |
| 4549 $contents .= "#include $include\n"; | 4690 $contents .= "#include $include\n"; |
| 4550 } | 4691 } |
| 4551 $contents .= "#endif\n"; | 4692 $contents .= "#endif\n"; |
| 4552 } | 4693 } |
| 4553 | 4694 |
| 4554 $contents .= "\n"; | 4695 $contents .= "\n"; |
| 4555 $contents .= join "", @implContentInternals, @implContent; | 4696 $contents .= join "", @implInternalStuff, @implStuff; |
| 4556 $codeGenerator->UpdateFile($implFileName, $contents); | 4697 $codeGenerator->UpdateFile($implFileName, $contents); |
| 4557 | 4698 |
| 4558 %implIncludes = (); | 4699 %implIncludes = (); |
| 4559 @implContentHeader = (); | 4700 @implContentHeader = (); |
| 4560 @implContentInternals = (); | 4701 @implInternalStuff = (); |
| 4561 @implContent = (); | 4702 @implStuff = (); |
| 4562 | 4703 |
| 4563 # Update a .h file if the contents are changed. | 4704 # Update a .h file if the contents are changed. |
| 4564 $contents = join "", @headerContent; | 4705 $contents = join "", @headerContent; |
| 4565 $codeGenerator->UpdateFile($headerFileName, $contents); | 4706 $codeGenerator->UpdateFile($headerFileName, $contents); |
| 4566 | 4707 |
| 4567 @headerContent = (); | 4708 @headerContent = (); |
| 4568 } | 4709 } |
| 4569 | 4710 |
| 4570 sub ConvertToV8StringResource | 4711 sub ConvertToV8StringResource |
| 4571 { | 4712 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4612 | 4753 |
| 4613 sub GetPassRefPtrType | 4754 sub GetPassRefPtrType |
| 4614 { | 4755 { |
| 4615 my $v8InterfaceName = shift; | 4756 my $v8InterfaceName = shift; |
| 4616 | 4757 |
| 4617 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; | 4758 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; |
| 4618 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; | 4759 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; |
| 4619 } | 4760 } |
| 4620 | 4761 |
| 4621 1; | 4762 1; |
| OLD | NEW |