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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 # Class | 138 # Class |
139 # ClassPublic | 139 # ClassPublic |
140 # ClassPrivate | 140 # ClassPrivate |
141 my %header; | 141 my %header; |
142 | 142 |
143 # Implementation code structure: | 143 # Implementation code structure: |
144 # Root ... Copyright | 144 # Root ... Copyright |
145 # Conditional ... #if FEATURE ... #endif (to be removed soon) | 145 # Conditional ... #if FEATURE ... #endif (to be removed soon) |
146 # Includes | 146 # Includes |
147 # NameSpaceWebCore | 147 # NameSpaceWebCore |
148 # NameSpaceInternal ... namespace ${interfaceName}V8Internal in case of no
n-callback | 148 # NameSpaceInternal ... namespace ${implClassName}V8Internal in case of no
n-callback |
149 my %implementation; | 149 my %implementation; |
150 | 150 |
151 my %primitiveTypeHash = ( "boolean" => 1, | 151 my %primitiveTypeHash = ( "boolean" => 1, |
152 "void" => 1, | 152 "void" => 1, |
153 "Date" => 1, | 153 "Date" => 1, |
154 "short" => 1, | 154 "short" => 1, |
155 "long" => 1, | 155 "long" => 1, |
156 "long long" => 1, | 156 "long long" => 1, |
157 "unsigned short" => 1, | 157 "unsigned short" => 1, |
158 "unsigned long" => 1, | 158 "unsigned long" => 1, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 }; | 258 }; |
259 find($wanted, @directories); | 259 find($wanted, @directories); |
260 } | 260 } |
261 | 261 |
262 return $idlFiles->{$interfaceName}; | 262 return $idlFiles->{$interfaceName}; |
263 } | 263 } |
264 | 264 |
265 sub HeaderFileForInterface | 265 sub HeaderFileForInterface |
266 { | 266 { |
267 my $interfaceName = shift; | 267 my $interfaceName = shift; |
| 268 my $implClassName = shift || $interfaceName; |
268 | 269 |
269 my $idlFilename = IDLFileForInterface($interfaceName) | 270 my $idlFilename = IDLFileForInterface($interfaceName) |
270 or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); | 271 or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); |
271 | 272 |
272 $idlFilename = "bindings/" . File::Spec->abs2rel($idlFilename, $sourceRoot); | 273 my $idlRelPath= "bindings/" . File::Spec->abs2rel($idlFilename, $sourceRoot)
; |
273 $idlFilename =~ s/idl$/h/; | 274 return dirname($idlRelPath) . "/" . $implClassName . ".h"; |
274 return $idlFilename; | |
275 } | 275 } |
276 | 276 |
277 sub ParseInterface | 277 sub ParseInterface |
278 { | 278 { |
279 my $interfaceName = shift; | 279 my $interfaceName = shift; |
280 | 280 |
281 return undef if $interfaceName eq 'Object'; | 281 return undef if $interfaceName eq 'Object'; |
282 | 282 |
283 if (exists $cachedInterfaces->{$interfaceName}) { | 283 if (exists $cachedInterfaces->{$interfaceName}) { |
284 return $cachedInterfaces->{$interfaceName}; | 284 return $cachedInterfaces->{$interfaceName}; |
(...skipping 18 matching lines...) Expand all Loading... |
303 | 303 |
304 die("Could NOT find interface definition for $interfaceName in $filename"); | 304 die("Could NOT find interface definition for $interfaceName in $filename"); |
305 } | 305 } |
306 | 306 |
307 sub GenerateInterface | 307 sub GenerateInterface |
308 { | 308 { |
309 my $object = shift; | 309 my $object = shift; |
310 my $interface = shift; | 310 my $interface = shift; |
311 | 311 |
312 %enumTypeHash = map { $_->name => $_->values } @{$idlDocument->enumerations}
; | 312 %enumTypeHash = map { $_->name => $_->values } @{$idlDocument->enumerations}
; |
313 my $interfaceName = $interface->name; | 313 my $v8ClassName = GetV8ClassName($interface); |
314 my $v8InterfaceName = "V8" . $interface->name; | 314 my $defineName = $v8ClassName . "_h"; |
315 my $defineName = $v8InterfaceName . "_h"; | 315 my $internalNamespace = GetImplClassName($interface) . "V8Internal"; |
316 my $internalNamespace = "${interfaceName}V8Internal"; | |
317 | 316 |
318 my $conditionalString = GenerateConditionalString($interface); | 317 my $conditionalString = GenerateConditionalString($interface); |
319 my $conditionalIf = ""; | 318 my $conditionalIf = ""; |
320 my $conditionalEndif = ""; | 319 my $conditionalEndif = ""; |
321 if ($conditionalString) { | 320 if ($conditionalString) { |
322 $conditionalIf = "#if ${conditionalString}"; | 321 $conditionalIf = "#if ${conditionalString}"; |
323 $conditionalEndif = "#endif // ${conditionalString}"; | 322 $conditionalEndif = "#endif // ${conditionalString}"; |
324 } | 323 } |
325 | 324 |
326 $header{root} = new Block("ROOT", "", ""); | 325 $header{root} = new Block("ROOT", "", ""); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 $implementation{root}->add($implementation{conditional}); | 359 $implementation{root}->add($implementation{conditional}); |
361 $implementation{conditional}->add($implementation{includes}); | 360 $implementation{conditional}->add($implementation{includes}); |
362 $implementation{conditional}->add($implementation{nameSpaceWebCore}); | 361 $implementation{conditional}->add($implementation{nameSpaceWebCore}); |
363 if (!$interface->isCallback) { | 362 if (!$interface->isCallback) { |
364 $implementation{nameSpaceWebCore}->add($implementation{nameSpaceInternal
}); | 363 $implementation{nameSpaceWebCore}->add($implementation{nameSpaceInternal
}); |
365 } | 364 } |
366 | 365 |
367 # - Add default header template | 366 # - Add default header template |
368 $implementation{root}->addHeader($headerTemplate); | 367 $implementation{root}->addHeader($headerTemplate); |
369 $implementation{root}->addHeader("\n#include \"config.h\""); | 368 $implementation{root}->addHeader("\n#include \"config.h\""); |
370 $implementation{includes}->add("#include \"${v8InterfaceName}.h\"\n\n"); | 369 $implementation{includes}->add("#include \"${v8ClassName}.h\"\n\n"); |
371 | 370 |
372 # Start actual generation | 371 # Start actual generation |
373 if ($interface->isCallback) { | 372 if ($interface->isCallback) { |
374 $object->GenerateCallbackHeader($interface); | 373 $object->GenerateCallbackHeader($interface); |
375 $object->GenerateCallbackImplementation($interface); | 374 $object->GenerateCallbackImplementation($interface); |
376 } else { | 375 } else { |
377 $object->GenerateHeader($interface); | 376 $object->GenerateHeader($interface); |
378 $object->GenerateImplementation($interface); | 377 $object->GenerateImplementation($interface); |
379 } | 378 } |
380 } | 379 } |
(...skipping 21 matching lines...) Expand all Loading... |
402 } | 401 } |
403 | 402 |
404 sub AddToHeaderIncludes | 403 sub AddToHeaderIncludes |
405 { | 404 { |
406 my $header = shift; | 405 my $header = shift; |
407 $headerIncludeFiles{$header} = 1; | 406 $headerIncludeFiles{$header} = 1; |
408 } | 407 } |
409 | 408 |
410 sub AddInterfaceToImplIncludes | 409 sub AddInterfaceToImplIncludes |
411 { | 410 { |
412 my $interface = shift; | 411 my $interfaceName = shift; |
413 my $include = HeaderFileForInterface($interface); | 412 |
| 413 my $include = HeaderFileForInterface($interfaceName); |
414 | 414 |
415 AddToImplIncludes($include); | 415 AddToImplIncludes($include); |
416 } | 416 } |
417 | 417 |
418 sub AddIncludesForType | 418 sub AddIncludesForType |
419 { | 419 { |
420 my $type = shift; | 420 my $type = shift; |
421 | 421 |
422 # When we're finished with the one-file-per-class | 422 # When we're finished with the one-file-per-class |
423 # reorganization, we won't need these special cases. | 423 # reorganization, we won't need these special cases. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 481 |
482 sub GetCustomIsReachable | 482 sub GetCustomIsReachable |
483 { | 483 { |
484 my $interface = shift; | 484 my $interface = shift; |
485 return $interface->extendedAttributes->{"CustomIsReachable"}; | 485 return $interface->extendedAttributes->{"CustomIsReachable"}; |
486 } | 486 } |
487 | 487 |
488 sub GenerateOpaqueRootForGC | 488 sub GenerateOpaqueRootForGC |
489 { | 489 { |
490 my $interface = shift; | 490 my $interface = shift; |
491 my $interfaceName = $interface->name; | 491 my $implClassName = GetImplClassName($interface); |
| 492 my $v8ClassName = GetV8ClassName($interface); |
492 | 493 |
493 if (GetCustomIsReachable($interface)) { | 494 if (GetCustomIsReachable($interface)) { |
494 return; | 495 return; |
495 } | 496 } |
496 | 497 |
497 my $code = <<END; | 498 my $code = <<END; |
498 void* V8${interfaceName}::opaqueRootForGC(void* object, v8::Persistent<v8::Objec
t> wrapper, v8::Isolate* isolate) | 499 void* ${v8ClassName}::opaqueRootForGC(void* object, v8::Persistent<v8::Object> w
rapper, v8::Isolate* isolate) |
499 { | 500 { |
500 ASSERT(!wrapper.IsIndependent(isolate)); | 501 ASSERT(!wrapper.IsIndependent(isolate)); |
501 ${interfaceName}* impl = static_cast<${interfaceName}*>(object); | 502 ${implClassName}* impl = static_cast<${implClassName}*>(object); |
502 END | 503 END |
503 if (GetGenerateIsReachable($interface) eq "ImplDocument" || | 504 if (GetGenerateIsReachable($interface) eq "ImplDocument" || |
504 GetGenerateIsReachable($interface) eq "ImplElementRoot" || | 505 GetGenerateIsReachable($interface) eq "ImplElementRoot" || |
505 GetGenerateIsReachable($interface) eq "ImplOwnerRoot" || | 506 GetGenerateIsReachable($interface) eq "ImplOwnerRoot" || |
506 GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") { | 507 GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") { |
507 | 508 |
508 AddToImplIncludes("bindings/v8/V8GCController.h"); | 509 AddToImplIncludes("bindings/v8/V8GCController.h"); |
509 | 510 |
510 my $methodName; | 511 my $methodName; |
511 $methodName = "document" if (GetGenerateIsReachable($interface) eq "Impl
Document"); | 512 $methodName = "document" if (GetGenerateIsReachable($interface) eq "Impl
Document"); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 612 |
612 return 0; | 613 return 0; |
613 } | 614 } |
614 | 615 |
615 sub GenerateHeader | 616 sub GenerateHeader |
616 { | 617 { |
617 my $object = shift; | 618 my $object = shift; |
618 my $interface = shift; | 619 my $interface = shift; |
619 | 620 |
620 my $interfaceName = $interface->name; | 621 my $interfaceName = $interface->name; |
621 my $v8InterfaceName = "V8$interfaceName"; | 622 my $implClassName = GetImplClassName($interface); |
| 623 my $v8ClassName = GetV8ClassName($interface); |
622 | 624 |
623 # Copy contents of parent interfaces except the first parent. | 625 # Copy contents of parent interfaces except the first parent. |
624 my @parents; | 626 my @parents; |
625 AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents,
1); | 627 AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents,
1); |
626 LinkOverloadedFunctions($interface); | 628 LinkOverloadedFunctions($interface); |
627 | 629 |
628 # Ensure the IsDOMNodeType function is in sync. | 630 # Ensure the IsDOMNodeType function is in sync. |
629 die("IsDOMNodeType is out of date with respect to $interfaceName") if IsDOMN
odeType($interfaceName) != InheritsInterface($interface, "Node"); | 631 die("IsDOMNodeType is out of date with respect to $interfaceName") if IsDOMN
odeType($interfaceName) != InheritsInterface($interface, "Node"); |
630 | 632 |
631 my $hasDependentLifetime = $interface->extendedAttributes->{"DependentLifeti
me"} || InheritsExtendedAttribute($interface, "ActiveDOMObject") || GetGenerateI
sReachable($interface) || $v8InterfaceName =~ /SVG/; | 633 my $hasDependentLifetime = $interface->extendedAttributes->{"DependentLifeti
me"} || InheritsExtendedAttribute($interface, "ActiveDOMObject") || GetGenerateI
sReachable($interface) || $v8ClassName =~ /SVG/; |
632 if (!$hasDependentLifetime) { | 634 if (!$hasDependentLifetime) { |
633 foreach (@{$interface->parents}) { | 635 foreach (@{$interface->parents}) { |
634 my $parent = $_; | 636 my $parent = $_; |
635 AddToHeaderIncludes("V8${parent}.h"); | 637 AddToHeaderIncludes("V8${parent}.h"); |
636 } | 638 } |
637 } | 639 } |
638 | 640 |
639 AddToHeaderIncludes("bindings/v8/WrapperTypeInfo.h"); | 641 AddToHeaderIncludes("bindings/v8/WrapperTypeInfo.h"); |
640 AddToHeaderIncludes("bindings/v8/V8Binding.h"); | 642 AddToHeaderIncludes("bindings/v8/V8Binding.h"); |
641 AddToHeaderIncludes("bindings/v8/V8DOMWrapper.h"); | 643 AddToHeaderIncludes("bindings/v8/V8DOMWrapper.h"); |
642 AddToHeaderIncludes("v8.h"); | 644 AddToHeaderIncludes("v8.h"); |
643 AddToHeaderIncludes("wtf/HashMap.h"); | 645 AddToHeaderIncludes("wtf/HashMap.h"); |
644 AddToHeaderIncludes("wtf/text/StringHash.h"); | 646 AddToHeaderIncludes("wtf/text/StringHash.h"); |
645 | 647 |
646 my $headerClassInclude = GetHeaderClassInclude($interfaceName); | 648 my $headerClassInclude = GetHeaderClassInclude($interfaceName, $implClassNam
e); |
647 AddToHeaderIncludes($headerClassInclude) if $headerClassInclude; | 649 AddToHeaderIncludes($headerClassInclude) if $headerClassInclude; |
648 | 650 |
649 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); | 651 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); |
650 | 652 |
651 foreach my $headerInclude (sort keys(%headerIncludeFiles)) { | 653 foreach my $headerInclude (sort keys(%headerIncludeFiles)) { |
652 $header{includes}->add("#include \"${headerInclude}\"\n") unless $header
Include =~ /v8\.h/; | 654 $header{includes}->add("#include \"${headerInclude}\"\n") unless $header
Include =~ /v8\.h/; |
653 } | 655 } |
654 $header{includes}->add("#include \<v8.h\>\n") if $headerIncludeFiles{"v8.h"}
; | 656 $header{includes}->add("#include \<v8.h\>\n") if $headerIncludeFiles{"v8.h"}
; |
655 | 657 |
656 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyType> clas
s SVGPropertyTearOff;\n") if $svgPropertyType; | 658 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyType> clas
s SVGPropertyTearOff;\n") if $svgPropertyType; |
(...skipping 13 matching lines...) Expand all Loading... |
670 $header{nameSpaceWebCore}->addHeader(<<END); | 672 $header{nameSpaceWebCore}->addHeader(<<END); |
671 | 673 |
672 class V8${nativeType}Constructor { | 674 class V8${nativeType}Constructor { |
673 public: | 675 public: |
674 static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, Wrappe
rWorldType); | 676 static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, Wrappe
rWorldType); |
675 static WrapperTypeInfo info; | 677 static WrapperTypeInfo info; |
676 }; | 678 }; |
677 END | 679 END |
678 } | 680 } |
679 | 681 |
680 $header{class}->addHeader("class $v8InterfaceName {"); | 682 $header{class}->addHeader("class $v8ClassName {"); |
681 $header{class}->addFooter("};"); | 683 $header{class}->addFooter("};"); |
682 | 684 |
683 my $code = ""; | 685 my $code = ""; |
684 $code .= " static const bool hasDependentLifetime = "; | 686 $code .= " static const bool hasDependentLifetime = "; |
685 if ($hasDependentLifetime) { | 687 if ($hasDependentLifetime) { |
686 $code .= "true;\n"; | 688 $code .= "true;\n"; |
687 } elsif (@{$interface->parents}) { | 689 } elsif (@{$interface->parents}) { |
688 # Even if this type doesn't have the [DependentLifetime] attribute its p
arents may. | 690 # Even if this type doesn't have the [DependentLifetime] attribute its p
arents may. |
689 # Let the compiler statically determine this for us. | 691 # Let the compiler statically determine this for us. |
690 my $separator = ""; | 692 my $separator = ""; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 friend v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); | 856 friend v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); |
855 static v8::Handle<v8::Object> createWrapper(${createWrapperArgumentType}, v8
::Handle<v8::Object> creationContext, v8::Isolate*); | 857 static v8::Handle<v8::Object> createWrapper(${createWrapperArgumentType}, v8
::Handle<v8::Object> creationContext, v8::Isolate*); |
856 END | 858 END |
857 } | 859 } |
858 | 860 |
859 $header{nameSpaceWebCore}->add(<<END); | 861 $header{nameSpaceWebCore}->add(<<END); |
860 | 862 |
861 template<> | 863 template<> |
862 class WrapperTypeTraits<${nativeType} > { | 864 class WrapperTypeTraits<${nativeType} > { |
863 public: | 865 public: |
864 static WrapperTypeInfo* info() { return &${v8InterfaceName}::info; } | 866 static WrapperTypeInfo* info() { return &${v8ClassName}::info; } |
865 }; | 867 }; |
866 | 868 |
867 END | 869 END |
868 | 870 |
869 my $customWrap = $interface->extendedAttributes->{"CustomToV8"}; | 871 my $customWrap = $interface->extendedAttributes->{"CustomToV8"}; |
870 if ($noToV8) { | 872 if ($noToV8) { |
871 die "Can't suppress toV8 for subclass\n" if @parents; | 873 die "Can't suppress toV8 for subclass\n" if @parents; |
872 } elsif ($noWrap) { | 874 } elsif ($noWrap) { |
873 die "Must have custom toV8\n" if !$customWrap; | 875 die "Must have custom toV8\n" if !$customWrap; |
874 $header{nameSpaceWebCore}->add(<<END); | 876 $header{nameSpaceWebCore}->add(<<END); |
875 class ${nativeType}; | 877 class ${nativeType}; |
876 v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContex
t, v8::Isolate*); | 878 v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContex
t, v8::Isolate*); |
877 v8::Handle<v8::Value> toV8ForMainWorld(${nativeType}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); | 879 v8::Handle<v8::Value> toV8ForMainWorld(${nativeType}*, v8::Handle<v8::Object> cr
eationContext, v8::Isolate*); |
878 | 880 |
879 template<class HolderContainer, class Wrappable> | 881 template<class HolderContainer, class Wrappable> |
880 inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer
& container, Wrappable*) | 882 inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer
& container, Wrappable*) |
881 { | 883 { |
882 return toV8(impl, container.Holder(), container.GetIsolate()); | 884 return toV8(impl, container.Holder(), container.GetIsolate()); |
883 } | 885 } |
884 | 886 |
885 template<class HolderContainer, class Wrappable> | 887 template<class HolderContainer, class Wrappable> |
886 inline v8::Handle<v8::Value> toV8FastForMainWorld(${nativeType}* impl, const Hol
derContainer& container, Wrappable*) | 888 inline v8::Handle<v8::Value> toV8FastForMainWorld(${nativeType}* impl, const Hol
derContainer& container, Wrappable*) |
887 { | 889 { |
888 return toV8ForMainWorld(impl, container.Holder(), container.GetIsolate()); | 890 return toV8ForMainWorld(impl, container.Holder(), container.GetIsolate()); |
889 } | 891 } |
890 END | 892 END |
891 } else { | 893 } else { |
892 | 894 |
893 my $createWrapperCall = $customWrap ? "${v8InterfaceName}::wrap" : "${v8
InterfaceName}::createWrapper"; | 895 my $createWrapperCall = $customWrap ? "${v8ClassName}::wrap" : "${v8Clas
sName}::createWrapper"; |
894 my $returningWrapper = $interface->extendedAttributes->{"WrapAsFunction"
} ? "V8DOMWrapper::toFunction(wrapper)" : "wrapper"; | 896 my $returningWrapper = $interface->extendedAttributes->{"WrapAsFunction"
} ? "V8DOMWrapper::toFunction(wrapper)" : "wrapper"; |
895 my $returningCreatedWrapperOpening = $interface->extendedAttributes->{"W
rapAsFunction"} ? "V8DOMWrapper::toFunction(" : ""; | 897 my $returningCreatedWrapperOpening = $interface->extendedAttributes->{"W
rapAsFunction"} ? "V8DOMWrapper::toFunction(" : ""; |
896 my $returningCreatedWrapperClosing = $interface->extendedAttributes->{"W
rapAsFunction"} ? ", \"${interfaceName}\", isolate)" : ""; | 898 my $returningCreatedWrapperClosing = $interface->extendedAttributes->{"W
rapAsFunction"} ? ", \"${implClassName}\", isolate)" : ""; |
897 | 899 |
898 if ($customWrap) { | 900 if ($customWrap) { |
899 $header{nameSpaceWebCore}->add(<<END); | 901 $header{nameSpaceWebCore}->add(<<END); |
900 | 902 |
901 v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> creation
Context, v8::Isolate*); | 903 v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> creation
Context, v8::Isolate*); |
902 END | 904 END |
903 } else { | 905 } else { |
904 $header{nameSpaceWebCore}->add(<<END); | 906 $header{nameSpaceWebCore}->add(<<END); |
905 | 907 |
906 inline v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) | 908 inline v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) |
907 { | 909 { |
908 ASSERT(impl); | 910 ASSERT(impl); |
909 ASSERT(DOMDataStore::getWrapper(impl, isolate).IsEmpty()); | 911 ASSERT(DOMDataStore::getWrapper(impl, isolate).IsEmpty()); |
910 if (ScriptWrappable::wrapperCanBeStoredInObject(impl)) { | 912 if (ScriptWrappable::wrapperCanBeStoredInObject(impl)) { |
911 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl); | 913 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl); |
912 // Might be a XXXConstructor::info instead of an XXX::info. These will b
oth have | 914 // Might be a XXXConstructor::info instead of an XXX::info. These will b
oth have |
913 // the same object de-ref functions, though, so use that as the basis of
the check. | 915 // the same object de-ref functions, though, so use that as the basis of
the check. |
914 RELEASE_ASSERT(actualInfo->derefObjectFunction == ${v8InterfaceName}::in
fo.derefObjectFunction); | 916 RELEASE_ASSERT(actualInfo->derefObjectFunction == ${v8ClassName}::info.d
erefObjectFunction); |
915 } | 917 } |
916 return ${returningCreatedWrapperOpening}$createWrapperCall(impl, creationCon
text, isolate)${returningCreatedWrapperClosing}; | 918 return ${returningCreatedWrapperOpening}$createWrapperCall(impl, creationCon
text, isolate)${returningCreatedWrapperClosing}; |
917 } | 919 } |
918 END | 920 END |
919 } | 921 } |
920 | 922 |
921 $header{nameSpaceWebCore}->add(<<END); | 923 $header{nameSpaceWebCore}->add(<<END); |
922 | 924 |
923 inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Handle<v8::Object> cr
eationContext, v8::Isolate* isolate) | 925 inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Handle<v8::Object> cr
eationContext, v8::Isolate* isolate) |
924 { | 926 { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 984 } |
983 | 985 |
984 inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl, v8::Handle<v
8::Object> creationContext, v8::Isolate* isolate) | 986 inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl, v8::Handle<v
8::Object> creationContext, v8::Isolate* isolate) |
985 { | 987 { |
986 return toV8(impl.get(), creationContext, isolate); | 988 return toV8(impl.get(), creationContext, isolate); |
987 } | 989 } |
988 | 990 |
989 END | 991 END |
990 | 992 |
991 if (IsConstructorTemplate($interface, "Event")) { | 993 if (IsConstructorTemplate($interface, "Event")) { |
992 $header{nameSpaceWebCore}->add("bool fill${interfaceName}Init(${interfac
eName}Init&, const Dictionary&);\n\n"); | 994 $header{nameSpaceWebCore}->add("bool fill${implClassName}Init(${implClas
sName}Init&, const Dictionary&);\n\n"); |
993 } | 995 } |
994 } | 996 } |
995 | 997 |
996 sub GetInternalFields | 998 sub GetInternalFields |
997 { | 999 { |
998 my $interface = shift; | 1000 my $interface = shift; |
999 | 1001 |
1000 my @customInternalFields = (); | 1002 my @customInternalFields = (); |
1001 # Event listeners on DOM nodes are explicitly supported in the GC controller
. | 1003 # Event listeners on DOM nodes are explicitly supported in the GC controller
. |
1002 if (!InheritsInterface($interface, "Node") && | 1004 if (!InheritsInterface($interface, "Node") && |
1003 InheritsExtendedAttribute($interface, "EventTarget")) { | 1005 InheritsExtendedAttribute($interface, "EventTarget")) { |
1004 push(@customInternalFields, "eventListenerCacheIndex"); | 1006 push(@customInternalFields, "eventListenerCacheIndex"); |
1005 } | 1007 } |
1006 return @customInternalFields; | 1008 return @customInternalFields; |
1007 } | 1009 } |
1008 | 1010 |
1009 sub GetHeaderClassInclude | 1011 sub GetHeaderClassInclude |
1010 { | 1012 { |
1011 my $v8InterfaceName = shift; | 1013 my $interfaceName = shift; |
1012 if ($v8InterfaceName =~ /SVGPathSeg/) { | 1014 my $implClassName = shift; |
1013 $v8InterfaceName =~ s/Abs|Rel//; | 1015 |
1014 return "core/svg/${v8InterfaceName}.h"; | 1016 if ($interfaceName =~ /SVGPathSeg/) { |
| 1017 $interfaceName =~ s/Abs|Rel//; |
| 1018 return "core/svg/${interfaceName}.h"; |
1015 } | 1019 } |
1016 return "wtf/${v8InterfaceName}.h" if IsTypedArrayType($v8InterfaceName); | 1020 return "wtf/${interfaceName}.h" if IsTypedArrayType($interfaceName); |
1017 return "" if (SkipIncludeHeader($v8InterfaceName)); | 1021 return "" if (SkipIncludeHeader($interfaceName)); |
1018 return HeaderFileForInterface($v8InterfaceName); | 1022 return HeaderFileForInterface($interfaceName, $implClassName); |
1019 } | 1023 } |
1020 | 1024 |
1021 sub GenerateHeaderCustomInternalFieldIndices | 1025 sub GenerateHeaderCustomInternalFieldIndices |
1022 { | 1026 { |
1023 my $interface = shift; | 1027 my $interface = shift; |
1024 my @customInternalFields = GetInternalFields($interface); | 1028 my @customInternalFields = GetInternalFields($interface); |
1025 my $customFieldCounter = 0; | 1029 my $customFieldCounter = 0; |
1026 foreach my $customInternalField (@customInternalFields) { | 1030 foreach my $customInternalField (@customInternalFields) { |
1027 $header{classPublic}->add(<<END); | 1031 $header{classPublic}->add(<<END); |
1028 static const int ${customInternalField} = v8DefaultWrapperInternalFieldCount
+ ${customFieldCounter}; | 1032 static const int ${customInternalField} = v8DefaultWrapperInternalFieldCount
+ ${customFieldCounter}; |
1029 END | 1033 END |
1030 $customFieldCounter++; | 1034 $customFieldCounter++; |
1031 } | 1035 } |
1032 $header{classPublic}->add(<<END); | 1036 $header{classPublic}->add(<<END); |
1033 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + $
{customFieldCounter}; | 1037 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + $
{customFieldCounter}; |
1034 END | 1038 END |
1035 } | 1039 } |
1036 | 1040 |
1037 sub GenerateHeaderNamedAndIndexedPropertyAccessors | 1041 sub GenerateHeaderNamedAndIndexedPropertyAccessors |
1038 { | 1042 { |
1039 my $interface = shift; | 1043 my $interface = shift; |
1040 my $interfaceName = $interface->name; | |
1041 my $hasIndexedGetter = GetIndexedGetterFunction($interface) || $interface->e
xtendedAttributes->{"CustomIndexedGetter"}; | 1044 my $hasIndexedGetter = GetIndexedGetterFunction($interface) || $interface->e
xtendedAttributes->{"CustomIndexedGetter"}; |
1042 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed
Setter"}; | 1045 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed
Setter"}; |
1043 my $hasCustomNamedGetter = GetNamedGetterFunction($interface) || $interface-
>extendedAttributes->{"CustomNamedGetter"}; | 1046 my $hasCustomNamedGetter = GetNamedGetterFunction($interface) || $interface-
>extendedAttributes->{"CustomNamedGetter"}; |
1044 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSett
er"}; | 1047 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSett
er"}; |
1045 my $hasCustomDeleters = $interface->extendedAttributes->{"CustomDeleteProper
ty"}; | 1048 my $hasCustomDeleters = $interface->extendedAttributes->{"CustomDeleteProper
ty"}; |
1046 my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateP
roperty"}; | 1049 my $hasCustomEnumerator = $interface->extendedAttributes->{"CustomEnumerateP
roperty"}; |
1047 | 1050 |
1048 if ($hasIndexedGetter) { | 1051 if ($hasIndexedGetter) { |
1049 $header{classPublic}->add(<<END); | 1052 $header{classPublic}->add(<<END); |
1050 static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::Acces
sorInfo&); | 1053 static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::Acces
sorInfo&); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 return $attrExt->{"Custom"}; | 1153 return $attrExt->{"Custom"}; |
1151 } | 1154 } |
1152 | 1155 |
1153 sub IsReadonly | 1156 sub IsReadonly |
1154 { | 1157 { |
1155 my $attribute = shift; | 1158 my $attribute = shift; |
1156 my $attrExt = $attribute->signature->extendedAttributes; | 1159 my $attrExt = $attribute->signature->extendedAttributes; |
1157 return $attribute->isReadOnly && !$attrExt->{"Replaceable"}; | 1160 return $attribute->isReadOnly && !$attrExt->{"Replaceable"}; |
1158 } | 1161 } |
1159 | 1162 |
| 1163 sub GetV8ClassName |
| 1164 { |
| 1165 my $interface = shift; |
| 1166 return "V8" . $interface->name; |
| 1167 } |
| 1168 |
| 1169 sub GetImplClassName |
| 1170 { |
| 1171 my $interface = shift; |
| 1172 return $interface->extendedAttributes->{"ImplementedAs"} || $interface->name
; |
| 1173 } |
| 1174 |
1160 sub GenerateDomainSafeFunctionGetter | 1175 sub GenerateDomainSafeFunctionGetter |
1161 { | 1176 { |
1162 my $function = shift; | 1177 my $function = shift; |
1163 my $interfaceName = shift; | 1178 my $interface = shift; |
1164 | 1179 |
1165 my $v8InterfaceName = "V8" . $interfaceName; | 1180 my $implClassName = GetImplClassName($interface); |
| 1181 my $v8ClassName = GetV8ClassName($interface); |
1166 my $funcName = $function->signature->name; | 1182 my $funcName = $function->signature->name; |
1167 | 1183 |
1168 my $functionLength = GetFunctionLength($function); | 1184 my $functionLength = GetFunctionLength($function); |
1169 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate()
)->rawTemplate(&" . $v8InterfaceName . "::info, currentWorldType))"; | 1185 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate()
)->rawTemplate(&" . $v8ClassName . "::info, currentWorldType))"; |
1170 if ($function->signature->extendedAttributes->{"DoNotCheckSignature"}) { | 1186 if ($function->signature->extendedAttributes->{"DoNotCheckSignature"}) { |
1171 $signature = "v8::Local<v8::Signature>()"; | 1187 $signature = "v8::Local<v8::Signature>()"; |
1172 } | 1188 } |
1173 | 1189 |
1174 my $newTemplateParams = "${interfaceName}V8Internal::${funcName}MethodCallba
ck, v8Undefined(), $signature"; | 1190 my $newTemplateParams = "${implClassName}V8Internal::${funcName}MethodCallba
ck, v8Undefined(), $signature"; |
1175 | 1191 |
1176 AddToImplIncludes("core/page/Frame.h"); | 1192 AddToImplIncludes("core/page/Frame.h"); |
1177 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1193 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
1178 $implementation{nameSpaceInternal}->add(<<END); | 1194 $implementation{nameSpaceInternal}->add(<<END); |
1179 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, c
onst v8::AccessorInfo& info) | 1195 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, c
onst v8::AccessorInfo& info) |
1180 { | 1196 { |
1181 // This is only for getting a unique pointer which we can pass to privateTem
plate. | 1197 // This is only for getting a unique pointer which we can pass to privateTem
plate. |
1182 static const char* privateTemplateUniqueKey = "${funcName}PrivateTemplate"; | 1198 static const char* privateTemplateUniqueKey = "${funcName}PrivateTemplate"; |
1183 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); | 1199 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); |
1184 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); | 1200 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); |
1185 v8::Persistent<v8::FunctionTemplate> privateTemplate = data->privateTemplate
(currentWorldType, &privateTemplateUniqueKey, $newTemplateParams, $functionLengt
h); | 1201 v8::Persistent<v8::FunctionTemplate> privateTemplate = data->privateTemplate
(currentWorldType, &privateTemplateUniqueKey, $newTemplateParams, $functionLengt
h); |
1186 | 1202 |
1187 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8InterfaceName}::GetTemplate(info.GetIsolate(), currentWorldType)); | 1203 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8ClassName}::GetTemplate(info.GetIsolate(), currentWorldType)); |
1188 if (holder.IsEmpty()) { | 1204 if (holder.IsEmpty()) { |
1189 // can only reach here by 'object.__proto__.func', and it should passed | 1205 // can only reach here by 'object.__proto__.func', and it should passed |
1190 // domain security check already | 1206 // domain security check already |
1191 return privateTemplate->GetFunction(); | 1207 return privateTemplate->GetFunction(); |
1192 } | 1208 } |
1193 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); | 1209 ${implClassName}* imp = ${v8ClassName}::toNative(holder); |
1194 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { | 1210 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { |
1195 static const char* sharedTemplateUniqueKey = "${funcName}SharedTemplate"
; | 1211 static const char* sharedTemplateUniqueKey = "${funcName}SharedTemplate"
; |
1196 v8::Persistent<v8::FunctionTemplate> sharedTemplate = data->privateTempl
ate(currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams, $functionLen
gth); | 1212 v8::Persistent<v8::FunctionTemplate> sharedTemplate = data->privateTempl
ate(currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams, $functionLen
gth); |
1197 return sharedTemplate->GetFunction(); | 1213 return sharedTemplate->GetFunction(); |
1198 } | 1214 } |
1199 | 1215 |
1200 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(name); | 1216 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(name); |
1201 if (!hiddenValue.IsEmpty()) | 1217 if (!hiddenValue.IsEmpty()) |
1202 return hiddenValue; | 1218 return hiddenValue; |
1203 | 1219 |
1204 return privateTemplate->GetFunction(); | 1220 return privateTemplate->GetFunction(); |
1205 } | 1221 } |
1206 | 1222 |
1207 END | 1223 END |
1208 $implementation{nameSpaceInternal}->add(<<END); | 1224 $implementation{nameSpaceInternal}->add(<<END); |
1209 static v8::Handle<v8::Value> ${funcName}AttrGetterCallback(v8::Local<v8::String>
name, const v8::AccessorInfo& info) | 1225 static v8::Handle<v8::Value> ${funcName}AttrGetterCallback(v8::Local<v8::String>
name, const v8::AccessorInfo& info) |
1210 { | 1226 { |
1211 return ${interfaceName}V8Internal::${funcName}AttrGetter(name, info); | 1227 return ${implClassName}V8Internal::${funcName}AttrGetter(name, info); |
1212 } | 1228 } |
1213 | 1229 |
1214 END | 1230 END |
1215 } | 1231 } |
1216 | 1232 |
1217 sub GenerateDomainSafeFunctionSetter | 1233 sub GenerateDomainSafeFunctionSetter |
1218 { | 1234 { |
1219 my $interfaceName = shift; | 1235 my $interface = shift; |
1220 my $v8InterfaceName = "V8" . $interfaceName; | 1236 |
| 1237 my $implClassName = GetImplClassName($interface); |
| 1238 my $v8ClassName = GetV8ClassName($interface); |
1221 | 1239 |
1222 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1240 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
1223 $implementation{nameSpaceInternal}->add(<<END); | 1241 $implementation{nameSpaceInternal}->add(<<END); |
1224 static void ${interfaceName}DomainSafeFunctionSetter(v8::Local<v8::String> name,
v8::Local<v8::Value> value, const v8::AccessorInfo& info) | 1242 static void ${implClassName}DomainSafeFunctionSetter(v8::Local<v8::String> name,
v8::Local<v8::Value> value, const v8::AccessorInfo& info) |
1225 { | 1243 { |
1226 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); | 1244 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); |
1227 if (holder.IsEmpty()) | 1245 if (holder.IsEmpty()) |
1228 return; | 1246 return; |
1229 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); | 1247 ${implClassName}* imp = ${v8ClassName}::toNative(holder); |
1230 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame())) | 1248 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame())) |
1231 return; | 1249 return; |
1232 | 1250 |
1233 info.This()->SetHiddenValue(name, value); | 1251 info.This()->SetHiddenValue(name, value); |
1234 } | 1252 } |
1235 | 1253 |
1236 END | 1254 END |
1237 } | 1255 } |
1238 | 1256 |
1239 sub GenerateConstructorGetter | 1257 sub GenerateConstructorGetter |
1240 { | 1258 { |
1241 my $interface = shift; | 1259 my $interface = shift; |
1242 my $interfaceName = $interface->name; | 1260 my $implClassName = GetImplClassName($interface); |
1243 | 1261 |
1244 $implementation{nameSpaceInternal}->add(<<END); | 1262 $implementation{nameSpaceInternal}->add(<<END); |
1245 static v8::Handle<v8::Value> ${interfaceName}ConstructorGetter(v8::Local<v8::Str
ing> name, const v8::AccessorInfo& info) | 1263 static v8::Handle<v8::Value> ${implClassName}ConstructorGetter(v8::Local<v8::Str
ing> name, const v8::AccessorInfo& info) |
1246 { | 1264 { |
1247 v8::Handle<v8::Value> data = info.Data(); | 1265 v8::Handle<v8::Value> data = info.Data(); |
1248 ASSERT(data->IsExternal()); | 1266 ASSERT(data->IsExternal()); |
1249 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); | 1267 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); |
1250 if (!perContextData) | 1268 if (!perContextData) |
1251 return v8Undefined(); | 1269 return v8Undefined(); |
1252 return perContextData->constructorForType(WrapperTypeInfo::unwrap(data)); | 1270 return perContextData->constructorForType(WrapperTypeInfo::unwrap(data)); |
1253 } | 1271 } |
1254 END | 1272 END |
1255 } | 1273 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 | 1336 |
1319 return $code; | 1337 return $code; |
1320 } | 1338 } |
1321 | 1339 |
1322 sub GenerateNormalAttrGetterCallback | 1340 sub GenerateNormalAttrGetterCallback |
1323 { | 1341 { |
1324 my $attribute = shift; | 1342 my $attribute = shift; |
1325 my $interface = shift; | 1343 my $interface = shift; |
1326 my $forMainWorldSuffix = shift; | 1344 my $forMainWorldSuffix = shift; |
1327 | 1345 |
1328 my $interfaceName = $interface->name; | 1346 my $implClassName = GetImplClassName($interface); |
1329 my $v8InterfaceName = "V8$interfaceName"; | 1347 my $v8ClassName = GetV8ClassName($interface); |
1330 my $attrExt = $attribute->signature->extendedAttributes; | 1348 my $attrExt = $attribute->signature->extendedAttributes; |
1331 my $attrName = $attribute->signature->name; | 1349 my $attrName = $attribute->signature->name; |
1332 | 1350 |
1333 my $conditionalString = GenerateConditionalString($attribute->signature); | 1351 my $conditionalString = GenerateConditionalString($attribute->signature); |
1334 my $code = ""; | 1352 my $code = ""; |
1335 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1353 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
1336 | 1354 |
1337 $code .= "static v8::Handle<v8::Value> ${attrName}AttrGetterCallback${forMai
nWorldSuffix}(v8::Local<v8::String> name, const v8::AccessorInfo& info)\n"; | 1355 $code .= "static v8::Handle<v8::Value> ${attrName}AttrGetterCallback${forMai
nWorldSuffix}(v8::Local<v8::String> name, const v8::AccessorInfo& info)\n"; |
1338 $code .= "{\n"; | 1356 $code .= "{\n"; |
1339 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); | 1357 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
1340 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); | 1358 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); |
1341 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) { | 1359 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) { |
1342 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}"); | 1360 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}"); |
1343 } | 1361 } |
1344 if (HasCustomGetter($attrExt)) { | 1362 if (HasCustomGetter($attrExt)) { |
1345 $code .= " return ${v8InterfaceName}::${attrName}AttrGetterCustom(nam
e, info);\n"; | 1363 $code .= " return ${v8ClassName}::${attrName}AttrGetterCustom(name, i
nfo);\n"; |
1346 } else { | 1364 } else { |
1347 $code .= " return ${interfaceName}V8Internal::${attrName}AttrGetter${
forMainWorldSuffix}(name, info);\n"; | 1365 $code .= " return ${implClassName}V8Internal::${attrName}AttrGetter${
forMainWorldSuffix}(name, info);\n"; |
1348 } | 1366 } |
1349 $code .= "}\n\n"; | 1367 $code .= "}\n\n"; |
1350 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1368 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
1351 | 1369 |
1352 $implementation{nameSpaceInternal}->add($code); | 1370 $implementation{nameSpaceInternal}->add($code); |
1353 } | 1371 } |
1354 | 1372 |
1355 sub GenerateNormalAttrGetter | 1373 sub GenerateNormalAttrGetter |
1356 { | 1374 { |
1357 my $attribute = shift; | 1375 my $attribute = shift; |
1358 my $interface = shift; | 1376 my $interface = shift; |
1359 my $forMainWorldSuffix = shift; | 1377 my $forMainWorldSuffix = shift; |
1360 | 1378 |
1361 my $interfaceName = $interface->name; | 1379 my $interfaceName = $interface->name; |
1362 my $v8InterfaceName = "V8$interfaceName"; | 1380 my $implClassName = GetImplClassName($interface); |
| 1381 my $v8ClassName = GetV8ClassName($interface); |
1363 my $attrExt = $attribute->signature->extendedAttributes; | 1382 my $attrExt = $attribute->signature->extendedAttributes; |
1364 my $attrName = $attribute->signature->name; | 1383 my $attrName = $attribute->signature->name; |
1365 my $attrType = $attribute->signature->type; | 1384 my $attrType = $attribute->signature->type; |
1366 | 1385 |
1367 if (HasCustomGetter($attrExt)) { | 1386 if (HasCustomGetter($attrExt)) { |
1368 return; | 1387 return; |
1369 } | 1388 } |
1370 | 1389 |
1371 AssertNotSequenceType($attrType); | 1390 AssertNotSequenceType($attrType); |
1372 my $getterStringUsesImp = $interfaceName ne "SVGNumber"; | 1391 my $getterStringUsesImp = $interfaceName ne "SVGNumber"; |
1373 my $nativeType = GetNativeTypeFromSignature($attribute->signature, -1); | 1392 my $nativeType = GetNativeTypeFromSignature($attribute->signature, -1); |
1374 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); | 1393 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); |
1375 | 1394 |
1376 my $conditionalString = GenerateConditionalString($attribute->signature); | 1395 my $conditionalString = GenerateConditionalString($attribute->signature); |
1377 my $code = ""; | 1396 my $code = ""; |
1378 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1397 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
1379 $code .= <<END; | 1398 $code .= <<END; |
1380 static v8::Handle<v8::Value> ${attrName}AttrGetter${forMainWorldSuffix}(v8::Loca
l<v8::String> name, const v8::AccessorInfo& info) | 1399 static v8::Handle<v8::Value> ${attrName}AttrGetter${forMainWorldSuffix}(v8::Loca
l<v8::String> name, const v8::AccessorInfo& info) |
1381 { | 1400 { |
1382 END | 1401 END |
1383 if ($svgNativeType) { | 1402 if ($svgNativeType) { |
1384 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); | 1403 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); |
1385 if ($svgWrappedNativeType =~ /List/) { | 1404 if ($svgWrappedNativeType =~ /List/) { |
1386 $code .= <<END; | 1405 $code .= <<END; |
1387 $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1406 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); |
1388 END | 1407 END |
1389 } else { | 1408 } else { |
1390 $code .= <<END; | 1409 $code .= <<END; |
1391 $svgNativeType* wrapper = ${v8InterfaceName}::toNative(info.Holder()); | 1410 $svgNativeType* wrapper = ${v8ClassName}::toNative(info.Holder()); |
1392 $svgWrappedNativeType& impInstance = wrapper->propertyReference(); | 1411 $svgWrappedNativeType& impInstance = wrapper->propertyReference(); |
1393 END | 1412 END |
1394 if ($getterStringUsesImp) { | 1413 if ($getterStringUsesImp) { |
1395 $code .= <<END; | 1414 $code .= <<END; |
1396 $svgWrappedNativeType* imp = &impInstance; | 1415 $svgWrappedNativeType* imp = &impInstance; |
1397 END | 1416 END |
1398 } | 1417 } |
1399 } | 1418 } |
1400 } elsif ($attrExt->{"OnProto"} || $attrExt->{"Unforgeable"}) { | 1419 } elsif ($attrExt->{"OnProto"} || $attrExt->{"Unforgeable"}) { |
1401 if ($interfaceName eq "DOMWindow") { | 1420 if ($interfaceName eq "DOMWindow") { |
1402 $code .= <<END; | 1421 $code .= <<END; |
1403 v8::Handle<v8::Object> holder = info.Holder(); | 1422 v8::Handle<v8::Object> holder = info.Holder(); |
1404 END | 1423 END |
1405 } else { | 1424 } else { |
1406 # perform lookup first | 1425 # perform lookup first |
1407 $code .= <<END; | 1426 $code .= <<END; |
1408 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); | 1427 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${
v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); |
1409 if (holder.IsEmpty()) | 1428 if (holder.IsEmpty()) |
1410 return v8Undefined(); | 1429 return v8Undefined(); |
1411 END | 1430 END |
1412 } | 1431 } |
1413 $code .= <<END; | 1432 $code .= <<END; |
1414 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); | 1433 ${implClassName}* imp = ${v8ClassName}::toNative(holder); |
1415 END | 1434 END |
1416 } else { | 1435 } else { |
1417 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; | 1436 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; |
1418 my $url = $attribute->signature->extendedAttributes->{"URL"}; | 1437 my $url = $attribute->signature->extendedAttributes->{"URL"}; |
1419 if ($getterStringUsesImp && $reflect && !$url && InheritsInterface($inte
rface, "Node") && $attrType eq "DOMString") { | 1438 if ($getterStringUsesImp && $reflect && !$url && InheritsInterface($inte
rface, "Node") && $attrType eq "DOMString") { |
1420 # Generate super-compact call for regular attribute getter: | 1439 # Generate super-compact call for regular attribute getter: |
1421 my ($functionName, @arguments) = GetterExpression(\%implIncludes, $i
nterfaceName, $attribute); | 1440 my ($functionName, @arguments) = GetterExpression(\%implIncludes, $i
nterfaceName, $attribute); |
1422 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; | 1441 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; |
1423 $code .= " return v8String(imp->${functionName}(" . join(", ", @a
rguments) . "), info.GetIsolate(), ReturnUnsafeHandle);\n"; | 1442 $code .= " return v8String(imp->${functionName}(" . join(", ", @a
rguments) . "), info.GetIsolate(), ReturnUnsafeHandle);\n"; |
1424 $code .= "}\n\n"; | 1443 $code .= "}\n\n"; |
1425 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1444 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
1426 $implementation{nameSpaceInternal}->add($code); | 1445 $implementation{nameSpaceInternal}->add($code); |
1427 return; | 1446 return; |
1428 # Skip the rest of the function! | 1447 # Skip the rest of the function! |
1429 } | 1448 } |
1430 if ($attribute->signature->type eq "SerializedScriptValue" && $attrExt->
{"CachedAttribute"}) { | 1449 if ($attribute->signature->type eq "SerializedScriptValue" && $attrExt->
{"CachedAttribute"}) { |
1431 $code .= <<END; | 1450 $code .= <<END; |
1432 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); | 1451 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); |
1433 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); | 1452 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); |
1434 if (!value.IsEmpty()) | 1453 if (!value.IsEmpty()) |
1435 return value; | 1454 return value; |
1436 END | 1455 END |
1437 } | 1456 } |
1438 if (!$attribute->isStatic) { | 1457 if (!$attribute->isStatic) { |
1439 $code .= <<END; | 1458 $code .= <<END; |
1440 ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1459 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
1441 END | 1460 END |
1442 } | 1461 } |
1443 } | 1462 } |
1444 | 1463 |
1445 # Generate security checks if necessary | 1464 # Generate security checks if necessary |
1446 if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { | 1465 if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { |
1447 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1466 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
1448 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . $at
tribute->signature->name . "()))\n return v8::Handle<v8::Value>(v8Null(in
fo.GetIsolate()));\n\n"; | 1467 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . $at
tribute->signature->name . "()))\n return v8::Handle<v8::Value>(v8Null(in
fo.GetIsolate()));\n\n"; |
1449 } | 1468 } |
1450 | 1469 |
(...skipping 14 matching lines...) Expand all Loading... |
1465 if ($getterStringUsesImp) { | 1484 if ($getterStringUsesImp) { |
1466 my ($functionName, @arguments) = GetterExpression(\%implIncludes, $inter
faceName, $attribute); | 1485 my ($functionName, @arguments) = GetterExpression(\%implIncludes, $inter
faceName, $attribute); |
1467 push(@arguments, "isNull") if $isNullable; | 1486 push(@arguments, "isNull") if $isNullable; |
1468 push(@arguments, "ec") if $useExceptions; | 1487 push(@arguments, "ec") if $useExceptions; |
1469 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { | 1488 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { |
1470 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp
lementedBy"}; | 1489 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp
lementedBy"}; |
1471 AddInterfaceToImplIncludes($implementedBy); | 1490 AddInterfaceToImplIncludes($implementedBy); |
1472 unshift(@arguments, "imp") if !$attribute->isStatic; | 1491 unshift(@arguments, "imp") if !$attribute->isStatic; |
1473 $functionName = "${implementedBy}::${functionName}"; | 1492 $functionName = "${implementedBy}::${functionName}"; |
1474 } elsif ($attribute->isStatic) { | 1493 } elsif ($attribute->isStatic) { |
1475 $functionName = "${interfaceName}::${functionName}"; | 1494 $functionName = "${implClassName}::${functionName}"; |
1476 } else { | 1495 } else { |
1477 $functionName = "imp->${functionName}"; | 1496 $functionName = "imp->${functionName}"; |
1478 } | 1497 } |
1479 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extendedAt
tributes->{"CallWith"}, " ", 0); | 1498 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extendedAt
tributes->{"CallWith"}, " ", 0); |
1480 $code .= $subCode; | 1499 $code .= $subCode; |
1481 unshift(@arguments, @$arg); | 1500 unshift(@arguments, @$arg); |
1482 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; | 1501 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; |
1483 } else { | 1502 } else { |
1484 $getterString = "impInstance"; | 1503 $getterString = "impInstance"; |
1485 } | 1504 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$
/) { | 1583 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$
/) { |
1565 AddToImplIncludes("V8$attrType.h"); | 1584 AddToImplIncludes("V8$attrType.h"); |
1566 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); | 1585 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); |
1567 my $tearOffType = GetSVGTypeNeedingTearOff($attrType); | 1586 my $tearOffType = GetSVGTypeNeedingTearOff($attrType); |
1568 my $wrappedValue; | 1587 my $wrappedValue; |
1569 if (IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not def
ined $attribute->signature->extendedAttributes->{"Immutable"}) { | 1588 if (IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not def
ined $attribute->signature->extendedAttributes->{"Immutable"}) { |
1570 my $getter = $expression; | 1589 my $getter = $expression; |
1571 $getter =~ s/imp->//; | 1590 $getter =~ s/imp->//; |
1572 $getter =~ s/\(\)//; | 1591 $getter =~ s/\(\)//; |
1573 | 1592 |
1574 my $updateMethod = "&${interfaceName}::update" . FirstLetterToUpperC
ase($getter); | 1593 my $updateMethod = "&${implClassName}::update" . FirstLetterToUpperC
ase($getter); |
1575 | 1594 |
1576 my $selfIsTearOffType = IsSVGTypeNeedingTearOff($interfaceName); | 1595 my $selfIsTearOffType = IsSVGTypeNeedingTearOff($interfaceName); |
1577 if ($selfIsTearOffType) { | 1596 if ($selfIsTearOffType) { |
1578 AddToImplIncludes("core/svg/properties/SVGStaticPropertyWithPare
ntTearOff.h"); | 1597 AddToImplIncludes("core/svg/properties/SVGStaticPropertyWithPare
ntTearOff.h"); |
1579 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParen
tTearOff<$interfaceName, /; | 1598 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParen
tTearOff<$implClassName, /; |
1580 | 1599 |
1581 if ($expression =~ /matrix/ and $interfaceName eq "SVGTransform"
) { | 1600 if ($expression =~ /matrix/ and $interfaceName eq "SVGTransform"
) { |
1582 # SVGTransform offers a matrix() method for internal usage t
hat returns an AffineTransform | 1601 # SVGTransform offers a matrix() method for internal usage t
hat returns an AffineTransform |
1583 # and a svgMatrix() method returning a SVGMatrix, used for t
he bindings. | 1602 # and a svgMatrix() method returning a SVGMatrix, used for t
he bindings. |
1584 $expression =~ s/matrix/svgMatrix/; | 1603 $expression =~ s/matrix/svgMatrix/; |
1585 } | 1604 } |
1586 | 1605 |
1587 $wrappedValue = "WTF::getPtr(${tearOffType}::create(wrapper, $ex
pression, $updateMethod))"; | 1606 $wrappedValue = "WTF::getPtr(${tearOffType}::create(wrapper, $ex
pression, $updateMethod))"; |
1588 } else { | 1607 } else { |
1589 AddToImplIncludes("core/svg/properties/SVGStaticPropertyTearOff.
h"); | 1608 AddToImplIncludes("core/svg/properties/SVGStaticPropertyTearOff.
h"); |
1590 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$
interfaceName, /; | 1609 $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$
implClassName, /; |
1591 | 1610 |
1592 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres
sion, $updateMethod))"; | 1611 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres
sion, $updateMethod))"; |
1593 } | 1612 } |
1594 } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { | 1613 } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { |
1595 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres
sion))"; | 1614 $wrappedValue = "WTF::getPtr(${tearOffType}::create(imp, $expres
sion))"; |
1596 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { | 1615 } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { |
1597 $wrappedValue = "WTF::getPtr($expression)"; | 1616 $wrappedValue = "WTF::getPtr($expression)"; |
1598 } else { | 1617 } else { |
1599 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression)
)"; | 1618 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression)
)"; |
1600 } | 1619 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 return 0 if $returnType eq "MessagePortArray"; | 1680 return 0 if $returnType eq "MessagePortArray"; |
1662 return 0 if $returnType =~ /SVG/; | 1681 return 0 if $returnType =~ /SVG/; |
1663 return 0 if $returnType =~ /HTML/; | 1682 return 0 if $returnType =~ /HTML/; |
1664 | 1683 |
1665 return 1; | 1684 return 1; |
1666 } | 1685 } |
1667 | 1686 |
1668 sub GenerateReplaceableAttrSetterCallback | 1687 sub GenerateReplaceableAttrSetterCallback |
1669 { | 1688 { |
1670 my $interface = shift; | 1689 my $interface = shift; |
1671 my $interfaceName = $interface->name; | 1690 my $implClassName = GetImplClassName($interface); |
1672 | 1691 |
1673 my $code = ""; | 1692 my $code = ""; |
1674 $code .= "static void ${interfaceName}ReplaceableAttrSetterCallback(v8::Loca
l<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n"
; | 1693 $code .= "static void ${implClassName}ReplaceableAttrSetterCallback(v8::Loca
l<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n"
; |
1675 $code .= "{\n"; | 1694 $code .= "{\n"; |
1676 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); | 1695 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); |
1677 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D
eprecateAs"}); | 1696 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D
eprecateAs"}); |
1678 if (HasActivityLogging("", $interface->extendedAttributes, "Setter")) { | 1697 if (HasActivityLogging("", $interface->extendedAttributes, "Setter")) { |
1679 die "IDL error: ActivityLog attribute cannot exist on a ReplacableAttrS
etterCallback"; | 1698 die "IDL error: ActivityLog attribute cannot exist on a ReplacableAttrS
etterCallback"; |
1680 } | 1699 } |
1681 $code .= " return ${interfaceName}V8Internal::${interfaceName}Replaceable
AttrSetter(name, value, info);\n"; | 1700 $code .= " return ${implClassName}V8Internal::${implClassName}Replaceable
AttrSetter(name, value, info);\n"; |
1682 $code .= "}\n\n"; | 1701 $code .= "}\n\n"; |
1683 $implementation{nameSpaceInternal}->add($code); | 1702 $implementation{nameSpaceInternal}->add($code); |
1684 } | 1703 } |
1685 | 1704 |
1686 sub GenerateReplaceableAttrSetter | 1705 sub GenerateReplaceableAttrSetter |
1687 { | 1706 { |
1688 my $interface = shift; | 1707 my $interface = shift; |
1689 my $interfaceName = $interface->name; | 1708 |
| 1709 my $implClassName = GetImplClassName($interface); |
| 1710 my $v8ClassName = GetV8ClassName($interface); |
1690 | 1711 |
1691 my $code = ""; | 1712 my $code = ""; |
1692 $code .= <<END; | 1713 $code .= <<END; |
1693 static void ${interfaceName}ReplaceableAttrSetter(v8::Local<v8::String> name, v8
::Local<v8::Value> value, const v8::AccessorInfo& info) | 1714 static void ${implClassName}ReplaceableAttrSetter(v8::Local<v8::String> name, v8
::Local<v8::Value> value, const v8::AccessorInfo& info) |
1694 { | 1715 { |
1695 END | 1716 END |
1696 if ($interface->extendedAttributes->{"CheckSecurity"}) { | 1717 if ($interface->extendedAttributes->{"CheckSecurity"}) { |
1697 AddToImplIncludes("core/page/Frame.h"); | 1718 AddToImplIncludes("core/page/Frame.h"); |
1698 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1719 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
1699 $code .= <<END; | 1720 $code .= <<END; |
1700 ${interfaceName}* imp = V8${interfaceName}::toNative(info.Holder()); | 1721 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
1701 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame())) | 1722 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame())) |
1702 return; | 1723 return; |
1703 END | 1724 END |
1704 } | 1725 } |
1705 | 1726 |
1706 $code .= <<END; | 1727 $code .= <<END; |
1707 info.This()->ForceSet(name, value); | 1728 info.This()->ForceSet(name, value); |
1708 } | 1729 } |
1709 | 1730 |
1710 END | 1731 END |
(...skipping 17 matching lines...) Expand all Loading... |
1728 } | 1749 } |
1729 return $code; | 1750 return $code; |
1730 } | 1751 } |
1731 | 1752 |
1732 sub GenerateNormalAttrSetterCallback | 1753 sub GenerateNormalAttrSetterCallback |
1733 { | 1754 { |
1734 my $attribute = shift; | 1755 my $attribute = shift; |
1735 my $interface = shift; | 1756 my $interface = shift; |
1736 my $forMainWorldSuffix = shift; | 1757 my $forMainWorldSuffix = shift; |
1737 | 1758 |
1738 my $interfaceName = $interface->name; | 1759 my $implClassName = GetImplClassName($interface); |
1739 my $v8InterfaceName = "V8$interfaceName"; | 1760 my $v8ClassName = GetV8ClassName($interface); |
1740 my $attrExt = $attribute->signature->extendedAttributes; | 1761 my $attrExt = $attribute->signature->extendedAttributes; |
1741 my $attrName = $attribute->signature->name; | 1762 my $attrName = $attribute->signature->name; |
1742 | 1763 |
1743 my $conditionalString = GenerateConditionalString($attribute->signature); | 1764 my $conditionalString = GenerateConditionalString($attribute->signature); |
1744 my $code = ""; | 1765 my $code = ""; |
1745 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 1766 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
1746 | 1767 |
1747 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8:
:Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& inf
o)\n"; | 1768 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8:
:Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& inf
o)\n"; |
1748 $code .= "{\n"; | 1769 $code .= "{\n"; |
1749 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); | 1770 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); |
1750 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); | 1771 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); |
1751 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) { | 1772 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) { |
1752 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}"); | 1773 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}"); |
1753 } | 1774 } |
1754 if (HasCustomSetter($attrExt)) { | 1775 if (HasCustomSetter($attrExt)) { |
1755 $code .= " ${v8InterfaceName}::${attrName}AttrSetterCustom(name, valu
e, info);\n"; | 1776 $code .= " ${v8ClassName}::${attrName}AttrSetterCustom(name, value, i
nfo);\n"; |
1756 } else { | 1777 } else { |
1757 $code .= " ${interfaceName}V8Internal::${attrName}AttrSetter${forMain
WorldSuffix}(name, value, info);\n"; | 1778 $code .= " ${implClassName}V8Internal::${attrName}AttrSetter${forMain
WorldSuffix}(name, value, info);\n"; |
1758 } | 1779 } |
1759 $code .= "}\n\n"; | 1780 $code .= "}\n\n"; |
1760 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1781 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
1761 $implementation{nameSpaceInternal}->add($code); | 1782 $implementation{nameSpaceInternal}->add($code); |
1762 } | 1783 } |
1763 | 1784 |
1764 sub GenerateNormalAttrSetter | 1785 sub GenerateNormalAttrSetter |
1765 { | 1786 { |
1766 my $attribute = shift; | 1787 my $attribute = shift; |
1767 my $interface = shift; | 1788 my $interface = shift; |
1768 my $forMainWorldSuffix = shift; | 1789 my $forMainWorldSuffix = shift; |
1769 | 1790 |
1770 my $interfaceName = $interface->name; | 1791 my $interfaceName = $interface->name; |
1771 my $v8InterfaceName = "V8$interfaceName"; | 1792 my $implClassName = GetImplClassName($interface); |
| 1793 my $v8ClassName = GetV8ClassName($interface); |
1772 my $attrName = $attribute->signature->name; | 1794 my $attrName = $attribute->signature->name; |
1773 my $attrExt = $attribute->signature->extendedAttributes; | 1795 my $attrExt = $attribute->signature->extendedAttributes; |
1774 my $attrType = $attribute->signature->type; | 1796 my $attrType = $attribute->signature->type; |
1775 | 1797 |
1776 if (HasCustomSetter($attrExt)) { | 1798 if (HasCustomSetter($attrExt)) { |
1777 return; | 1799 return; |
1778 } | 1800 } |
1779 | 1801 |
1780 my $conditionalString = GenerateConditionalString($attribute->signature); | 1802 my $conditionalString = GenerateConditionalString($attribute->signature); |
1781 my $code = ""; | 1803 my $code = ""; |
(...skipping 14 matching lines...) Expand all Loading... |
1796 $code .= " return;\n"; | 1818 $code .= " return;\n"; |
1797 $code .= " }\n"; | 1819 $code .= " }\n"; |
1798 } | 1820 } |
1799 } | 1821 } |
1800 | 1822 |
1801 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); | 1823 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); |
1802 if ($svgNativeType) { | 1824 if ($svgNativeType) { |
1803 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); | 1825 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); |
1804 if ($svgWrappedNativeType =~ /List$/) { | 1826 if ($svgWrappedNativeType =~ /List$/) { |
1805 $code .= <<END; | 1827 $code .= <<END; |
1806 $svgNativeType* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1828 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); |
1807 END | 1829 END |
1808 } else { | 1830 } else { |
1809 AddToImplIncludes("core/dom/ExceptionCode.h"); | 1831 AddToImplIncludes("core/dom/ExceptionCode.h"); |
1810 $code .= " $svgNativeType* wrapper = ${v8InterfaceName}::toNative
(info.Holder());\n"; | 1832 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf
o.Holder());\n"; |
1811 $code .= " if (wrapper->isReadOnly()) {\n"; | 1833 $code .= " if (wrapper->isReadOnly()) {\n"; |
1812 $code .= " setDOMException(NO_MODIFICATION_ALLOWED_ERR, info.
GetIsolate());\n"; | 1834 $code .= " setDOMException(NO_MODIFICATION_ALLOWED_ERR, info.
GetIsolate());\n"; |
1813 $code .= " return;\n"; | 1835 $code .= " return;\n"; |
1814 $code .= " }\n"; | 1836 $code .= " }\n"; |
1815 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; | 1837 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; |
1816 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; | 1838 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
1817 } | 1839 } |
1818 } elsif ($attrExt->{"OnProto"}) { | 1840 } elsif ($attrExt->{"OnProto"}) { |
1819 $code .= <<END; | 1841 $code .= <<END; |
1820 ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1842 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
1821 END | 1843 END |
1822 } else { | 1844 } else { |
1823 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; | 1845 my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; |
1824 if ($reflect && InheritsInterface($interface, "Node") && $attrType eq "D
OMString") { | 1846 if ($reflect && InheritsInterface($interface, "Node") && $attrType eq "D
OMString") { |
1825 # Generate super-compact call for regular attribute setter: | 1847 # Generate super-compact call for regular attribute setter: |
1826 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr
Name : $reflect; | 1848 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr
Name : $reflect; |
1827 my $namespace = NamespaceForAttributeName($interfaceName, $contentAt
tributeName); | 1849 my $namespace = NamespaceForAttributeName($interfaceName, $contentAt
tributeName); |
1828 AddToImplIncludes("${namespace}.h"); | 1850 AddToImplIncludes("${namespace}.h"); |
1829 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; | 1851 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; |
1830 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<
WithNullCheck>, stringResource, value);\n"; | 1852 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<
WithNullCheck>, stringResource, value);\n"; |
1831 $code .= " imp->setAttribute(${namespace}::${contentAttributeName
}Attr, stringResource);\n"; | 1853 $code .= " imp->setAttribute(${namespace}::${contentAttributeName
}Attr, stringResource);\n"; |
1832 $code .= "}\n\n"; | 1854 $code .= "}\n\n"; |
1833 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 1855 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
1834 $implementation{nameSpaceInternal}->add($code); | 1856 $implementation{nameSpaceInternal}->add($code); |
1835 return; | 1857 return; |
1836 # Skip the rest of the function! | 1858 # Skip the rest of the function! |
1837 } | 1859 } |
1838 | 1860 |
1839 if (!$attribute->isStatic) { | 1861 if (!$attribute->isStatic) { |
1840 $code .= <<END; | 1862 $code .= <<END; |
1841 ${interfaceName}* imp = ${v8InterfaceName}::toNative(info.Holder()); | 1863 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
1842 END | 1864 END |
1843 } | 1865 } |
1844 } | 1866 } |
1845 | 1867 |
1846 my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); | 1868 my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0); |
1847 if ($attribute->signature->type eq "EventListener") { | 1869 if ($attribute->signature->type eq "EventListener") { |
1848 if ($interface->name eq "DOMWindow") { | 1870 if ($interface->name eq "DOMWindow") { |
1849 $code .= " if (!imp->document())\n"; | 1871 $code .= " if (!imp->document())\n"; |
1850 $code .= " return;\n"; | 1872 $code .= " return;\n"; |
1851 } | 1873 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 $code .= " ExceptionCode ec = 0;\n"; | 1916 $code .= " ExceptionCode ec = 0;\n"; |
1895 } | 1917 } |
1896 | 1918 |
1897 if ($interfaceName eq "SVGNumber") { | 1919 if ($interfaceName eq "SVGNumber") { |
1898 $code .= " *imp = $expression;\n"; | 1920 $code .= " *imp = $expression;\n"; |
1899 } else { | 1921 } else { |
1900 if ($attribute->signature->type eq "EventListener") { | 1922 if ($attribute->signature->type eq "EventListener") { |
1901 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); | 1923 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); |
1902 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); | 1924 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); |
1903 if (!InheritsInterface($interface, "Node")) { | 1925 if (!InheritsInterface($interface, "Node")) { |
1904 $code .= " transferHiddenDependency(info.Holder(), imp->$attr
Name(), value, ${v8InterfaceName}::eventListenerCacheIndex, info.GetIsolate());\
n"; | 1926 $code .= " transferHiddenDependency(info.Holder(), imp->$attr
Name(), value, ${v8ClassName}::eventListenerCacheIndex, info.GetIsolate());\n"; |
1905 } | 1927 } |
1906 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); | 1928 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); |
1907 if ($interfaceName eq "WorkerContext" and $attribute->signature->nam
e eq "onerror") { | 1929 if ($interfaceName eq "WorkerContext" and $attribute->signature->nam
e eq "onerror") { |
1908 AddToImplIncludes("bindings/v8/V8WorkerContextErrorHandler.h"); | 1930 AddToImplIncludes("bindings/v8/V8WorkerContextErrorHandler.h"); |
1909 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)"; | 1931 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)"; |
1910 } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->na
me eq "onerror") { | 1932 } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->na
me eq "onerror") { |
1911 AddToImplIncludes("bindings/v8/V8WindowErrorHandler.h"); | 1933 AddToImplIncludes("bindings/v8/V8WindowErrorHandler.h"); |
1912 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::findOrCreateWrapper<V8WindowErrorHandler>(value, true)"; | 1934 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::findOrCreateWrapper<V8WindowErrorHandler>(value, true)"; |
1913 } else { | 1935 } else { |
1914 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::getEventListener(value, true, ListenerFindOrCreate)"; | 1936 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis
t::getEventListener(value, true, ListenerFindOrCreate)"; |
1915 } | 1937 } |
1916 $code .= ", ec" if $useExceptions; | 1938 $code .= ", ec" if $useExceptions; |
1917 $code .= ");\n"; | 1939 $code .= ");\n"; |
1918 } else { | 1940 } else { |
1919 my ($functionName, @arguments) = SetterExpression(\%implIncludes, $i
nterfaceName, $attribute); | 1941 my ($functionName, @arguments) = SetterExpression(\%implIncludes, $i
nterfaceName, $attribute); |
1920 push(@arguments, $expression); | 1942 push(@arguments, $expression); |
1921 push(@arguments, "ec") if $useExceptions; | 1943 push(@arguments, "ec") if $useExceptions; |
1922 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { | 1944 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { |
1923 my $implementedBy = $attribute->signature->extendedAttributes->{
"ImplementedBy"}; | 1945 my $implementedBy = $attribute->signature->extendedAttributes->{
"ImplementedBy"}; |
1924 AddInterfaceToImplIncludes($implementedBy); | 1946 AddInterfaceToImplIncludes($implementedBy); |
1925 unshift(@arguments, "imp") if !$attribute->isStatic; | 1947 unshift(@arguments, "imp") if !$attribute->isStatic; |
1926 $functionName = "${implementedBy}::${functionName}"; | 1948 $functionName = "${implementedBy}::${functionName}"; |
1927 } elsif ($attribute->isStatic) { | 1949 } elsif ($attribute->isStatic) { |
1928 $functionName = "${interfaceName}::${functionName}"; | 1950 $functionName = "${implClassName}::${functionName}"; |
1929 } else { | 1951 } else { |
1930 $functionName = "imp->${functionName}"; | 1952 $functionName = "imp->${functionName}"; |
1931 } | 1953 } |
1932 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extend
edAttributes->{"CallWith"}, " ", 1); | 1954 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extend
edAttributes->{"CallWith"}, " ", 1); |
1933 $code .= $subCode; | 1955 $code .= $subCode; |
1934 unshift(@arguments, @$arg); | 1956 unshift(@arguments, @$arg); |
1935 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; | 1957 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; |
1936 } | 1958 } |
1937 } | 1959 } |
1938 | 1960 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 push(@orExpression, GenerateParametersCheckExpression($numParameters, $f
unction)); | 2074 push(@orExpression, GenerateParametersCheckExpression($numParameters, $f
unction)); |
2053 } | 2075 } |
2054 return ($numMandatoryParams, join(" || ", @orExpression)); | 2076 return ($numMandatoryParams, join(" || ", @orExpression)); |
2055 } | 2077 } |
2056 | 2078 |
2057 sub GenerateOverloadedFunction | 2079 sub GenerateOverloadedFunction |
2058 { | 2080 { |
2059 my $function = shift; | 2081 my $function = shift; |
2060 my $interface = shift; | 2082 my $interface = shift; |
2061 my $forMainWorldSuffix = shift; | 2083 my $forMainWorldSuffix = shift; |
2062 my $interfaceName = $interface->name; | |
2063 | 2084 |
2064 # Generate code for choosing the correct overload to call. Overloads are | 2085 # Generate code for choosing the correct overload to call. Overloads are |
2065 # chosen based on the total number of arguments passed and the type of | 2086 # chosen based on the total number of arguments passed and the type of |
2066 # values passed in non-primitive argument slots. When more than a single | 2087 # values passed in non-primitive argument slots. When more than a single |
2067 # overload is applicable, precedence is given according to the order of | 2088 # overload is applicable, precedence is given according to the order of |
2068 # declaration in the IDL. | 2089 # declaration in the IDL. |
2069 | 2090 |
2070 my $name = $function->signature->name; | 2091 my $name = $function->signature->name; |
2071 | 2092 |
2072 my $conditionalString = GenerateConditionalString($function->signature); | 2093 my $conditionalString = GenerateConditionalString($function->signature); |
(...skipping 25 matching lines...) Expand all Loading... |
2098 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2119 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
2099 $implementation{nameSpaceInternal}->add($code); | 2120 $implementation{nameSpaceInternal}->add($code); |
2100 } | 2121 } |
2101 | 2122 |
2102 sub GenerateFunctionCallback | 2123 sub GenerateFunctionCallback |
2103 { | 2124 { |
2104 my $function = shift; | 2125 my $function = shift; |
2105 my $interface = shift; | 2126 my $interface = shift; |
2106 my $forMainWorldSuffix = shift; | 2127 my $forMainWorldSuffix = shift; |
2107 | 2128 |
2108 my $interfaceName = $interface->name; | 2129 my $implClassName = GetImplClassName($interface); |
2109 my $v8InterfaceName = "V8$interfaceName"; | 2130 my $v8ClassName = GetV8ClassName($interface); |
2110 my $name = $function->signature->name; | 2131 my $name = $function->signature->name; |
2111 | 2132 |
2112 if ($name eq "") { | 2133 if ($name eq "") { |
2113 return; | 2134 return; |
2114 } | 2135 } |
2115 | 2136 |
2116 my $conditionalString = GenerateConditionalString($function->signature); | 2137 my $conditionalString = GenerateConditionalString($function->signature); |
2117 my $code = ""; | 2138 my $code = ""; |
2118 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 2139 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
2119 $code .= <<END; | 2140 $code .= <<END; |
2120 static v8::Handle<v8::Value> ${name}MethodCallback${forMainWorldSuffix}(const v8
::Arguments& args) | 2141 static v8::Handle<v8::Value> ${name}MethodCallback${forMainWorldSuffix}(const v8
::Arguments& args) |
2121 { | 2142 { |
2122 END | 2143 END |
2123 $code .= GenerateFeatureObservation($function->signature->extendedAttributes
->{"MeasureAs"}); | 2144 $code .= GenerateFeatureObservation($function->signature->extendedAttributes
->{"MeasureAs"}); |
2124 $code .= GenerateDeprecationNotification($function->signature->extendedAttri
butes->{"DeprecateAs"}); | 2145 $code .= GenerateDeprecationNotification($function->signature->extendedAttri
butes->{"DeprecateAs"}); |
2125 if (HasActivityLogging($forMainWorldSuffix, $function->signature->extendedAt
tributes, "Access")) { | 2146 if (HasActivityLogging($forMainWorldSuffix, $function->signature->extendedAt
tributes, "Access")) { |
2126 $code .= GenerateActivityLogging("Method", $interface, "${name}"); | 2147 $code .= GenerateActivityLogging("Method", $interface, "${name}"); |
2127 } | 2148 } |
2128 if (HasCustomMethod($function->signature->extendedAttributes)) { | 2149 if (HasCustomMethod($function->signature->extendedAttributes)) { |
2129 $code .= " return ${v8InterfaceName}::${name}MethodCustom(args);\n"; | 2150 $code .= " return ${v8ClassName}::${name}MethodCustom(args);\n"; |
2130 } else { | 2151 } else { |
2131 $code .= " return ${interfaceName}V8Internal::${name}Method${forMainW
orldSuffix}(args);\n"; | 2152 $code .= " return ${implClassName}V8Internal::${name}Method${forMainW
orldSuffix}(args);\n"; |
2132 } | 2153 } |
2133 $code .= "}\n\n"; | 2154 $code .= "}\n\n"; |
2134 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2155 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
2135 $implementation{nameSpaceInternal}->add($code); | 2156 $implementation{nameSpaceInternal}->add($code); |
2136 } | 2157 } |
2137 | 2158 |
2138 sub GenerateFunction | 2159 sub GenerateFunction |
2139 { | 2160 { |
2140 my $function = shift; | 2161 my $function = shift; |
2141 my $interface = shift; | 2162 my $interface = shift; |
2142 my $forMainWorldSuffix = shift; | 2163 my $forMainWorldSuffix = shift; |
2143 | 2164 |
2144 my $interfaceName = $interface->name; | 2165 my $interfaceName = $interface->name; |
2145 my $v8InterfaceName = "V8$interfaceName"; | 2166 my $implClassName = GetImplClassName($interface); |
| 2167 my $v8ClassName = GetV8ClassName($interface); |
2146 my $name = $function->signature->name; | 2168 my $name = $function->signature->name; |
2147 my $funcExt = $function->signature->extendedAttributes; | 2169 my $funcExt = $function->signature->extendedAttributes; |
2148 | 2170 |
2149 if (HasCustomMethod($funcExt) || $name eq "") { | 2171 if (HasCustomMethod($funcExt) || $name eq "") { |
2150 return; | 2172 return; |
2151 } | 2173 } |
2152 | 2174 |
2153 if (@{$function->{overloads}} > 1) { | 2175 if (@{$function->{overloads}} > 1) { |
2154 # Append a number to an overloaded method's name to make it unique: | 2176 # Append a number to an overloaded method's name to make it unique: |
2155 $name = $name . $function->{overloadIndex}; | 2177 $name = $name . $function->{overloadIndex}; |
2156 } | 2178 } |
2157 | 2179 |
2158 my $conditionalString = GenerateConditionalString($function->signature); | 2180 my $conditionalString = GenerateConditionalString($function->signature); |
2159 my $code = ""; | 2181 my $code = ""; |
2160 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 2182 $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
2161 $code .= "static v8::Handle<v8::Value> ${name}Method${forMainWorldSuffix}(co
nst v8::Arguments& args)\n"; | 2183 $code .= "static v8::Handle<v8::Value> ${name}Method${forMainWorldSuffix}(co
nst v8::Arguments& args)\n"; |
2162 $code .= "{\n"; | 2184 $code .= "{\n"; |
2163 | 2185 |
2164 if ($name eq "addEventListener" || $name eq "removeEventListener") { | 2186 if ($name eq "addEventListener" || $name eq "removeEventListener") { |
2165 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; | 2187 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; |
2166 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; | 2188 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; |
2167 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" :
"remove"; | 2189 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" :
"remove"; |
2168 | 2190 |
2169 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); | 2191 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); |
2170 $code .= <<END; | 2192 $code .= <<END; |
2171 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(args[
1], false, ListenerFind${lookupType}); | 2193 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(args[
1], false, ListenerFind${lookupType}); |
2172 if (listener) { | 2194 if (listener) { |
2173 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<WithNullCheck>, stringR
esource, args[0]); | 2195 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<WithNullCheck>, stringR
esource, args[0]); |
2174 V8${interfaceName}::toNative(args.Holder())->${name}(stringResource, lis
tener${passRefPtrHandling}, args[2]->BooleanValue()); | 2196 ${v8ClassName}::toNative(args.Holder())->${name}(stringResource, listene
r${passRefPtrHandling}, args[2]->BooleanValue()); |
2175 END | 2197 END |
2176 if (!InheritsInterface($interface, "Node")) { | 2198 if (!InheritsInterface($interface, "Node")) { |
2177 $code .= <<END; | 2199 $code .= <<END; |
2178 ${hiddenDependencyAction}HiddenDependency(args.Holder(), args[1], V8${in
terfaceName}::eventListenerCacheIndex, args.GetIsolate()); | 2200 ${hiddenDependencyAction}HiddenDependency(args.Holder(), args[1], ${v8Cl
assName}::eventListenerCacheIndex, args.GetIsolate()); |
2179 END | 2201 END |
2180 } | 2202 } |
2181 $code .= <<END; | 2203 $code .= <<END; |
2182 } | 2204 } |
2183 return v8Undefined(); | 2205 return v8Undefined(); |
2184 } | 2206 } |
2185 | 2207 |
2186 END | 2208 END |
2187 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2209 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
2188 $implementation{nameSpaceInternal}->add($code); | 2210 $implementation{nameSpaceInternal}->add($code); |
2189 return; | 2211 return; |
2190 } | 2212 } |
2191 | 2213 |
2192 $code .= GenerateArgumentsCountCheck($function, $interface); | 2214 $code .= GenerateArgumentsCountCheck($function, $interface); |
2193 | 2215 |
2194 if ($name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { | 2216 if ($name eq "set" and $interface->extendedAttributes->{"TypedArray"}) { |
2195 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); | 2217 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); |
2196 $code .= <<END; | 2218 $code .= <<END; |
2197 return setWebGLArrayHelper<$interfaceName, ${v8InterfaceName}>(args); | 2219 return setWebGLArrayHelper<$implClassName, ${v8ClassName}>(args); |
2198 } | 2220 } |
2199 | 2221 |
2200 END | 2222 END |
2201 $implementation{nameSpaceInternal}->add($code); | 2223 $implementation{nameSpaceInternal}->add($code); |
2202 return; | 2224 return; |
2203 } | 2225 } |
2204 | 2226 |
2205 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); | 2227 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); |
2206 | 2228 |
2207 if ($svgNativeType) { | 2229 if ($svgNativeType) { |
2208 my $nativeClassName = GetNativeType($interfaceName); | 2230 my $nativeClassName = GetNativeType($interfaceName); |
2209 if ($interfaceName =~ /List$/) { | 2231 if ($interfaceName =~ /List$/) { |
2210 $code .= " $nativeClassName imp = ${v8InterfaceName}::toNative(ar
gs.Holder());\n"; | 2232 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(args.H
older());\n"; |
2211 } else { | 2233 } else { |
2212 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2234 AddToImplIncludes("core/dom/ExceptionCode.h"); |
2213 $code .= " $nativeClassName wrapper = ${v8InterfaceName}::toNativ
e(args.Holder());\n"; | 2235 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(ar
gs.Holder());\n"; |
2214 $code .= " if (wrapper->isReadOnly())\n"; | 2236 $code .= " if (wrapper->isReadOnly())\n"; |
2215 $code .= " return setDOMException(NO_MODIFICATION_ALLOWED_ERR
, args.GetIsolate());\n"; | 2237 $code .= " return setDOMException(NO_MODIFICATION_ALLOWED_ERR
, args.GetIsolate());\n"; |
2216 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac
eName); | 2238 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac
eName); |
2217 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; | 2239 $code .= " $svgWrappedNativeType& impInstance = wrapper->property
Reference();\n"; |
2218 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; | 2240 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; |
2219 } | 2241 } |
2220 } elsif (!$function->isStatic) { | 2242 } elsif (!$function->isStatic) { |
2221 $code .= <<END; | 2243 $code .= <<END; |
2222 ${interfaceName}* imp = ${v8InterfaceName}::toNative(args.Holder()); | 2244 ${implClassName}* imp = ${v8ClassName}::toNative(args.Holder()); |
2223 END | 2245 END |
2224 } | 2246 } |
2225 | 2247 |
2226 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); | 2248 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); |
2227 | 2249 |
2228 # Check domain security if needed | 2250 # Check domain security if needed |
2229 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->signatu
re->extendedAttributes->{"DoNotCheckSecurity"}) { | 2251 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->signatu
re->extendedAttributes->{"DoNotCheckSecurity"}) { |
2230 # We have not find real use cases yet. | 2252 # We have not find real use cases yet. |
2231 AddToImplIncludes("core/page/Frame.h"); | 2253 AddToImplIncludes("core/page/Frame.h"); |
2232 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2254 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
(...skipping 21 matching lines...) Expand all Loading... |
2254 # right before the label 'fail:'. | 2276 # right before the label 'fail:'. |
2255 } | 2277 } |
2256 | 2278 |
2257 if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { | 2279 if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { |
2258 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2280 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
2259 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . $fu
nction->signature->name . "(ec)))\n"; | 2281 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . $fu
nction->signature->name . "(ec)))\n"; |
2260 $code .= " return v8::Handle<v8::Value>(v8Null(args.GetIsolate())
);\n"; | 2282 $code .= " return v8::Handle<v8::Value>(v8Null(args.GetIsolate())
);\n"; |
2261 END | 2283 END |
2262 } | 2284 } |
2263 | 2285 |
2264 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interfaceName, $forMainWorldSuffix); | 2286 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, $forMainWorldSuffix); |
2265 $code .= $parameterCheckString; | 2287 $code .= $parameterCheckString; |
2266 | 2288 |
2267 # Build the function call string. | 2289 # Build the function call string. |
2268 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa
ceName, $forMainWorldSuffix, %replacements); | 2290 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa
ce, $forMainWorldSuffix, %replacements); |
2269 | 2291 |
2270 if ($raisesExceptions) { | 2292 if ($raisesExceptions) { |
2271 $code .= " }\n"; | 2293 $code .= " }\n"; |
2272 $code .= " fail:\n"; | 2294 $code .= " fail:\n"; |
2273 $code .= " return setDOMException(ec, args.GetIsolate());\n"; | 2295 $code .= " return setDOMException(ec, args.GetIsolate());\n"; |
2274 } | 2296 } |
2275 | 2297 |
2276 $code .= "}\n\n"; | 2298 $code .= "}\n\n"; |
2277 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2299 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
2278 $implementation{nameSpaceInternal}->add($code); | 2300 $implementation{nameSpaceInternal}->add($code); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2342 return $index; | 2364 return $index; |
2343 } | 2365 } |
2344 $index++; | 2366 $index++; |
2345 } | 2367 } |
2346 return -1; | 2368 return -1; |
2347 } | 2369 } |
2348 | 2370 |
2349 sub GenerateParametersCheck | 2371 sub GenerateParametersCheck |
2350 { | 2372 { |
2351 my $function = shift; | 2373 my $function = shift; |
2352 my $interfaceName = shift; | 2374 my $interface = shift; |
2353 my $forMainWorldSuffix = shift; | 2375 my $forMainWorldSuffix = shift; |
2354 | 2376 |
2355 my $parameterCheckString = ""; | 2377 my $parameterCheckString = ""; |
2356 my $paramIndex = 0; | 2378 my $paramIndex = 0; |
2357 my %replacements = (); | 2379 my %replacements = (); |
2358 | 2380 |
2359 foreach my $parameter (@{$function->parameters}) { | 2381 foreach my $parameter (@{$function->parameters}) { |
2360 my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); | 2382 my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); |
2361 | 2383 |
2362 # Optional arguments without [Default=...] should generate an early call
with fewer arguments. | 2384 # Optional arguments without [Default=...] should generate an early call
with fewer arguments. |
2363 # Optional arguments with [Optional=...] should not generate the early c
all. | 2385 # Optional arguments with [Optional=...] should not generate the early c
all. |
2364 # Optional Dictionary arguments always considered to have default of emp
ty dictionary. | 2386 # Optional Dictionary arguments always considered to have default of emp
ty dictionary. |
2365 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default
"} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) { | 2387 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default
"} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) { |
2366 $parameterCheckString .= " if (args.Length() <= $paramIndex) {\n"
; | 2388 $parameterCheckString .= " if (args.Length() <= $paramIndex) {\n"
; |
2367 my $functionCall = GenerateFunctionCallString($function, $paramIndex
, " " x 2, $interfaceName, $forMainWorldSuffix, %replacements); | 2389 my $functionCall = GenerateFunctionCallString($function, $paramIndex
, " " x 2, $interface, $forMainWorldSuffix, %replacements); |
2368 $parameterCheckString .= $functionCall; | 2390 $parameterCheckString .= $functionCall; |
2369 $parameterCheckString .= " }\n"; | 2391 $parameterCheckString .= " }\n"; |
2370 } | 2392 } |
2371 | 2393 |
2372 my $parameterDefaultPolicy = "DefaultIsUndefined"; | 2394 my $parameterDefaultPolicy = "DefaultIsUndefined"; |
2373 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par
ameter->extendedAttributes->{"Default"} : ""; | 2395 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par
ameter->extendedAttributes->{"Default"} : ""; |
2374 if ($parameter->isOptional and $default eq "NullString") { | 2396 if ($parameter->isOptional and $default eq "NullString") { |
2375 $parameterDefaultPolicy = "DefaultIsNullString"; | 2397 $parameterDefaultPolicy = "DefaultIsNullString"; |
2376 } | 2398 } |
2377 | 2399 |
2378 my $parameterName = $parameter->name; | 2400 my $parameterName = $parameter->name; |
2379 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2401 AddToImplIncludes("core/dom/ExceptionCode.h"); |
2380 if (IsCallbackInterface($parameter->type)) { | 2402 if (IsCallbackInterface($parameter->type)) { |
2381 my $v8InterfaceName = "V8" . $parameter->type; | 2403 my $v8ClassName = "V8" . $parameter->type; |
2382 AddToImplIncludes("$v8InterfaceName.h"); | 2404 AddToImplIncludes("$v8ClassName.h"); |
2383 if ($parameter->isOptional) { | 2405 if ($parameter->isOptional) { |
2384 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $
parameterName;\n"; | 2406 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $
parameterName;\n"; |
2385 $parameterCheckString .= " if (args.Length() > $paramIndex &&
!args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; | 2407 $parameterCheckString .= " if (args.Length() > $paramIndex &&
!args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; |
2386 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc
tion())\n"; | 2408 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc
tion())\n"; |
2387 $parameterCheckString .= " return throwTypeError(0, a
rgs.GetIsolate());\n"; | 2409 $parameterCheckString .= " return throwTypeError(0, a
rgs.GetIsolate());\n"; |
2388 $parameterCheckString .= " $parameterName = ${v8Interface
Name}::create(args[$paramIndex], getScriptExecutionContext());\n"; | 2410 $parameterCheckString .= " $parameterName = ${v8ClassName
}::create(args[$paramIndex], getScriptExecutionContext());\n"; |
2389 $parameterCheckString .= " }\n"; | 2411 $parameterCheckString .= " }\n"; |
2390 } else { | 2412 } else { |
2391 $parameterCheckString .= " if (args.Length() <= $paramIndex |
| !args[$paramIndex]->IsFunction())\n"; | 2413 $parameterCheckString .= " if (args.Length() <= $paramIndex |
| !args[$paramIndex]->IsFunction())\n"; |
2392 $parameterCheckString .= " return throwTypeError(0, args.
GetIsolate());\n"; | 2414 $parameterCheckString .= " return throwTypeError(0, args.
GetIsolate());\n"; |
2393 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $
parameterName = ${v8InterfaceName}::create(args[$paramIndex], getScriptExecution
Context());\n"; | 2415 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $
parameterName = ${v8ClassName}::create(args[$paramIndex], getScriptExecutionCont
ext());\n"; |
2394 } | 2416 } |
2395 } elsif ($parameter->extendedAttributes->{"Clamp"}) { | 2417 } elsif ($parameter->extendedAttributes->{"Clamp"}) { |
2396 my $nativeValue = "${parameterName}NativeValue"; | 2418 my $nativeValue = "${parameterName}NativeValue"; |
2397 my $paramType = $parameter->type; | 2419 my $paramType = $parameter->type; |
2398 $parameterCheckString .= " $paramType $parameterName = 0;\n"; | 2420 $parameterCheckString .= " $paramType $parameterName = 0;\n"; |
2399 $parameterCheckString .= " V8TRYCATCH(double, $nativeValue, a
rgs[$paramIndex]->NumberValue());\n"; | 2421 $parameterCheckString .= " V8TRYCATCH(double, $nativeValue, a
rgs[$paramIndex]->NumberValue());\n"; |
2400 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; | 2422 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; |
2401 $parameterCheckString .= " $parameterName = clampTo<$para
mType>($nativeValue);\n"; | 2423 $parameterCheckString .= " $parameterName = clampTo<$para
mType>($nativeValue);\n"; |
2402 } elsif ($parameter->type eq "SerializedScriptValue") { | 2424 } elsif ($parameter->type eq "SerializedScriptValue") { |
2403 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 2425 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2480 } | 2502 } |
2481 | 2503 |
2482 $paramIndex++; | 2504 $paramIndex++; |
2483 } | 2505 } |
2484 return ($parameterCheckString, $paramIndex, %replacements); | 2506 return ($parameterCheckString, $paramIndex, %replacements); |
2485 } | 2507 } |
2486 | 2508 |
2487 sub GenerateOverloadedConstructorCallback | 2509 sub GenerateOverloadedConstructorCallback |
2488 { | 2510 { |
2489 my $interface = shift; | 2511 my $interface = shift; |
2490 my $interfaceName = $interface->name; | 2512 my $implClassName = GetImplClassName($interface); |
2491 | 2513 |
2492 my $code = ""; | 2514 my $code = ""; |
2493 $code .= <<END; | 2515 $code .= <<END; |
2494 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2516 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) |
2495 { | 2517 { |
2496 END | 2518 END |
2497 my $leastNumMandatoryParams = 255; | 2519 my $leastNumMandatoryParams = 255; |
2498 foreach my $constructor (@{$interface->constructors}) { | 2520 foreach my $constructor (@{$interface->constructors}) { |
2499 my $name = "constructor" . $constructor->{overloadedIndex}; | 2521 my $name = "constructor" . $constructor->{overloadedIndex}; |
2500 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($constructor); | 2522 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($constructor); |
2501 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); | 2523 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); |
2502 $code .= " if ($parametersCheck)\n"; | 2524 $code .= " if ($parametersCheck)\n"; |
2503 $code .= " return ${interfaceName}V8Internal::${name}(args);\n"; | 2525 $code .= " return ${implClassName}V8Internal::${name}(args);\n"; |
2504 } | 2526 } |
2505 if ($leastNumMandatoryParams >= 1) { | 2527 if ($leastNumMandatoryParams >= 1) { |
2506 $code .= " if (args.Length() < $leastNumMandatoryParams)\n"; | 2528 $code .= " if (args.Length() < $leastNumMandatoryParams)\n"; |
2507 $code .= " return throwNotEnoughArgumentsError(args.GetIsolate())
;\n"; | 2529 $code .= " return throwNotEnoughArgumentsError(args.GetIsolate())
;\n"; |
2508 } | 2530 } |
2509 $code .= <<END; | 2531 $code .= <<END; |
2510 return throwTypeError(0, args.GetIsolate()); | 2532 return throwTypeError(0, args.GetIsolate()); |
2511 END | 2533 END |
2512 $code .= "}\n\n"; | 2534 $code .= "}\n\n"; |
2513 $implementation{nameSpaceInternal}->add($code); | 2535 $implementation{nameSpaceInternal}->add($code); |
2514 } | 2536 } |
2515 | 2537 |
2516 sub GenerateSingleConstructorCallback | 2538 sub GenerateSingleConstructorCallback |
2517 { | 2539 { |
2518 my $interface = shift; | 2540 my $interface = shift; |
2519 my $function = shift; | 2541 my $function = shift; |
2520 | 2542 |
2521 my $interfaceName = $interface->name; | 2543 my $implClassName = GetImplClassName($interface); |
| 2544 my $v8ClassName = GetV8ClassName($interface); |
2522 my $overloadedIndexString = ""; | 2545 my $overloadedIndexString = ""; |
2523 if ($function->{overloadedIndex} > 0) { | 2546 if ($function->{overloadedIndex} > 0) { |
2524 $overloadedIndexString .= $function->{overloadedIndex}; | 2547 $overloadedIndexString .= $function->{overloadedIndex}; |
2525 } | 2548 } |
2526 | 2549 |
2527 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc
eption"}; | 2550 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc
eption"}; |
2528 if ($interface->extendedAttributes->{"RaisesException"}) { | 2551 if ($interface->extendedAttributes->{"RaisesException"}) { |
2529 $raisesExceptions = 1; | 2552 $raisesExceptions = 1; |
2530 } | 2553 } |
2531 if (!$raisesExceptions) { | 2554 if (!$raisesExceptions) { |
(...skipping 16 matching lines...) Expand all Loading... |
2548 $code .= GenerateArgumentsCountCheck($function, $interface); | 2571 $code .= GenerateArgumentsCountCheck($function, $interface); |
2549 } | 2572 } |
2550 | 2573 |
2551 if ($raisesExceptions) { | 2574 if ($raisesExceptions) { |
2552 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2575 AddToImplIncludes("core/dom/ExceptionCode.h"); |
2553 $code .= "\n"; | 2576 $code .= "\n"; |
2554 $code .= " ExceptionCode ec = 0;\n"; | 2577 $code .= " ExceptionCode ec = 0;\n"; |
2555 } | 2578 } |
2556 | 2579 |
2557 # FIXME: Currently [Constructor(...)] does not yet support optional argument
s without [Default=...] | 2580 # FIXME: Currently [Constructor(...)] does not yet support optional argument
s without [Default=...] |
2558 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interfaceName, ""); | 2581 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, ""); |
2559 $code .= $parameterCheckString; | 2582 $code .= $parameterCheckString; |
2560 | 2583 |
2561 if ($interface->extendedAttributes->{"CallWith"} && $interface->extendedAttr
ibutes->{"CallWith"} eq "ScriptExecutionContext") { | 2584 if ($interface->extendedAttributes->{"CallWith"} && $interface->extendedAttr
ibutes->{"CallWith"} eq "ScriptExecutionContext") { |
2562 push(@beforeArgumentList, "context"); | 2585 push(@beforeArgumentList, "context"); |
2563 $code .= <<END; | 2586 $code .= <<END; |
2564 | 2587 |
2565 ScriptExecutionContext* context = getScriptExecutionContext(); | 2588 ScriptExecutionContext* context = getScriptExecutionContext(); |
2566 END | 2589 END |
2567 } | 2590 } |
2568 | 2591 |
2569 if ($interface->extendedAttributes->{"RaisesException"}) { | 2592 if ($interface->extendedAttributes->{"RaisesException"}) { |
2570 push(@afterArgumentList, "ec"); | 2593 push(@afterArgumentList, "ec"); |
2571 } | 2594 } |
2572 | 2595 |
2573 my @argumentList; | 2596 my @argumentList; |
2574 my $index = 0; | 2597 my $index = 0; |
2575 foreach my $parameter (@{$function->parameters}) { | 2598 foreach my $parameter (@{$function->parameters}) { |
2576 last if $index eq $paramIndex; | 2599 last if $index eq $paramIndex; |
2577 if ($replacements{$parameter->name}) { | 2600 if ($replacements{$parameter->name}) { |
2578 push(@argumentList, $replacements{$parameter->name}); | 2601 push(@argumentList, $replacements{$parameter->name}); |
2579 } else { | 2602 } else { |
2580 push(@argumentList, $parameter->name); | 2603 push(@argumentList, $parameter->name); |
2581 } | 2604 } |
2582 $index++; | 2605 $index++; |
2583 } | 2606 } |
2584 | 2607 |
2585 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr
gumentList); | 2608 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr
gumentList); |
2586 $code .= "\n"; | 2609 $code .= "\n"; |
2587 $code .= " RefPtr<${interfaceName}> impl = ${interfaceName}::create(${arg
umentString});\n"; | 2610 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg
umentString});\n"; |
2588 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; | 2611 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; |
2589 | 2612 |
2590 if ($interface->extendedAttributes->{"RaisesException"}) { | 2613 if ($interface->extendedAttributes->{"RaisesException"}) { |
2591 $code .= " if (ec)\n"; | 2614 $code .= " if (ec)\n"; |
2592 $code .= " goto fail;\n"; | 2615 $code .= " goto fail;\n"; |
2593 } | 2616 } |
2594 | 2617 |
2595 $code .= <<END; | 2618 $code .= <<END; |
2596 | 2619 |
2597 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &V8${interfaceName}
::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); | 2620 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}::in
fo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); |
2598 return wrapper; | 2621 return wrapper; |
2599 END | 2622 END |
2600 | 2623 |
2601 if ($raisesExceptions) { | 2624 if ($raisesExceptions) { |
2602 $code .= " fail:\n"; | 2625 $code .= " fail:\n"; |
2603 $code .= " return setDOMException(ec, args.GetIsolate());\n"; | 2626 $code .= " return setDOMException(ec, args.GetIsolate());\n"; |
2604 } | 2627 } |
2605 | 2628 |
2606 $code .= "}\n"; | 2629 $code .= "}\n"; |
2607 $code .= "\n"; | 2630 $code .= "\n"; |
(...skipping 21 matching lines...) Expand all Loading... |
2629 } | 2652 } |
2630 } | 2653 } |
2631 | 2654 |
2632 return $leastConstructorLength; | 2655 return $leastConstructorLength; |
2633 } | 2656 } |
2634 | 2657 |
2635 sub GenerateConstructorCallback | 2658 sub GenerateConstructorCallback |
2636 { | 2659 { |
2637 my $interface = shift; | 2660 my $interface = shift; |
2638 | 2661 |
2639 my $interfaceName = $interface->name; | 2662 my $implClassName = GetImplClassName($interface); |
| 2663 my $v8ClassName = GetV8ClassName($interface); |
2640 my $code = ""; | 2664 my $code = ""; |
2641 $code .= "v8::Handle<v8::Value> V8${interfaceName}::constructorCallback(cons
t v8::Arguments& args)\n"; | 2665 $code .= "v8::Handle<v8::Value> ${v8ClassName}::constructorCallback(const v8
::Arguments& args)\n"; |
2642 $code .= "{\n"; | 2666 $code .= "{\n"; |
2643 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); | 2667 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur
eAs"}); |
2644 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D
eprecateAs"}); | 2668 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D
eprecateAs"}); |
2645 $code .= GenerateConstructorHeader(); | 2669 $code .= GenerateConstructorHeader(); |
2646 if (HasCustomConstructor($interface)) { | 2670 if (HasCustomConstructor($interface)) { |
2647 $code .= " return V8${interfaceName}::constructorCustom(args);\n"; | 2671 $code .= " return ${v8ClassName}::constructorCustom(args);\n"; |
2648 } else { | 2672 } else { |
2649 $code .= " return ${interfaceName}V8Internal::constructor(args);\n"; | 2673 $code .= " return ${implClassName}V8Internal::constructor(args);\n"; |
2650 } | 2674 } |
2651 $code .= "}\n\n"; | 2675 $code .= "}\n\n"; |
2652 $implementation{nameSpaceWebCore}->add($code); | 2676 $implementation{nameSpaceWebCore}->add($code); |
2653 } | 2677 } |
2654 | 2678 |
2655 sub GenerateConstructor | 2679 sub GenerateConstructor |
2656 { | 2680 { |
2657 my $interface = shift; | 2681 my $interface = shift; |
2658 my $interfaceName = $interface->name; | |
2659 | 2682 |
2660 if (@{$interface->constructors} == 1) { | 2683 if (@{$interface->constructors} == 1) { |
2661 GenerateSingleConstructorCallback($interface, @{$interface->constructors
}[0]); | 2684 GenerateSingleConstructorCallback($interface, @{$interface->constructors
}[0]); |
2662 } else { | 2685 } else { |
2663 foreach my $constructor (@{$interface->constructors}) { | 2686 foreach my $constructor (@{$interface->constructors}) { |
2664 GenerateSingleConstructorCallback($interface, $constructor); | 2687 GenerateSingleConstructorCallback($interface, $constructor); |
2665 } | 2688 } |
2666 GenerateOverloadedConstructorCallback($interface); | 2689 GenerateOverloadedConstructorCallback($interface); |
2667 } | 2690 } |
2668 } | 2691 } |
2669 | 2692 |
2670 sub GenerateEventConstructor | 2693 sub GenerateEventConstructor |
2671 { | 2694 { |
2672 my $interface = shift; | 2695 my $interface = shift; |
2673 my $interfaceName = $interface->name; | 2696 my $implClassName = GetImplClassName($interface); |
| 2697 my $v8ClassName = GetV8ClassName($interface); |
2674 | 2698 |
2675 AddToImplIncludes("bindings/v8/Dictionary.h"); | 2699 AddToImplIncludes("bindings/v8/Dictionary.h"); |
2676 $implementation{nameSpaceInternal}->add(<<END); | 2700 $implementation{nameSpaceInternal}->add(<<END); |
2677 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2701 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) |
2678 { | 2702 { |
2679 if (args.Length() < 1) | 2703 if (args.Length() < 1) |
2680 return throwNotEnoughArgumentsError(args.GetIsolate()); | 2704 return throwNotEnoughArgumentsError(args.GetIsolate()); |
2681 | 2705 |
2682 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]); | 2706 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]); |
2683 ${interfaceName}Init eventInit; | 2707 ${implClassName}Init eventInit; |
2684 if (args.Length() >= 2) { | 2708 if (args.Length() >= 2) { |
2685 V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate())); | 2709 V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate())); |
2686 if (!fill${interfaceName}Init(eventInit, options)) | 2710 if (!fill${implClassName}Init(eventInit, options)) |
2687 return v8Undefined(); | 2711 return v8Undefined(); |
2688 } | 2712 } |
2689 | 2713 |
2690 RefPtr<${interfaceName}> event = ${interfaceName}::create(type, eventInit); | 2714 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit); |
2691 | 2715 |
2692 v8::Handle<v8::Object> wrapper = args.Holder(); | 2716 v8::Handle<v8::Object> wrapper = args.Holder(); |
2693 V8DOMWrapper::associateObjectWithWrapper(event.release(), &V8${interfaceName
}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); | 2717 V8DOMWrapper::associateObjectWithWrapper(event.release(), &${v8ClassName}::i
nfo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); |
2694 return wrapper; | 2718 return wrapper; |
2695 } | 2719 } |
2696 END | 2720 END |
2697 | 2721 |
2698 my $code = ""; | 2722 my $code = ""; |
2699 $code .= <<END; | 2723 $code .= <<END; |
2700 bool fill${interfaceName}Init(${interfaceName}Init& eventInit, const Dictionary&
options) | 2724 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary&
options) |
2701 { | 2725 { |
2702 END | 2726 END |
2703 | 2727 |
2704 foreach my $interfaceBase (@{$interface->parents}) { | 2728 foreach my $interfaceBase (@{$interface->parents}) { |
2705 $code .= <<END; | 2729 $code .= <<END; |
2706 if (!fill${interfaceBase}Init(eventInit, options)) | 2730 if (!fill${interfaceBase}Init(eventInit, options)) |
2707 return false; | 2731 return false; |
2708 | 2732 |
2709 END | 2733 END |
2710 } | 2734 } |
(...skipping 10 matching lines...) Expand all Loading... |
2721 return true; | 2745 return true; |
2722 } | 2746 } |
2723 | 2747 |
2724 END | 2748 END |
2725 $implementation{nameSpaceWebCore}->add($code); | 2749 $implementation{nameSpaceWebCore}->add($code); |
2726 } | 2750 } |
2727 | 2751 |
2728 sub GenerateTypedArrayConstructor | 2752 sub GenerateTypedArrayConstructor |
2729 { | 2753 { |
2730 my $interface = shift; | 2754 my $interface = shift; |
2731 my $interfaceName = $interface->name; | 2755 my $implClassName = GetImplClassName($interface); |
| 2756 my $v8ClassName = GetV8ClassName($interface); |
| 2757 |
2732 my $viewType = GetTypeNameOfExternalTypedArray($interface); | 2758 my $viewType = GetTypeNameOfExternalTypedArray($interface); |
2733 my $type = $interface->extendedAttributes->{"TypedArray"}; | 2759 my $type = $interface->extendedAttributes->{"TypedArray"}; |
2734 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); | 2760 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); |
2735 | 2761 |
2736 $implementation{nameSpaceInternal}->add(<<END); | 2762 $implementation{nameSpaceInternal}->add(<<END); |
2737 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) | 2763 static v8::Handle<v8::Value> constructor(const v8::Arguments& args) |
2738 { | 2764 { |
2739 return constructWebGLArray<$interfaceName, V8${interfaceName}, $type>(args,
&V8${interfaceName}::info, $viewType); | 2765 return constructWebGLArray<$implClassName, ${v8ClassName}, $type>(args, &${v
8ClassName}::info, $viewType); |
2740 } | 2766 } |
2741 | 2767 |
2742 END | 2768 END |
2743 } | 2769 } |
2744 | 2770 |
2745 sub GenerateNamedConstructor | 2771 sub GenerateNamedConstructor |
2746 { | 2772 { |
2747 my $function = shift; | 2773 my $function = shift; |
2748 my $interface = shift; | 2774 my $interface = shift; |
2749 | 2775 |
2750 my $interfaceName = $interface->name; | 2776 my $implClassName = GetImplClassName($interface); |
2751 my $v8InterfaceName = "V8$interfaceName"; | 2777 my $v8ClassName = GetV8ClassName($interface); |
2752 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc
eption"}; | 2778 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc
eption"}; |
2753 if ($interface->extendedAttributes->{"RaisesException"}) { | 2779 if ($interface->extendedAttributes->{"RaisesException"}) { |
2754 $raisesExceptions = 1; | 2780 $raisesExceptions = 1; |
2755 } | 2781 } |
2756 if (!$raisesExceptions) { | 2782 if (!$raisesExceptions) { |
2757 foreach my $parameter (@{$function->parameters}) { | 2783 foreach my $parameter (@{$function->parameters}) { |
2758 if ((!IsCallbackInterface($parameter->type) and TypeCanFailConversio
n($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { | 2784 if ((!IsCallbackInterface($parameter->type) and TypeCanFailConversio
n($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) { |
2759 $raisesExceptions = 1; | 2785 $raisesExceptions = 1; |
2760 } | 2786 } |
2761 } | 2787 } |
2762 } | 2788 } |
2763 | 2789 |
2764 my $maybeObserveFeature = GenerateFeatureObservation($function->signature->e
xtendedAttributes->{"MeasureAs"}); | 2790 my $maybeObserveFeature = GenerateFeatureObservation($function->signature->e
xtendedAttributes->{"MeasureAs"}); |
2765 my $maybeDeprecateFeature = GenerateDeprecationNotification($function->signa
ture->extendedAttributes->{"DeprecateAs"}); | 2791 my $maybeDeprecateFeature = GenerateDeprecationNotification($function->signa
ture->extendedAttributes->{"DeprecateAs"}); |
2766 | 2792 |
2767 my @beforeArgumentList; | 2793 my @beforeArgumentList; |
2768 my @afterArgumentList; | 2794 my @afterArgumentList; |
2769 | 2795 |
2770 my $toActiveDOMObject = "0"; | 2796 my $toActiveDOMObject = "0"; |
2771 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { | 2797 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { |
2772 $toActiveDOMObject = "${v8InterfaceName}::toActiveDOMObject"; | 2798 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject"; |
2773 } | 2799 } |
2774 | 2800 |
2775 my $toEventTarget = "0"; | 2801 my $toEventTarget = "0"; |
2776 if (InheritsExtendedAttribute($interface, "EventTarget")) { | 2802 if (InheritsExtendedAttribute($interface, "EventTarget")) { |
2777 $toEventTarget = "${v8InterfaceName}::toEventTarget"; | 2803 $toEventTarget = "${v8ClassName}::toEventTarget"; |
2778 } | 2804 } |
2779 | 2805 |
2780 AddToImplIncludes("core/page/Frame.h"); | 2806 AddToImplIncludes("core/page/Frame.h"); |
2781 $implementation{nameSpaceWebCore}->add(<<END); | 2807 $implementation{nameSpaceWebCore}->add(<<END); |
2782 WrapperTypeInfo ${v8InterfaceName}Constructor::info = { ${v8InterfaceName}Constr
uctor::GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObject, $toEven
tTarget, 0, ${v8InterfaceName}::installPerContextPrototypeProperties, 0, Wrapper
TypeObjectPrototype }; | 2808 WrapperTypeInfo ${v8ClassName}Constructor::info = { ${v8ClassName}Constructor::G
etTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, 0,
${v8ClassName}::installPerContextPrototypeProperties, 0, WrapperTypeObjectProtot
ype }; |
2783 | 2809 |
2784 END | 2810 END |
2785 | 2811 |
2786 my $code = ""; | 2812 my $code = ""; |
2787 $code .= <<END; | 2813 $code .= <<END; |
2788 static v8::Handle<v8::Value> ${v8InterfaceName}ConstructorCallback(const v8::Arg
uments& args) | 2814 static v8::Handle<v8::Value> ${v8ClassName}ConstructorCallback(const v8::Argumen
ts& args) |
2789 { | 2815 { |
2790 END | 2816 END |
2791 $code .= $maybeObserveFeature if $maybeObserveFeature; | 2817 $code .= $maybeObserveFeature if $maybeObserveFeature; |
2792 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; | 2818 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; |
2793 $code .= GenerateConstructorHeader(); | 2819 $code .= GenerateConstructorHeader(); |
2794 AddToImplIncludes("V8Document.h"); | 2820 AddToImplIncludes("V8Document.h"); |
2795 $code .= <<END; | 2821 $code .= <<END; |
2796 Document* document = currentDocument(); | 2822 Document* document = currentDocument(); |
2797 | 2823 |
2798 // Make sure the document is added to the DOM Node map. Otherwise, the ${int
erfaceName} instance | 2824 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp
lClassName} instance |
2799 // may end up being the only node in the map and get garbage-collected prema
turely. | 2825 // may end up being the only node in the map and get garbage-collected prema
turely. |
2800 toV8(document, args.Holder(), args.GetIsolate()); | 2826 toV8(document, args.Holder(), args.GetIsolate()); |
2801 | 2827 |
2802 END | 2828 END |
2803 | 2829 |
2804 $code .= GenerateArgumentsCountCheck($function, $interface); | 2830 $code .= GenerateArgumentsCountCheck($function, $interface); |
2805 | 2831 |
2806 if ($raisesExceptions) { | 2832 if ($raisesExceptions) { |
2807 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2833 AddToImplIncludes("core/dom/ExceptionCode.h"); |
2808 $code .= "\n"; | 2834 $code .= "\n"; |
2809 $code .= " ExceptionCode ec = 0;\n"; | 2835 $code .= " ExceptionCode ec = 0;\n"; |
2810 } | 2836 } |
2811 | 2837 |
2812 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interfaceName); | 2838 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface); |
2813 $code .= $parameterCheckString; | 2839 $code .= $parameterCheckString; |
2814 | 2840 |
2815 push(@beforeArgumentList, "document"); | 2841 push(@beforeArgumentList, "document"); |
2816 | 2842 |
2817 if ($interface->extendedAttributes->{"RaisesException"}) { | 2843 if ($interface->extendedAttributes->{"RaisesException"}) { |
2818 push(@afterArgumentList, "ec"); | 2844 push(@afterArgumentList, "ec"); |
2819 } | 2845 } |
2820 | 2846 |
2821 my @argumentList; | 2847 my @argumentList; |
2822 my $index = 0; | 2848 my $index = 0; |
2823 foreach my $parameter (@{$function->parameters}) { | 2849 foreach my $parameter (@{$function->parameters}) { |
2824 last if $index eq $paramIndex; | 2850 last if $index eq $paramIndex; |
2825 if ($replacements{$parameter->name}) { | 2851 if ($replacements{$parameter->name}) { |
2826 push(@argumentList, $replacements{$parameter->name}); | 2852 push(@argumentList, $replacements{$parameter->name}); |
2827 } else { | 2853 } else { |
2828 push(@argumentList, $parameter->name); | 2854 push(@argumentList, $parameter->name); |
2829 } | 2855 } |
2830 $index++; | 2856 $index++; |
2831 } | 2857 } |
2832 | 2858 |
2833 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr
gumentList); | 2859 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr
gumentList); |
2834 $code .= "\n"; | 2860 $code .= "\n"; |
2835 $code .= " RefPtr<${interfaceName}> impl = ${interfaceName}::createForJSC
onstructor(${argumentString});\n"; | 2861 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC
onstructor(${argumentString});\n"; |
2836 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; | 2862 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; |
2837 | 2863 |
2838 if ($interface->extendedAttributes->{"RaisesException"}) { | 2864 if ($interface->extendedAttributes->{"RaisesException"}) { |
2839 $code .= " if (ec)\n"; | 2865 $code .= " if (ec)\n"; |
2840 $code .= " goto fail;\n"; | 2866 $code .= " goto fail;\n"; |
2841 } | 2867 } |
2842 | 2868 |
2843 $code .= <<END; | 2869 $code .= <<END; |
2844 | 2870 |
2845 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8InterfaceName}
Constructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); | 2871 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}Cons
tructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); |
2846 return wrapper; | 2872 return wrapper; |
2847 END | 2873 END |
2848 | 2874 |
2849 if ($raisesExceptions) { | 2875 if ($raisesExceptions) { |
2850 $code .= " fail:\n"; | 2876 $code .= " fail:\n"; |
2851 $code .= " return setDOMException(ec, args.GetIsolate());\n"; | 2877 $code .= " return setDOMException(ec, args.GetIsolate());\n"; |
2852 } | 2878 } |
2853 | 2879 |
2854 $code .= "}\n"; | 2880 $code .= "}\n"; |
2855 $implementation{nameSpaceWebCore}->add($code); | 2881 $implementation{nameSpaceWebCore}->add($code); |
2856 | 2882 |
2857 $code = <<END; | 2883 $code = <<END; |
2858 | 2884 |
2859 v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}Constructor::GetTemplate(
v8::Isolate* isolate, WrapperWorldType currentWorldType) | 2885 v8::Persistent<v8::FunctionTemplate> ${v8ClassName}Constructor::GetTemplate(v8::
Isolate* isolate, WrapperWorldType currentWorldType) |
2860 { | 2886 { |
2861 static v8::Persistent<v8::FunctionTemplate> cachedTemplate; | 2887 static v8::Persistent<v8::FunctionTemplate> cachedTemplate; |
2862 if (!cachedTemplate.IsEmpty()) | 2888 if (!cachedTemplate.IsEmpty()) |
2863 return cachedTemplate; | 2889 return cachedTemplate; |
2864 | 2890 |
2865 v8::HandleScope scope; | 2891 v8::HandleScope scope; |
2866 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(${v8Inter
faceName}ConstructorCallback); | 2892 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(${v8Class
Name}ConstructorCallback); |
2867 | 2893 |
2868 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate(); | 2894 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate(); |
2869 instance->SetInternalFieldCount(${v8InterfaceName}::internalFieldCount); | 2895 instance->SetInternalFieldCount(${v8ClassName}::internalFieldCount); |
2870 result->SetClassName(v8::String::NewSymbol("${interfaceName}")); | 2896 result->SetClassName(v8::String::NewSymbol("${implClassName}")); |
2871 result->Inherit(${v8InterfaceName}::GetTemplate(isolate, currentWorldType)); | 2897 result->Inherit(${v8ClassName}::GetTemplate(isolate, currentWorldType)); |
2872 | 2898 |
2873 cachedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, result); | 2899 cachedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, result); |
2874 return cachedTemplate; | 2900 return cachedTemplate; |
2875 } | 2901 } |
2876 | 2902 |
2877 END | 2903 END |
2878 $implementation{nameSpaceWebCore}->add($code); | 2904 $implementation{nameSpaceWebCore}->add($code); |
2879 } | 2905 } |
2880 | 2906 |
2881 sub GenerateConstructorHeader | 2907 sub GenerateConstructorHeader |
2882 { | 2908 { |
2883 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h"); | 2909 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h"); |
2884 my $content = <<END; | 2910 my $content = <<END; |
2885 if (!args.IsConstructCall()) | 2911 if (!args.IsConstructCall()) |
2886 return throwTypeError("DOM object constructor cannot be called as a func
tion.", args.GetIsolate()); | 2912 return throwTypeError("DOM object constructor cannot be called as a func
tion.", args.GetIsolate()); |
2887 | 2913 |
2888 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) | 2914 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) |
2889 return args.Holder(); | 2915 return args.Holder(); |
2890 | 2916 |
2891 END | 2917 END |
2892 return $content; | 2918 return $content; |
2893 } | 2919 } |
2894 | 2920 |
2895 sub GenerateBatchedAttributeData | 2921 sub GenerateBatchedAttributeData |
2896 { | 2922 { |
2897 my $interface = shift; | 2923 my $interface = shift; |
2898 my $attributes = shift; | 2924 my $attributes = shift; |
2899 my $code = ""; | 2925 my $code = ""; |
2900 my $interfaceName = $interface->name; | |
2901 | 2926 |
2902 foreach my $attribute (@$attributes) { | 2927 foreach my $attribute (@$attributes) { |
2903 my $conditionalString = GenerateConditionalString($attribute->signature)
; | 2928 my $conditionalString = GenerateConditionalString($attribute->signature)
; |
2904 my $subCode = ""; | 2929 my $subCode = ""; |
2905 $subCode .= "#if ${conditionalString}\n" if $conditionalString; | 2930 $subCode .= "#if ${conditionalString}\n" if $conditionalString; |
2906 $subCode .= GenerateSingleBatchedAttribute($interfaceName, $attribute, "
,", ""); | 2931 $subCode .= GenerateSingleBatchedAttribute($interface, $attribute, ",",
""); |
2907 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString; | 2932 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString; |
2908 $code .= $subCode; | 2933 $code .= $subCode; |
2909 } | 2934 } |
2910 return $code; | 2935 return $code; |
2911 } | 2936 } |
2912 | 2937 |
2913 sub GenerateSingleBatchedAttribute | 2938 sub GenerateSingleBatchedAttribute |
2914 { | 2939 { |
2915 my $interfaceName = shift; | 2940 my $interface = shift; |
2916 my $attribute = shift; | 2941 my $attribute = shift; |
2917 my $delimiter = shift; | 2942 my $delimiter = shift; |
2918 my $indent = shift; | 2943 my $indent = shift; |
2919 my $code = ""; | 2944 my $code = ""; |
2920 my $attrName = $attribute->signature->name; | 2945 my $attrName = $attribute->signature->name; |
2921 my $attrExt = $attribute->signature->extendedAttributes; | 2946 my $attrExt = $attribute->signature->extendedAttributes; |
| 2947 my $implClassName = GetImplClassName($interface); |
2922 | 2948 |
2923 my $accessControl = "v8::DEFAULT"; | 2949 my $accessControl = "v8::DEFAULT"; |
2924 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { | 2950 if ($attrExt->{"DoNotCheckSecurityOnGetter"}) { |
2925 $accessControl = "v8::ALL_CAN_READ"; | 2951 $accessControl = "v8::ALL_CAN_READ"; |
2926 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { | 2952 } elsif ($attrExt->{"DoNotCheckSecurityOnSetter"}) { |
2927 $accessControl = "v8::ALL_CAN_WRITE"; | 2953 $accessControl = "v8::ALL_CAN_WRITE"; |
2928 } elsif ($attrExt->{"DoNotCheckSecurity"}) { | 2954 } elsif ($attrExt->{"DoNotCheckSecurity"}) { |
2929 $accessControl = "v8::ALL_CAN_READ"; | 2955 $accessControl = "v8::ALL_CAN_READ"; |
2930 if (!IsReadonly($attribute)) { | 2956 if (!IsReadonly($attribute)) { |
2931 $accessControl .= " | v8::ALL_CAN_WRITE"; | 2957 $accessControl .= " | v8::ALL_CAN_WRITE"; |
2932 } | 2958 } |
2933 } | 2959 } |
2934 if ($attrExt->{"Unforgeable"}) { | 2960 if ($attrExt->{"Unforgeable"}) { |
2935 $accessControl .= " | v8::PROHIBITS_OVERWRITING"; | 2961 $accessControl .= " | v8::PROHIBITS_OVERWRITING"; |
2936 } | 2962 } |
2937 $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")"; | 2963 $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")"; |
2938 | 2964 |
2939 my $customAccessor = HasCustomGetter($attrExt) || HasCustomSetter($attrExt)
|| ""; | 2965 my $customAccessor = HasCustomGetter($attrExt) || HasCustomSetter($attrExt)
|| ""; |
2940 if ($customAccessor eq "VALUE_IS_MISSING") { | 2966 if ($customAccessor eq "VALUE_IS_MISSING") { |
2941 # use the naming convension, interface + (capitalize) attr name | 2967 # use the naming convension, interface + (capitalize) attr name |
2942 $customAccessor = $interfaceName . "::" . $attrName; | 2968 $customAccessor = $implClassName . "::" . $attrName; |
2943 } | 2969 } |
2944 | 2970 |
2945 my $getter; | 2971 my $getter; |
2946 my $setter; | 2972 my $setter; |
2947 my $getterForMainWorld; | 2973 my $getterForMainWorld; |
2948 my $setterForMainWorld; | 2974 my $setterForMainWorld; |
2949 my $propAttr = "v8::None"; | 2975 my $propAttr = "v8::None"; |
2950 | 2976 |
2951 my $isConstructor = ($attribute->signature->type =~ /Constructor$/); | 2977 my $isConstructor = ($attribute->signature->type =~ /Constructor$/); |
2952 | 2978 |
(...skipping 14 matching lines...) Expand all Loading... |
2967 if ($isConstructor) { | 2993 if ($isConstructor) { |
2968 my $constructorType = $attribute->signature->type; | 2994 my $constructorType = $attribute->signature->type; |
2969 $constructorType =~ s/Constructor$//; | 2995 $constructorType =~ s/Constructor$//; |
2970 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. | 2996 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct
or. |
2971 # We do not generate the header file for NamedConstructor of class XXXX, | 2997 # We do not generate the header file for NamedConstructor of class XXXX, |
2972 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. | 2998 # since we generate the NamedConstructor declaration into the header fil
e of class XXXX. |
2973 if ($constructorType !~ /Constructor$/ || $attribute->signature->extende
dAttributes->{"CustomConstructor"}) { | 2999 if ($constructorType !~ /Constructor$/ || $attribute->signature->extende
dAttributes->{"CustomConstructor"}) { |
2974 AddToImplIncludes("V8${constructorType}.h", $attribute->signature->e
xtendedAttributes->{"Conditional"}); | 3000 AddToImplIncludes("V8${constructorType}.h", $attribute->signature->e
xtendedAttributes->{"Conditional"}); |
2975 } | 3001 } |
2976 $data = "&V8${constructorType}::info"; | 3002 $data = "&V8${constructorType}::info"; |
2977 $getter = "${interfaceName}V8Internal::${interfaceName}ConstructorGetter
"; | 3003 $getter = "${implClassName}V8Internal::${implClassName}ConstructorGetter
"; |
2978 $setter = "${interfaceName}V8Internal::${interfaceName}ReplaceableAttrSe
tterCallback"; | 3004 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAttrSe
tterCallback"; |
2979 $getterForMainWorld = "0"; | 3005 $getterForMainWorld = "0"; |
2980 $setterForMainWorld = "0"; | 3006 $setterForMainWorld = "0"; |
2981 } else { | 3007 } else { |
2982 # Default Getter and Setter | 3008 # Default Getter and Setter |
2983 $getter = "${interfaceName}V8Internal::${attrName}AttrGetterCallback"; | 3009 $getter = "${implClassName}V8Internal::${attrName}AttrGetterCallback"; |
2984 $setter = "${interfaceName}V8Internal::${attrName}AttrSetterCallback"; | 3010 $setter = "${implClassName}V8Internal::${attrName}AttrSetterCallback"; |
2985 $getterForMainWorld = "${getter}ForMainWorld"; | 3011 $getterForMainWorld = "${getter}ForMainWorld"; |
2986 $setterForMainWorld = "${setter}ForMainWorld"; | 3012 $setterForMainWorld = "${setter}ForMainWorld"; |
2987 | 3013 |
2988 if (!HasCustomSetter($attrExt) && $attrExt->{"Replaceable"}) { | 3014 if (!HasCustomSetter($attrExt) && $attrExt->{"Replaceable"}) { |
2989 $setter = "${interfaceName}V8Internal::${interfaceName}ReplaceableAt
trSetterCallback"; | 3015 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAt
trSetterCallback"; |
2990 $setterForMainWorld = "0"; | 3016 $setterForMainWorld = "0"; |
2991 } | 3017 } |
2992 } | 3018 } |
2993 | 3019 |
2994 # Read only attributes | 3020 # Read only attributes |
2995 if (IsReadonly($attribute)) { | 3021 if (IsReadonly($attribute)) { |
2996 $setter = "0"; | 3022 $setter = "0"; |
2997 $setterForMainWorld = "0"; | 3023 $setterForMainWorld = "0"; |
2998 } | 3024 } |
2999 | 3025 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3033 return 0 if $attrExt->{"ReadOnly"}; | 3059 return 0 if $attrExt->{"ReadOnly"}; |
3034 return 1; | 3060 return 1; |
3035 } | 3061 } |
3036 | 3062 |
3037 sub GenerateNonStandardFunction | 3063 sub GenerateNonStandardFunction |
3038 { | 3064 { |
3039 my $interface = shift; | 3065 my $interface = shift; |
3040 my $function = shift; | 3066 my $function = shift; |
3041 my $code = ""; | 3067 my $code = ""; |
3042 | 3068 |
3043 my $interfaceName = $interface->name; | 3069 my $implClassName = GetImplClassName($interface); |
3044 my $attrExt = $function->signature->extendedAttributes; | 3070 my $attrExt = $function->signature->extendedAttributes; |
3045 my $name = $function->signature->name; | 3071 my $name = $function->signature->name; |
3046 | 3072 |
3047 my $property_attributes = "v8::DontDelete"; | 3073 my $property_attributes = "v8::DontDelete"; |
3048 if ($attrExt->{"NotEnumerable"}) { | 3074 if ($attrExt->{"NotEnumerable"}) { |
3049 $property_attributes .= " | v8::DontEnum"; | 3075 $property_attributes .= " | v8::DontEnum"; |
3050 } | 3076 } |
3051 if ($attrExt->{"ReadOnly"}) { | 3077 if ($attrExt->{"ReadOnly"}) { |
3052 $property_attributes .= " | v8::ReadOnly"; | 3078 $property_attributes .= " | v8::ReadOnly"; |
3053 } | 3079 } |
(...skipping 21 matching lines...) Expand all Loading... |
3075 } | 3101 } |
3076 | 3102 |
3077 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh
eckSecurity"}) { | 3103 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh
eckSecurity"}) { |
3078 # Functions that are marked DoNotCheckSecurity are always readable but i
f they are changed | 3104 # Functions that are marked DoNotCheckSecurity are always readable but i
f they are changed |
3079 # and then accessed on a different domain we do not return the underlyin
g value but instead | 3105 # and then accessed on a different domain we do not return the underlyin
g value but instead |
3080 # return a new copy of the original function. This is achieved by storin
g the changed value | 3106 # return a new copy of the original function. This is achieved by storin
g the changed value |
3081 # as hidden property. | 3107 # as hidden property. |
3082 $code .= <<END; | 3108 $code .= <<END; |
3083 | 3109 |
3084 // $commentInfo | 3110 // $commentInfo |
3085 ${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)); | 3111 ${conditional}$template->SetAccessor(v8::String::NewSymbol("$name"), ${implC
lassName}V8Internal::${name}AttrGetterCallback, ${implClassName}V8Internal::${im
plClassName}DomainSafeFunctionSetter, v8Undefined(), v8::ALL_CAN_READ, static_ca
st<v8::PropertyAttribute>($property_attributes)); |
3086 END | 3112 END |
3087 return $code; | 3113 return $code; |
3088 } | 3114 } |
3089 | 3115 |
3090 my $signature = "defaultSignature"; | 3116 my $signature = "defaultSignature"; |
3091 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { | 3117 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { |
3092 $signature = "v8::Local<v8::Signature>()"; | 3118 $signature = "v8::Local<v8::Signature>()"; |
3093 } | 3119 } |
3094 | 3120 |
3095 if (RequiresCustomSignature($function)) { | 3121 if (RequiresCustomSignature($function)) { |
3096 $signature = "${name}Signature"; | 3122 $signature = "${name}Signature"; |
3097 $code .= "\n // Custom Signature '$name'\n" . CreateCustomSignature($
function); | 3123 $code .= "\n // Custom Signature '$name'\n" . CreateCustomSignature($
function); |
3098 } | 3124 } |
3099 | 3125 |
3100 if ($property_attributes eq "v8::DontDelete") { | 3126 if ($property_attributes eq "v8::DontDelete") { |
3101 $property_attributes = ""; | 3127 $property_attributes = ""; |
3102 } else { | 3128 } else { |
3103 $property_attributes = ", static_cast<v8::PropertyAttribute>($property_a
ttributes)"; | 3129 $property_attributes = ", static_cast<v8::PropertyAttribute>($property_a
ttributes)"; |
3104 } | 3130 } |
3105 | 3131 |
3106 if ($template eq "proto" && $conditional eq "" && $signature eq "defaultSign
ature" && $property_attributes eq "") { | 3132 if ($template eq "proto" && $conditional eq "" && $signature eq "defaultSign
ature" && $property_attributes eq "") { |
3107 die "This shouldn't happen: Intraface '$interfaceName' $commentInfo\n"; | 3133 die "This shouldn't happen: Class '$implClassName' $commentInfo\n"; |
3108 } | 3134 } |
3109 | 3135 |
3110 my $functionLength = GetFunctionLength($function); | 3136 my $functionLength = GetFunctionLength($function); |
3111 | 3137 |
3112 my $conditionalString = GenerateConditionalString($function->signature); | 3138 my $conditionalString = GenerateConditionalString($function->signature); |
3113 $code .= "#if ${conditionalString}\n" if $conditionalString; | 3139 $code .= "#if ${conditionalString}\n" if $conditionalString; |
3114 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { | 3140 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { |
3115 $code .= " if (currentWorldType == MainWorld) {\n"; | 3141 $code .= " if (currentWorldType == MainWorld) {\n"; |
3116 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$
name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCall
backForMainWorld, v8Undefined(), ${signature}, $functionLength)$property_attribu
tes);\n"; | 3142 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$
name\"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCall
backForMainWorld, v8Undefined(), ${signature}, $functionLength)$property_attribu
tes);\n"; |
3117 $code .= " } else {\n"; | 3143 $code .= " } else {\n"; |
3118 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$
name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCall
back, v8Undefined(), ${signature}, $functionLength)$property_attributes);\n"; | 3144 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$
name\"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCall
back, v8Undefined(), ${signature}, $functionLength)$property_attributes);\n"; |
3119 $code .= " }\n"; | 3145 $code .= " }\n"; |
3120 } else { | 3146 } else { |
3121 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$name
\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCallback
, v8Undefined(), ${signature}, $functionLength)$property_attributes);\n"; | 3147 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$name
\"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCallback
, v8Undefined(), ${signature}, $functionLength)$property_attributes);\n"; |
3122 } | 3148 } |
3123 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 3149 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
3124 return $code; | 3150 return $code; |
3125 } | 3151 } |
3126 | 3152 |
3127 sub GenerateImplementationIndexedProperty | 3153 sub GenerateImplementationIndexedProperty |
3128 { | 3154 { |
3129 my $interface = shift; | 3155 my $interface = shift; |
3130 my $interfaceName = $interface->name; | 3156 my $interfaceName = $interface->name; |
3131 my $v8InterfaceName = "V8$interfaceName"; | 3157 my $implClassName = GetImplClassName($interface); |
| 3158 my $v8ClassName = GetV8ClassName($interface); |
3132 | 3159 |
3133 my $indexedGetterfunction = GetIndexedGetterFunction($interface); | 3160 my $indexedGetterfunction = GetIndexedGetterFunction($interface); |
3134 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed
Setter"}; | 3161 my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexed
Setter"}; |
3135 my $hasCustomIndexedGetter = $interface->extendedAttributes->{"CustomIndexed
Getter"}; | 3162 my $hasCustomIndexedGetter = $interface->extendedAttributes->{"CustomIndexed
Getter"}; |
3136 | 3163 |
3137 if (!$indexedGetterfunction && !$hasCustomIndexedGetter) { | 3164 if (!$indexedGetterfunction && !$hasCustomIndexedGetter) { |
3138 return ""; | 3165 return ""; |
3139 } | 3166 } |
3140 | 3167 |
3141 my $hasEnumerator = 1; | 3168 my $hasEnumerator = 1; |
(...skipping 12 matching lines...) Expand all Loading... |
3154 | 3181 |
3155 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba
cks) and it's used on DOMWindow | 3182 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba
cks) and it's used on DOMWindow |
3156 # instead of deleters or enumerators. In addition, the getter should be set
on prototype template, to | 3183 # instead of deleters or enumerators. In addition, the getter should be set
on prototype template, to |
3157 # get implementation straight out of the DOMWindow prototype regardless of w
hat prototype is actually set | 3184 # get implementation straight out of the DOMWindow prototype regardless of w
hat prototype is actually set |
3158 # on the object. | 3185 # on the object. |
3159 if ($interfaceName eq "DOMWindow") { | 3186 if ($interfaceName eq "DOMWindow") { |
3160 $setOn = "Prototype"; | 3187 $setOn = "Prototype"; |
3161 } | 3188 } |
3162 | 3189 |
3163 my $code = ""; | 3190 my $code = ""; |
3164 $code .= " desc->${setOn}Template()->SetIndexedPropertyHandler(${v8Interf
aceName}::indexedPropertyGetter"; | 3191 $code .= " desc->${setOn}Template()->SetIndexedPropertyHandler(${v8ClassN
ame}::indexedPropertyGetter"; |
3165 $code .= $hasCustomIndexedSetter ? ", ${v8InterfaceName}::indexedPropertySet
ter" : ", 0"; | 3192 $code .= $hasCustomIndexedSetter ? ", ${v8ClassName}::indexedPropertySetter"
: ", 0"; |
3166 $code .= ", 0"; # IndexedPropertyQuery -- not being used at the moment. | 3193 $code .= ", 0"; # IndexedPropertyQuery -- not being used at the moment. |
3167 $code .= $hasDeleter ? ", ${v8InterfaceName}::indexedPropertyDeleter" : ", 0
"; | 3194 $code .= $hasDeleter ? ", ${v8ClassName}::indexedPropertyDeleter" : ", 0"; |
3168 $code .= ", nodeCollectionIndexedPropertyEnumerator<${interfaceName}>" if $h
asEnumerator; | 3195 $code .= ", nodeCollectionIndexedPropertyEnumerator<${implClassName}>" if $h
asEnumerator; |
3169 $code .= ");\n"; | 3196 $code .= ");\n"; |
3170 | 3197 |
3171 if ($indexedGetterfunction && !$hasCustomIndexedGetter) { | 3198 if ($indexedGetterfunction && !$hasCustomIndexedGetter) { |
3172 my $returnType = $indexedGetterfunction->signature->type; | 3199 my $returnType = $indexedGetterfunction->signature->type; |
3173 my $methodName = $indexedGetterfunction->signature->name || "anonymousIn
dexedGetter"; | 3200 my $methodName = $indexedGetterfunction->signature->name || "anonymousIn
dexedGetter"; |
3174 AddToImplIncludes("bindings/v8/V8Collection.h"); | 3201 AddToImplIncludes("bindings/v8/V8Collection.h"); |
3175 my $jsValue = ""; | 3202 my $jsValue = ""; |
3176 my $nativeType = GetNativeType($returnType); | 3203 my $nativeType = GetNativeType($returnType); |
3177 my $isNull = ""; | 3204 my $isNull = ""; |
3178 | 3205 |
3179 if (IsRefPtrType($returnType)) { | 3206 if (IsRefPtrType($returnType)) { |
3180 AddToImplIncludes("V8$returnType.h"); | 3207 AddToImplIncludes("V8$returnType.h"); |
3181 $isNull = "!element"; | 3208 $isNull = "!element"; |
3182 $jsValue = NativeToJSValue($indexedGetterfunction->signature, "eleme
nt.release()", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "
"); | 3209 $jsValue = NativeToJSValue($indexedGetterfunction->signature, "eleme
nt.release()", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "
"); |
3183 } else { | 3210 } else { |
3184 $isNull = "element.isNull()"; | 3211 $isNull = "element.isNull()"; |
3185 $jsValue = NativeToJSValue($indexedGetterfunction->signature, "eleme
nt", "info.Holder()", "info.GetIsolate()"); | 3212 $jsValue = NativeToJSValue($indexedGetterfunction->signature, "eleme
nt", "info.Holder()", "info.GetIsolate()"); |
3186 } | 3213 } |
3187 | 3214 |
3188 $implementation{nameSpaceWebCore}->add(<<END); | 3215 $implementation{nameSpaceWebCore}->add(<<END); |
3189 v8::Handle<v8::Value> ${v8InterfaceName}::indexedPropertyGetter(uint32_t index,
const v8::AccessorInfo& info) | 3216 v8::Handle<v8::Value> ${v8ClassName}::indexedPropertyGetter(uint32_t index, cons
t v8::AccessorInfo& info) |
3190 { | 3217 { |
3191 ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); | 3218 ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); |
3192 ${interfaceName}* collection = toNative(info.Holder()); | 3219 ${implClassName}* collection = toNative(info.Holder()); |
3193 $nativeType element = collection->$methodName(index); | 3220 $nativeType element = collection->$methodName(index); |
3194 if ($isNull) | 3221 if ($isNull) |
3195 return v8Undefined(); | 3222 return v8Undefined(); |
3196 return $jsValue; | 3223 return $jsValue; |
3197 } | 3224 } |
3198 END | 3225 END |
3199 } | 3226 } |
3200 return $code; | 3227 return $code; |
3201 } | 3228 } |
3202 | 3229 |
3203 sub GenerateImplementationNamedPropertyGetter | 3230 sub GenerateImplementationNamedPropertyGetter |
3204 { | 3231 { |
3205 my $interface = shift; | 3232 my $interface = shift; |
3206 | 3233 |
3207 my $subCode = ""; | 3234 my $subCode = ""; |
3208 my $interfaceName = $interface->name; | 3235 my $interfaceName = $interface->name; |
3209 my $v8InterfaceName = "V8$interfaceName"; | 3236 my $implClassName = GetImplClassName($interface); |
| 3237 my $v8ClassName = GetV8ClassName($interface); |
3210 | 3238 |
3211 my $namedGetterFunction = GetNamedGetterFunction($interface); | 3239 my $namedGetterFunction = GetNamedGetterFunction($interface); |
3212 my $hasCustomNamedGetter = $interface->extendedAttributes->{"CustomNamedGett
er"}; | 3240 my $hasCustomNamedGetter = $interface->extendedAttributes->{"CustomNamedGett
er"}; |
3213 | 3241 |
3214 if ($namedGetterFunction && !$hasCustomNamedGetter) { | 3242 if ($namedGetterFunction && !$hasCustomNamedGetter) { |
3215 my $returnType = $namedGetterFunction->signature->type; | 3243 my $returnType = $namedGetterFunction->signature->type; |
3216 my $methodName = $namedGetterFunction->signature->name; | 3244 my $methodName = $namedGetterFunction->signature->name; |
3217 AddToImplIncludes("bindings/v8/V8Collection.h"); | 3245 AddToImplIncludes("bindings/v8/V8Collection.h"); |
3218 AddToImplIncludes("V8$returnType.h"); | 3246 AddToImplIncludes("V8$returnType.h"); |
3219 $subCode .= <<END; | 3247 $subCode .= <<END; |
3220 desc->InstanceTemplate()->SetNamedPropertyHandler(${v8InterfaceName}::namedP
ropertyGetter, 0, 0, 0, 0); | 3248 desc->InstanceTemplate()->SetNamedPropertyHandler(${v8ClassName}::namedPrope
rtyGetter, 0, 0, 0, 0); |
3221 END | 3249 END |
3222 | 3250 |
3223 my $code .= <<END; | 3251 my $code .= <<END; |
3224 v8::Handle<v8::Value> ${v8InterfaceName}::namedPropertyGetter(v8::Local<v8::Stri
ng> name, const v8::AccessorInfo& info) | 3252 v8::Handle<v8::Value> ${v8ClassName}::namedPropertyGetter(v8::Local<v8::String>
name, const v8::AccessorInfo& info) |
3225 { | 3253 { |
3226 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 3254 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
3227 return v8Undefined(); | 3255 return v8Undefined(); |
3228 if (info.Holder()->HasRealNamedCallbackProperty(name)) | 3256 if (info.Holder()->HasRealNamedCallbackProperty(name)) |
3229 return v8Undefined(); | 3257 return v8Undefined(); |
3230 | 3258 |
3231 v8::Local<v8::Object> object = info.Holder(); | 3259 v8::Local<v8::Object> object = info.Holder(); |
3232 ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); | 3260 ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); |
3233 $interfaceName* collection = toNative(object); | 3261 $implClassName* collection = toNative(object); |
3234 | 3262 |
3235 AtomicString propertyName = toWebCoreAtomicString(name); | 3263 AtomicString propertyName = toWebCoreAtomicString(name); |
3236 RefPtr<$returnType> element = collection->$methodName(propertyName); | 3264 RefPtr<$returnType> element = collection->$methodName(propertyName); |
3237 | 3265 |
3238 if (!element) | 3266 if (!element) |
3239 return v8Undefined(); | 3267 return v8Undefined(); |
3240 | 3268 |
3241 return toV8Fast(element.release(), info, collection); | 3269 return toV8Fast(element.release(), info, collection); |
3242 } | 3270 } |
3243 | 3271 |
3244 END | 3272 END |
3245 $implementation{nameSpaceWebCore}->add($code); | 3273 $implementation{nameSpaceWebCore}->add($code); |
3246 } | 3274 } |
3247 | 3275 |
3248 if ($hasCustomNamedGetter) { | 3276 if ($hasCustomNamedGetter) { |
3249 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamed
Setter"}; | 3277 my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamed
Setter"}; |
3250 my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"
}; | 3278 my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"
}; |
3251 my $hasEnumerator = $interface->extendedAttributes->{"CustomEnumeratePro
perty"}; | 3279 my $hasEnumerator = $interface->extendedAttributes->{"CustomEnumeratePro
perty"}; |
3252 my $setOn = "Instance"; | 3280 my $setOn = "Instance"; |
3253 | 3281 |
3254 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCa
llbacks) and it's used on DOMWindow | 3282 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCa
llbacks) and it's used on DOMWindow |
3255 # instead of deleters or enumerators. In addition, the getter should be
set on prototype template, to | 3283 # instead of deleters or enumerators. In addition, the getter should be
set on prototype template, to |
3256 # get implementation straight out of the DOMWindow prototype regardless
of what prototype is actually set | 3284 # get implementation straight out of the DOMWindow prototype regardless
of what prototype is actually set |
3257 # on the object. | 3285 # on the object. |
3258 if ($interfaceName eq "DOMWindow") { | 3286 if ($interfaceName eq "DOMWindow") { |
3259 $setOn = "Prototype"; | 3287 $setOn = "Prototype"; |
3260 } | 3288 } |
3261 | 3289 |
3262 $subCode .= " desc->${setOn}Template()->SetNamedPropertyHandler(${v8I
nterfaceName}::namedPropertyGetter, "; | 3290 $subCode .= " desc->${setOn}Template()->SetNamedPropertyHandler(${v8C
lassName}::namedPropertyGetter, "; |
3263 $subCode .= $hasCustomNamedSetter ? "${v8InterfaceName}::namedPropertySe
tter, " : "0, "; | 3291 $subCode .= $hasCustomNamedSetter ? "${v8ClassName}::namedPropertySetter
, " : "0, "; |
3264 # If there is a custom enumerator, there MUST be custom query to properl
y communicate property attributes. | 3292 # If there is a custom enumerator, there MUST be custom query to properl
y communicate property attributes. |
3265 $subCode .= $hasEnumerator ? "${v8InterfaceName}::namedPropertyQuery, "
: "0, "; | 3293 $subCode .= $hasEnumerator ? "${v8ClassName}::namedPropertyQuery, " : "0
, "; |
3266 $subCode .= $hasDeleter ? "${v8InterfaceName}::namedPropertyDeleter, " :
"0, "; | 3294 $subCode .= $hasDeleter ? "${v8ClassName}::namedPropertyDeleter, " : "0,
"; |
3267 $subCode .= $hasEnumerator ? "${v8InterfaceName}::namedPropertyEnumerato
r" : "0"; | 3295 $subCode .= $hasEnumerator ? "${v8ClassName}::namedPropertyEnumerator" :
"0"; |
3268 $subCode .= ");\n"; | 3296 $subCode .= ");\n"; |
3269 } | 3297 } |
3270 | 3298 |
3271 return $subCode; | 3299 return $subCode; |
3272 } | 3300 } |
3273 | 3301 |
3274 sub GenerateImplementationCustomCall | 3302 sub GenerateImplementationCustomCall |
3275 { | 3303 { |
3276 my $interface = shift; | 3304 my $interface = shift; |
3277 my $code = ""; | 3305 my $code = ""; |
3278 | 3306 |
3279 my $interfaceName = $interface->name; | 3307 my $v8ClassName = GetV8ClassName($interface); |
3280 | 3308 |
3281 if ($interface->extendedAttributes->{"CustomCall"}) { | 3309 if ($interface->extendedAttributes->{"CustomCall"}) { |
3282 $code .= " desc->InstanceTemplate()->SetCallAsFunctionHandler(V8${int
erfaceName}::callAsFunctionCallback);\n"; | 3310 $code .= " desc->InstanceTemplate()->SetCallAsFunctionHandler(${v8Cla
ssName}::callAsFunctionCallback);\n"; |
3283 } | 3311 } |
3284 return $code; | 3312 return $code; |
3285 } | 3313 } |
3286 | 3314 |
3287 sub GenerateImplementationMasqueradesAsUndefined | 3315 sub GenerateImplementationMasqueradesAsUndefined |
3288 { | 3316 { |
3289 my $interface = shift; | 3317 my $interface = shift; |
3290 my $code = ""; | 3318 my $code = ""; |
3291 | 3319 |
3292 if ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) | 3320 if ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) |
3293 { | 3321 { |
3294 $code .= " desc->InstanceTemplate()->MarkAsUndetectable();\n"; | 3322 $code .= " desc->InstanceTemplate()->MarkAsUndetectable();\n"; |
3295 } | 3323 } |
3296 return $code; | 3324 return $code; |
3297 } | 3325 } |
3298 | 3326 |
3299 sub GenerateImplementation | 3327 sub GenerateImplementation |
3300 { | 3328 { |
3301 my $object = shift; | 3329 my $object = shift; |
3302 my $interface = shift; | 3330 my $interface = shift; |
3303 my $interfaceName = $interface->name; | 3331 my $interfaceName = $interface->name; |
3304 my $visibleInterfaceName = GetVisibleInterfaceName($interface); | 3332 my $visibleInterfaceName = GetVisibleInterfaceName($interface); |
3305 my $v8InterfaceName = "V8$interfaceName"; | 3333 my $implClassName = GetImplClassName($interface); |
| 3334 my $v8ClassName = GetV8ClassName($interface); |
3306 my $nativeType = GetNativeTypeForConversions($interface); | 3335 my $nativeType = GetNativeTypeForConversions($interface); |
3307 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); | 3336 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); |
3308 my $vtableRefGnu = GetGnuVTableRefForInterface($interface); | 3337 my $vtableRefGnu = GetGnuVTableRefForInterface($interface); |
3309 my $vtableRefWin = GetWinVTableRefForInterface($interface); | 3338 my $vtableRefWin = GetWinVTableRefForInterface($interface); |
3310 | 3339 |
3311 AddToImplIncludes("bindings/v8/V8Binding.h"); | 3340 AddToImplIncludes("bindings/v8/V8Binding.h"); |
3312 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); | 3341 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); |
3313 AddToImplIncludes("core/dom/ContextFeatures.h"); | 3342 AddToImplIncludes("core/dom/ContextFeatures.h"); |
3314 AddToImplIncludes("core/dom/Document.h"); | 3343 AddToImplIncludes("core/dom/Document.h"); |
3315 AddToImplIncludes("RuntimeEnabledFeatures.h"); | 3344 AddToImplIncludes("RuntimeEnabledFeatures.h"); |
3316 | 3345 |
3317 AddExtraIncludesForType($interfaceName); | 3346 AddExtraIncludesForType($interfaceName); |
3318 | 3347 |
3319 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8InterfaceName}::toActiveDOMObject" : "0"; | 3348 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; |
3320 my $toEventTarget = InheritsExtendedAttribute($interface, "EventTarget") ? "
${v8InterfaceName}::toEventTarget" : "0"; | 3349 my $toEventTarget = InheritsExtendedAttribute($interface, "EventTarget") ? "
${v8ClassName}::toEventTarget" : "0"; |
3321 my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8InterfaceName}
::opaqueRootForGC" : "0"; | 3350 my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8ClassName}::op
aqueRootForGC" : "0"; |
3322 | 3351 |
3323 # Find the super descriptor. | 3352 # Find the super descriptor. |
3324 my $parentClass = ""; | 3353 my $parentClass = ""; |
3325 my $parentClassTemplate = ""; | 3354 my $parentClassTemplate = ""; |
3326 foreach (@{$interface->parents}) { | 3355 foreach (@{$interface->parents}) { |
3327 my $parent = $_; | 3356 my $parent = $_; |
3328 AddToImplIncludes("V8${parent}.h"); | 3357 AddToImplIncludes("V8${parent}.h"); |
3329 $parentClass = "V8" . $parent; | 3358 $parentClass = "V8" . $parent; |
3330 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; | 3359 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; |
3331 last; | 3360 last; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3371 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; | 3400 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; |
3372 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot
ype" : "WrapperTypeObjectPrototype"; | 3401 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot
ype" : "WrapperTypeObjectPrototype"; |
3373 | 3402 |
3374 if (!IsSVGTypeNeedingTearOff($interfaceName)) { | 3403 if (!IsSVGTypeNeedingTearOff($interfaceName)) { |
3375 my $code = <<END; | 3404 my $code = <<END; |
3376 #if defined(OS_WIN) | 3405 #if defined(OS_WIN) |
3377 // In ScriptWrappable, the use of extern function prototypes inside templated st
atic methods has an issue on windows. | 3406 // In ScriptWrappable, the use of extern function prototypes inside templated st
atic methods has an issue on windows. |
3378 // These prototypes do not pick up the surrounding namespace, so drop out of Web
Core as a workaround. | 3407 // These prototypes do not pick up the surrounding namespace, so drop out of Web
Core as a workaround. |
3379 } // namespace WebCore | 3408 } // namespace WebCore |
3380 using WebCore::ScriptWrappable; | 3409 using WebCore::ScriptWrappable; |
3381 using WebCore::${v8InterfaceName}; | 3410 using WebCore::${v8ClassName}; |
3382 END | 3411 END |
3383 $code .= <<END if (GetNamespaceForInterface($interface) eq "WebCore"); | 3412 $code .= <<END if (GetNamespaceForInterface($interface) eq "WebCore"); |
3384 using WebCore::${interfaceName}; | 3413 using WebCore::${implClassName}; |
3385 END | 3414 END |
3386 $code .= <<END; | 3415 $code .= <<END; |
3387 #endif | 3416 #endif |
3388 void initializeScriptWrappableForInterface(${interfaceName}* object) | 3417 void initializeScriptWrappableForInterface(${implClassName}* object) |
3389 { | 3418 { |
3390 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | 3419 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) |
3391 ScriptWrappable::setTypeInfoInObject(object, &${v8InterfaceName}::info); | 3420 ScriptWrappable::setTypeInfoInObject(object, &${v8ClassName}::info); |
3392 } | 3421 } |
3393 #if defined(OS_WIN) | 3422 #if defined(OS_WIN) |
3394 namespace WebCore { | 3423 namespace WebCore { |
3395 #endif | 3424 #endif |
3396 END | 3425 END |
3397 $implementation{nameSpaceWebCore}->addHeader($code); | 3426 $implementation{nameSpaceWebCore}->addHeader($code); |
3398 } | 3427 } |
3399 | 3428 |
3400 my $code = "WrapperTypeInfo ${v8InterfaceName}::info = { ${v8InterfaceName}:
:GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObject, $toEventTarge
t, "; | 3429 my $code = "WrapperTypeInfo ${v8ClassName}::info = { ${v8ClassName}::GetTemp
late, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, "; |
3401 $code .= "$rootForGC, ${v8InterfaceName}::installPerContextPrototypeProperti
es, $parentClassInfo, $WrapperTypePrototype };\n"; | 3430 $code .= "$rootForGC, ${v8ClassName}::installPerContextPrototypeProperties,
$parentClassInfo, $WrapperTypePrototype };\n"; |
3402 $implementation{nameSpaceWebCore}->addHeader($code); | 3431 $implementation{nameSpaceWebCore}->addHeader($code); |
3403 | 3432 |
3404 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); | 3433 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); |
3405 | 3434 |
3406 my $hasConstructors = 0; | 3435 my $hasConstructors = 0; |
3407 my $hasReplaceable = 0; | 3436 my $hasReplaceable = 0; |
3408 | 3437 |
3409 # Generate property accessors for attributes. | 3438 # Generate property accessors for attributes. |
3410 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 3439 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
3411 my $attribute = @{$interface->attributes}[$index]; | 3440 my $attribute = @{$interface->attributes}[$index]; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3459 GenerateOpaqueRootForGC($interface); | 3488 GenerateOpaqueRootForGC($interface); |
3460 } | 3489 } |
3461 | 3490 |
3462 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne
"DOMWindow") { | 3491 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne
"DOMWindow") { |
3463 GenerateSecurityCheckFunctions($interface); | 3492 GenerateSecurityCheckFunctions($interface); |
3464 } | 3493 } |
3465 | 3494 |
3466 if ($interface->extendedAttributes->{"TypedArray"}) { | 3495 if ($interface->extendedAttributes->{"TypedArray"}) { |
3467 my $viewType = GetTypeNameOfExternalTypedArray($interface); | 3496 my $viewType = GetTypeNameOfExternalTypedArray($interface); |
3468 $implementation{nameSpaceWebCore}->add(<<END); | 3497 $implementation{nameSpaceWebCore}->add(<<END); |
3469 v8::Handle<v8::Object> wrap($interfaceName* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) | 3498 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) |
3470 { | 3499 { |
3471 ASSERT(impl); | 3500 ASSERT(impl); |
3472 v8::Handle<v8::Object> wrapper = ${v8InterfaceName}::createWrapper(impl, cre
ationContext, isolate); | 3501 v8::Handle<v8::Object> wrapper = ${v8ClassName}::createWrapper(impl, creatio
nContext, isolate); |
3473 if (!wrapper.IsEmpty()) | 3502 if (!wrapper.IsEmpty()) |
3474 wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $v
iewType, impl->length()); | 3503 wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $v
iewType, impl->length()); |
3475 return wrapper; | 3504 return wrapper; |
3476 } | 3505 } |
3477 | 3506 |
3478 END | 3507 END |
3479 } | 3508 } |
3480 | 3509 |
3481 my $indexer; | 3510 my $indexer; |
3482 my @enabledPerContextFunctions; | 3511 my @enabledPerContextFunctions; |
(...skipping 20 matching lines...) Expand all Loading... |
3503 | 3532 |
3504 if ($function->signature->name eq "item") { | 3533 if ($function->signature->name eq "item") { |
3505 $indexer = $function->signature; | 3534 $indexer = $function->signature; |
3506 } | 3535 } |
3507 | 3536 |
3508 # If the function does not need domain security check, we need to | 3537 # If the function does not need domain security check, we need to |
3509 # generate an access getter that returns different function objects | 3538 # generate an access getter that returns different function objects |
3510 # for different calling context. | 3539 # for different calling context. |
3511 if ($interface->extendedAttributes->{"CheckSecurity"} && $function->sign
ature->extendedAttributes->{"DoNotCheckSecurity"}) { | 3540 if ($interface->extendedAttributes->{"CheckSecurity"} && $function->sign
ature->extendedAttributes->{"DoNotCheckSecurity"}) { |
3512 if (!HasCustomMethod($function->signature->extendedAttributes) || $f
unction->{overloadIndex} == 1) { | 3541 if (!HasCustomMethod($function->signature->extendedAttributes) || $f
unction->{overloadIndex} == 1) { |
3513 GenerateDomainSafeFunctionGetter($function, $interfaceName); | 3542 GenerateDomainSafeFunctionGetter($function, $interface); |
3514 $needsDomainSafeFunctionSetter = 1; | 3543 $needsDomainSafeFunctionSetter = 1; |
3515 } | 3544 } |
3516 } | 3545 } |
3517 | 3546 |
3518 # Separate out functions that are enabled per context so we can process
them specially. | 3547 # Separate out functions that are enabled per context so we can process
them specially. |
3519 if ($function->signature->extendedAttributes->{"EnabledPerContext"}) { | 3548 if ($function->signature->extendedAttributes->{"EnabledPerContext"}) { |
3520 push(@enabledPerContextFunctions, $function); | 3549 push(@enabledPerContextFunctions, $function); |
3521 } else { | 3550 } else { |
3522 push(@normalFunctions, $function); | 3551 push(@normalFunctions, $function); |
3523 } | 3552 } |
3524 } | 3553 } |
3525 | 3554 |
3526 if ($needsDomainSafeFunctionSetter) { | 3555 if ($needsDomainSafeFunctionSetter) { |
3527 GenerateDomainSafeFunctionSetter($interfaceName); | 3556 GenerateDomainSafeFunctionSetter($interface); |
3528 } | 3557 } |
3529 | 3558 |
3530 # Attributes | 3559 # Attributes |
3531 my $attributes = $interface->attributes; | 3560 my $attributes = $interface->attributes; |
3532 | 3561 |
3533 # For the DOMWindow interface we partition the attributes into the | 3562 # For the DOMWindow interface we partition the attributes into the |
3534 # ones that disallows shadowing and the rest. | 3563 # ones that disallows shadowing and the rest. |
3535 my @disallowsShadowing; | 3564 my @disallowsShadowing; |
3536 # Also separate out attributes that are enabled at runtime so we can process
them specially. | 3565 # Also separate out attributes that are enabled at runtime so we can process
them specially. |
3537 my @enabledAtRuntimeAttributes; | 3566 my @enabledAtRuntimeAttributes; |
(...skipping 22 matching lines...) Expand all Loading... |
3560 $code .= "static const V8DOMConfiguration::BatchedAttribute shadowAttrs[
] = {\n"; | 3589 $code .= "static const V8DOMConfiguration::BatchedAttribute shadowAttrs[
] = {\n"; |
3561 $code .= GenerateBatchedAttributeData($interface, \@disallowsShadowing); | 3590 $code .= GenerateBatchedAttributeData($interface, \@disallowsShadowing); |
3562 $code .= "};\n\n"; | 3591 $code .= "};\n\n"; |
3563 $implementation{nameSpaceWebCore}->add($code); | 3592 $implementation{nameSpaceWebCore}->add($code); |
3564 } | 3593 } |
3565 | 3594 |
3566 my $has_attributes = 0; | 3595 my $has_attributes = 0; |
3567 if (@$attributes) { | 3596 if (@$attributes) { |
3568 $has_attributes = 1; | 3597 $has_attributes = 1; |
3569 my $code = ""; | 3598 my $code = ""; |
3570 $code .= "static const V8DOMConfiguration::BatchedAttribute ${v8Interfac
eName}Attrs[] = {\n"; | 3599 $code .= "static const V8DOMConfiguration::BatchedAttribute ${v8ClassNam
e}Attrs[] = {\n"; |
3571 $code .= GenerateBatchedAttributeData($interface, $attributes); | 3600 $code .= GenerateBatchedAttributeData($interface, $attributes); |
3572 $code .= "};\n\n"; | 3601 $code .= "};\n\n"; |
3573 $implementation{nameSpaceWebCore}->add($code); | 3602 $implementation{nameSpaceWebCore}->add($code); |
3574 } | 3603 } |
3575 | 3604 |
3576 # Setup table of standard callback functions | 3605 # Setup table of standard callback functions |
3577 my $num_callbacks = 0; | 3606 my $num_callbacks = 0; |
3578 my $has_callbacks = 0; | 3607 my $has_callbacks = 0; |
3579 $code = ""; | 3608 $code = ""; |
3580 foreach my $function (@normalFunctions) { | 3609 foreach my $function (@normalFunctions) { |
3581 # Only one table entry is needed for overloaded methods: | 3610 # Only one table entry is needed for overloaded methods: |
3582 next if $function->{overloadIndex} > 1; | 3611 next if $function->{overloadIndex} > 1; |
3583 # Don't put any nonstandard functions into this table: | 3612 # Don't put any nonstandard functions into this table: |
3584 next if !IsStandardFunction($interface, $function); | 3613 next if !IsStandardFunction($interface, $function); |
3585 next if $function->signature->name eq ""; | 3614 next if $function->signature->name eq ""; |
3586 if (!$has_callbacks) { | 3615 if (!$has_callbacks) { |
3587 $has_callbacks = 1; | 3616 $has_callbacks = 1; |
3588 $code .= "static const V8DOMConfiguration::BatchedMethod ${v8Interfa
ceName}Methods[] = {\n"; | 3617 $code .= "static const V8DOMConfiguration::BatchedMethod ${v8ClassNa
me}Methods[] = {\n"; |
3589 } | 3618 } |
3590 my $name = $function->signature->name; | 3619 my $name = $function->signature->name; |
3591 my $methodForMainWorld = "0"; | 3620 my $methodForMainWorld = "0"; |
3592 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { | 3621 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { |
3593 $methodForMainWorld = "${interfaceName}V8Internal::${name}MethodCall
backForMainWorld"; | 3622 $methodForMainWorld = "${implClassName}V8Internal::${name}MethodCall
backForMainWorld"; |
3594 } | 3623 } |
3595 my $functionLength = GetFunctionLength($function); | 3624 my $functionLength = GetFunctionLength($function); |
3596 my $conditionalString = GenerateConditionalString($function->signature); | 3625 my $conditionalString = GenerateConditionalString($function->signature); |
3597 $code .= "#if ${conditionalString}\n" if $conditionalString; | 3626 $code .= "#if ${conditionalString}\n" if $conditionalString; |
3598 $code .= <<END; | 3627 $code .= <<END; |
3599 {"$name", ${interfaceName}V8Internal::${name}MethodCallback, ${methodForMain
World}, ${functionLength}}, | 3628 {"$name", ${implClassName}V8Internal::${name}MethodCallback, ${methodForMain
World}, ${functionLength}}, |
3600 END | 3629 END |
3601 $code .= "#endif\n" if $conditionalString; | 3630 $code .= "#endif\n" if $conditionalString; |
3602 $num_callbacks++; | 3631 $num_callbacks++; |
3603 } | 3632 } |
3604 $code .= "};\n\n" if $has_callbacks; | 3633 $code .= "};\n\n" if $has_callbacks; |
3605 $implementation{nameSpaceWebCore}->add($code); | 3634 $implementation{nameSpaceWebCore}->add($code); |
3606 | 3635 |
3607 # Setup constants | 3636 # Setup constants |
3608 my $has_constants = 0; | 3637 my $has_constants = 0; |
3609 my @constantsEnabledAtRuntime; | 3638 my @constantsEnabledAtRuntime; |
3610 $code = ""; | 3639 $code = ""; |
3611 if (@{$interface->constants}) { | 3640 if (@{$interface->constants}) { |
3612 $has_constants = 1; | 3641 $has_constants = 1; |
3613 $code .= "static const V8DOMConfiguration::BatchedConstant ${v8Interface
Name}Consts[] = {\n"; | 3642 $code .= "static const V8DOMConfiguration::BatchedConstant ${v8ClassName
}Consts[] = {\n"; |
3614 } | 3643 } |
3615 foreach my $constant (@{$interface->constants}) { | 3644 foreach my $constant (@{$interface->constants}) { |
3616 my $name = $constant->name; | 3645 my $name = $constant->name; |
3617 my $value = $constant->value; | 3646 my $value = $constant->value; |
3618 my $attrExt = $constant->extendedAttributes; | 3647 my $attrExt = $constant->extendedAttributes; |
3619 my $implementedBy = $attrExt->{"ImplementedBy"}; | 3648 my $implementedBy = $attrExt->{"ImplementedBy"}; |
3620 if ($implementedBy) { | 3649 if ($implementedBy) { |
3621 AddInterfaceToImplIncludes($implementedBy); | 3650 AddInterfaceToImplIncludes($implementedBy); |
3622 } | 3651 } |
3623 if ($attrExt->{"EnabledAtRuntime"}) { | 3652 if ($attrExt->{"EnabledAtRuntime"}) { |
(...skipping 28 matching lines...) Expand all Loading... |
3652 } elsif (IsConstructorTemplate($interface, "TypedArray")) { | 3681 } elsif (IsConstructorTemplate($interface, "TypedArray")) { |
3653 GenerateTypedArrayConstructor($interface); | 3682 GenerateTypedArrayConstructor($interface); |
3654 } | 3683 } |
3655 } | 3684 } |
3656 if (IsConstructable($interface)) { | 3685 if (IsConstructable($interface)) { |
3657 GenerateConstructorCallback($interface); | 3686 GenerateConstructorCallback($interface); |
3658 } | 3687 } |
3659 | 3688 |
3660 my $access_check = ""; | 3689 my $access_check = ""; |
3661 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "
DOMWindow") { | 3690 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "
DOMWindow") { |
3662 $access_check = "instance->SetAccessCheckCallbacks(${interfaceName}V8Int
ernal::namedSecurityCheck, ${interfaceName}V8Internal::indexedSecurityCheck, v8:
:External::New(&${v8InterfaceName}::info));"; | 3691 $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Int
ernal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8:
:External::New(&${v8ClassName}::info));"; |
3663 } | 3692 } |
3664 | 3693 |
3665 # For the DOMWindow interface, generate the shadow object template | 3694 # For the DOMWindow interface, generate the shadow object template |
3666 # configuration method. | 3695 # configuration method. |
3667 if ($interfaceName eq "DOMWindow") { | 3696 if ($interfaceName eq "DOMWindow") { |
3668 $implementation{nameSpaceWebCore}->add(<<END); | 3697 $implementation{nameSpaceWebCore}->add(<<END); |
3669 static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Pers
istent<v8::ObjectTemplate> templ, v8::Isolate* isolate, WrapperWorldType current
WorldType) | 3698 static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Pers
istent<v8::ObjectTemplate> templ, v8::Isolate* isolate, WrapperWorldType current
WorldType) |
3670 { | 3699 { |
3671 V8DOMConfiguration::batchConfigureAttributes(templ, v8::Handle<v8::ObjectTem
plate>(), shadowAttrs, WTF_ARRAY_LENGTH(shadowAttrs), isolate, currentWorldType)
; | 3700 V8DOMConfiguration::batchConfigureAttributes(templ, v8::Handle<v8::ObjectTem
plate>(), shadowAttrs, WTF_ARRAY_LENGTH(shadowAttrs), isolate, currentWorldType)
; |
3672 | 3701 |
3673 // Install a security handler with V8. | 3702 // Install a security handler with V8. |
3674 templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheckCustom, V8DOMW
indow::indexedSecurityCheckCustom, v8::External::New(&V8DOMWindow::info)); | 3703 templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheckCustom, V8DOMW
indow::indexedSecurityCheckCustom, v8::External::New(&V8DOMWindow::info)); |
3675 templ->SetInternalFieldCount(V8DOMWindow::internalFieldCount); | 3704 templ->SetInternalFieldCount(V8DOMWindow::internalFieldCount); |
3676 return templ; | 3705 return templ; |
3677 } | 3706 } |
3678 END | 3707 END |
3679 } | 3708 } |
3680 | 3709 |
3681 if (!$parentClassTemplate) { | 3710 if (!$parentClassTemplate) { |
3682 $parentClassTemplate = "v8::Persistent<v8::FunctionTemplate>()"; | 3711 $parentClassTemplate = "v8::Persistent<v8::FunctionTemplate>()"; |
3683 } | 3712 } |
3684 | 3713 |
3685 # Generate the template configuration method | 3714 # Generate the template configuration method |
3686 $code = <<END; | 3715 $code = <<END; |
3687 static v8::Persistent<v8::FunctionTemplate> Configure${v8InterfaceName}Template(
v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldTyp
e currentWorldType) | 3716 static v8::Persistent<v8::FunctionTemplate> Configure${v8ClassName}Template(v8::
Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType cu
rrentWorldType) |
3688 { | 3717 { |
3689 desc->ReadOnlyPrototype(); | 3718 desc->ReadOnlyPrototype(); |
3690 | 3719 |
3691 v8::Local<v8::Signature> defaultSignature; | 3720 v8::Local<v8::Signature> defaultSignature; |
3692 END | 3721 END |
3693 if ($interface->extendedAttributes->{"EnabledAtRuntime"}) { | 3722 if ($interface->extendedAttributes->{"EnabledAtRuntime"}) { |
3694 my $enable_function = GetRuntimeEnableFunctionName($interface); | 3723 my $enable_function = GetRuntimeEnableFunctionName($interface); |
3695 $code .= <<END; | 3724 $code .= <<END; |
3696 if (!${enable_function}()) | 3725 if (!${enable_function}()) |
3697 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"\", $pa
rentClassTemplate, ${v8InterfaceName}::internalFieldCount, 0, 0, 0, 0, isolate,
currentWorldType); | 3726 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"\", $pa
rentClassTemplate, ${v8ClassName}::internalFieldCount, 0, 0, 0, 0, isolate, curr
entWorldType); |
3698 else | 3727 else |
3699 END | 3728 END |
3700 } | 3729 } |
3701 $code .= <<END; | 3730 $code .= <<END; |
3702 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"${visibleIn
terfaceName}\", $parentClassTemplate, ${v8InterfaceName}::internalFieldCount, | 3731 defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"${visibleIn
terfaceName}\", $parentClassTemplate, ${v8ClassName}::internalFieldCount, |
3703 END | 3732 END |
3704 # Set up our attributes if we have them | 3733 # Set up our attributes if we have them |
3705 if ($has_attributes) { | 3734 if ($has_attributes) { |
3706 $code .= <<END; | 3735 $code .= <<END; |
3707 ${v8InterfaceName}Attrs, WTF_ARRAY_LENGTH(${v8InterfaceName}Attrs), | 3736 ${v8ClassName}Attrs, WTF_ARRAY_LENGTH(${v8ClassName}Attrs), |
3708 END | 3737 END |
3709 } else { | 3738 } else { |
3710 $code .= <<END; | 3739 $code .= <<END; |
3711 0, 0, | 3740 0, 0, |
3712 END | 3741 END |
3713 } | 3742 } |
3714 | 3743 |
3715 if ($has_callbacks) { | 3744 if ($has_callbacks) { |
3716 $code .= <<END; | 3745 $code .= <<END; |
3717 ${v8InterfaceName}Methods, WTF_ARRAY_LENGTH(${v8InterfaceName}Methods),
isolate, currentWorldType); | 3746 ${v8ClassName}Methods, WTF_ARRAY_LENGTH(${v8ClassName}Methods), isolate,
currentWorldType); |
3718 END | 3747 END |
3719 } else { | 3748 } else { |
3720 $code .= <<END; | 3749 $code .= <<END; |
3721 0, 0, isolate, currentWorldType); | 3750 0, 0, isolate, currentWorldType); |
3722 END | 3751 END |
3723 } | 3752 } |
3724 | 3753 |
3725 AddToImplIncludes("wtf/UnusedParam.h"); | 3754 AddToImplIncludes("wtf/UnusedParam.h"); |
3726 $code .= <<END; | 3755 $code .= <<END; |
3727 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 3756 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
3728 END | 3757 END |
3729 | 3758 |
3730 if (IsConstructable($interface)) { | 3759 if (IsConstructable($interface)) { |
3731 $code .= " desc->SetCallHandler(${v8InterfaceName}::constructorCallba
ck);\n"; | 3760 $code .= " desc->SetCallHandler(${v8ClassName}::constructorCallback);
\n"; |
3732 my $interfaceLength = GetInterfaceLength($interface); | 3761 my $interfaceLength = GetInterfaceLength($interface); |
3733 $code .= " desc->SetLength(${interfaceLength});\n"; | 3762 $code .= " desc->SetLength(${interfaceLength});\n"; |
3734 } | 3763 } |
3735 | 3764 |
3736 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has
_constants) { | 3765 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has
_constants) { |
3737 $code .= <<END; | 3766 $code .= <<END; |
3738 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 3767 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
3739 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 3768 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
3740 UNUSED_PARAM(instance); // In some cases, it will not be used. | 3769 UNUSED_PARAM(instance); // In some cases, it will not be used. |
3741 UNUSED_PARAM(proto); // In some cases, it will not be used. | 3770 UNUSED_PARAM(proto); // In some cases, it will not be used. |
3742 END | 3771 END |
3743 } | 3772 } |
3744 | 3773 |
3745 if ($access_check) { | 3774 if ($access_check) { |
3746 $code .= " $access_check\n"; | 3775 $code .= " $access_check\n"; |
3747 } | 3776 } |
3748 | 3777 |
3749 # Setup the enable-at-runtime attrs if we have them | 3778 # Setup the enable-at-runtime attrs if we have them |
3750 foreach my $runtime_attr (@enabledAtRuntimeAttributes) { | 3779 foreach my $runtime_attr (@enabledAtRuntimeAttributes) { |
3751 next if grep { $_ eq $runtime_attr } @enabledPerContextAttributes; | 3780 next if grep { $_ eq $runtime_attr } @enabledPerContextAttributes; |
3752 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr->signat
ure); | 3781 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr->signat
ure); |
3753 my $conditionalString = GenerateConditionalString($runtime_attr->signatu
re); | 3782 my $conditionalString = GenerateConditionalString($runtime_attr->signatu
re); |
3754 $code .= "\n#if ${conditionalString}\n" if $conditionalString; | 3783 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
3755 $code .= " if (${enable_function}()) {\n"; | 3784 $code .= " if (${enable_function}()) {\n"; |
3756 $code .= " static const V8DOMConfiguration::BatchedAttribute attr
Data =\\\n"; | 3785 $code .= " static const V8DOMConfiguration::BatchedAttribute attr
Data =\\\n"; |
3757 $code .= GenerateSingleBatchedAttribute($interfaceName, $runtime_attr, "
;", " "); | 3786 $code .= GenerateSingleBatchedAttribute($interface, $runtime_attr, ";",
" "); |
3758 $code .= <<END; | 3787 $code .= <<END; |
3759 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat
e, currentWorldType); | 3788 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat
e, currentWorldType); |
3760 } | 3789 } |
3761 END | 3790 END |
3762 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; | 3791 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; |
3763 } | 3792 } |
3764 | 3793 |
3765 # Setup the enable-at-runtime constants if we have them | 3794 # Setup the enable-at-runtime constants if we have them |
3766 foreach my $runtime_const (@constantsEnabledAtRuntime) { | 3795 foreach my $runtime_const (@constantsEnabledAtRuntime) { |
3767 my $enable_function = GetRuntimeEnableFunctionName($runtime_const); | 3796 my $enable_function = GetRuntimeEnableFunctionName($runtime_const); |
(...skipping 25 matching lines...) Expand all Loading... |
3793 $total_functions++; | 3822 $total_functions++; |
3794 next if IsStandardFunction($interface, $function); | 3823 next if IsStandardFunction($interface, $function); |
3795 $code .= GenerateNonStandardFunction($interface, $function); | 3824 $code .= GenerateNonStandardFunction($interface, $function); |
3796 $num_callbacks++; | 3825 $num_callbacks++; |
3797 } | 3826 } |
3798 | 3827 |
3799 die "Wrong number of callbacks generated for $interfaceName ($num_callbacks,
should be $total_functions)" if $num_callbacks != $total_functions; | 3828 die "Wrong number of callbacks generated for $interfaceName ($num_callbacks,
should be $total_functions)" if $num_callbacks != $total_functions; |
3800 | 3829 |
3801 if ($has_constants) { | 3830 if ($has_constants) { |
3802 $code .= <<END; | 3831 $code .= <<END; |
3803 V8DOMConfiguration::batchConfigureConstants(desc, proto, ${v8InterfaceName}C
onsts, WTF_ARRAY_LENGTH(${v8InterfaceName}Consts), isolate); | 3832 V8DOMConfiguration::batchConfigureConstants(desc, proto, ${v8ClassName}Const
s, WTF_ARRAY_LENGTH(${v8ClassName}Consts), isolate); |
3804 END | 3833 END |
3805 } | 3834 } |
3806 | 3835 |
3807 # Special cases | 3836 # Special cases |
3808 if ($interfaceName eq "DOMWindow") { | 3837 if ($interfaceName eq "DOMWindow") { |
3809 $code .= <<END; | 3838 $code .= <<END; |
3810 | 3839 |
3811 proto->SetInternalFieldCount(V8DOMWindow::internalFieldCount); | 3840 proto->SetInternalFieldCount(V8DOMWindow::internalFieldCount); |
3812 desc->SetHiddenPrototype(true); | 3841 desc->SetHiddenPrototype(true); |
3813 instance->SetInternalFieldCount(V8DOMWindow::internalFieldCount); | 3842 instance->SetInternalFieldCount(V8DOMWindow::internalFieldCount); |
(...skipping 23 matching lines...) Expand all Loading... |
3837 | 3866 |
3838 // Custom toString template | 3867 // Custom toString template |
3839 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
StringTemplate()); | 3868 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
StringTemplate()); |
3840 return desc; | 3869 return desc; |
3841 } | 3870 } |
3842 | 3871 |
3843 END | 3872 END |
3844 $implementation{nameSpaceWebCore}->add($code); | 3873 $implementation{nameSpaceWebCore}->add($code); |
3845 | 3874 |
3846 $implementation{nameSpaceWebCore}->add(<<END); | 3875 $implementation{nameSpaceWebCore}->add(<<END); |
3847 v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}::GetTemplate(v8::Isolate
* isolate, WrapperWorldType currentWorldType) | 3876 v8::Persistent<v8::FunctionTemplate> ${v8ClassName}::GetTemplate(v8::Isolate* is
olate, WrapperWorldType currentWorldType) |
3848 { | 3877 { |
3849 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 3878 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
3850 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&info); | 3879 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&info); |
3851 if (result != data->templateMap(currentWorldType).end()) | 3880 if (result != data->templateMap(currentWorldType).end()) |
3852 return result->value; | 3881 return result->value; |
3853 | 3882 |
3854 v8::HandleScope handleScope; | 3883 v8::HandleScope handleScope; |
3855 v8::Persistent<v8::FunctionTemplate> templ = | 3884 v8::Persistent<v8::FunctionTemplate> templ = |
3856 Configure${v8InterfaceName}Template(data->rawTemplate(&info, currentWorl
dType), isolate, currentWorldType); | 3885 Configure${v8ClassName}Template(data->rawTemplate(&info, currentWorldTyp
e), isolate, currentWorldType); |
3857 data->templateMap(currentWorldType).add(&info, templ); | 3886 data->templateMap(currentWorldType).add(&info, templ); |
3858 return templ; | 3887 return templ; |
3859 } | 3888 } |
3860 | 3889 |
3861 END | 3890 END |
3862 $implementation{nameSpaceWebCore}->add(<<END); | 3891 $implementation{nameSpaceWebCore}->add(<<END); |
3863 bool ${v8InterfaceName}::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* i
solate, WrapperWorldType currentWorldType) | 3892 bool ${v8ClassName}::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isola
te, WrapperWorldType currentWorldType) |
3864 { | 3893 { |
3865 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor
ldType); | 3894 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor
ldType); |
3866 } | 3895 } |
3867 | 3896 |
3868 END | 3897 END |
3869 $implementation{nameSpaceWebCore}->add(<<END); | 3898 $implementation{nameSpaceWebCore}->add(<<END); |
3870 bool ${v8InterfaceName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::
Isolate* isolate) | 3899 bool ${v8ClassName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isol
ate* isolate) |
3871 { | 3900 { |
3872 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | 3901 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) |
3873 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo
rld) | 3902 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo
rld) |
3874 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl
d); | 3903 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl
d); |
3875 } | 3904 } |
3876 | 3905 |
3877 END | 3906 END |
3878 | 3907 |
3879 if (@enabledPerContextAttributes) { | 3908 if (@enabledPerContextAttributes) { |
3880 my $code = ""; | 3909 my $code = ""; |
3881 $code .= <<END; | 3910 $code .= <<END; |
3882 void ${v8InterfaceName}::installPerContextProperties(v8::Handle<v8::Object> inst
ance, ${nativeType}* impl, v8::Isolate* isolate) | 3911 void ${v8ClassName}::installPerContextProperties(v8::Handle<v8::Object> instance
, ${nativeType}* impl, v8::Isolate* isolate) |
3883 { | 3912 { |
3884 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto
type()); | 3913 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto
type()); |
3885 END | 3914 END |
3886 | 3915 |
3887 # Setup the enable-by-settings attrs if we have them | 3916 # Setup the enable-by-settings attrs if we have them |
3888 foreach my $runtimeAttr (@enabledPerContextAttributes) { | 3917 foreach my $runtimeAttr (@enabledPerContextAttributes) { |
3889 my $enableFunction = GetContextEnableFunction($runtimeAttr->signatur
e); | 3918 my $enableFunction = GetContextEnableFunction($runtimeAttr->signatur
e); |
3890 my $conditionalString = GenerateConditionalString($runtimeAttr->sign
ature); | 3919 my $conditionalString = GenerateConditionalString($runtimeAttr->sign
ature); |
3891 $code .= "\n#if ${conditionalString}\n" if $conditionalString; | 3920 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
3892 if (grep { $_ eq $runtimeAttr } @enabledAtRuntimeAttributes) { | 3921 if (grep { $_ eq $runtimeAttr } @enabledAtRuntimeAttributes) { |
3893 my $runtimeEnableFunction = GetRuntimeEnableFunctionName($runtim
eAttr->signature); | 3922 my $runtimeEnableFunction = GetRuntimeEnableFunctionName($runtim
eAttr->signature); |
3894 $code .= " if (${enableFunction}(impl->document()) && ${runti
meEnableFunction}()) {\n"; | 3923 $code .= " if (${enableFunction}(impl->document()) && ${runti
meEnableFunction}()) {\n"; |
3895 } else { | 3924 } else { |
3896 $code .= " if (${enableFunction}(impl->document())) {\n"; | 3925 $code .= " if (${enableFunction}(impl->document())) {\n"; |
3897 } | 3926 } |
3898 | 3927 |
3899 $code .= " static const V8DOMConfiguration::BatchedAttribute
attrData =\\\n"; | 3928 $code .= " static const V8DOMConfiguration::BatchedAttribute
attrData =\\\n"; |
3900 $code .= GenerateSingleBatchedAttribute($interfaceName, $runtimeAttr
, ";", " "); | 3929 $code .= GenerateSingleBatchedAttribute($interface, $runtimeAttr, ";
", " "); |
3901 $code .= <<END; | 3930 $code .= <<END; |
3902 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat
e); | 3931 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat
e); |
3903 END | 3932 END |
3904 $code .= " }\n"; | 3933 $code .= " }\n"; |
3905 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 3934 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
3906 } | 3935 } |
3907 $code .= <<END; | 3936 $code .= <<END; |
3908 } | 3937 } |
3909 | 3938 |
3910 END | 3939 END |
3911 $implementation{nameSpaceWebCore}->add($code); | 3940 $implementation{nameSpaceWebCore}->add($code); |
3912 } | 3941 } |
3913 | 3942 |
3914 if (@enabledPerContextFunctions) { | 3943 if (@enabledPerContextFunctions) { |
3915 my $code = ""; | 3944 my $code = ""; |
3916 $code .= <<END; | 3945 $code .= <<END; |
3917 void ${v8InterfaceName}::installPerContextPrototypeProperties(v8::Handle<v8::Obj
ect> proto, v8::Isolate* isolate) | 3946 void ${v8ClassName}::installPerContextPrototypeProperties(v8::Handle<v8::Object>
proto, v8::Isolate* isolate) |
3918 { | 3947 { |
3919 UNUSED_PARAM(proto); | 3948 UNUSED_PARAM(proto); |
3920 END | 3949 END |
3921 # Setup the enable-by-settings functions if we have them | 3950 # Setup the enable-by-settings functions if we have them |
3922 $code .= <<END; | 3951 $code .= <<END; |
3923 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i
solate, worldType(isolate))); | 3952 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i
solate, worldType(isolate))); |
3924 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 3953 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
3925 | 3954 |
3926 ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationCo
ntext()); | 3955 ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationCo
ntext()); |
3927 END | 3956 END |
3928 | 3957 |
3929 foreach my $runtimeFunc (@enabledPerContextFunctions) { | 3958 foreach my $runtimeFunc (@enabledPerContextFunctions) { |
3930 my $enableFunction = GetContextEnableFunction($runtimeFunc->signatur
e); | 3959 my $enableFunction = GetContextEnableFunction($runtimeFunc->signatur
e); |
3931 my $functionLength = GetFunctionLength($runtimeFunc); | 3960 my $functionLength = GetFunctionLength($runtimeFunc); |
3932 my $conditionalString = GenerateConditionalString($runtimeFunc->sign
ature); | 3961 my $conditionalString = GenerateConditionalString($runtimeFunc->sign
ature); |
3933 $code .= "\n#if ${conditionalString}\n" if $conditionalString; | 3962 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
3934 $code .= " if (context && context->isDocument() && ${enableFuncti
on}(toDocument(context))) {\n"; | 3963 $code .= " if (context && context->isDocument() && ${enableFuncti
on}(toDocument(context))) {\n"; |
3935 my $name = $runtimeFunc->signature->name; | 3964 my $name = $runtimeFunc->signature->name; |
3936 $code .= <<END; | 3965 $code .= <<END; |
3937 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($
{interfaceName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur
e, $functionLength)->GetFunction()); | 3966 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($
{implClassName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur
e, $functionLength)->GetFunction()); |
3938 END | 3967 END |
3939 $code .= " }\n"; | 3968 $code .= " }\n"; |
3940 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 3969 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
3941 } | 3970 } |
3942 | 3971 |
3943 $code .= <<END; | 3972 $code .= <<END; |
3944 } | 3973 } |
3945 | 3974 |
3946 END | 3975 END |
3947 $implementation{nameSpaceWebCore}->add($code); | 3976 $implementation{nameSpaceWebCore}->add($code); |
3948 } | 3977 } |
3949 | 3978 |
3950 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { | 3979 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { |
3951 # MessagePort is handled like an active dom object even though it doesn'
t inherit | 3980 # MessagePort is handled like an active dom object even though it doesn'
t inherit |
3952 # from ActiveDOMObject, so don't try to cast it to ActiveDOMObject. | 3981 # from ActiveDOMObject, so don't try to cast it to ActiveDOMObject. |
3953 my $returnValue = $interfaceName eq "MessagePort" ? "0" : "toNative(obje
ct)"; | 3982 my $returnValue = $interfaceName eq "MessagePort" ? "0" : "toNative(obje
ct)"; |
3954 $implementation{nameSpaceWebCore}->add(<<END); | 3983 $implementation{nameSpaceWebCore}->add(<<END); |
3955 ActiveDOMObject* ${v8InterfaceName}::toActiveDOMObject(v8::Handle<v8::Object> ob
ject) | 3984 ActiveDOMObject* ${v8ClassName}::toActiveDOMObject(v8::Handle<v8::Object> object
) |
3956 { | 3985 { |
3957 return $returnValue; | 3986 return $returnValue; |
3958 } | 3987 } |
3959 | 3988 |
3960 END | 3989 END |
3961 } | 3990 } |
3962 | 3991 |
3963 if (InheritsExtendedAttribute($interface, "EventTarget")) { | 3992 if (InheritsExtendedAttribute($interface, "EventTarget")) { |
3964 $implementation{nameSpaceWebCore}->add(<<END); | 3993 $implementation{nameSpaceWebCore}->add(<<END); |
3965 EventTarget* ${v8InterfaceName}::toEventTarget(v8::Handle<v8::Object> object) | 3994 EventTarget* ${v8ClassName}::toEventTarget(v8::Handle<v8::Object> object) |
3966 { | 3995 { |
3967 return toNative(object); | 3996 return toNative(object); |
3968 } | 3997 } |
3969 | 3998 |
3970 END | 3999 END |
3971 } | 4000 } |
3972 | 4001 |
3973 if ($interfaceName eq "DOMWindow") { | 4002 if ($interfaceName eq "DOMWindow") { |
3974 $implementation{nameSpaceWebCore}->add(<<END); | 4003 $implementation{nameSpaceWebCore}->add(<<END); |
3975 v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate(v8::Isol
ate* isolate, WrapperWorldType currentWorldType) | 4004 v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate(v8::Isol
ate* isolate, WrapperWorldType currentWorldType) |
(...skipping 11 matching lines...) Expand all Loading... |
3987 V8DOMWindowShadowObjectCacheForNonMainWorld = v8::Persistent<v8::Obj
ectTemplate>::New(isolate, v8::ObjectTemplate::New()); | 4016 V8DOMWindowShadowObjectCacheForNonMainWorld = v8::Persistent<v8::Obj
ectTemplate>::New(isolate, v8::ObjectTemplate::New()); |
3988 ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCacheForNonMain
World, isolate, currentWorldType); | 4017 ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCacheForNonMain
World, isolate, currentWorldType); |
3989 } | 4018 } |
3990 return V8DOMWindowShadowObjectCacheForNonMainWorld; | 4019 return V8DOMWindowShadowObjectCacheForNonMainWorld; |
3991 } | 4020 } |
3992 } | 4021 } |
3993 | 4022 |
3994 END | 4023 END |
3995 } | 4024 } |
3996 | 4025 |
3997 GenerateToV8Converters($interface, $v8InterfaceName, $nativeType); | 4026 GenerateToV8Converters($interface, $v8ClassName, $nativeType); |
3998 | 4027 |
3999 $implementation{nameSpaceWebCore}->add(<<END); | 4028 $implementation{nameSpaceWebCore}->add(<<END); |
4000 void ${v8InterfaceName}::derefObject(void* object) | 4029 void ${v8ClassName}::derefObject(void* object) |
4001 { | 4030 { |
4002 static_cast<${nativeType}*>(object)->deref(); | 4031 static_cast<${nativeType}*>(object)->deref(); |
4003 } | 4032 } |
4004 | 4033 |
4005 END | 4034 END |
4006 } | 4035 } |
4007 | 4036 |
4008 sub GenerateHeaderContentHeader | 4037 sub GenerateHeaderContentHeader |
4009 { | 4038 { |
4010 my $interface = shift; | 4039 my $interface = shift; |
4011 my $v8InterfaceName = "V8" . $interface->name; | 4040 my $v8ClassName = GetV8ClassName($interface); |
4012 my $conditionalString = GenerateConditionalString($interface); | 4041 my $conditionalString = GenerateConditionalString($interface); |
4013 | 4042 |
4014 my @headerContentHeader = split("\r", $headerTemplate); | 4043 my @headerContentHeader = split("\r", $headerTemplate); |
4015 | 4044 |
4016 push(@headerContentHeader, "\n#ifndef ${v8InterfaceName}" . "_h\n"); | 4045 push(@headerContentHeader, "\n#ifndef ${v8ClassName}" . "_h\n"); |
4017 push(@headerContentHeader, "#define ${v8InterfaceName}" . "_h\n\n"); | 4046 push(@headerContentHeader, "#define ${v8ClassName}" . "_h\n\n"); |
4018 push(@headerContentHeader, "#if ${conditionalString}\n") if $conditionalStri
ng; | 4047 push(@headerContentHeader, "#if ${conditionalString}\n") if $conditionalStri
ng; |
4019 return join "", @headerContentHeader; | 4048 return join "", @headerContentHeader; |
4020 } | 4049 } |
4021 | 4050 |
4022 sub GenerateCallbackHeader | 4051 sub GenerateCallbackHeader |
4023 { | 4052 { |
4024 my $object = shift; | 4053 my $object = shift; |
4025 my $interface = shift; | 4054 my $interface = shift; |
4026 | 4055 |
4027 my $interfaceName = $interface->name; | 4056 my $interfaceName = $interface->name; |
4028 my $v8InterfaceName = "V8$interfaceName"; | 4057 my $implClassName = GetImplClassName($interface); |
| 4058 my $v8ClassName = GetV8ClassName($interface); |
4029 | 4059 |
4030 $header{root}->addFooter("\n"); | 4060 $header{root}->addFooter("\n"); |
4031 | 4061 |
4032 my @unsortedIncludes = (); | 4062 my @unsortedIncludes = (); |
4033 push(@unsortedIncludes, "#include \"bindings/v8/ActiveDOMCallback.h\""); | 4063 push(@unsortedIncludes, "#include \"bindings/v8/ActiveDOMCallback.h\""); |
4034 push(@unsortedIncludes, "#include \"bindings/v8/DOMWrapperWorld.h\""); | 4064 push(@unsortedIncludes, "#include \"bindings/v8/DOMWrapperWorld.h\""); |
4035 push(@unsortedIncludes, "#include \"bindings/v8/ScopedPersistent.h\""); | 4065 push(@unsortedIncludes, "#include \"bindings/v8/ScopedPersistent.h\""); |
4036 my $interfaceHeader = HeaderFileForInterface($interfaceName); | 4066 my $interfaceHeader = HeaderFileForInterface($interfaceName, $implClassName)
; |
4037 push(@unsortedIncludes, "#include \"$interfaceHeader\""); | 4067 push(@unsortedIncludes, "#include \"$interfaceHeader\""); |
4038 push(@unsortedIncludes, "#include <v8.h>"); | 4068 push(@unsortedIncludes, "#include <v8.h>"); |
4039 push(@unsortedIncludes, "#include \"wtf/Forward.h\""); | 4069 push(@unsortedIncludes, "#include \"wtf/Forward.h\""); |
4040 $header{includes}->add(join("\n", sort @unsortedIncludes)); | 4070 $header{includes}->add(join("\n", sort @unsortedIncludes)); |
4041 unshift(@{$header{nameSpaceWebCore}->{header}}, "\n"); | 4071 unshift(@{$header{nameSpaceWebCore}->{header}}, "\n"); |
4042 $header{nameSpaceWebCore}->addHeader("class ScriptExecutionContext;\n\n"); | 4072 $header{nameSpaceWebCore}->addHeader("class ScriptExecutionContext;\n\n"); |
4043 $header{class}->addHeader("class $v8InterfaceName : public $interfaceName, p
ublic ActiveDOMCallback {"); | 4073 $header{class}->addHeader("class $v8ClassName : public $implClassName, publi
c ActiveDOMCallback {"); |
4044 $header{class}->addFooter("};\n"); | 4074 $header{class}->addFooter("};\n"); |
4045 | 4075 |
4046 $header{classPublic}->add(<<END); | 4076 $header{classPublic}->add(<<END); |
4047 static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, Sc
riptExecutionContext* context) | 4077 static PassRefPtr<${v8ClassName}> create(v8::Handle<v8::Value> value, Script
ExecutionContext* context) |
4048 { | 4078 { |
4049 ASSERT(value->IsObject()); | 4079 ASSERT(value->IsObject()); |
4050 ASSERT(context); | 4080 ASSERT(context); |
4051 return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(valu
e), context)); | 4081 return adoptRef(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(value),
context)); |
4052 } | 4082 } |
4053 | 4083 |
4054 virtual ~${v8InterfaceName}(); | 4084 virtual ~${v8ClassName}(); |
4055 | 4085 |
4056 END | 4086 END |
4057 | 4087 |
4058 # Functions | 4088 # Functions |
4059 my $numFunctions = @{$interface->functions}; | 4089 my $numFunctions = @{$interface->functions}; |
4060 if ($numFunctions > 0) { | 4090 if ($numFunctions > 0) { |
4061 $header{classPublic}->add(" // Functions\n"); | 4091 $header{classPublic}->add(" // Functions\n"); |
4062 foreach my $function (@{$interface->functions}) { | 4092 foreach my $function (@{$interface->functions}) { |
4063 my $code = ""; | 4093 my $code = ""; |
4064 my @params = @{$function->parameters}; | 4094 my @params = @{$function->parameters}; |
(...skipping 13 matching lines...) Expand all Loading... |
4078 $header{classPublic}->add($code); | 4108 $header{classPublic}->add($code); |
4079 } | 4109 } |
4080 } | 4110 } |
4081 | 4111 |
4082 $header{classPublic}->add(<<END); | 4112 $header{classPublic}->add(<<END); |
4083 | 4113 |
4084 virtual ScriptExecutionContext* scriptExecutionContext() const { return Cont
extDestructionObserver::scriptExecutionContext(); } | 4114 virtual ScriptExecutionContext* scriptExecutionContext() const { return Cont
extDestructionObserver::scriptExecutionContext(); } |
4085 | 4115 |
4086 END | 4116 END |
4087 $header{classPrivate}->add(<<END); | 4117 $header{classPrivate}->add(<<END); |
4088 ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*); | 4118 ${v8ClassName}(v8::Handle<v8::Object>, ScriptExecutionContext*); |
4089 | 4119 |
4090 ScopedPersistent<v8::Object> m_callback; | 4120 ScopedPersistent<v8::Object> m_callback; |
4091 RefPtr<DOMWrapperWorld> m_world; | 4121 RefPtr<DOMWrapperWorld> m_world; |
4092 END | 4122 END |
4093 } | 4123 } |
4094 | 4124 |
4095 sub GenerateCallbackImplementation | 4125 sub GenerateCallbackImplementation |
4096 { | 4126 { |
4097 my $object = shift; | 4127 my $object = shift; |
4098 my $interface = shift; | 4128 my $interface = shift; |
4099 my $interfaceName = $interface->name; | 4129 my $v8ClassName = GetV8ClassName($interface); |
4100 my $v8InterfaceName = "V8$interfaceName"; | |
4101 | 4130 |
4102 AddToImplIncludes("core/dom/ScriptExecutionContext.h"); | 4131 AddToImplIncludes("core/dom/ScriptExecutionContext.h"); |
4103 AddToImplIncludes("bindings/v8/V8Binding.h"); | 4132 AddToImplIncludes("bindings/v8/V8Binding.h"); |
4104 AddToImplIncludes("bindings/v8/V8Callback.h"); | 4133 AddToImplIncludes("bindings/v8/V8Callback.h"); |
4105 AddToImplIncludes("wtf/Assertions.h"); | 4134 AddToImplIncludes("wtf/Assertions.h"); |
4106 | 4135 |
4107 $implementation{nameSpaceWebCore}->add(<<END); | 4136 $implementation{nameSpaceWebCore}->add(<<END); |
4108 ${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptEx
ecutionContext* context) | 4137 ${v8ClassName}::${v8ClassName}(v8::Handle<v8::Object> callback, ScriptExecutionC
ontext* context) |
4109 : ActiveDOMCallback(context) | 4138 : ActiveDOMCallback(context) |
4110 , m_callback(callback) | 4139 , m_callback(callback) |
4111 , m_world(DOMWrapperWorld::current()) | 4140 , m_world(DOMWrapperWorld::current()) |
4112 { | 4141 { |
4113 } | 4142 } |
4114 | 4143 |
4115 END | 4144 END |
4116 | 4145 |
4117 $implementation{nameSpaceWebCore}->add(<<END); | 4146 $implementation{nameSpaceWebCore}->add(<<END); |
4118 ${v8InterfaceName}::~${v8InterfaceName}() | 4147 ${v8ClassName}::~${v8ClassName}() |
4119 { | 4148 { |
4120 } | 4149 } |
4121 | 4150 |
4122 END | 4151 END |
4123 | 4152 |
4124 # Functions | 4153 # Functions |
4125 my $numFunctions = @{$interface->functions}; | 4154 my $numFunctions = @{$interface->functions}; |
4126 if ($numFunctions > 0) { | 4155 if ($numFunctions > 0) { |
4127 $implementation{nameSpaceWebCore}->add("// Functions\n"); | 4156 $implementation{nameSpaceWebCore}->add("// Functions\n"); |
4128 foreach my $function (@{$interface->functions}) { | 4157 foreach my $function (@{$interface->functions}) { |
4129 my $code = ""; | 4158 my $code = ""; |
4130 my @params = @{$function->parameters}; | 4159 my @params = @{$function->parameters}; |
4131 if ($function->signature->extendedAttributes->{"Custom"} || | 4160 if ($function->signature->extendedAttributes->{"Custom"} || |
4132 !(GetNativeTypeForCallbacks($function->signature->type) eq "bool
")) { | 4161 !(GetNativeTypeForCallbacks($function->signature->type) eq "bool
")) { |
4133 next; | 4162 next; |
4134 } | 4163 } |
4135 | 4164 |
4136 AddIncludesForType($function->signature->type); | 4165 AddIncludesForType($function->signature->type); |
4137 $code .= "\n" . GetNativeTypeForCallbacks($function->signature->type
) . " ${v8InterfaceName}::" . $function->signature->name . "("; | 4166 $code .= "\n" . GetNativeTypeForCallbacks($function->signature->type
) . " ${v8ClassName}::" . $function->signature->name . "("; |
4138 | 4167 |
4139 my @args = (); | 4168 my @args = (); |
4140 my @argsCheck = (); | 4169 my @argsCheck = (); |
4141 foreach my $param (@params) { | 4170 foreach my $param (@params) { |
4142 my $paramName = $param->name; | 4171 my $paramName = $param->name; |
4143 AddIncludesForType($param->type); | 4172 AddIncludesForType($param->type); |
4144 push(@args, GetNativeTypeForCallbacks($param->type) . " " . $par
amName); | 4173 push(@args, GetNativeTypeForCallbacks($param->type) . " " . $par
amName); |
4145 } | 4174 } |
4146 $code .= join(", ", @args); | 4175 $code .= join(", ", @args); |
4147 | 4176 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4190 while (@{$interface->parents}) { | 4219 while (@{$interface->parents}) { |
4191 $interface = ParseInterface(@{$interface->parents}[0]); | 4220 $interface = ParseInterface(@{$interface->parents}[0]); |
4192 } | 4221 } |
4193 | 4222 |
4194 return $interface->name; | 4223 return $interface->name; |
4195 } | 4224 } |
4196 | 4225 |
4197 sub GenerateToV8Converters | 4226 sub GenerateToV8Converters |
4198 { | 4227 { |
4199 my $interface = shift; | 4228 my $interface = shift; |
4200 my $v8InterfaceName = shift; | 4229 my $v8ClassName = shift; |
4201 my $nativeType = shift; | 4230 my $nativeType = shift; |
4202 my $interfaceName = $interface->name; | 4231 my $interfaceName = $interface->name; |
4203 | 4232 |
4204 if ($interface->extendedAttributes->{"DoNotGenerateWrap"} || $interface->ext
endedAttributes->{"DoNotGenerateToV8"}) { | 4233 if ($interface->extendedAttributes->{"DoNotGenerateWrap"} || $interface->ext
endedAttributes->{"DoNotGenerateToV8"}) { |
4205 return; | 4234 return; |
4206 } | 4235 } |
4207 | 4236 |
4208 AddToImplIncludes("bindings/v8/ScriptController.h"); | 4237 AddToImplIncludes("bindings/v8/ScriptController.h"); |
4209 AddToImplIncludes("core/page/Frame.h"); | 4238 AddToImplIncludes("core/page/Frame.h"); |
4210 | 4239 |
4211 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); | 4240 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); |
4212 my $baseType = BaseInterfaceName($interface); | 4241 my $baseType = BaseInterfaceName($interface); |
4213 | 4242 |
4214 my $code = ""; | 4243 my $code = ""; |
4215 $code .= <<END; | 4244 $code .= <<END; |
4216 | 4245 |
4217 v8::Handle<v8::Object> ${v8InterfaceName}::createWrapper(${createWrapperArgument
Type} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 4246 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType
} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
4218 { | 4247 { |
4219 ASSERT(impl.get()); | 4248 ASSERT(impl.get()); |
4220 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); | 4249 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); |
4221 END | 4250 END |
4222 | 4251 |
4223 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); | 4252 my $vtableNameGnu = GetGnuVTableNameForInterface($interface); |
4224 $code .= <<END if $vtableNameGnu; | 4253 $code .= <<END if $vtableNameGnu; |
4225 | 4254 |
4226 #if ENABLE(BINDING_INTEGRITY) | 4255 #if ENABLE(BINDING_INTEGRITY) |
4227 checkTypeOrDieTrying(impl.get()); | 4256 checkTypeOrDieTrying(impl.get()); |
(...skipping 27 matching lines...) Expand all Loading... |
4255 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasD
ependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Indep
endent); | 4284 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasD
ependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Indep
endent); |
4256 return wrapper; | 4285 return wrapper; |
4257 } | 4286 } |
4258 END | 4287 END |
4259 $implementation{nameSpaceWebCore}->add($code); | 4288 $implementation{nameSpaceWebCore}->add($code); |
4260 } | 4289 } |
4261 | 4290 |
4262 sub GenerateSecurityCheckFunctions | 4291 sub GenerateSecurityCheckFunctions |
4263 { | 4292 { |
4264 my $interface = shift; | 4293 my $interface = shift; |
4265 my $interfaceName = $interface->name; | 4294 my $implClassName = GetImplClassName($interface); |
4266 my $v8InterfaceName = "V8$interfaceName"; | 4295 my $v8ClassName = GetV8ClassName($interface); |
4267 | 4296 |
4268 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 4297 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
4269 $implementation{nameSpaceInternal}->add(<<END); | 4298 $implementation{nameSpaceInternal}->add(<<END); |
4270 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access
Type type, v8::Local<v8::Value>) | 4299 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access
Type type, v8::Local<v8::Value>) |
4271 { | 4300 { |
4272 $interfaceName* imp = ${v8InterfaceName}::toNative(host); | 4301 $implClassName* imp = ${v8ClassName}::toNative(host); |
4273 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe
curityError); | 4302 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe
curityError); |
4274 } | 4303 } |
4275 | 4304 |
4276 END | 4305 END |
4277 $implementation{nameSpaceInternal}->add(<<END); | 4306 $implementation{nameSpaceInternal}->add(<<END); |
4278 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8
::AccessType type, v8::Local<v8::Value>) | 4307 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8
::AccessType type, v8::Local<v8::Value>) |
4279 { | 4308 { |
4280 $interfaceName* imp = ${v8InterfaceName}::toNative(host); | 4309 $implClassName* imp = ${v8ClassName}::toNative(host); |
4281 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe
curityError); | 4310 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe
curityError); |
4282 } | 4311 } |
4283 | 4312 |
4284 END | 4313 END |
4285 } | 4314 } |
4286 | 4315 |
4287 sub GetNativeTypeForConversions | 4316 sub GetNativeTypeForConversions |
4288 { | 4317 { |
4289 my $interface = shift; | 4318 my $interface = shift; |
4290 my $interfaceName = $interface->name; | 4319 my $implClassName = GetImplClassName($interface); |
4291 $interfaceName = GetSVGTypeNeedingTearOff($interfaceName) if IsSVGTypeNeedin
gTearOff($interfaceName); | 4320 $implClassName = GetSVGTypeNeedingTearOff($interface->name) if IsSVGTypeNeed
ingTearOff($interface->name); |
4292 return $interfaceName; | 4321 return $implClassName; |
4293 } | 4322 } |
4294 | 4323 |
4295 # See http://refspecs.linux-foundation.org/cxxabi-1.83.html. | 4324 # See http://refspecs.linux-foundation.org/cxxabi-1.83.html. |
4296 sub GetGnuVTableRefForInterface | 4325 sub GetGnuVTableRefForInterface |
4297 { | 4326 { |
4298 my $interface = shift; | 4327 my $interface = shift; |
4299 my $vtableName = GetGnuVTableNameForInterface($interface); | 4328 my $vtableName = GetGnuVTableNameForInterface($interface); |
4300 if (!$vtableName) { | 4329 if (!$vtableName) { |
4301 return "0"; | 4330 return "0"; |
4302 } | 4331 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4403 { | 4432 { |
4404 my $interface = shift; | 4433 my $interface = shift; |
4405 return $interface->extendedAttributes->{"SkipVTableValidation"}; | 4434 return $interface->extendedAttributes->{"SkipVTableValidation"}; |
4406 } | 4435 } |
4407 | 4436 |
4408 sub GenerateFunctionCallString | 4437 sub GenerateFunctionCallString |
4409 { | 4438 { |
4410 my $function = shift; | 4439 my $function = shift; |
4411 my $numberOfParameters = shift; | 4440 my $numberOfParameters = shift; |
4412 my $indent = shift; | 4441 my $indent = shift; |
4413 my $interfaceName = shift; | 4442 my $interface = shift; |
4414 my $forMainWorldSuffix = shift; | 4443 my $forMainWorldSuffix = shift; |
4415 my %replacements = @_; | 4444 my %replacements = @_; |
4416 | 4445 |
| 4446 my $interfaceName = $interface->name; |
| 4447 my $implClassName = GetImplClassName($interface); |
4417 my $name = $function->signature->name; | 4448 my $name = $function->signature->name; |
4418 my $returnType = $function->signature->type; | 4449 my $returnType = $function->signature->type; |
4419 my $nativeReturnType = GetNativeType($returnType, 0); | 4450 my $nativeReturnType = GetNativeType($returnType, 0); |
4420 my $code = ""; | 4451 my $code = ""; |
4421 | 4452 |
4422 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf
aceName =~ /List$/); | 4453 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf
aceName =~ /List$/); |
4423 $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTe
arOffType; | 4454 $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTe
arOffType; |
4424 | 4455 |
4425 if ($function->signature->extendedAttributes->{"ImplementedAs"}) { | 4456 if ($function->signature->extendedAttributes->{"ImplementedAs"}) { |
4426 $name = $function->signature->extendedAttributes->{"ImplementedAs"}; | 4457 $name = $function->signature->extendedAttributes->{"ImplementedAs"}; |
4427 } | 4458 } |
4428 | 4459 |
4429 my $index = 0; | 4460 my $index = 0; |
4430 | 4461 |
4431 my @arguments; | 4462 my @arguments; |
4432 my $functionName; | 4463 my $functionName; |
4433 my $implementedBy = $function->signature->extendedAttributes->{"ImplementedB
y"}; | 4464 my $implementedBy = $function->signature->extendedAttributes->{"ImplementedB
y"}; |
4434 if ($implementedBy) { | 4465 if ($implementedBy) { |
4435 AddInterfaceToImplIncludes($implementedBy); | 4466 AddInterfaceToImplIncludes($implementedBy); |
4436 unshift(@arguments, "imp") if !$function->isStatic; | 4467 unshift(@arguments, "imp") if !$function->isStatic; |
4437 $functionName = "${implementedBy}::${name}"; | 4468 $functionName = "${implementedBy}::${name}"; |
4438 } elsif ($function->isStatic) { | 4469 } elsif ($function->isStatic) { |
4439 $functionName = "${interfaceName}::${name}"; | 4470 $functionName = "${implClassName}::${name}"; |
4440 } else { | 4471 } else { |
4441 $functionName = "imp->${name}"; | 4472 $functionName = "imp->${name}"; |
4442 } | 4473 } |
4443 | 4474 |
4444 my $callWith = $function->signature->extendedAttributes->{"CallWith"}; | 4475 my $callWith = $function->signature->extendedAttributes->{"CallWith"}; |
4445 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 0, $func
tion); | 4476 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 0, $func
tion); |
4446 $code .= $subCode; | 4477 $code .= $subCode; |
4447 unshift(@arguments, @$callWithArgs); | 4478 unshift(@arguments, @$callWithArgs); |
4448 $index += @$callWithArgs; | 4479 $index += @$callWithArgs; |
4449 $numberOfParameters += @$callWithArgs; | 4480 $numberOfParameters += @$callWithArgs; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4599 return "DOMTimeStamp" if $type eq "DOMTimeStamp"; | 4630 return "DOMTimeStamp" if $type eq "DOMTimeStamp"; |
4600 return "double" if $type eq "Date"; | 4631 return "double" if $type eq "Date"; |
4601 return "ScriptValue" if $type eq "any"; | 4632 return "ScriptValue" if $type eq "any"; |
4602 return "Dictionary" if $type eq "Dictionary"; | 4633 return "Dictionary" if $type eq "Dictionary"; |
4603 | 4634 |
4604 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; | 4635 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; |
4605 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"
; | 4636 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"
; |
4606 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; | 4637 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; |
4607 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; | 4638 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; |
4608 return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; | 4639 return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; |
| 4640 |
| 4641 # We need to check [ImplementedBy] extended attribute for wrapper types. |
| 4642 if (IsWrapperType($type)) { |
| 4643 my $interface = ParseInterface($type); |
| 4644 my $implClassName = GetImplClassName($interface); |
| 4645 return $isParameter ? "${implClassName}*" : "RefPtr<${implClassName}>"; |
| 4646 } |
4609 return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter; | 4647 return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter; |
4610 | 4648 |
4611 my $arrayType = GetArrayType($type); | 4649 my $arrayType = GetArrayType($type); |
4612 my $sequenceType = GetSequenceType($type); | 4650 my $sequenceType = GetSequenceType($type); |
4613 my $arrayOrSequenceType = $arrayType || $sequenceType; | 4651 my $arrayOrSequenceType = $arrayType || $sequenceType; |
4614 | 4652 |
4615 if ($arrayOrSequenceType) { | 4653 if ($arrayOrSequenceType) { |
4616 my $nativeType = GetNativeType($arrayOrSequenceType); | 4654 my $nativeType = GetNativeType($arrayOrSequenceType); |
4617 $nativeType .= " " if ($nativeType =~ />$/); | 4655 $nativeType .= " " if ($nativeType =~ />$/); |
4618 return "Vector<${nativeType}>"; | 4656 return "Vector<${nativeType}>"; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4827 'DOMString' => 1, | 4865 'DOMString' => 1, |
4828 'DOMTimeStamp' => 1, | 4866 'DOMTimeStamp' => 1, |
4829 'Date' => 1, | 4867 'Date' => 1, |
4830 'Dictionary' => 1, | 4868 'Dictionary' => 1, |
4831 'EventListener' => 1, | 4869 'EventListener' => 1, |
4832 # FIXME: When EventTarget is an interface and not a mixin, fix this so that | 4870 # FIXME: When EventTarget is an interface and not a mixin, fix this so that |
4833 # EventTarget is treated as a wrapper type. | 4871 # EventTarget is treated as a wrapper type. |
4834 'EventTarget' => 1, | 4872 'EventTarget' => 1, |
4835 'JSObject' => 1, | 4873 'JSObject' => 1, |
4836 'MediaQueryListListener' => 1, | 4874 'MediaQueryListListener' => 1, |
| 4875 'MessagePortArray' => 1, |
4837 'NodeFilter' => 1, | 4876 'NodeFilter' => 1, |
4838 'SerializedScriptValue' => 1, | 4877 'SerializedScriptValue' => 1, |
4839 'any' => 1, | 4878 'any' => 1, |
4840 'boolean' => 1, | 4879 'boolean' => 1, |
4841 'double' => 1, | 4880 'double' => 1, |
4842 'float' => 1, | 4881 'float' => 1, |
4843 'int' => 1, | 4882 'int' => 1, |
4844 'long long' => 1, | 4883 'long long' => 1, |
4845 'long' => 1, | 4884 'long' => 1, |
4846 'short' => 1, | 4885 'short' => 1, |
4847 'unsigned int' => 1, | 4886 'unsigned int' => 1, |
4848 'unsigned long long' => 1, | 4887 'unsigned long long' => 1, |
4849 'unsigned long' => 1, | 4888 'unsigned long' => 1, |
4850 'unsigned short' => 1 | 4889 'unsigned short' => 1, |
| 4890 'void' => 1 |
4851 ); | 4891 ); |
4852 | 4892 |
4853 | 4893 |
4854 sub IsWrapperType | 4894 sub IsWrapperType |
4855 { | 4895 { |
4856 my $type = shift; | 4896 my $type = shift; |
4857 # FIXME: Should this return false for Sequence and Array types? | 4897 return 0 if GetArrayType($type); |
| 4898 return 0 if GetSequenceType($type); |
4858 return 0 if IsEnumType($type); | 4899 return 0 if IsEnumType($type); |
4859 return !($non_wrapper_types{$type}); | 4900 return !($non_wrapper_types{$type}); |
4860 } | 4901 } |
4861 | 4902 |
4862 sub IsCallbackInterface | 4903 sub IsCallbackInterface |
4863 { | 4904 { |
4864 my $type = shift; | 4905 my $type = shift; |
4865 return 0 unless IsWrapperType($type); | 4906 return 0 unless IsWrapperType($type); |
4866 # FIXME: Those checks for Sequence and Array types should probably | |
4867 # be moved to IsWrapperType(). | |
4868 return 0 if GetArrayType($type); | |
4869 return 0 if GetSequenceType($type); | |
4870 | 4907 |
4871 my $idlFile = IDLFileForInterface($type) | 4908 my $idlFile = IDLFileForInterface($type) |
4872 or die("Could NOT find IDL file for interface \"$type\"!\n"); | 4909 or die("Could NOT find IDL file for interface \"$type\"!\n"); |
4873 | 4910 |
4874 open FILE, "<", $idlFile; | 4911 open FILE, "<", $idlFile; |
4875 my @lines = <FILE>; | 4912 my @lines = <FILE>; |
4876 close FILE; | 4913 close FILE; |
4877 | 4914 |
4878 my $fileContents = join('', @lines); | 4915 my $fileContents = join('', @lines); |
4879 return ($fileContents =~ /callback\s+interface\s+(\w+)/gs); | 4916 return ($fileContents =~ /callback\s+interface\s+(\w+)/gs); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5109 if ($signature->extendedAttributes->{"EnabledPerContext"} && $signature->ext
endedAttributes->{"EnabledPerContext"} ne "VALUE_IS_MISSING") { | 5146 if ($signature->extendedAttributes->{"EnabledPerContext"} && $signature->ext
endedAttributes->{"EnabledPerContext"} ne "VALUE_IS_MISSING") { |
5110 return "ContextFeatures::" . ToMethodName($signature->extendedAttributes
->{"EnabledPerContext"}) . "Enabled"; | 5147 return "ContextFeatures::" . ToMethodName($signature->extendedAttributes
->{"EnabledPerContext"}) . "Enabled"; |
5111 } | 5148 } |
5112 | 5149 |
5113 # Or it fallbacks to the attribute name if the parameter value is missing. | 5150 # Or it fallbacks to the attribute name if the parameter value is missing. |
5114 return "ContextFeatures::" . ToMethodName($signature->name) . "Enabled"; | 5151 return "ContextFeatures::" . ToMethodName($signature->name) . "Enabled"; |
5115 } | 5152 } |
5116 | 5153 |
5117 sub GetPassRefPtrType | 5154 sub GetPassRefPtrType |
5118 { | 5155 { |
5119 my $v8InterfaceName = shift; | 5156 my $v8ClassName = shift; |
5120 | 5157 |
5121 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; | 5158 my $angleBracketSpace = $v8ClassName =~ />$/ ? " " : ""; |
5122 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; | 5159 return "PassRefPtr<${v8ClassName}${angleBracketSpace}>"; |
5123 } | 5160 } |
5124 | 5161 |
5125 sub UpdateFile | 5162 sub UpdateFile |
5126 { | 5163 { |
5127 my $fileName = shift; | 5164 my $fileName = shift; |
5128 my $contents = shift; | 5165 my $contents = shift; |
5129 | 5166 |
5130 open FH, "> $fileName" or die "Couldn't open $fileName: $!\n"; | 5167 open FH, "> $fileName" or die "Couldn't open $fileName: $!\n"; |
5131 print FH $contents; | 5168 print FH $contents; |
5132 close FH; | 5169 close FH; |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5555 map { $conditions{$_} = 1 } split('\\' . $operator, $conditional); | 5592 map { $conditions{$_} = 1 } split('\\' . $operator, $conditional); |
5556 return "ENABLE(" . join(") $operator$operator ENABLE(", sort keys %condi
tions) . ")"; | 5593 return "ENABLE(" . join(") $operator$operator ENABLE(", sort keys %condi
tions) . ")"; |
5557 } else { | 5594 } else { |
5558 return "ENABLE(" . $conditional . ")"; | 5595 return "ENABLE(" . $conditional . ")"; |
5559 } | 5596 } |
5560 } | 5597 } |
5561 | 5598 |
5562 sub GenerateCompileTimeCheckForEnumsIfNeeded | 5599 sub GenerateCompileTimeCheckForEnumsIfNeeded |
5563 { | 5600 { |
5564 my $interface = shift; | 5601 my $interface = shift; |
5565 my $interfaceName = $interface->name; | 5602 my $implClassName = GetImplClassName($interface); |
5566 my @checks = (); | 5603 my @checks = (); |
5567 # If necessary, check that all constants are available as enums with the sam
e value. | 5604 # If necessary, check that all constants are available as enums with the sam
e value. |
5568 if (!$interface->extendedAttributes->{"DoNotCheckConstants"} && @{$interface
->constants}) { | 5605 if (!$interface->extendedAttributes->{"DoNotCheckConstants"} && @{$interface
->constants}) { |
5569 push(@checks, "\n"); | 5606 push(@checks, "\n"); |
5570 foreach my $constant (@{$interface->constants}) { | 5607 foreach my $constant (@{$interface->constants}) { |
5571 my $reflect = $constant->extendedAttributes->{"Reflect"}; | 5608 my $reflect = $constant->extendedAttributes->{"Reflect"}; |
5572 my $name = $reflect ? $reflect : $constant->name; | 5609 my $name = $reflect ? $reflect : $constant->name; |
5573 my $value = $constant->value; | 5610 my $value = $constant->value; |
5574 my $conditionalString = GenerateConditionalString($constant); | 5611 my $conditionalString = GenerateConditionalString($constant); |
5575 push(@checks, "#if ${conditionalString}\n") if $conditionalString; | 5612 push(@checks, "#if ${conditionalString}\n") if $conditionalString; |
5576 | 5613 |
5577 if ($constant->extendedAttributes->{"ImplementedBy"}) { | 5614 if ($constant->extendedAttributes->{"ImplementedBy"}) { |
5578 push(@checks, "COMPILE_ASSERT($value == " . $constant->extendedA
ttributes->{"ImplementedBy"} . "::$name, ${interfaceName}Enum${name}IsWrongUseDo
NotCheckConstants);\n"); | 5615 push(@checks, "COMPILE_ASSERT($value == " . $constant->extendedA
ttributes->{"ImplementedBy"} . "::$name, ${implClassName}Enum${name}IsWrongUseDo
NotCheckConstants);\n"); |
5579 } else { | 5616 } else { |
5580 push(@checks, "COMPILE_ASSERT($value == ${interfaceName}::$name,
${interfaceName}Enum${name}IsWrongUseDoNotCheckConstants);\n"); | 5617 push(@checks, "COMPILE_ASSERT($value == ${implClassName}::$name,
${implClassName}Enum${name}IsWrongUseDoNotCheckConstants);\n"); |
5581 } | 5618 } |
5582 | 5619 |
5583 push(@checks, "#endif\n") if $conditionalString; | 5620 push(@checks, "#endif\n") if $conditionalString; |
5584 } | 5621 } |
5585 push(@checks, "\n"); | 5622 push(@checks, "\n"); |
5586 } | 5623 } |
5587 return @checks; | 5624 return @checks; |
5588 } | 5625 } |
5589 | 5626 |
5590 sub ExtendedAttributeContains | 5627 sub ExtendedAttributeContains |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5636 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 5673 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
5637 $found = 1; | 5674 $found = 1; |
5638 } | 5675 } |
5639 return 1 if $found; | 5676 return 1 if $found; |
5640 }, 0); | 5677 }, 0); |
5641 | 5678 |
5642 return $found; | 5679 return $found; |
5643 } | 5680 } |
5644 | 5681 |
5645 1; | 5682 1; |
OLD | NEW |