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 .= " v8::Local<v8::Object> creationContext = v8::Local<v8::Obje
ct>::New(isolate, wrapper);\n"; |
| 477 } |
| 478 for my $setReference (@{$interface->extendedAttributes->{"SetReference"}}) { |
| 479 my $setReferenceType = $setReference->type; |
| 480 my $setReferenceName = $setReference->name; |
| 481 my $setReferenceV8Type = "V8".$setReferenceType; |
| 482 |
| 483 AddIncludesForType($setReferenceType); |
| 484 $code .= <<END; |
| 485 ${setReferenceType}* ${setReferenceName} = impl->${setReferenceName}(); |
| 486 if (${setReferenceName}) { |
| 487 if(!DOMDataStore::containsWrapper<${setReferenceV8Type}>(${setReferenceN
ame}, isolate)) |
| 488 wrap(${setReferenceName}, creationContext, isolate); |
| 489 DOMDataStore::setWrapperReference<${setReferenceV8Type}>(wrapper, ${setR
eferenceName}, isolate); |
| 490 } |
| 491 END |
| 492 } |
| 493 |
475 my $isReachableMethod = $interface->extendedAttributes->{"GenerateIsReachabl
e"}; | 494 my $isReachableMethod = $interface->extendedAttributes->{"GenerateIsReachabl
e"}; |
476 if ($isReachableMethod) { | 495 if ($isReachableMethod) { |
477 AddToImplIncludes("bindings/v8/V8GCController.h"); | 496 AddToImplIncludes("bindings/v8/V8GCController.h"); |
478 AddToImplIncludes("core/dom/Element.h"); | 497 AddToImplIncludes("core/dom/Element.h"); |
479 $code .= <<END; | 498 $code .= <<END; |
480 if (Node* owner = impl->${isReachableMethod}()) | 499 if (Node* owner = impl->${isReachableMethod}()) { |
481 return V8GCController::opaqueRootForGC(owner, isolate); | 500 setObjectGroup(V8GCController::opaqueRootForGC(owner, isolate), wrapper,
isolate); |
| 501 return; |
| 502 } |
482 END | 503 END |
483 } | 504 } |
484 | 505 |
485 $code .= <<END; | 506 $code .= <<END; |
486 return object; | 507 setObjectGroup(object, wrapper, isolate); |
487 } | 508 } |
488 | 509 |
489 END | 510 END |
490 $implementation{nameSpaceWebCore}->add($code); | 511 $implementation{nameSpaceWebCore}->add($code); |
491 } | 512 } |
492 | 513 |
493 sub GetSVGPropertyTypes | 514 sub GetSVGPropertyTypes |
494 { | 515 { |
495 my $implType = shift; | 516 my $implType = shift; |
496 | 517 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); | 680 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); |
660 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor
ldType); | 681 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor
ldType); |
661 static ${nativeType}* toNative(v8::Handle<v8::Object> object) | 682 static ${nativeType}* toNative(v8::Handle<v8::Object> object) |
662 { | 683 { |
663 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); | 684 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); |
664 } | 685 } |
665 static void derefObject(void*); | 686 static void derefObject(void*); |
666 static const WrapperTypeInfo wrapperTypeInfo; | 687 static const WrapperTypeInfo wrapperTypeInfo; |
667 END | 688 END |
668 | 689 |
669 if (NeedsOpaqueRootForGC($interface)) { | 690 if (NeedsResolveWrapperReachability($interface)) { |
670 $header{classPublic}->add(" static void* opaqueRootForGC(void*, v8::I
solate*);\n"); | 691 $header{classPublic}->add(" static void resolveWrapperReachability(vo
id*, const v8::Persistent<v8::Object>&, v8::Isolate*);\n"); |
671 } | 692 } |
672 | 693 |
673 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { | 694 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { |
674 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject
(v8::Handle<v8::Object>);\n"); | 695 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject
(v8::Handle<v8::Object>);\n"); |
675 } | 696 } |
676 | 697 |
677 if (InheritsInterface($interface, "EventTarget")) { | 698 if (InheritsInterface($interface, "EventTarget")) { |
678 $header{classPublic}->add(" static EventTarget* toEventTarget(v8::Han
dle<v8::Object>);\n"); | 699 $header{classPublic}->add(" static EventTarget* toEventTarget(v8::Han
dle<v8::Object>);\n"); |
679 } | 700 } |
680 | 701 |
(...skipping 3308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3989 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); | 4010 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); |
3990 AddToImplIncludes("core/dom/ContextFeatures.h"); | 4011 AddToImplIncludes("core/dom/ContextFeatures.h"); |
3991 AddToImplIncludes("core/dom/Document.h"); | 4012 AddToImplIncludes("core/dom/Document.h"); |
3992 AddToImplIncludes("RuntimeEnabledFeatures.h"); | 4013 AddToImplIncludes("RuntimeEnabledFeatures.h"); |
3993 AddToImplIncludes("platform/TraceEvent.h"); | 4014 AddToImplIncludes("platform/TraceEvent.h"); |
3994 | 4015 |
3995 AddIncludesForType($interfaceName); | 4016 AddIncludesForType($interfaceName); |
3996 | 4017 |
3997 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; | 4018 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje
ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; |
3998 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas
sName}::toEventTarget" : "0"; | 4019 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas
sName}::toEventTarget" : "0"; |
3999 my $rootForGC = NeedsOpaqueRootForGC($interface) ? "${v8ClassName}::opaqueRo
otForGC" : "0"; | 4020 my $resolveWrapperReachability = NeedsResolveWrapperReachability($interface)
? "${v8ClassName}::resolveWrapperReachability" : "0"; |
4000 | 4021 |
4001 # Find the super descriptor. | 4022 # Find the super descriptor. |
4002 my $parentClass = ""; | 4023 my $parentClass = ""; |
4003 my $parentClassTemplate = ""; | 4024 my $parentClassTemplate = ""; |
4004 if ($interface->parent) { | 4025 if ($interface->parent) { |
4005 my $parent = $interface->parent; | 4026 my $parent = $interface->parent; |
4006 AddToImplIncludes("V8${parent}.h"); | 4027 AddToImplIncludes("V8${parent}.h"); |
4007 $parentClass = "V8" . $parent; | 4028 $parentClass = "V8" . $parent; |
4008 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; | 4029 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor
ldType)"; |
4009 } | 4030 } |
(...skipping 29 matching lines...) Expand all Loading... |
4039 { | 4060 { |
4040 WebCore::initializeScriptWrappableForInterface(object); | 4061 WebCore::initializeScriptWrappableForInterface(object); |
4041 } | 4062 } |
4042 | 4063 |
4043 namespace WebCore { | 4064 namespace WebCore { |
4044 END | 4065 END |
4045 $implementation{nameSpaceWebCore}->addHeader($code); | 4066 $implementation{nameSpaceWebCore}->addHeader($code); |
4046 } | 4067 } |
4047 | 4068 |
4048 my $code = "const WrapperTypeInfo ${v8ClassName}::wrapperTypeInfo = { ${v8Cl
assName}::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEvent
Target, "; | 4069 my $code = "const WrapperTypeInfo ${v8ClassName}::wrapperTypeInfo = { ${v8Cl
assName}::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEvent
Target, "; |
4049 $code .= "$rootForGC, ${v8ClassName}::installPerContextEnabledPrototypePrope
rties, $parentClassInfo, $WrapperTypePrototype };\n"; | 4070 $code .= "$resolveWrapperReachability, ${v8ClassName}::installPerContextEnab
ledPrototypeProperties, $parentClassInfo, $WrapperTypePrototype };\n"; |
4050 $implementation{nameSpaceWebCore}->addHeader($code); | 4071 $implementation{nameSpaceWebCore}->addHeader($code); |
4051 | 4072 |
4052 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); | 4073 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T
) { }\n\n"); |
4053 | 4074 |
4054 my $hasConstructors = 0; | 4075 my $hasConstructors = 0; |
4055 my $hasReplaceable = 0; | 4076 my $hasReplaceable = 0; |
4056 | 4077 |
4057 # Generate property accessors for attributes. | 4078 # Generate property accessors for attributes. |
4058 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 4079 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
4059 my $attribute = @{$interface->attributes}[$index]; | 4080 my $attribute = @{$interface->attributes}[$index]; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4098 | 4119 |
4099 if ($hasConstructors) { | 4120 if ($hasConstructors) { |
4100 GenerateConstructorGetter($interface); | 4121 GenerateConstructorGetter($interface); |
4101 } | 4122 } |
4102 | 4123 |
4103 if ($hasConstructors || $hasReplaceable) { | 4124 if ($hasConstructors || $hasReplaceable) { |
4104 GenerateReplaceableAttributeSetter($interface); | 4125 GenerateReplaceableAttributeSetter($interface); |
4105 GenerateReplaceableAttributeSetterCallback($interface); | 4126 GenerateReplaceableAttributeSetterCallback($interface); |
4106 } | 4127 } |
4107 | 4128 |
4108 if (NeedsOpaqueRootForGC($interface)) { | 4129 if (NeedsResolveWrapperReachability($interface)) { |
4109 GenerateOpaqueRootForGC($interface); | 4130 GenerateResolveWrapperReachability($interface); |
4110 } | 4131 } |
4111 | 4132 |
4112 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne
"Window") { | 4133 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne
"Window") { |
4113 GenerateSecurityCheckFunctions($interface); | 4134 GenerateSecurityCheckFunctions($interface); |
4114 } | 4135 } |
4115 | 4136 |
4116 if (IsConstructorTemplate($interface, "TypedArray")) { | 4137 if (IsConstructorTemplate($interface, "TypedArray")) { |
4117 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); | 4138 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); |
4118 $implementation{nameSpaceWebCore}->add(<<END); | 4139 $implementation{nameSpaceWebCore}->add(<<END); |
4119 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) | 4140 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... |
4896 GenerateSpecialWrap($interface, $v8ClassName, $nativeType); | 4917 GenerateSpecialWrap($interface, $v8ClassName, $nativeType); |
4897 | 4918 |
4898 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); | 4919 my $createWrapperArgumentType = GetPassRefPtrType($nativeType); |
4899 my $baseType = BaseInterfaceName($interface); | 4920 my $baseType = BaseInterfaceName($interface); |
4900 | 4921 |
4901 # FIXME: Do we really need to treat "GenerateIsReachable", "CustomIsReachabl
e" and /SVG/ | 4922 # FIXME: Do we really need to treat "GenerateIsReachable", "CustomIsReachabl
e" and /SVG/ |
4902 # as dependent DOM objects? | 4923 # as dependent DOM objects? |
4903 my $wrapperConfiguration = "WrapperConfiguration::Independent"; | 4924 my $wrapperConfiguration = "WrapperConfiguration::Independent"; |
4904 if (InheritsExtendedAttribute($interface, "ActiveDOMObject") | 4925 if (InheritsExtendedAttribute($interface, "ActiveDOMObject") |
4905 || InheritsExtendedAttribute($interface, "DependentLifetime") | 4926 || InheritsExtendedAttribute($interface, "DependentLifetime") |
4906 || InheritsExtendedAttribute($interface, "GenerateIsReachable") | 4927 || NeedsResolveWrapperReachability($interface) |
4907 || InheritsExtendedAttribute($interface, "CustomIsReachable") | |
4908 || $v8ClassName =~ /SVG/) { | 4928 || $v8ClassName =~ /SVG/) { |
4909 $wrapperConfiguration = "WrapperConfiguration::Dependent"; | 4929 $wrapperConfiguration = "WrapperConfiguration::Dependent"; |
4910 } | 4930 } |
4911 | 4931 |
4912 my $code = ""; | 4932 my $code = ""; |
4913 $code .= <<END; | 4933 $code .= <<END; |
4914 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType
} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 4934 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType
} impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
4915 { | 4935 { |
4916 ASSERT(impl); | 4936 ASSERT(impl); |
4917 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate)); | 4937 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate)); |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6197 my $interface = shift; | 6217 my $interface = shift; |
6198 | 6218 |
6199 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6219 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
6200 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6220 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6201 return 1 if InheritsInterface($interface, "Document"); | 6221 return 1 if InheritsInterface($interface, "Document"); |
6202 | 6222 |
6203 return 0; | 6223 return 0; |
6204 } | 6224 } |
6205 | 6225 |
6206 1; | 6226 1; |
OLD | NEW |