Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> | 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> |
| 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> | 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> |
| 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> | 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> |
| 5 # Copyright (C) 2006 Apple Computer, Inc. | 5 # Copyright (C) 2006 Apple Computer, Inc. |
| 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. | 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. |
| 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
| 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. | 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 # Copyright (C) 2012 Ericsson AB. All rights reserved. | 10 # Copyright (C) 2012 Ericsson AB. All rights reserved. |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 if (IsTypedArrayType($interfaceName)) { | 447 if (IsTypedArrayType($interfaceName)) { |
| 448 push(@includes, "wtf/${interfaceName}.h"); | 448 push(@includes, "wtf/${interfaceName}.h"); |
| 449 } elsif (!SkipIncludeHeader($interfaceName)) { | 449 } elsif (!SkipIncludeHeader($interfaceName)) { |
| 450 my $idlFilename = Cwd::abs_path(IDLFileForInterface($interfaceName)) or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); | 450 my $idlFilename = Cwd::abs_path(IDLFileForInterface($interfaceName)) or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); |
| 451 my $idlRelPath = File::Spec->abs2rel($idlFilename, $sourceRoot); | 451 my $idlRelPath = File::Spec->abs2rel($idlFilename, $sourceRoot); |
| 452 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); | 452 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); |
| 453 } | 453 } |
| 454 return @includes; | 454 return @includes; |
| 455 } | 455 } |
| 456 | 456 |
| 457 sub NeedsOpaqueRootForGC | 457 sub NeedsResolveWrapperReachability |
| 458 { | 458 { |
| 459 my $interface = shift; | 459 my $interface = shift; |
| 460 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface ->extendedAttributes->{"CustomIsReachable"}; | 460 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface ->extendedAttributes->{"CustomIsReachable"} || $interface->extendedAttributes->{ "ReachableTo"}; |
| 461 } | 461 } |
| 462 | 462 |
| 463 sub GenerateOpaqueRootForGC | 463 sub GenerateResolveWrapperReachability |
| 464 { | 464 { |
| 465 my $interface = shift; | 465 my $interface = shift; |
| 466 my $implClassName = GetImplName($interface); | 466 my $implClassName = GetImplName($interface); |
| 467 my $v8ClassName = GetV8ClassName($interface); | 467 my $v8ClassName = GetV8ClassName($interface); |
| 468 | 468 |
| 469 if ($interface->extendedAttributes->{"CustomIsReachable"}) { | 469 if ($interface->extendedAttributes->{"CustomIsReachable"}) { |
| 470 return; | 470 return; |
| 471 } | 471 } |
| 472 | 472 |
| 473 my $code = <<END; | 473 my $code = <<END; |
| 474 void* ${v8ClassName}::opaqueRootForGC(void* object, v8::Isolate* isolate) | 474 void ${v8ClassName}::resolveWrapperReachability(void* object, const v8::Persiste nt<v8::Object>& wrapper, v8::Isolate* isolate) |
| 475 { | 475 { |
| 476 ${implClassName}* impl = fromInternalPointer(object); | 476 ${implClassName}* impl = fromInternalPointer(object); |
| 477 END | 477 END |
| 478 if ($interface->extendedAttributes->{"ReachableTo"}) { | |
| 479 $code .= " v8::Local<v8::Object> creationContext = v8::Local<v8::Obje ct>::New(isolate, wrapper);\n"; | |
| 480 } | |
| 481 for my $reachableTo (@{$interface->extendedAttributes->{"ReachableTo"}}) { | |
| 482 my $reachableToType = $reachableTo->type; | |
| 483 my $reachableToName = $reachableTo->name; | |
| 484 my $reachableToV8Type = "V8".$reachableToType; | |
| 485 | |
| 486 AddIncludesForType($reachableToType); | |
| 487 $code .= <<END; | |
| 488 ${reachableToType}* ${reachableToName} = impl->${reachableToName}(); | |
| 489 if (${reachableToName}) { | |
| 490 if(! DOMDataStore::containsWrapper<${reachableToV8Type}>(${reachableToNa me}, isolate)) | |
|
haraken
2013/10/16 04:46:38
Nit: Unnecessary space after '!'.
kouhei (in TOK)
2013/10/17 02:30:09
Done.
| |
| 491 wrap(${reachableToName}, creationContext, isolate); | |
| 492 DOMDataStore::setWrapperReferenceFrom<${reachableToV8Type}>(wrapper, ${r eachableToName}, isolate); | |
| 493 } | |
| 494 END | |
| 495 } | |
| 496 | |
| 478 my $isReachableMethod = $interface->extendedAttributes->{"GenerateIsReachabl e"}; | 497 my $isReachableMethod = $interface->extendedAttributes->{"GenerateIsReachabl e"}; |
| 479 if ($isReachableMethod) { | 498 if ($isReachableMethod) { |
| 480 AddToImplIncludes("bindings/v8/V8GCController.h"); | 499 AddToImplIncludes("bindings/v8/V8GCController.h"); |
| 481 AddToImplIncludes("core/dom/Element.h"); | 500 AddToImplIncludes("core/dom/Element.h"); |
| 482 $code .= <<END; | 501 $code .= <<END; |
| 483 if (Node* owner = impl->${isReachableMethod}()) | 502 if (Node* owner = impl->${isReachableMethod}()) { |
| 484 return V8GCController::opaqueRootForGC(owner, isolate); | 503 setObjectGroup(V8GCController::opaqueRootForGC(owner, isolate), wrapper, isolate); |
| 504 return; | |
| 505 } | |
| 485 END | 506 END |
| 486 } | 507 } |
| 487 | 508 |
| 488 $code .= <<END; | 509 $code .= <<END; |
| 489 return object; | 510 setObjectGroup(object, wrapper, isolate); |
| 490 } | 511 } |
| 491 | 512 |
| 492 END | 513 END |
| 493 $implementation{nameSpaceWebCore}->add($code); | 514 $implementation{nameSpaceWebCore}->add($code); |
| 494 } | 515 } |
| 495 | 516 |
| 496 sub GetSVGPropertyTypes | 517 sub GetSVGPropertyTypes |
| 497 { | 518 { |
| 498 my $implType = shift; | 519 my $implType = shift; |
| 499 | 520 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 662 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); | 683 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); |
| 663 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType); | 684 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType); |
| 664 static ${nativeType}* toNative(v8::Handle<v8::Object> object) | 685 static ${nativeType}* toNative(v8::Handle<v8::Object> object) |
| 665 { | 686 { |
| 666 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex)); | 687 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex)); |
| 667 } | 688 } |
| 668 static void derefObject(void*); | 689 static void derefObject(void*); |
| 669 static WrapperTypeInfo info; | 690 static WrapperTypeInfo info; |
| 670 END | 691 END |
| 671 | 692 |
| 672 if (NeedsOpaqueRootForGC($interface)) { | 693 if (NeedsResolveWrapperReachability($interface)) { |
| 673 $header{classPublic}->add(" static void* opaqueRootForGC(void*, v8::I solate*);\n"); | 694 $header{classPublic}->add(" static void resolveWrapperReachability(vo id*, const v8::Persistent<v8::Object>&, v8::Isolate*);\n"); |
| 674 } | 695 } |
| 675 | 696 |
| 676 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { | 697 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { |
| 677 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject (v8::Handle<v8::Object>);\n"); | 698 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject (v8::Handle<v8::Object>);\n"); |
| 678 } | 699 } |
| 679 | 700 |
| 680 if (InheritsInterface($interface, "EventTarget")) { | 701 if (InheritsInterface($interface, "EventTarget")) { |
| 681 $header{classPublic}->add(" static EventTarget* toEventTarget(v8::Han dle<v8::Object>);\n"); | 702 $header{classPublic}->add(" static EventTarget* toEventTarget(v8::Han dle<v8::Object>);\n"); |
| 682 } | 703 } |
| 683 | 704 |
| (...skipping 3271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3955 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); | 3976 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); |
| 3956 AddToImplIncludes("core/dom/ContextFeatures.h"); | 3977 AddToImplIncludes("core/dom/ContextFeatures.h"); |
| 3957 AddToImplIncludes("core/dom/Document.h"); | 3978 AddToImplIncludes("core/dom/Document.h"); |
| 3958 AddToImplIncludes("RuntimeEnabledFeatures.h"); | 3979 AddToImplIncludes("RuntimeEnabledFeatures.h"); |
| 3959 AddToImplIncludes("platform/TraceEvent.h"); | 3980 AddToImplIncludes("platform/TraceEvent.h"); |
| 3960 | 3981 |
| 3961 AddIncludesForType($interfaceName); | 3982 AddIncludesForType($interfaceName); |
| 3962 | 3983 |
| 3963 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; | 3984 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; |
| 3964 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas sName}::toEventTarget" : "0"; | 3985 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas sName}::toEventTarget" : "0"; |
| 3965 my $rootForGC = NeedsOpaqueRootForGC($interface) ? "${v8ClassName}::opaqueRo otForGC" : "0"; | 3986 my $resolveWrapperReachability = NeedsResolveWrapperReachability($interface) ? "${v8ClassName}::resolveWrapperReachability" : "0"; |
| 3966 | 3987 |
| 3967 # Find the super descriptor. | 3988 # Find the super descriptor. |
| 3968 my $parentClass = ""; | 3989 my $parentClass = ""; |
| 3969 my $parentClassTemplate = ""; | 3990 my $parentClassTemplate = ""; |
| 3970 if ($interface->parent) { | 3991 if ($interface->parent) { |
| 3971 my $parent = $interface->parent; | 3992 my $parent = $interface->parent; |
| 3972 AddToImplIncludes("V8${parent}.h"); | 3993 AddToImplIncludes("V8${parent}.h"); |
| 3973 $parentClass = "V8" . $parent; | 3994 $parentClass = "V8" . $parent; |
| 3974 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)"; | 3995 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)"; |
| 3975 } | 3996 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 4005 { | 4026 { |
| 4006 WebCore::initializeScriptWrappableForInterface(object); | 4027 WebCore::initializeScriptWrappableForInterface(object); |
| 4007 } | 4028 } |
| 4008 | 4029 |
| 4009 namespace WebCore { | 4030 namespace WebCore { |
| 4010 END | 4031 END |
| 4011 $implementation{nameSpaceWebCore}->addHeader($code); | 4032 $implementation{nameSpaceWebCore}->addHeader($code); |
| 4012 } | 4033 } |
| 4013 | 4034 |
| 4014 my $code = "WrapperTypeInfo ${v8ClassName}::info = { ${v8ClassName}::GetTemp late, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, "; | 4035 my $code = "WrapperTypeInfo ${v8ClassName}::info = { ${v8ClassName}::GetTemp late, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, "; |
| 4015 $code .= "$rootForGC, ${v8ClassName}::installPerContextPrototypeProperties, $parentClassInfo, $WrapperTypePrototype };\n"; | 4036 $code .= "$resolveWrapperReachability, ${v8ClassName}::installPerContextProt otypeProperties, $parentClassInfo, $WrapperTypePrototype };\n"; |
| 4016 $implementation{nameSpaceWebCore}->addHeader($code); | 4037 $implementation{nameSpaceWebCore}->addHeader($code); |
| 4017 | 4038 |
| 4018 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n"); | 4039 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n"); |
| 4019 | 4040 |
| 4020 my $hasConstructors = 0; | 4041 my $hasConstructors = 0; |
| 4021 my $hasReplaceable = 0; | 4042 my $hasReplaceable = 0; |
| 4022 | 4043 |
| 4023 # Generate property accessors for attributes. | 4044 # Generate property accessors for attributes. |
| 4024 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 4045 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
| 4025 my $attribute = @{$interface->attributes}[$index]; | 4046 my $attribute = @{$interface->attributes}[$index]; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4062 | 4083 |
| 4063 if ($hasConstructors) { | 4084 if ($hasConstructors) { |
| 4064 GenerateConstructorGetter($interface); | 4085 GenerateConstructorGetter($interface); |
| 4065 } | 4086 } |
| 4066 | 4087 |
| 4067 if ($hasConstructors || $hasReplaceable) { | 4088 if ($hasConstructors || $hasReplaceable) { |
| 4068 GenerateReplaceableAttributeSetter($interface); | 4089 GenerateReplaceableAttributeSetter($interface); |
| 4069 GenerateReplaceableAttributeSetterCallback($interface); | 4090 GenerateReplaceableAttributeSetterCallback($interface); |
| 4070 } | 4091 } |
| 4071 | 4092 |
| 4072 if (NeedsOpaqueRootForGC($interface)) { | 4093 if (NeedsResolveWrapperReachability($interface)) { |
| 4073 GenerateOpaqueRootForGC($interface); | 4094 GenerateResolveWrapperReachability($interface); |
| 4074 } | 4095 } |
| 4075 | 4096 |
| 4076 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne "Window") { | 4097 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne "Window") { |
| 4077 GenerateSecurityCheckFunctions($interface); | 4098 GenerateSecurityCheckFunctions($interface); |
| 4078 } | 4099 } |
| 4079 | 4100 |
| 4080 if (IsConstructorTemplate($interface, "TypedArray")) { | 4101 if (IsConstructorTemplate($interface, "TypedArray")) { |
| 4081 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); | 4102 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); |
| 4082 $implementation{nameSpaceWebCore}->add(<<END); | 4103 $implementation{nameSpaceWebCore}->add(<<END); |
| 4083 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) | 4104 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4872 GenerateSpecialWrap($interface, $v8ClassName, $nativeType); | 4893 GenerateSpecialWrap($interface, $v8ClassName, $nativeType); |
| 4873 | 4894 |
| 4874 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); | 4895 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); |
| 4875 my $baseType = BaseInterfaceName($interface); | 4896 my $baseType = BaseInterfaceName($interface); |
| 4876 | 4897 |
| 4877 # FIXME: Do we really need to treat "GenerateIsReachable", "CustomIsReachabl e" and /SVG/ | 4898 # FIXME: Do we really need to treat "GenerateIsReachable", "CustomIsReachabl e" and /SVG/ |
| 4878 # as dependent DOM objects? | 4899 # as dependent DOM objects? |
| 4879 my $wrapperConfiguration = "WrapperConfiguration::Independent"; | 4900 my $wrapperConfiguration = "WrapperConfiguration::Independent"; |
| 4880 if (InheritsExtendedAttribute($interface, "ActiveDOMObject") | 4901 if (InheritsExtendedAttribute($interface, "ActiveDOMObject") |
| 4881 || InheritsExtendedAttribute($interface, "DependentLifetime") | 4902 || InheritsExtendedAttribute($interface, "DependentLifetime") |
| 4882 || InheritsExtendedAttribute($interface, "GenerateIsReachable") | 4903 || NeedsResolveWrapperReachability($interface) |
| 4883 || InheritsExtendedAttribute($interface, "CustomIsReachable") | |
| 4884 || $v8ClassName =~ /SVG/) { | 4904 || $v8ClassName =~ /SVG/) { |
| 4885 $wrapperConfiguration = "WrapperConfiguration::Dependent"; | 4905 $wrapperConfiguration = "WrapperConfiguration::Dependent"; |
| 4886 } | 4906 } |
| 4887 | 4907 |
| 4888 my $code = ""; | 4908 my $code = ""; |
| 4889 $code .= <<END; | 4909 $code .= <<END; |
| 4890 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType } impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 4910 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType } impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 4891 { | 4911 { |
| 4892 ASSERT(impl); | 4912 ASSERT(impl); |
| 4893 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate)); | 4913 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate)); |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6177 my $interface = shift; | 6197 my $interface = shift; |
| 6178 | 6198 |
| 6179 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6199 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
| 6180 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6200 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
| 6181 return 1 if InheritsInterface($interface, "Document"); | 6201 return 1 if InheritsInterface($interface, "Document"); |
| 6182 | 6202 |
| 6183 return 0; | 6203 return 0; |
| 6184 } | 6204 } |
| 6185 | 6205 |
| 6186 1; | 6206 1; |
| OLD | NEW |