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 3353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4034 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); | 4058 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); |
4035 AddToImplIncludes("core/dom/ContextFeatures.h"); | 4059 AddToImplIncludes("core/dom/ContextFeatures.h"); |
4036 AddToImplIncludes("core/dom/Document.h"); | 4060 AddToImplIncludes("core/dom/Document.h"); |
4037 AddToImplIncludes("RuntimeEnabledFeatures.h"); | 4061 AddToImplIncludes("RuntimeEnabledFeatures.h"); |
4038 AddToImplIncludes("platform/TraceEvent.h"); | 4062 AddToImplIncludes("platform/TraceEvent.h"); |
4039 | 4063 |
4040 AddIncludesForType($interfaceName); | 4064 AddIncludesForType($interfaceName); |
4041 | 4065 |
4042 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; | 4066 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; |
4043 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas
sName}::toEventTarget" : "0"; | 4067 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas
sName}::toEventTarget" : "0"; |
4044 my $rootForGC = NeedsOpaqueRootForGC($interface) ? "${v8ClassName}::opaqueRo
otForGC" : "0"; | 4068 my $resolveWrapperReachability = NeedsResolveWrapperReachability($interface)
? "${v8ClassName}::resolveWrapperReachability" : "0"; |
4045 | 4069 |
4046 # Find the super descriptor. | 4070 # Find the super descriptor. |
4047 my $parentClass = ""; | 4071 my $parentClass = ""; |
4048 my $parentClassTemplate = ""; | 4072 my $parentClassTemplate = ""; |
4049 if ($interface->parent) { | 4073 if ($interface->parent) { |
4050 my $parent = $interface->parent; | 4074 my $parent = $interface->parent; |
4051 AddToImplIncludes("V8${parent}.h"); | 4075 AddToImplIncludes("V8${parent}.h"); |
4052 $parentClass = "V8" . $parent; | 4076 $parentClass = "V8" . $parent; |
4053 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; | 4077 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; |
4054 } | 4078 } |
(...skipping 29 matching lines...) Expand all Loading... |
4084 { | 4108 { |
4085 WebCore::initializeScriptWrappableForInterface(object); | 4109 WebCore::initializeScriptWrappableForInterface(object); |
4086 } | 4110 } |
4087 | 4111 |
4088 namespace WebCore { | 4112 namespace WebCore { |
4089 END | 4113 END |
4090 $implementation{nameSpaceWebCore}->addHeader($code); | 4114 $implementation{nameSpaceWebCore}->addHeader($code); |
4091 } | 4115 } |
4092 | 4116 |
4093 my $code = "const WrapperTypeInfo ${v8ClassName}::wrapperTypeInfo = { ${v8Cl
assName}::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEvent
Target, "; | 4117 my $code = "const WrapperTypeInfo ${v8ClassName}::wrapperTypeInfo = { ${v8Cl
assName}::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEvent
Target, "; |
4094 $code .= "$rootForGC, ${v8ClassName}::installPerContextEnabledPrototypePrope
rties, $parentClassInfo, $WrapperTypePrototype };\n"; | 4118 $code .= "$resolveWrapperReachability, ${v8ClassName}::installPerContextEnab
ledPrototypeProperties, $parentClassInfo, $WrapperTypePrototype };\n"; |
4095 $implementation{nameSpaceWebCore}->addHeader($code); | 4119 $implementation{nameSpaceWebCore}->addHeader($code); |
4096 | 4120 |
4097 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); | 4121 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); |
4098 | 4122 |
4099 my $hasConstructors = 0; | 4123 my $hasConstructors = 0; |
4100 my $hasReplaceable = 0; | 4124 my $hasReplaceable = 0; |
4101 | 4125 |
4102 # Generate property accessors for attributes. | 4126 # Generate property accessors for attributes. |
4103 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 4127 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
4104 my $attribute = @{$interface->attributes}[$index]; | 4128 my $attribute = @{$interface->attributes}[$index]; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4143 | 4167 |
4144 if ($hasConstructors) { | 4168 if ($hasConstructors) { |
4145 GenerateConstructorGetter($interface); | 4169 GenerateConstructorGetter($interface); |
4146 } | 4170 } |
4147 | 4171 |
4148 if ($hasConstructors || $hasReplaceable) { | 4172 if ($hasConstructors || $hasReplaceable) { |
4149 GenerateReplaceableAttributeSetter($interface); | 4173 GenerateReplaceableAttributeSetter($interface); |
4150 GenerateReplaceableAttributeSetterCallback($interface); | 4174 GenerateReplaceableAttributeSetterCallback($interface); |
4151 } | 4175 } |
4152 | 4176 |
4153 if (NeedsOpaqueRootForGC($interface)) { | 4177 if (NeedsResolveWrapperReachability($interface)) { |
4154 GenerateOpaqueRootForGC($interface); | 4178 GenerateResolveWrapperReachability($interface); |
4155 } | 4179 } |
4156 | 4180 |
4157 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne
"Window") { | 4181 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne
"Window") { |
4158 GenerateSecurityCheckFunctions($interface); | 4182 GenerateSecurityCheckFunctions($interface); |
4159 } | 4183 } |
4160 | 4184 |
4161 if (IsConstructorTemplate($interface, "TypedArray")) { | 4185 if (IsConstructorTemplate($interface, "TypedArray")) { |
4162 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); | 4186 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); |
4163 $implementation{nameSpaceWebCore}->add(<<END); | 4187 $implementation{nameSpaceWebCore}->add(<<END); |
4164 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) | 4188 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4966 GenerateSpecialWrap($interface, $v8ClassName, $nativeType); | 4990 GenerateSpecialWrap($interface, $v8ClassName, $nativeType); |
4967 | 4991 |
4968 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); | 4992 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); |
4969 my $baseType = BaseInterfaceName($interface); | 4993 my $baseType = BaseInterfaceName($interface); |
4970 | 4994 |
4971 # FIXME: Do we really need to treat "GenerateIsReachable", "CustomIsReachabl
e" and /SVG/ | 4995 # FIXME: Do we really need to treat "GenerateIsReachable", "CustomIsReachabl
e" and /SVG/ |
4972 # as dependent DOM objects? | 4996 # as dependent DOM objects? |
4973 my $wrapperConfiguration = "WrapperConfiguration::Independent"; | 4997 my $wrapperConfiguration = "WrapperConfiguration::Independent"; |
4974 if (InheritsExtendedAttribute($interface, "ActiveDOMObject") | 4998 if (InheritsExtendedAttribute($interface, "ActiveDOMObject") |
4975 || InheritsExtendedAttribute($interface, "DependentLifetime") | 4999 || InheritsExtendedAttribute($interface, "DependentLifetime") |
4976 || InheritsExtendedAttribute($interface, "GenerateIsReachable") | 5000 || NeedsResolveWrapperReachability($interface) |
4977 || InheritsExtendedAttribute($interface, "CustomIsReachable") | |
4978 || $v8ClassName =~ /SVG/) { | 5001 || $v8ClassName =~ /SVG/) { |
4979 $wrapperConfiguration = "WrapperConfiguration::Dependent"; | 5002 $wrapperConfiguration = "WrapperConfiguration::Dependent"; |
4980 } | 5003 } |
4981 | 5004 |
4982 my $code = ""; | 5005 my $code = ""; |
4983 $code .= <<END; | 5006 $code .= <<END; |
4984 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType
} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 5007 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType
} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
4985 { | 5008 { |
4986 ASSERT(impl); | 5009 ASSERT(impl); |
4987 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate)); | 5010 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate)); |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6274 | 6297 |
6275 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6298 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
6276 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6299 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6277 return 1 if InheritsInterface($interface, "Document"); | 6300 return 1 if InheritsInterface($interface, "Document"); |
6278 return 1 if SVGTypeNeedsToHoldContextElement($interface->name); | 6301 return 1 if SVGTypeNeedsToHoldContextElement($interface->name); |
6279 | 6302 |
6280 return 0; | 6303 return 0; |
6281 } | 6304 } |
6282 | 6305 |
6283 1; | 6306 1; |
OLD | NEW |