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

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

Issue 26547005: IDL compiler: [PerContextEnabled] for getters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Reupload 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/scripts/unstable/v8_attributes.py » ('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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 767
768 if ($interface->name eq "Window") { 768 if ($interface->name eq "Window") {
769 $header{classPublic}->add(<<END); 769 $header{classPublic}->add(<<END);
770 static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v 8::Value> key, v8::AccessType, v8::Local<v8::Value> data); 770 static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v 8::Value> key, v8::AccessType, v8::Local<v8::Value> data);
771 static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data); 771 static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data);
772 END 772 END
773 } 773 }
774 774
775 if (@perContextEnabledAttributes) { 775 if (@perContextEnabledAttributes) {
776 $header{classPublic}->add(<<END); 776 $header{classPublic}->add(<<END);
777 static void installPerContextProperties(v8::Handle<v8::Object>, ${nativeType }*, v8::Isolate*); 777 static void installPerContextEnabledProperties(v8::Handle<v8::Object>, ${nat iveType}*, v8::Isolate*);
778 END 778 END
779 } else { 779 } else {
780 $header{classPublic}->add(<<END); 780 $header{classPublic}->add(<<END);
781 static void installPerContextProperties(v8::Handle<v8::Object>, ${nativeType }*, v8::Isolate*) { } 781 static void installPerContextEnabledProperties(v8::Handle<v8::Object>, ${nat iveType}*, v8::Isolate*) { }
782 END 782 END
783 } 783 }
784 784
785 if (@perContextEnabledFunctions) { 785 if (@perContextEnabledFunctions) {
786 $header{classPublic}->add(<<END); 786 $header{classPublic}->add(<<END);
787 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8: :Isolate*); 787 static void installPerContextEnabledPrototypeProperties(v8::Handle<v8::Objec t>, v8::Isolate*);
788 END 788 END
789 } else { 789 } else {
790 $header{classPublic}->add(<<END); 790 $header{classPublic}->add(<<END);
791 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8: :Isolate*) { } 791 static void installPerContextEnabledPrototypeProperties(v8::Handle<v8::Objec t>, v8::Isolate*) { }
792 END 792 END
793 } 793 }
794 794
795 if ($interfaceName eq "HTMLElement") { 795 if ($interfaceName eq "HTMLElement") {
796 $header{classPublic}->add(<<END); 796 $header{classPublic}->add(<<END);
797 friend v8::Handle<v8::Object> createV8HTMLWrapper(HTMLElement*, v8::Handle<v 8::Object> creationContext, v8::Isolate*); 797 friend v8::Handle<v8::Object> createV8HTMLWrapper(HTMLElement*, v8::Handle<v 8::Object> creationContext, v8::Isolate*);
798 friend v8::Handle<v8::Object> createV8HTMLDirectWrapper(HTMLElement*, v8::Ha ndle<v8::Object> creationContext, v8::Isolate*); 798 friend v8::Handle<v8::Object> createV8HTMLDirectWrapper(HTMLElement*, v8::Ha ndle<v8::Object> creationContext, v8::Isolate*);
799 END 799 END
800 } elsif ($interfaceName eq "SVGElement") { 800 } elsif ($interfaceName eq "SVGElement") {
801 $header{classPublic}->add(<<END); 801 $header{classPublic}->add(<<END);
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { 2891 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) {
2892 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject"; 2892 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject";
2893 } 2893 }
2894 2894
2895 my $toEventTarget = "0"; 2895 my $toEventTarget = "0";
2896 if (InheritsInterface($interface, "EventTarget")) { 2896 if (InheritsInterface($interface, "EventTarget")) {
2897 $toEventTarget = "${v8ClassName}::toEventTarget"; 2897 $toEventTarget = "${v8ClassName}::toEventTarget";
2898 } 2898 }
2899 2899
2900 $implementation{nameSpaceWebCore}->add(<<END); 2900 $implementation{nameSpaceWebCore}->add(<<END);
2901 WrapperTypeInfo ${v8ClassName}Constructor::info = { ${v8ClassName}Constructor::G etTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, 0, ${v8ClassName}::installPerContextPrototypeProperties, 0, WrapperTypeObjectProtot ype }; 2901 WrapperTypeInfo ${v8ClassName}Constructor::info = { ${v8ClassName}Constructor::G etTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, 0, ${v8ClassName}::installPerContextEnabledPrototypeProperties, 0, WrapperTypeObjec tPrototype };
2902 2902
2903 END 2903 END
2904 2904
2905 my $code = ""; 2905 my $code = "";
2906 $code .= <<END; 2906 $code .= <<END;
2907 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args) 2907 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args)
2908 { 2908 {
2909 END 2909 END
2910 $code .= $maybeObserveFeature if $maybeObserveFeature; 2910 $code .= $maybeObserveFeature if $maybeObserveFeature;
2911 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; 2911 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature;
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4045 { 4045 {
4046 WebCore::initializeScriptWrappableForInterface(object); 4046 WebCore::initializeScriptWrappableForInterface(object);
4047 } 4047 }
4048 4048
4049 namespace WebCore { 4049 namespace WebCore {
4050 END 4050 END
4051 $implementation{nameSpaceWebCore}->addHeader($code); 4051 $implementation{nameSpaceWebCore}->addHeader($code);
4052 } 4052 }
4053 4053
4054 my $code = "WrapperTypeInfo ${v8ClassName}::info = { ${v8ClassName}::GetTemp late, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, "; 4054 my $code = "WrapperTypeInfo ${v8ClassName}::info = { ${v8ClassName}::GetTemp late, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, ";
4055 $code .= "$rootForGC, ${v8ClassName}::installPerContextPrototypeProperties, $parentClassInfo, $WrapperTypePrototype };\n"; 4055 $code .= "$rootForGC, ${v8ClassName}::installPerContextEnabledPrototypePrope rties, $parentClassInfo, $WrapperTypePrototype };\n";
4056 $implementation{nameSpaceWebCore}->addHeader($code); 4056 $implementation{nameSpaceWebCore}->addHeader($code);
4057 4057
4058 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n"); 4058 $implementation{nameSpaceInternal}->add("template <typename T> void V8_USE(T ) { }\n\n");
4059 4059
4060 my $hasConstructors = 0; 4060 my $hasConstructors = 0;
4061 my $hasReplaceable = 0; 4061 my $hasReplaceable = 0;
4062 4062
4063 # Generate property accessors for attributes. 4063 # Generate property accessors for attributes.
4064 for (my $index = 0; $index < @{$interface->attributes}; $index++) { 4064 for (my $index = 0; $index < @{$interface->attributes}; $index++) {
4065 my $attribute = @{$interface->attributes}[$index]; 4065 my $attribute = @{$interface->attributes}[$index];
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4189 my @runtimeEnabledAttributes; 4189 my @runtimeEnabledAttributes;
4190 my @perContextEnabledAttributes; 4190 my @perContextEnabledAttributes;
4191 my @normalAttributes; 4191 my @normalAttributes;
4192 my @staticAttributes; 4192 my @staticAttributes;
4193 foreach my $attribute (@$attributes) { 4193 foreach my $attribute (@$attributes) {
4194 4194
4195 if ($attribute->isStatic) { 4195 if ($attribute->isStatic) {
4196 push(@staticAttributes, $attribute); 4196 push(@staticAttributes, $attribute);
4197 } elsif ($interfaceName eq "Window" && $attribute->extendedAttributes->{ "Unforgeable"}) { 4197 } elsif ($interfaceName eq "Window" && $attribute->extendedAttributes->{ "Unforgeable"}) {
4198 push(@disallowsShadowing, $attribute); 4198 push(@disallowsShadowing, $attribute);
4199 } elsif ($attribute->extendedAttributes->{"RuntimeEnabled"} || $attribut e->extendedAttributes->{"PerContextEnabled"}) { 4199 } elsif ($attribute->extendedAttributes->{"PerContextEnabled"}) {
4200 if ($attribute->extendedAttributes->{"PerContextEnabled"}) { 4200 push(@perContextEnabledAttributes, $attribute);
4201 push(@perContextEnabledAttributes, $attribute); 4201 } elsif ($attribute->extendedAttributes->{"RuntimeEnabled"}) {
4202 } 4202 push(@runtimeEnabledAttributes, $attribute);
4203 if ($attribute->extendedAttributes->{"RuntimeEnabled"}) {
4204 push(@runtimeEnabledAttributes, $attribute);
4205 }
4206 } else { 4203 } else {
4207 push(@normalAttributes, $attribute); 4204 push(@normalAttributes, $attribute);
4208 } 4205 }
4209 } 4206 }
4210 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h"); 4207 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h");
4211 # Put the attributes that disallow shadowing on the shadow object. 4208 # Put the attributes that disallow shadowing on the shadow object.
4212 if (@disallowsShadowing) { 4209 if (@disallowsShadowing) {
4213 my $code = ""; 4210 my $code = "";
4214 $code .= "static const V8DOMConfiguration::AttributeConfiguration shadow Attributes[] = {\n"; 4211 $code .= "static const V8DOMConfiguration::AttributeConfiguration shadow Attributes[] = {\n";
4215 $code .= GenerateAttributeConfigurationArray($interface, \@disallowsShad owing); 4212 $code .= GenerateAttributeConfigurationArray($interface, \@disallowsShad owing);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4359 UNUSED_PARAM(proto); 4356 UNUSED_PARAM(proto);
4360 END 4357 END
4361 } 4358 }
4362 4359
4363 if ($access_check) { 4360 if ($access_check) {
4364 $code .= " $access_check\n"; 4361 $code .= " $access_check\n";
4365 } 4362 }
4366 4363
4367 # Setup the enable-at-runtime attributes if we have them 4364 # Setup the enable-at-runtime attributes if we have them
4368 foreach my $runtime_attr (@runtimeEnabledAttributes) { 4365 foreach my $runtime_attr (@runtimeEnabledAttributes) {
4369 next if grep { $_ eq $runtime_attr } @perContextEnabledAttributes;
4370 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtime_attr ); 4366 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtime_attr );
4371 my $conditionalString = GenerateConditionalString($runtime_attr); 4367 my $conditionalString = GenerateConditionalString($runtime_attr);
4372 $code .= "#if ${conditionalString}\n" if $conditionalString; 4368 $code .= "#if ${conditionalString}\n" if $conditionalString;
4373 $code .= " if (${runtimeEnabledFunction}()) {\n"; 4369 $code .= " if (${runtimeEnabledFunction}()) {\n";
4374 $code .= " static const V8DOMConfiguration::AttributeConfiguratio n attributeConfiguration =\\\n"; 4370 $code .= " static const V8DOMConfiguration::AttributeConfiguratio n attributeConfiguration =\\\n";
4375 $code .= GenerateAttributeConfiguration($interface, $runtime_attr, ";", " "); 4371 $code .= GenerateAttributeConfiguration($interface, $runtime_attr, ";", " ");
4376 $code .= <<END; 4372 $code .= <<END;
4377 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura tion, isolate, currentWorldType); 4373 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura tion, isolate, currentWorldType);
4378 } 4374 }
4379 END 4375 END
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4503 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) 4499 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld)
4504 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) 4500 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld)
4505 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); 4501 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d);
4506 } 4502 }
4507 4503
4508 END 4504 END
4509 4505
4510 if (@perContextEnabledAttributes) { 4506 if (@perContextEnabledAttributes) {
4511 my $code = ""; 4507 my $code = "";
4512 $code .= <<END; 4508 $code .= <<END;
4513 void ${v8ClassName}::installPerContextProperties(v8::Handle<v8::Object> instance , ${nativeType}* impl, v8::Isolate* isolate) 4509 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i nstance, ${nativeType}* impl, v8::Isolate* isolate)
4514 { 4510 {
4515 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type()); 4511 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type());
4516 END 4512 END
4517 4513
4518 # Setup the enable-by-settings attributes if we have them 4514 # Setup the enable-by-settings attributes if we have them
4519 foreach my $runtimeAttribute (@perContextEnabledAttributes) { 4515 foreach my $perContextEnabledAttribute (@perContextEnabledAttributes) {
4520 my $contextEnabledFunction = GetContextEnabledFunctionName($runtimeA ttribute); 4516 my $contextEnabledFunction = GetContextEnabledFunctionName($perConte xtEnabledAttribute);
4521 my $conditionalString = GenerateConditionalString($runtimeAttribute) ; 4517 $code .= " if (${contextEnabledFunction}(impl->document())) {\n";
4522 $code .= "\n#if ${conditionalString}\n" if $conditionalString;
4523 if (grep { $_ eq $runtimeAttribute } @runtimeEnabledAttributes) {
4524 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runt imeAttribute);
4525 $code .= " if (${contextEnabledFunction}(impl->document()) && ${runtimeEnabledFunction}()) {\n";
4526 } else {
4527 $code .= " if (${contextEnabledFunction}(impl->document())) { \n";
4528 }
4529 4518
4530 $code .= " static const V8DOMConfiguration::AttributeConfigur ation attributeConfiguration =\\\n"; 4519 $code .= " static const V8DOMConfiguration::AttributeConfigur ation attributeConfiguration =\\\n";
4531 $code .= GenerateAttributeConfiguration($interface, $runtimeAttribut e, ";", " "); 4520 $code .= GenerateAttributeConfiguration($interface, $perContextEnabl edAttribute, ";", " ");
4532 $code .= <<END; 4521 $code .= <<END;
4533 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura tion, isolate); 4522 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura tion, isolate);
4534 END 4523 END
4535 $code .= " }\n"; 4524 $code .= " }\n";
4536 $code .= "#endif // ${conditionalString}\n" if $conditionalString;
4537 } 4525 }
4538 $code .= <<END; 4526 $code .= <<END;
4539 } 4527 }
4540 4528
4541 END 4529 END
4542 $implementation{nameSpaceWebCore}->add($code); 4530 $implementation{nameSpaceWebCore}->add($code);
4543 } 4531 }
4544 4532
4545 if (@perContextEnabledFunctions) { 4533 if (@perContextEnabledFunctions) {
4546 my $code = ""; 4534 my $code = "";
4547 $code .= <<END; 4535 $code .= <<END;
4548 void ${v8ClassName}::installPerContextPrototypeProperties(v8::Handle<v8::Object> proto, v8::Isolate* isolate) 4536 void ${v8ClassName}::installPerContextEnabledPrototypeProperties(v8::Handle<v8:: Object> proto, v8::Isolate* isolate)
4549 { 4537 {
4550 UNUSED_PARAM(proto); 4538 UNUSED_PARAM(proto);
4551 END 4539 END
4552 # Setup the enable-by-settings functions if we have them 4540 # Setup the enable-by-settings functions if we have them
4553 $code .= <<END; 4541 $code .= <<END;
4554 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate))); 4542 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate)));
4555 UNUSED_PARAM(defaultSignature); 4543 UNUSED_PARAM(defaultSignature);
4556 4544
4557 ExecutionContext* context = toExecutionContext(proto->CreationContext()); 4545 ExecutionContext* context = toExecutionContext(proto->CreationContext());
4558 END 4546 END
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
4975 $code .= <<END; 4963 $code .= <<END;
4976 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) { 4964 for (unsigned i = 0, n = impl->numberOfChannels(); i < n; i++) {
4977 Float32Array* channelData = impl->getChannelData(i); 4965 Float32Array* channelData = impl->getChannelData(i);
4978 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation Observer::instance()); 4966 channelData->buffer()->setDeallocationObserver(V8ArrayBufferDeallocation Observer::instance());
4979 } 4967 }
4980 END 4968 END
4981 } 4969 }
4982 4970
4983 4971
4984 $code .= <<END; 4972 $code .= <<END;
4985 installPerContextProperties(wrapper, impl.get(), isolate); 4973 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
4986 V8DOMWrapper::associateObjectWithWrapper<$v8ClassName>(impl, &info, wrapper, isolate, $wrapperConfiguration); 4974 V8DOMWrapper::associateObjectWithWrapper<$v8ClassName>(impl, &info, wrapper, isolate, $wrapperConfiguration);
4987 return wrapper; 4975 return wrapper;
4988 } 4976 }
4989 4977
4990 END 4978 END
4991 $implementation{nameSpaceWebCore}->add($code); 4979 $implementation{nameSpaceWebCore}->add($code);
4992 } 4980 }
4993 4981
4994 sub GenerateSecurityCheckFunctions 4982 sub GenerateSecurityCheckFunctions
4995 { 4983 {
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
6219 my $interface = shift; 6207 my $interface = shift;
6220 6208
6221 return 1 if $interface->extendedAttributes->{"CustomToV8"}; 6209 return 1 if $interface->extendedAttributes->{"CustomToV8"};
6222 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; 6210 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"};
6223 return 1 if InheritsInterface($interface, "Document"); 6211 return 1 if InheritsInterface($interface, "Document");
6224 6212
6225 return 0; 6213 return 0;
6226 } 6214 }
6227 6215
6228 1; 6216 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/unstable/v8_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698