Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 39393004: IDL compiler: rename WrapperTypeInfo info => wrapperTypeInfo (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8Float64Array.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 639
640 $header{nameSpaceWebCore}->addHeader("\nclass Dictionary;") if IsConstructor Template($interface, "Event"); 640 $header{nameSpaceWebCore}->addHeader("\nclass Dictionary;") if IsConstructor Template($interface, "Event");
641 641
642 my $nativeType = GetNativeTypeForConversions($interface); 642 my $nativeType = GetNativeTypeForConversions($interface);
643 if ($interface->extendedAttributes->{"NamedConstructor"}) { 643 if ($interface->extendedAttributes->{"NamedConstructor"}) {
644 $header{nameSpaceWebCore}->addHeader(<<END); 644 $header{nameSpaceWebCore}->addHeader(<<END);
645 645
646 class V8${nativeType}Constructor { 646 class V8${nativeType}Constructor {
647 public: 647 public:
648 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType); 648 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType);
649 static WrapperTypeInfo info; 649 static WrapperTypeInfo wrapperTypeInfo;
650 }; 650 };
651 END 651 END
652 } 652 }
653 653
654 $header{class}->addHeader("class $v8ClassName {"); 654 $header{class}->addHeader("class $v8ClassName {");
655 $header{class}->addFooter("};"); 655 $header{class}->addFooter("};");
656 656
657 $header{classPublic}->add(<<END); 657 $header{classPublic}->add(<<END);
658 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp e); 658 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp e);
659 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); 659 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*);
660 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType); 660 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType);
661 static ${nativeType}* toNative(v8::Handle<v8::Object> object) 661 static ${nativeType}* toNative(v8::Handle<v8::Object> object)
662 { 662 {
663 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex)); 663 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex));
664 } 664 }
665 static void derefObject(void*); 665 static void derefObject(void*);
666 static WrapperTypeInfo info; 666 static WrapperTypeInfo wrapperTypeInfo;
667 END 667 END
668 668
669 if (NeedsOpaqueRootForGC($interface)) { 669 if (NeedsOpaqueRootForGC($interface)) {
670 $header{classPublic}->add(" static void* opaqueRootForGC(void*, v8::I solate*);\n"); 670 $header{classPublic}->add(" static void* opaqueRootForGC(void*, v8::I solate*);\n");
671 } 671 }
672 672
673 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { 673 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) {
674 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject (v8::Handle<v8::Object>);\n"); 674 $header{classPublic}->add(" static ActiveDOMObject* toActiveDOMObject (v8::Handle<v8::Object>);\n");
675 } 675 }
676 676
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 friend v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> cr eationContext, v8::Isolate*); 820 friend v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> cr eationContext, v8::Isolate*);
821 static v8::Handle<v8::Object> createWrapper(${createWrapperArgumentType}, v8 ::Handle<v8::Object> creationContext, v8::Isolate*); 821 static v8::Handle<v8::Object> createWrapper(${createWrapperArgumentType}, v8 ::Handle<v8::Object> creationContext, v8::Isolate*);
822 END 822 END
823 } 823 }
824 824
825 $header{nameSpaceWebCore}->add(<<END); 825 $header{nameSpaceWebCore}->add(<<END);
826 826
827 template<> 827 template<>
828 class WrapperTypeTraits<${nativeType} > { 828 class WrapperTypeTraits<${nativeType} > {
829 public: 829 public:
830 static WrapperTypeInfo* info() { return &${v8ClassName}::info; } 830 static WrapperTypeInfo* wrapperTypeInfo() { return &${v8ClassName}::wrapperT ypeInfo; }
831 }; 831 };
832 END 832 END
833 833
834 my $customWrap = NeedsSpecialWrap($interface); 834 my $customWrap = NeedsSpecialWrap($interface);
835 if ($noToV8) { 835 if ($noToV8) {
836 die "Can't suppress toV8 for subclass\n" if $interface->parent; 836 die "Can't suppress toV8 for subclass\n" if $interface->parent;
837 } elsif ($noWrap) { 837 } elsif ($noWrap) {
838 die "Must have custom toV8\n" if !$customWrap; 838 die "Must have custom toV8\n" if !$customWrap;
839 $header{nameSpaceWebCore}->add(<<END); 839 $header{nameSpaceWebCore}->add(<<END);
840 class ${nativeType}; 840 class ${nativeType};
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 sub GenerateDomainSafeFunctionGetter 1143 sub GenerateDomainSafeFunctionGetter
1144 { 1144 {
1145 my $function = shift; 1145 my $function = shift;
1146 my $interface = shift; 1146 my $interface = shift;
1147 1147
1148 my $implClassName = GetImplName($interface); 1148 my $implClassName = GetImplName($interface);
1149 my $v8ClassName = GetV8ClassName($interface); 1149 my $v8ClassName = GetV8ClassName($interface);
1150 my $funcName = $function->name; 1150 my $funcName = $function->name;
1151 1151
1152 my $functionLength = GetFunctionLength($function); 1152 my $functionLength = GetFunctionLength($function);
1153 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8ClassName . "::info, currentWorldType))"; 1153 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8ClassName . "::wrapperTypeInfo, currentWorldType))";
1154 if ($function->extendedAttributes->{"DoNotCheckSignature"}) { 1154 if ($function->extendedAttributes->{"DoNotCheckSignature"}) {
1155 $signature = "v8::Local<v8::Signature>()"; 1155 $signature = "v8::Local<v8::Signature>()";
1156 } 1156 }
1157 1157
1158 my $newTemplateParams = "${implClassName}V8Internal::${funcName}MethodCallba ck, v8Undefined(), $signature"; 1158 my $newTemplateParams = "${implClassName}V8Internal::${funcName}MethodCallba ck, v8Undefined(), $signature";
1159 1159
1160 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1160 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1161 $implementation{nameSpaceInternal}->add(<<END); 1161 $implementation{nameSpaceInternal}->add(<<END);
1162 static void ${funcName}AttributeGetter(v8::Local<v8::String> name, const v8::Pro pertyCallbackInfo<v8::Value>& info) 1162 static void ${funcName}AttributeGetter(v8::Local<v8::String> name, const v8::Pro pertyCallbackInfo<v8::Value>& info)
1163 { 1163 {
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n"; 2666 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n";
2667 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2667 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2668 2668
2669 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2669 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2670 $code .= " if (es.throwIfNeeded())\n"; 2670 $code .= " if (es.throwIfNeeded())\n";
2671 $code .= " return;\n"; 2671 $code .= " return;\n";
2672 } 2672 }
2673 2673
2674 $code .= <<END; 2674 $code .= <<END;
2675 2675
2676 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent) ; 2676 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}::wrapperTypeInfo, wrapper, args.GetIsolate(), WrapperConfiguration: :Dependent);
2677 args.GetReturnValue().Set(wrapper); 2677 args.GetReturnValue().Set(wrapper);
2678 } 2678 }
2679 2679
2680 END 2680 END
2681 $implementation{nameSpaceInternal}->add($code); 2681 $implementation{nameSpaceInternal}->add($code);
2682 } 2682 }
2683 2683
2684 # The Web IDL specification states that Interface objects for interfaces MUST ha ve a property named 2684 # The Web IDL specification states that Interface objects for interfaces MUST ha ve a property named
2685 # "length" that returns the length of the shortest argument list of the entries in the effective 2685 # "length" that returns the length of the shortest argument list of the entries in the effective
2686 # overload set for constructors. In other words, use the lowest number of mandat ory arguments among 2686 # overload set for constructors. In other words, use the lowest number of mandat ory arguments among
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2809 $implementation{nameSpaceInternal}->add(<<END); 2809 $implementation{nameSpaceInternal}->add(<<END);
2810 if (!${attrName}.IsEmpty()) 2810 if (!${attrName}.IsEmpty())
2811 event->${setter}(SerializedScriptValue::createAndSwallowExceptions($ {attrName}, args.GetIsolate())); 2811 event->${setter}(SerializedScriptValue::createAndSwallowExceptions($ {attrName}, args.GetIsolate()));
2812 END 2812 END
2813 } 2813 }
2814 $implementation{nameSpaceInternal}->add(" }\n\n"); 2814 $implementation{nameSpaceInternal}->add(" }\n\n");
2815 } 2815 }
2816 2816
2817 $implementation{nameSpaceInternal}->add(<<END); 2817 $implementation{nameSpaceInternal}->add(<<END);
2818 v8::Handle<v8::Object> wrapper = args.Holder(); 2818 v8::Handle<v8::Object> wrapper = args.Holder();
2819 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$ {v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent ); 2819 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$ {v8ClassName}::wrapperTypeInfo, wrapper, args.GetIsolate(), WrapperConfiguration ::Dependent);
2820 v8SetReturnValue(args, wrapper); 2820 v8SetReturnValue(args, wrapper);
2821 } 2821 }
2822 END 2822 END
2823 2823
2824 my $code = ""; 2824 my $code = "";
2825 $code .= <<END; 2825 $code .= <<END;
2826 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options) 2826 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options)
2827 { 2827 {
2828 END 2828 END
2829 2829
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2883 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { 2883 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) {
2884 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject"; 2884 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject";
2885 } 2885 }
2886 2886
2887 my $toEventTarget = "0"; 2887 my $toEventTarget = "0";
2888 if (InheritsInterface($interface, "EventTarget")) { 2888 if (InheritsInterface($interface, "EventTarget")) {
2889 $toEventTarget = "${v8ClassName}::toEventTarget"; 2889 $toEventTarget = "${v8ClassName}::toEventTarget";
2890 } 2890 }
2891 2891
2892 $implementation{nameSpaceWebCore}->add(<<END); 2892 $implementation{nameSpaceWebCore}->add(<<END);
2893 WrapperTypeInfo ${v8ClassName}Constructor::info = { ${v8ClassName}Constructor::G etTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, 0, ${v8ClassName}::installPerContextEnabledPrototypeProperties, 0, WrapperTypeObjec tPrototype }; 2893 WrapperTypeInfo ${v8ClassName}Constructor::wrapperTypeInfo = { ${v8ClassName}Con structor::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEvent Target, 0, ${v8ClassName}::installPerContextEnabledPrototypeProperties, 0, Wrapp erTypeObjectPrototype };
2894 2894
2895 END 2895 END
2896 2896
2897 my $code = ""; 2897 my $code = "";
2898 $code .= <<END; 2898 $code .= <<END;
2899 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args) 2899 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args)
2900 { 2900 {
2901 END 2901 END
2902 $code .= $maybeObserveFeature if $maybeObserveFeature; 2902 $code .= $maybeObserveFeature if $maybeObserveFeature;
2903 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; 2903 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; 2947 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n";
2948 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2948 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2949 2949
2950 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2950 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2951 $code .= " if (es.throwIfNeeded())\n"; 2951 $code .= " if (es.throwIfNeeded())\n";
2952 $code .= " return;\n"; 2952 $code .= " return;\n";
2953 } 2953 }
2954 2954
2955 $code .= <<END; 2955 $code .= <<END;
2956 2956
2957 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::info, wrapper, args.GetIsolate(), WrapperConfiguration: :Dependent); 2957 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::wrapperTypeInfo, wrapper, args.GetIsolate(), WrapperCon figuration::Dependent);
2958 args.GetReturnValue().Set(wrapper); 2958 args.GetReturnValue().Set(wrapper);
2959 } 2959 }
2960 2960
2961 END 2961 END
2962 $implementation{nameSpaceWebCore}->add($code); 2962 $implementation{nameSpaceWebCore}->add($code);
2963 2963
2964 $code = <<END; 2964 $code = <<END;
2965 v8::Handle<v8::FunctionTemplate> ${v8ClassName}Constructor::GetTemplate(v8::Isol ate* isolate, WrapperWorldType currentWorldType) 2965 v8::Handle<v8::FunctionTemplate> ${v8ClassName}Constructor::GetTemplate(v8::Isol ate* isolate, WrapperWorldType currentWorldType)
2966 { 2966 {
2967 // This is only for getting a unique pointer which we can pass to privateTem plate. 2967 // This is only for getting a unique pointer which we can pass to privateTem plate.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3084 # Constructor 3084 # Constructor
3085 if ($isConstructor) { 3085 if ($isConstructor) {
3086 my $constructorType = $attribute->type; 3086 my $constructorType = $attribute->type;
3087 $constructorType =~ s/Constructor$//; 3087 $constructorType =~ s/Constructor$//;
3088 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct or. 3088 # $constructorType ~= /Constructor$/ indicates that it is NamedConstruct or.
3089 # We do not generate the header file for NamedConstructor of class XXXX, 3089 # We do not generate the header file for NamedConstructor of class XXXX,
3090 # since we generate the NamedConstructor declaration into the header fil e of class XXXX. 3090 # since we generate the NamedConstructor declaration into the header fil e of class XXXX.
3091 if ($constructorType !~ /Constructor$/ || $attribute->extendedAttributes ->{"CustomConstructor"}) { 3091 if ($constructorType !~ /Constructor$/ || $attribute->extendedAttributes ->{"CustomConstructor"}) {
3092 AddToImplIncludes("V8${constructorType}.h"); 3092 AddToImplIncludes("V8${constructorType}.h");
3093 } 3093 }
3094 $data = "&V8${constructorType}::info"; 3094 $data = "&V8${constructorType}::wrapperTypeInfo";
3095 $getter = "${implClassName}V8Internal::${implClassName}ConstructorGetter "; 3095 $getter = "${implClassName}V8Internal::${implClassName}ConstructorGetter ";
3096 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAttrib uteSetterCallback"; 3096 $setter = "${implClassName}V8Internal::${implClassName}ReplaceableAttrib uteSetterCallback";
3097 $getterForMainWorld = "0"; 3097 $getterForMainWorld = "0";
3098 $setterForMainWorld = "0"; 3098 $setterForMainWorld = "0";
3099 } else { 3099 } else {
3100 # Default Getter and Setter 3100 # Default Getter and Setter
3101 $getter = "${implClassName}V8Internal::${attrName}AttributeGetterCallbac k"; 3101 $getter = "${implClassName}V8Internal::${attrName}AttributeGetterCallbac k";
3102 $setter = "${implClassName}V8Internal::${attrName}AttributeSetterCallbac k"; 3102 $setter = "${implClassName}V8Internal::${attrName}AttributeSetterCallbac k";
3103 $getterForMainWorld = "${getter}ForMainWorld"; 3103 $getterForMainWorld = "${getter}ForMainWorld";
3104 $setterForMainWorld = "${setter}ForMainWorld"; 3104 $setterForMainWorld = "${setter}ForMainWorld";
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
4000 # Find the super descriptor. 4000 # Find the super descriptor.
4001 my $parentClass = ""; 4001 my $parentClass = "";
4002 my $parentClassTemplate = ""; 4002 my $parentClassTemplate = "";
4003 if ($interface->parent) { 4003 if ($interface->parent) {
4004 my $parent = $interface->parent; 4004 my $parent = $interface->parent;
4005 AddToImplIncludes("V8${parent}.h"); 4005 AddToImplIncludes("V8${parent}.h");
4006 $parentClass = "V8" . $parent; 4006 $parentClass = "V8" . $parent;
4007 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)"; 4007 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)";
4008 } 4008 }
4009 4009
4010 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; 4010 my $parentClassInfo = $parentClass ? "&${parentClass}::wrapperTypeInfo" : "0 ";
4011 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot ype" : "WrapperTypeObjectPrototype"; 4011 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot ype" : "WrapperTypeObjectPrototype";
4012 4012
4013 if (!IsSVGTypeNeedingTearOff($interfaceName)) { 4013 if (!IsSVGTypeNeedingTearOff($interfaceName)) {
4014 my $code = <<END; 4014 my $code = <<END;
4015 static void initializeScriptWrappableForInterface(${implClassName}* object) 4015 static void initializeScriptWrappableForInterface(${implClassName}* object)
4016 { 4016 {
4017 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 4017 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
4018 ScriptWrappable::setTypeInfoInObject(object, &${v8ClassName}::info); 4018 ScriptWrappable::setTypeInfoInObject(object, &${v8ClassName}::wrapperTyp eInfo);
4019 else 4019 else
4020 ASSERT_NOT_REACHED(); 4020 ASSERT_NOT_REACHED();
4021 } 4021 }
4022 4022
4023 } // namespace WebCore 4023 } // namespace WebCore
4024 4024
4025 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows: 4025 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows:
4026 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function 4026 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
4027 // in the global namespace. 4027 // in the global namespace.
4028 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c) 4028 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c)
4029 END 4029 END
4030 4030
4031 if (GetNamespaceForInterface($interface) eq "WebCore") { 4031 if (GetNamespaceForInterface($interface) eq "WebCore") {
4032 $code .= "void webCoreInitializeScriptWrappableForInterface(WebCore::${i mplClassName}* object)\n"; 4032 $code .= "void webCoreInitializeScriptWrappableForInterface(WebCore::${i mplClassName}* object)\n";
4033 } else { 4033 } else {
4034 $code .= "void webCoreInitializeScriptWrappableForInterface(${implClassN ame}* object)\n"; 4034 $code .= "void webCoreInitializeScriptWrappableForInterface(${implClassN ame}* object)\n";
4035 } 4035 }
4036 4036
4037 $code .= <<END; 4037 $code .= <<END;
4038 { 4038 {
4039 WebCore::initializeScriptWrappableForInterface(object); 4039 WebCore::initializeScriptWrappableForInterface(object);
4040 } 4040 }
4041 4041
4042 namespace WebCore { 4042 namespace WebCore {
4043 END 4043 END
4044 $implementation{nameSpaceWebCore}->addHeader($code); 4044 $implementation{nameSpaceWebCore}->addHeader($code);
4045 } 4045 }
4046 4046
4047 my $code = "WrapperTypeInfo ${v8ClassName}::info = { ${v8ClassName}::GetTemp late, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, "; 4047 my $code = "WrapperTypeInfo ${v8ClassName}::wrapperTypeInfo = { ${v8ClassNam e}::GetTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget , ";
4048 $code .= "$rootForGC, ${v8ClassName}::installPerContextEnabledPrototypePrope rties, $parentClassInfo, $WrapperTypePrototype };\n"; 4048 $code .= "$rootForGC, ${v8ClassName}::installPerContextEnabledPrototypePrope rties, $parentClassInfo, $WrapperTypePrototype };\n";
4049 $implementation{nameSpaceWebCore}->addHeader($code); 4049 $implementation{nameSpaceWebCore}->addHeader($code);
4050 4050
4051 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n"); 4051 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n");
4052 4052
4053 my $hasConstructors = 0; 4053 my $hasConstructors = 0;
4054 my $hasReplaceable = 0; 4054 my $hasReplaceable = 0;
4055 4055
4056 # Generate property accessors for attributes. 4056 # Generate property accessors for attributes.
4057 for (my $index = 0; $index < @{$interface->attributes}; $index++) { 4057 for (my $index = 0; $index < @{$interface->attributes}; $index++) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
4263 } elsif (IsConstructorTemplate($interface, "Event")) { 4263 } elsif (IsConstructorTemplate($interface, "Event")) {
4264 GenerateEventConstructor($interface); 4264 GenerateEventConstructor($interface);
4265 } 4265 }
4266 } 4266 }
4267 if (IsConstructable($interface)) { 4267 if (IsConstructable($interface)) {
4268 GenerateConstructorCallback($interface); 4268 GenerateConstructorCallback($interface);
4269 } 4269 }
4270 4270
4271 my $access_check = ""; 4271 my $access_check = "";
4272 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne " Window") { 4272 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne " Window") {
4273 $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Int ernal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8: :External::New(&${v8ClassName}::info));"; 4273 $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Int ernal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8: :External::New(&${v8ClassName}::wrapperTypeInfo));";
4274 } 4274 }
4275 4275
4276 # For the Window interface, generate the shadow object template 4276 # For the Window interface, generate the shadow object template
4277 # configuration method. 4277 # configuration method.
4278 if ($interfaceName eq "Window") { 4278 if ($interfaceName eq "Window") {
4279 $implementation{nameSpaceWebCore}->add(<<END); 4279 $implementation{nameSpaceWebCore}->add(<<END);
4280 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ, v8::Isolate* isolate, WrapperWorldType currentWorldType) 4280 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ, v8::Isolate* isolate, WrapperWorldType currentWorldType)
4281 { 4281 {
4282 V8DOMConfiguration::installAttributes(templ, v8::Handle<v8::ObjectTemplate>( ), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes), isolate, currentWorldTy pe); 4282 V8DOMConfiguration::installAttributes(templ, v8::Handle<v8::ObjectTemplate>( ), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes), isolate, currentWorldTy pe);
4283 4283
4284 // Install a security handler with V8. 4284 // Install a security handler with V8.
4285 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window: :indexedSecurityCheckCustom, v8::External::New(&V8Window::info)); 4285 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window: :indexedSecurityCheckCustom, v8::External::New(&V8Window::wrapperTypeInfo));
4286 templ->SetInternalFieldCount(V8Window::internalFieldCount); 4286 templ->SetInternalFieldCount(V8Window::internalFieldCount);
4287 } 4287 }
4288 END 4288 END
4289 } 4289 }
4290 4290
4291 if (!$parentClassTemplate) { 4291 if (!$parentClassTemplate) {
4292 $parentClassTemplate = "v8::Local<v8::FunctionTemplate>()"; 4292 $parentClassTemplate = "v8::Local<v8::FunctionTemplate>()";
4293 } 4293 }
4294 4294
4295 # Generate the template configuration method 4295 # Generate the template configuration method
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
4438 # Special cases 4438 # Special cases
4439 if ($interfaceName eq "Window") { 4439 if ($interfaceName eq "Window") {
4440 $code .= <<END; 4440 $code .= <<END;
4441 4441
4442 proto->SetInternalFieldCount(V8Window::internalFieldCount); 4442 proto->SetInternalFieldCount(V8Window::internalFieldCount);
4443 desc->SetHiddenPrototype(true); 4443 desc->SetHiddenPrototype(true);
4444 instance->SetInternalFieldCount(V8Window::internalFieldCount); 4444 instance->SetInternalFieldCount(V8Window::internalFieldCount);
4445 // Set access check callbacks, but turned off initially. 4445 // Set access check callbacks, but turned off initially.
4446 // When a context is detached from a frame, turn on the access check. 4446 // When a context is detached from a frame, turn on the access check.
4447 // Turning on checks also invalidates inline caches of the object. 4447 // Turning on checks also invalidates inline caches of the object.
4448 instance->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Wind ow::indexedSecurityCheckCustom, v8::External::New(&V8Window::info), false); 4448 instance->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Wind ow::indexedSecurityCheckCustom, v8::External::New(&V8Window::wrapperTypeInfo), f alse);
4449 END 4449 END
4450 } 4450 }
4451 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerGl obalScope" or $interfaceName eq "SharedWorkerGlobalScope") { 4451 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerGl obalScope" or $interfaceName eq "SharedWorkerGlobalScope") {
4452 $code .= <<END; 4452 $code .= <<END;
4453 desc->SetHiddenPrototype(true); 4453 desc->SetHiddenPrototype(true);
4454 END 4454 END
4455 } 4455 }
4456 4456
4457 $code .= <<END; 4457 $code .= <<END;
4458 4458
4459 // Custom toString template 4459 // Custom toString template
4460 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate()); 4460 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate());
4461 return desc; 4461 return desc;
4462 } 4462 }
4463 4463
4464 END 4464 END
4465 $implementation{nameSpaceWebCore}->add($code); 4465 $implementation{nameSpaceWebCore}->add($code);
4466 4466
4467 $implementation{nameSpaceWebCore}->add(<<END); 4467 $implementation{nameSpaceWebCore}->add(<<END);
4468 v8::Handle<v8::FunctionTemplate> ${v8ClassName}::GetTemplate(v8::Isolate* isolat e, WrapperWorldType currentWorldType) 4468 v8::Handle<v8::FunctionTemplate> ${v8ClassName}::GetTemplate(v8::Isolate* isolat e, WrapperWorldType currentWorldType)
4469 { 4469 {
4470 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 4470 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
4471 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info); 4471 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo);
4472 if (result != data->templateMap(currentWorldType).end()) 4472 if (result != data->templateMap(currentWorldType).end())
4473 return result->value.newLocal(isolate); 4473 return result->value.newLocal(isolate);
4474 4474
4475 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 4475 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
4476 v8::HandleScope handleScope(isolate); 4476 v8::HandleScope handleScope(isolate);
4477 v8::Handle<v8::FunctionTemplate> templ = 4477 v8::Handle<v8::FunctionTemplate> templ =
4478 Configure${v8ClassName}Template(data->rawTemplate(&info, currentWorldTyp e), isolate, currentWorldType); 4478 Configure${v8ClassName}Template(data->rawTemplate(&wrapperTypeInfo, curr entWorldType), isolate, currentWorldType);
4479 data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::Function Template>(isolate, templ)); 4479 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
4480 return handleScope.Close(templ); 4480 return handleScope.Close(templ);
4481 } 4481 }
4482 4482
4483 END 4483 END
4484 $implementation{nameSpaceWebCore}->add(<<END); 4484 $implementation{nameSpaceWebCore}->add(<<END);
4485 bool ${v8ClassName}::HasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso late, WrapperWorldType currentWorldType) 4485 bool ${v8ClassName}::HasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso late, WrapperWorldType currentWorldType)
4486 { 4486 {
4487 return V8PerIsolateData::from(isolate)->hasInstance(&info, jsValue, currentW orldType); 4487 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType);
4488 } 4488 }
4489 4489
4490 END 4490 END
4491 $implementation{nameSpaceWebCore}->add(<<END); 4491 $implementation{nameSpaceWebCore}->add(<<END);
4492 bool ${v8ClassName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Is olate* isolate) 4492 bool ${v8ClassName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Is olate* isolate)
4493 { 4493 {
4494 return V8PerIsolateData::from(isolate)->hasInstance(&info, jsValue, MainWorl d) 4494 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld)
4495 || V8PerIsolateData::from(isolate)->hasInstance(&info, jsValue, Isolated World) 4495 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld)
4496 || V8PerIsolateData::from(isolate)->hasInstance(&info, jsValue, WorkerWo rld); 4496 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld);
4497 } 4497 }
4498 4498
4499 END 4499 END
4500 4500
4501 if (@perContextEnabledAttributes) { 4501 if (@perContextEnabledAttributes) {
4502 my $code = ""; 4502 my $code = "";
4503 $code .= <<END; 4503 $code .= <<END;
4504 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i nstance, ${nativeType}* impl, v8::Isolate* isolate) 4504 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i nstance, ${nativeType}* impl, v8::Isolate* isolate)
4505 { 4505 {
4506 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type()); 4506 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type());
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
4909 } 4909 }
4910 4910
4911 my $code = ""; 4911 my $code = "";
4912 $code .= <<END; 4912 $code .= <<END;
4913 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType } impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 4913 v8::Handle<v8::Object> ${v8ClassName}::createWrapper(${createWrapperArgumentType } impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
4914 { 4914 {
4915 ASSERT(impl); 4915 ASSERT(impl);
4916 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate)); 4916 ASSERT(!DOMDataStore::containsWrapper<${v8ClassName}>(impl.get(), isolate));
4917 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 4917 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
4918 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); 4918 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
4919 // Might be a XXXConstructor::info instead of an XXX::info. These will b oth have 4919 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
4920 // the same object de-ref functions, though, so use that as the basis of the check. 4920 // the same object de-ref functions, though, so use that as the basis of the check.
4921 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction); 4921 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
4922 } 4922 }
4923 4923
4924 END 4924 END
4925 4925
4926 $code .= <<END if ($baseType ne $interfaceName); 4926 $code .= <<END if ($baseType ne $interfaceName);
4927 END 4927 END
4928 4928
4929 if (InheritsInterface($interface, "Document")) { 4929 if (InheritsInterface($interface, "Document")) {
4930 AddToImplIncludes("core/frame/Frame.h"); 4930 AddToImplIncludes("core/frame/Frame.h");
4931 $code .= <<END; 4931 $code .= <<END;
4932 if (Frame* frame = impl->frame()) { 4932 if (Frame* frame = impl->frame()) {
4933 if (frame->script().initializeMainWorld()) { 4933 if (frame->script().initializeMainWorld()) {
4934 // initializeMainWorld may have created a wrapper for the object, re try from the start. 4934 // initializeMainWorld may have created a wrapper for the object, re try from the start.
4935 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<${v8ClassN ame}>(impl.get(), isolate); 4935 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<${v8ClassN ame}>(impl.get(), isolate);
4936 if (!wrapper.IsEmpty()) 4936 if (!wrapper.IsEmpty())
4937 return wrapper; 4937 return wrapper;
4938 } 4938 }
4939 } 4939 }
4940 END 4940 END
4941 } 4941 }
4942 4942
4943 $code .= <<END; 4943 $code .= <<END;
4944 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, toInternalPointer(impl.get()), isolate); 4944 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
4945 if (UNLIKELY(wrapper.IsEmpty())) 4945 if (UNLIKELY(wrapper.IsEmpty()))
4946 return wrapper; 4946 return wrapper;
4947 4947
4948 END 4948 END
4949 if (IsTypedArrayType($interface->name)) { 4949 if (IsTypedArrayType($interface->name)) {
4950 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferCustom.h"); 4950 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferCustom.h");
4951 $code .= <<END; 4951 $code .= <<END;
4952 impl->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserver::i nstance()); 4952 impl->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserver::i nstance());
4953 END 4953 END
4954 } 4954 }
4955 4955
4956 if (InheritsInterface($interface, "AudioBuffer")) { 4956 if (InheritsInterface($interface, "AudioBuffer")) {
4957 AddToImplIncludes("modules/webaudio/AudioBuffer.h"); 4957 AddToImplIncludes("modules/webaudio/AudioBuffer.h");
4958 $code .= <<END; 4958 $code .= <<END;
4959 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) { 4959 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) {
4960 Float32Array* channelData = impl->getChannelData(i); 4960 Float32Array* channelData = impl->getChannelData(i);
4961 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation Observer::instance()); 4961 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation Observer::instance());
4962 } 4962 }
4963 END 4963 END
4964 } 4964 }
4965 4965
4966 4966
4967 $code .= <<END; 4967 $code .= <<END;
4968 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 4968 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
4969 V8DOMWrapper::associateObjectWithWrapper<$v8ClassName>(impl, &info, wrapper, isolate, $wrapperConfiguration); 4969 V8DOMWrapper::associateObjectWithWrapper<$v8ClassName>(impl, &wrapperTypeInf o, wrapper, isolate, $wrapperConfiguration);
4970 return wrapper; 4970 return wrapper;
4971 } 4971 }
4972 4972
4973 END 4973 END
4974 $implementation{nameSpaceWebCore}->add($code); 4974 $implementation{nameSpaceWebCore}->add($code);
4975 } 4975 }
4976 4976
4977 sub GenerateSecurityCheckFunctions 4977 sub GenerateSecurityCheckFunctions
4978 { 4978 {
4979 my $interface = shift; 4979 my $interface = shift;
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
5386 if ($arrayOrSequenceType) { 5386 if ($arrayOrSequenceType) {
5387 if (IsRefPtrType($arrayOrSequenceType)) { 5387 if (IsRefPtrType($arrayOrSequenceType)) {
5388 AddIncludesForType($arrayOrSequenceType); 5388 AddIncludesForType($arrayOrSequenceType);
5389 } else { 5389 } else {
5390 $code .= "v8::Handle<v8::FunctionTemplate>()"; 5390 $code .= "v8::Handle<v8::FunctionTemplate>()";
5391 next; 5391 next;
5392 } 5392 }
5393 } else { 5393 } else {
5394 AddIncludesForType($type); 5394 AddIncludesForType($type);
5395 } 5395 }
5396 $code .= "V8PerIsolateData::from(isolate)->rawTemplate(&V8${type }::info, currentWorldType)"; 5396 $code .= "V8PerIsolateData::from(isolate)->rawTemplate(&V8${type }::wrapperTypeInfo, currentWorldType)";
5397 } 5397 }
5398 } else { 5398 } else {
5399 $code .= "v8::Handle<v8::FunctionTemplate>()"; 5399 $code .= "v8::Handle<v8::FunctionTemplate>()";
5400 } 5400 }
5401 } 5401 }
5402 $code .= " };\n"; 5402 $code .= " };\n";
5403 $code .= " v8::Handle<v8::Signature> ${name}Signature = v8::Signature::Ne w(desc, ${name}Argc, ${name}Argv);\n"; 5403 $code .= " v8::Handle<v8::Signature> ${name}Signature = v8::Signature::Ne w(desc, ${name}Argc, ${name}Argv);\n";
5404 return $code; 5404 return $code;
5405 } 5405 }
5406 5406
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
6196 my $interface = shift; 6196 my $interface = shift;
6197 6197
6198 return 1 if $interface->extendedAttributes->{"CustomToV8"}; 6198 return 1 if $interface->extendedAttributes->{"CustomToV8"};
6199 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; 6199 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"};
6200 return 1 if InheritsInterface($interface, "Document"); 6200 return 1 if InheritsInterface($interface, "Document");
6201 6201
6202 return 0; 6202 return 0;
6203 } 6203 }
6204 6204
6205 1; 6205 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8Float64Array.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698