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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } elsif (IsTypedArrayType($interfaceName)) { | 444 } elsif (IsTypedArrayType($interfaceName)) { |
445 push(@includes, "wtf/${interfaceName}.h"); | 445 push(@includes, "wtf/${interfaceName}.h"); |
446 } else { | 446 } else { |
447 my $idlFilename = Cwd::abs_path(IDLFileForInterface($interfaceName)) or
die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); | 447 my $idlFilename = Cwd::abs_path(IDLFileForInterface($interfaceName)) or
die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); |
448 my $idlRelPath = File::Spec->abs2rel($idlFilename, $sourceRoot); | 448 my $idlRelPath = File::Spec->abs2rel($idlFilename, $sourceRoot); |
449 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); | 449 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); |
450 } | 450 } |
451 return @includes; | 451 return @includes; |
452 } | 452 } |
453 | 453 |
454 sub NeedsOpaqueRootForGC | 454 sub NeedsResolveWrapperReachability |
455 { | 455 { |
456 my $interface = shift; | 456 my $interface = shift; |
457 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface
->extendedAttributes->{"CustomIsReachable"}; | 457 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface
->extendedAttributes->{"CustomIsReachable"} || $interface->extendedAttributes->{
"SetReference"}; |
458 } | 458 } |
459 | 459 |
460 sub GenerateOpaqueRootForGC | 460 sub GenerateResolveWrapperReachability |
461 { | 461 { |
462 my $interface = shift; | 462 my $interface = shift; |
463 my $implClassName = GetImplName($interface); | 463 my $implClassName = GetImplName($interface); |
464 my $v8ClassName = GetV8ClassName($interface); | 464 my $v8ClassName = GetV8ClassName($interface); |
465 | 465 |
466 if ($interface->extendedAttributes->{"CustomIsReachable"}) { | 466 if ($interface->extendedAttributes->{"CustomIsReachable"}) { |
467 return; | 467 return; |
468 } | 468 } |
469 | 469 |
470 my $code = <<END; | 470 my $code = <<END; |
471 void* ${v8ClassName}::opaqueRootForGC(void* object, v8::Isolate* isolate) | 471 void ${v8ClassName}::resolveWrapperReachability(void* object, const v8::Persiste
nt<v8::Object>& wrapper, v8::Isolate* isolate) |
472 { | 472 { |
473 ${implClassName}* impl = fromInternalPointer(object); | 473 ${implClassName}* impl = fromInternalPointer(object); |
474 END | 474 END |
| 475 if ($interface->extendedAttributes->{"SetReference"}) { |
| 476 $code .= <<END; |
| 477 v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate,
wrapper); |
| 478 V8WrapperInstantiationScope scope(creationContext, isolate); |
| 479 END |
| 480 } |
| 481 for my $setReference (@{$interface->extendedAttributes->{"SetReference"}}) { |
| 482 my $setReferenceType = $setReference->type; |
| 483 my $setReferenceName = $setReference->name; |
| 484 my $setReferenceV8Type = "V8".$setReferenceType; |
| 485 |
| 486 AddIncludesForType($setReferenceType); |
| 487 $code .= <<END; |
| 488 ${setReferenceType}* ${setReferenceName} = impl->${setReferenceName}(); |
| 489 if (${setReferenceName}) { |
| 490 if (!DOMDataStore::containsWrapper<${setReferenceV8Type}>(${setReference
Name}, isolate)) |
| 491 wrap(${setReferenceName}, creationContext, isolate); |
| 492 DOMDataStore::setWrapperReference<${setReferenceV8Type}>(wrapper, ${setR
eferenceName}, isolate); |
| 493 } |
| 494 END |
| 495 } |
| 496 |
475 my $isReachableMethod = $interface->extendedAttributes->{"GenerateIsReachabl
e"}; | 497 my $isReachableMethod = $interface->extendedAttributes->{"GenerateIsReachabl
e"}; |
476 if ($isReachableMethod) { | 498 if ($isReachableMethod) { |
477 AddToImplIncludes("bindings/v8/V8GCController.h"); | 499 AddToImplIncludes("bindings/v8/V8GCController.h"); |
478 AddToImplIncludes("core/dom/Element.h"); | 500 AddToImplIncludes("core/dom/Element.h"); |
479 $code .= <<END; | 501 $code .= <<END; |
480 if (Node* owner = impl->${isReachableMethod}()) | 502 if (Node* owner = impl->${isReachableMethod}()) { |
481 return V8GCController::opaqueRootForGC(owner, isolate); | 503 setObjectGroup(V8GCController::opaqueRootForGC(owner, isolate), wrapper,
isolate); |
| 504 return; |
| 505 } |
482 END | 506 END |
483 } | 507 } |
484 | 508 |
485 $code .= <<END; | 509 $code .= <<END; |
486 return object; | 510 setObjectGroup(object, wrapper, isolate); |
487 } | 511 } |
488 | 512 |
489 END | 513 END |
490 $implementation{nameSpaceWebCore}->add($code); | 514 $implementation{nameSpaceWebCore}->add($code); |
491 } | 515 } |
492 | 516 |
493 sub GetSVGPropertyTypes | 517 sub GetSVGPropertyTypes |
494 { | 518 { |
495 my $implType = shift; | 519 my $implType = shift; |
496 | 520 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); | 683 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); |
660 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor
ldType); | 684 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor
ldType); |
661 static ${nativeType}* toNative(v8::Handle<v8::Object> object) | 685 static ${nativeType}* toNative(v8::Handle<v8::Object> object) |
662 { | 686 { |
663 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); | 687 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); |
664 } | 688 } |
665 static void derefObject(void*); | 689 static void derefObject(void*); |
666 static const WrapperTypeInfo wrapperTypeInfo; | 690 static const WrapperTypeInfo wrapperTypeInfo; |
667 END | 691 END |
668 | 692 |
669 if (NeedsOpaqueRootForGC($interface)) { | 693 if (NeedsResolveWrapperReachability($interface)) { |
670 $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"); |
671 } | 695 } |
672 | 696 |
673 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { | 697 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { |
674 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject
(v8::Handle<v8::Object>);\n"); | 698 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject
(v8::Handle<v8::Object>);\n"); |
675 } | 699 } |
676 | 700 |
677 if (InheritsInterface($interface, "EventTarget")) { | 701 if (InheritsInterface($interface, "EventTarget")) { |
678 $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"); |
679 } | 703 } |
680 | 704 |
(...skipping 3341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4022 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); | 4046 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); |
4023 AddToImplIncludes("core/dom/ContextFeatures.h"); | 4047 AddToImplIncludes("core/dom/ContextFeatures.h"); |
4024 AddToImplIncludes("core/dom/Document.h"); | 4048 AddToImplIncludes("core/dom/Document.h"); |
4025 AddToImplIncludes("RuntimeEnabledFeatures.h"); | 4049 AddToImplIncludes("RuntimeEnabledFeatures.h"); |
4026 AddToImplIncludes("platform/TraceEvent.h"); | 4050 AddToImplIncludes("platform/TraceEvent.h"); |
4027 | 4051 |
4028 AddIncludesForType($interfaceName); | 4052 AddIncludesForType($interfaceName); |
4029 | 4053 |
4030 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; | 4054 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; |
4031 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas
sName}::toEventTarget" : "0"; | 4055 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas
sName}::toEventTarget" : "0"; |
4032 my $rootForGC = NeedsOpaqueRootForGC($interface) ? "${v8ClassName}::opaqueRo
otForGC" : "0"; | 4056 my $resolveWrapperReachability = NeedsResolveWrapperReachability($interface)
? "${v8ClassName}::resolveWrapperReachability" : "0"; |
4033 | 4057 |
4034 # Find the super descriptor. | 4058 # Find the super descriptor. |
4035 my $parentClass = ""; | 4059 my $parentClass = ""; |
4036 my $parentClassTemplate = ""; | 4060 my $parentClassTemplate = ""; |
4037 if ($interface->parent) { | 4061 if ($interface->parent) { |
4038 my $parent = $interface->parent; | 4062 my $parent = $interface->parent; |
4039 AddToImplIncludes("V8${parent}.h"); | 4063 AddToImplIncludes("V8${parent}.h"); |
4040 $parentClass = "V8" . $parent; | 4064 $parentClass = "V8" . $parent; |
4041 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; | 4065 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; |
4042 } | 4066 } |
(...skipping 29 matching lines...) Expand all Loading... |
4072 { | 4096 { |
4073 WebCore::initializeScriptWrappableForInterface(object); | 4097 WebCore::initializeScriptWrappableForInterface(object); |
4074 } | 4098 } |
4075 | 4099 |
4076 namespace WebCore { | 4100 namespace WebCore { |
4077 END | 4101 END |
4078 $implementation{nameSpaceWebCore}->addHeader($code); | 4102 $implementation{nameSpaceWebCore}->addHeader($code); |
4079 } | 4103 } |
4080 | 4104 |
4081 my $code = "const WrapperTypeInfo ${v8ClassName}::wrapperTypeInfo = { ${v8Cl
assName}::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEvent
Target, "; | 4105 my $code = "const WrapperTypeInfo ${v8ClassName}::wrapperTypeInfo = { ${v8Cl
assName}::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEvent
Target, "; |
4082 $code .= "$rootForGC, ${v8ClassName}::installPerContextEnabledPrototypePrope
rties, $parentClassInfo, $WrapperTypePrototype };\n"; | 4106 $code .= "$resolveWrapperReachability, ${v8ClassName}::installPerContextEnab
ledPrototypeProperties, $parentClassInfo, $WrapperTypePrototype };\n"; |
4083 $implementation{nameSpaceWebCore}->addHeader($code); | 4107 $implementation{nameSpaceWebCore}->addHeader($code); |
4084 | 4108 |
4085 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); | 4109 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); |
4086 | 4110 |
4087 my $hasConstructors = 0; | 4111 my $hasConstructors = 0; |
4088 my $hasReplaceable = 0; | 4112 my $hasReplaceable = 0; |
4089 | 4113 |
4090 # Generate property accessors for attributes. | 4114 # Generate property accessors for attributes. |
4091 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 4115 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
4092 my $attribute = @{$interface->attributes}[$index]; | 4116 my $attribute = @{$interface->attributes}[$index]; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4131 | 4155 |
4132 if ($hasConstructors) { | 4156 if ($hasConstructors) { |
4133 GenerateConstructorGetter($interface); | 4157 GenerateConstructorGetter($interface); |
4134 } | 4158 } |
4135 | 4159 |
4136 if ($hasConstructors || $hasReplaceable) { | 4160 if ($hasConstructors || $hasReplaceable) { |
4137 GenerateReplaceableAttributeSetter($interface); | 4161 GenerateReplaceableAttributeSetter($interface); |
4138 GenerateReplaceableAttributeSetterCallback($interface); | 4162 GenerateReplaceableAttributeSetterCallback($interface); |
4139 } | 4163 } |
4140 | 4164 |
4141 if (NeedsOpaqueRootForGC($interface)) { | 4165 if (NeedsResolveWrapperReachability($interface)) { |
4142 GenerateOpaqueRootForGC($interface); | 4166 GenerateResolveWrapperReachability($interface); |
4143 } | 4167 } |
4144 | 4168 |
4145 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne
"Window") { | 4169 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne
"Window") { |
4146 GenerateSecurityCheckFunctions($interface); | 4170 GenerateSecurityCheckFunctions($interface); |
4147 } | 4171 } |
4148 | 4172 |
4149 if (IsConstructorTemplate($interface, "TypedArray")) { | 4173 if (IsConstructorTemplate($interface, "TypedArray")) { |
4150 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); | 4174 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); |
4151 $implementation{nameSpaceWebCore}->add(<<END); | 4175 $implementation{nameSpaceWebCore}->add(<<END); |
4152 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) | 4176 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4929 GenerateSpecialWrap($interface, $v8ClassName, $nativeType); | 4953 GenerateSpecialWrap($interface, $v8ClassName, $nativeType); |
4930 | 4954 |
4931 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); | 4955 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); |
4932 my $baseType = BaseInterfaceName($interface); | 4956 my $baseType = BaseInterfaceName($interface); |
4933 | 4957 |
4934 # FIXME: Do we really need to treat "GenerateIsReachable", "CustomIsReachabl
e" and /SVG/ | 4958 # FIXME: Do we really need to treat "GenerateIsReachable", "CustomIsReachabl
e" and /SVG/ |
4935 # as dependent DOM objects? | 4959 # as dependent DOM objects? |
4936 my $wrapperConfiguration = "WrapperConfiguration::Independent"; | 4960 my $wrapperConfiguration = "WrapperConfiguration::Independent"; |
4937 if (InheritsExtendedAttribute($interface, "ActiveDOMObject") | 4961 if (InheritsExtendedAttribute($interface, "ActiveDOMObject") |
4938 || InheritsExtendedAttribute($interface, "DependentLifetime") | 4962 || InheritsExtendedAttribute($interface, "DependentLifetime") |
4939 || InheritsExtendedAttribute($interface, "GenerateIsReachable") | 4963 || NeedsResolveWrapperReachability($interface) |
4940 || InheritsExtendedAttribute($interface, "CustomIsReachable") | |
4941 || $v8ClassName =~ /SVG/) { | 4964 || $v8ClassName =~ /SVG/) { |
4942 $wrapperConfiguration = "WrapperConfiguration::Dependent"; | 4965 $wrapperConfiguration = "WrapperConfiguration::Dependent"; |
4943 } | 4966 } |
4944 | 4967 |
4945 my $code = ""; | 4968 my $code = ""; |
4946 $code .= <<END; | 4969 $code .= <<END; |
4947 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType
} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 4970 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType
} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
4948 { | 4971 { |
4949 ASSERT(impl); | 4972 ASSERT(impl); |
4950 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate)); | 4973 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate)); |
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6233 my $interface = shift; | 6256 my $interface = shift; |
6234 | 6257 |
6235 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6258 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
6236 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6259 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6237 return 1 if InheritsInterface($interface, "Document"); | 6260 return 1 if InheritsInterface($interface, "Document"); |
6238 | 6261 |
6239 return 0; | 6262 return 0; |
6240 } | 6263 } |
6241 | 6264 |
6242 1; | 6265 1; |
OLD | NEW |