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