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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 package code_generator_v8; | 110 package code_generator_v8; |
111 | 111 |
112 use strict; | 112 use strict; |
113 use Cwd; | 113 use Cwd; |
114 use File::Basename; | 114 use File::Basename; |
115 use File::Find; | 115 use File::Find; |
116 use File::Spec; | 116 use File::Spec; |
117 use Data::Dumper; | |
haraken
2013/10/10 06:08:32
Remove this.
| |
117 | 118 |
118 my $idlDocument; | 119 my $idlDocument; |
119 my $idlDirectories; | 120 my $idlDirectories; |
120 my $preprocessor; | 121 my $preprocessor; |
121 my $verbose; | 122 my $verbose; |
122 my $interfaceIdlFiles; | 123 my $interfaceIdlFiles; |
123 my $writeFileOnlyIfChanged; | 124 my $writeFileOnlyIfChanged; |
124 my $sourceRoot; | 125 my $sourceRoot; |
125 | 126 |
126 # Cache of IDL file pathnames. | 127 # Cache of IDL file pathnames. |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 if (IsTypedArrayType($interfaceName)) { | 448 if (IsTypedArrayType($interfaceName)) { |
448 push(@includes, "wtf/${interfaceName}.h"); | 449 push(@includes, "wtf/${interfaceName}.h"); |
449 } elsif (!SkipIncludeHeader($interfaceName)) { | 450 } elsif (!SkipIncludeHeader($interfaceName)) { |
450 my $idlFilename = Cwd::abs_path(IDLFileForInterface($interfaceName)) or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); | 451 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); | 452 my $idlRelPath = File::Spec->abs2rel($idlFilename, $sourceRoot); |
452 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); | 453 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); |
453 } | 454 } |
454 return @includes; | 455 return @includes; |
455 } | 456 } |
456 | 457 |
457 sub NeedsOpaqueRootForGC | 458 sub NeedResolveWrapperReachability |
458 { | 459 { |
459 my $interface = shift; | 460 my $interface = shift; |
460 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface ->extendedAttributes->{"CustomIsReachable"}; | 461 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface ->extendedAttributes->{"CustomIsReachable"} || $interface->extendedAttributes->{ "ReachableTo"}; |
461 } | 462 } |
462 | 463 |
463 sub GenerateOpaqueRootForGC | 464 sub GenerateResolveWrapperReachability |
464 { | 465 { |
465 my $interface = shift; | 466 my $interface = shift; |
466 my $implClassName = GetImplName($interface); | 467 my $implClassName = GetImplName($interface); |
467 my $v8ClassName = GetV8ClassName($interface); | 468 my $v8ClassName = GetV8ClassName($interface); |
468 | 469 |
469 if ($interface->extendedAttributes->{"CustomIsReachable"}) { | 470 if ($interface->extendedAttributes->{"CustomIsReachable"}) { |
470 return; | 471 return; |
471 } | 472 } |
472 | 473 |
473 my $code = <<END; | 474 my $code = <<END; |
474 void* ${v8ClassName}::opaqueRootForGC(void* object, v8::Isolate* isolate) | 475 void* ${v8ClassName}::resolveWrapperReachability(void* object, const v8::Persist ent<v8::Object>& wrapper, v8::Isolate* isolate) |
475 { | 476 { |
476 ${implClassName}* impl = fromInternalPointer(object); | 477 ${implClassName}* impl = fromInternalPointer(object); |
477 END | 478 END |
479 for my $reachableTo (@{$interface->extendedAttributes->{"ReachableTo"}}) { | |
480 $code .= <<END; | |
481 // isolate->SetReference(wrapper, toV8(impl->filter(), wrapper, isolate)); | |
482 END | |
483 warn Dumper($reachableTo->type); | |
484 } | |
485 | |
478 my $isReachableMethod = $interface->extendedAttributes->{"GenerateIsReachabl e"}; | 486 my $isReachableMethod = $interface->extendedAttributes->{"GenerateIsReachabl e"}; |
479 if ($isReachableMethod) { | 487 if ($isReachableMethod) { |
480 AddToImplIncludes("bindings/v8/V8GCController.h"); | 488 AddToImplIncludes("bindings/v8/V8GCController.h"); |
481 AddToImplIncludes("core/dom/Element.h"); | 489 AddToImplIncludes("core/dom/Element.h"); |
482 $code .= <<END; | 490 $code .= <<END; |
483 if (Node* owner = impl->${isReachableMethod}()) | 491 if (Node* owner = impl->${isReachableMethod}()) |
484 return V8GCController::opaqueRootForGC(owner, isolate); | 492 return V8GCController::opaqueRootForGC(owner, isolate); |
485 END | 493 END |
486 } | 494 } |
487 | 495 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); | 653 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); |
646 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType); | 654 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType); |
647 static ${nativeType}* toNative(v8::Handle<v8::Object> object) | 655 static ${nativeType}* toNative(v8::Handle<v8::Object> object) |
648 { | 656 { |
649 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex)); | 657 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex)); |
650 } | 658 } |
651 static void derefObject(void*); | 659 static void derefObject(void*); |
652 static WrapperTypeInfo info; | 660 static WrapperTypeInfo info; |
653 END | 661 END |
654 | 662 |
655 if (NeedsOpaqueRootForGC($interface)) { | 663 if (NeedResolveWrapperReachability($interface)) { |
656 $header{classPublic}->add(" static void* opaqueRootForGC(void*, v8::I solate*);\n"); | 664 $header{classPublic}->add(" static void* resolveWrapperReachability(v oid*, const v8::Persistent<v8::Object>&, v8::Isolate*);\n"); |
657 } | 665 } |
658 | 666 |
659 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { | 667 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { |
660 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject (v8::Handle<v8::Object>);\n"); | 668 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject (v8::Handle<v8::Object>);\n"); |
661 } | 669 } |
662 | 670 |
663 if (InheritsInterface($interface, "EventTarget")) { | 671 if (InheritsInterface($interface, "EventTarget")) { |
664 $header{classPublic}->add(" static EventTarget* toEventTarget(v8::Han dle<v8::Object>);\n"); | 672 $header{classPublic}->add(" static EventTarget* toEventTarget(v8::Han dle<v8::Object>);\n"); |
665 } | 673 } |
666 | 674 |
(...skipping 3267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3934 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); | 3942 AddToImplIncludes("bindings/v8/V8DOMWrapper.h"); |
3935 AddToImplIncludes("core/dom/ContextFeatures.h"); | 3943 AddToImplIncludes("core/dom/ContextFeatures.h"); |
3936 AddToImplIncludes("core/dom/Document.h"); | 3944 AddToImplIncludes("core/dom/Document.h"); |
3937 AddToImplIncludes("RuntimeEnabledFeatures.h"); | 3945 AddToImplIncludes("RuntimeEnabledFeatures.h"); |
3938 AddToImplIncludes("platform/TraceEvent.h"); | 3946 AddToImplIncludes("platform/TraceEvent.h"); |
3939 | 3947 |
3940 AddIncludesForType($interfaceName); | 3948 AddIncludesForType($interfaceName); |
3941 | 3949 |
3942 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; | 3950 my $toActiveDOMObject = InheritsExtendedAttribute($interface, "ActiveDOMObje ct") ? "${v8ClassName}::toActiveDOMObject" : "0"; |
3943 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas sName}::toEventTarget" : "0"; | 3951 my $toEventTarget = InheritsInterface($interface, "EventTarget") ? "${v8Clas sName}::toEventTarget" : "0"; |
3944 my $rootForGC = NeedsOpaqueRootForGC($interface) ? "${v8ClassName}::opaqueRo otForGC" : "0"; | 3952 my $resolveWrapperReachability = NeedResolveWrapperReachability($interface) ? "${v8ClassName}::resolveWrapperReachability" : "0"; |
3945 | 3953 |
3946 # Find the super descriptor. | 3954 # Find the super descriptor. |
3947 my $parentClass = ""; | 3955 my $parentClass = ""; |
3948 my $parentClassTemplate = ""; | 3956 my $parentClassTemplate = ""; |
3949 if ($interface->parent) { | 3957 if ($interface->parent) { |
3950 my $parent = $interface->parent; | 3958 my $parent = $interface->parent; |
3951 AddToImplIncludes("V8${parent}.h"); | 3959 AddToImplIncludes("V8${parent}.h"); |
3952 $parentClass = "V8" . $parent; | 3960 $parentClass = "V8" . $parent; |
3953 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)"; | 3961 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)"; |
3954 } | 3962 } |
(...skipping 29 matching lines...) Expand all Loading... | |
3984 { | 3992 { |
3985 WebCore::initializeScriptWrappableForInterface(object); | 3993 WebCore::initializeScriptWrappableForInterface(object); |
3986 } | 3994 } |
3987 | 3995 |
3988 namespace WebCore { | 3996 namespace WebCore { |
3989 END | 3997 END |
3990 $implementation{nameSpaceWebCore}->addHeader($code); | 3998 $implementation{nameSpaceWebCore}->addHeader($code); |
3991 } | 3999 } |
3992 | 4000 |
3993 my $code = "WrapperTypeInfo ${v8ClassName}::info = { ${v8ClassName}::GetTemp late, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, "; | 4001 my $code = "WrapperTypeInfo ${v8ClassName}::info = { ${v8ClassName}::GetTemp late, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, "; |
3994 $code .= "$rootForGC, ${v8ClassName}::installPerContextPrototypeProperties, $parentClassInfo, $WrapperTypePrototype };\n"; | 4002 $code .= "$resolveWrapperReachability, ${v8ClassName}::installPerContextProt otypeProperties, $parentClassInfo, $WrapperTypePrototype };\n"; |
3995 $implementation{nameSpaceWebCore}->addHeader($code); | 4003 $implementation{nameSpaceWebCore}->addHeader($code); |
3996 | 4004 |
3997 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n"); | 4005 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n"); |
3998 | 4006 |
3999 my $hasConstructors = 0; | 4007 my $hasConstructors = 0; |
4000 my $hasReplaceable = 0; | 4008 my $hasReplaceable = 0; |
4001 | 4009 |
4002 # Generate property accessors for attributes. | 4010 # Generate property accessors for attributes. |
4003 for (my $index = 0; $index < @{$interface->attributes}; $index++) { | 4011 for (my $index = 0; $index < @{$interface->attributes}; $index++) { |
4004 my $attribute = @{$interface->attributes}[$index]; | 4012 my $attribute = @{$interface->attributes}[$index]; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4041 | 4049 |
4042 if ($hasConstructors) { | 4050 if ($hasConstructors) { |
4043 GenerateConstructorGetter($interface); | 4051 GenerateConstructorGetter($interface); |
4044 } | 4052 } |
4045 | 4053 |
4046 if ($hasConstructors || $hasReplaceable) { | 4054 if ($hasConstructors || $hasReplaceable) { |
4047 GenerateReplaceableAttributeSetter($interface); | 4055 GenerateReplaceableAttributeSetter($interface); |
4048 GenerateReplaceableAttributeSetterCallback($interface); | 4056 GenerateReplaceableAttributeSetterCallback($interface); |
4049 } | 4057 } |
4050 | 4058 |
4051 if (NeedsOpaqueRootForGC($interface)) { | 4059 if (NeedResolveWrapperReachability($interface)) { |
4052 GenerateOpaqueRootForGC($interface); | 4060 GenerateResolveWrapperReachability($interface); |
4053 } | 4061 } |
4054 | 4062 |
4055 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne "Window") { | 4063 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne "Window") { |
4056 GenerateSecurityCheckFunctions($interface); | 4064 GenerateSecurityCheckFunctions($interface); |
4057 } | 4065 } |
4058 | 4066 |
4059 if (IsConstructorTemplate($interface, "TypedArray")) { | 4067 if (IsConstructorTemplate($interface, "TypedArray")) { |
4060 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); | 4068 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); |
4061 $implementation{nameSpaceWebCore}->add(<<END); | 4069 $implementation{nameSpaceWebCore}->add(<<END); |
4062 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) | 4070 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) |
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6163 my $interface = shift; | 6171 my $interface = shift; |
6164 | 6172 |
6165 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6173 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
6166 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6174 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6167 return 1 if InheritsInterface($interface, "Document"); | 6175 return 1 if InheritsInterface($interface, "Document"); |
6168 | 6176 |
6169 return 0; | 6177 return 0; |
6170 } | 6178 } |
6171 | 6179 |
6172 1; | 6180 1; |
OLD | NEW |