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

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

Issue 14049021: 'length' property is invalid for some DOM bindings functions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 8 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
« no previous file with comments | « LayoutTests/fast/js/function-length-expected.txt ('k') | no next file » | 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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 } 862 }
863 863
864 sub GenerateDomainSafeFunctionGetter 864 sub GenerateDomainSafeFunctionGetter
865 { 865 {
866 my $function = shift; 866 my $function = shift;
867 my $interfaceName = shift; 867 my $interfaceName = shift;
868 868
869 my $v8InterfaceName = "V8" . $interfaceName; 869 my $v8InterfaceName = "V8" . $interfaceName;
870 my $funcName = $function->signature->name; 870 my $funcName = $function->signature->name;
871 871
872 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck ($function);
872 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8InterfaceName . "::info, currentWorldType))"; 873 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8InterfaceName . "::info, currentWorldType))";
873 if ($function->signature->extendedAttributes->{"DoNotCheckSignature"}) { 874 if ($function->signature->extendedAttributes->{"DoNotCheckSignature"}) {
874 $signature = "v8::Local<v8::Signature>()"; 875 $signature = "v8::Local<v8::Signature>()";
875 } 876 }
876 877
877 my $newTemplateParams = "${interfaceName}V8Internal::${funcName}MethodCallba ck, v8Undefined(), $signature"; 878 my $newTemplateParams = "${interfaceName}V8Internal::${funcName}MethodCallba ck, v8Undefined(), $signature";
878 879
879 AddToImplIncludes("Frame.h"); 880 AddToImplIncludes("Frame.h");
880 AddToImplContentInternals(<<END); 881 AddToImplContentInternals(<<END);
881 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, c onst v8::AccessorInfo& info) 882 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, c onst v8::AccessorInfo& info)
882 { 883 {
883 // This is only for getting a unique pointer which we can pass to privateTem plate. 884 // This is only for getting a unique pointer which we can pass to privateTem plate.
884 static const char* privateTemplateUniqueKey = "${funcName}PrivateTemplate"; 885 static const char* privateTemplateUniqueKey = "${funcName}PrivateTemplate";
885 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); 886 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
886 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 887 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
887 v8::Persistent<v8::FunctionTemplate> privateTemplate = data->privateTemplate (currentWorldType, &privateTemplateUniqueKey, $newTemplateParams); 888 v8::Persistent<v8::FunctionTemplate> privateTemplate = data->privateTemplate (currentWorldType, &privateTemplateUniqueKey, $newTemplateParams, $numMandatoryP arams);
888 889
889 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), currentWorldType)); 890 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8InterfaceName}::GetTemplate(info.GetIsolate(), currentWorldType));
890 if (holder.IsEmpty()) { 891 if (holder.IsEmpty()) {
891 // can only reach here by 'object.__proto__.func', and it should passed 892 // can only reach here by 'object.__proto__.func', and it should passed
892 // domain security check already 893 // domain security check already
893 return privateTemplate->GetFunction(); 894 return privateTemplate->GetFunction();
894 } 895 }
895 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); 896 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder);
896 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame(), DoNotReportSecurityError)) { 897 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp ->frame(), DoNotReportSecurityError)) {
897 static const char* sharedTemplateUniqueKey = "${funcName}SharedTemplate" ; 898 static const char* sharedTemplateUniqueKey = "${funcName}SharedTemplate" ;
898 v8::Persistent<v8::FunctionTemplate> sharedTemplate = data->privateTempl ate(currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams); 899 v8::Persistent<v8::FunctionTemplate> sharedTemplate = data->privateTempl ate(currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams, $numMandator yParams);
899 return sharedTemplate->GetFunction(); 900 return sharedTemplate->GetFunction();
900 } 901 }
901 902
902 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(name); 903 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(name);
903 if (!hiddenValue.IsEmpty()) 904 if (!hiddenValue.IsEmpty())
904 return hiddenValue; 905 return hiddenValue;
905 906
906 return privateTemplate->GetFunction(); 907 return privateTemplate->GetFunction();
907 } 908 }
908 909
(...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 if ($property_attributes eq "v8::DontDelete") { 2766 if ($property_attributes eq "v8::DontDelete") {
2766 $property_attributes = ""; 2767 $property_attributes = "";
2767 } else { 2768 } else {
2768 $property_attributes = ", static_cast<v8::PropertyAttribute>($property_a ttributes)"; 2769 $property_attributes = ", static_cast<v8::PropertyAttribute>($property_a ttributes)";
2769 } 2770 }
2770 2771
2771 if ($template eq "proto" && $conditional eq "" && $signature eq "defaultSign ature" && $property_attributes eq "") { 2772 if ($template eq "proto" && $conditional eq "" && $signature eq "defaultSign ature" && $property_attributes eq "") {
2772 die "This shouldn't happen: Intraface '$interfaceName' $commentInfo\n"; 2773 die "This shouldn't happen: Intraface '$interfaceName' $commentInfo\n";
2773 } 2774 }
2774 2775
2776 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck ($function);
2777
2775 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature); 2778 my $conditionalString = $codeGenerator->GenerateConditionalString($function- >signature);
2776 $code .= "#if ${conditionalString}\n" if $conditionalString; 2779 $code .= "#if ${conditionalString}\n" if $conditionalString;
2777 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) { 2780 if ($function->signature->extendedAttributes->{"PerWorldBindings"}) {
2778 $code .= " if (currentWorldType == MainWorld) {\n"; 2781 $code .= " if (currentWorldType == MainWorld) {\n";
2779 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$ name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCall backForMainWorld, v8Undefined(), ${signature})$property_attributes);\n"; 2782 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$ name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCall backForMainWorld, v8Undefined(), ${signature}, $numMandatoryParams)$property_att ributes);\n";
2780 $code .= " } else {\n"; 2783 $code .= " } else {\n";
2781 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$ name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCall back, v8Undefined(), ${signature})$property_attributes);\n"; 2784 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$ name\"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCall back, v8Undefined(), ${signature}, $numMandatoryParams)$property_attributes);\n" ;
2782 $code .= " }\n"; 2785 $code .= " }\n";
2783 } else { 2786 } else {
2784 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$name \"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCallback , v8Undefined(), ${signature})$property_attributes);\n"; 2787 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$name \"), v8::FunctionTemplate::New(${interfaceName}V8Internal::${name}MethodCallback , v8Undefined(), ${signature}, $numMandatoryParams)$property_attributes);\n";
2785 } 2788 }
2786 $code .= "#endif // ${conditionalString}\n" if $conditionalString; 2789 $code .= "#endif // ${conditionalString}\n" if $conditionalString;
2787 return $code; 2790 return $code;
2788 } 2791 }
2789 2792
2790 sub GenerateImplementationIndexedProperty 2793 sub GenerateImplementationIndexedProperty
2791 { 2794 {
2792 my $interface = shift; 2795 my $interface = shift;
2793 my $indexer = shift; 2796 my $indexer = shift;
2794 my $interfaceName = $interface->name; 2797 my $interfaceName = $interface->name;
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
3634 # Setup the enable-by-settings functions if we have them 3637 # Setup the enable-by-settings functions if we have them
3635 $code .= <<END; 3638 $code .= <<END;
3636 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate))); 3639 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate)));
3637 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. 3640 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
3638 3641
3639 ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationCo ntext()); 3642 ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationCo ntext());
3640 END 3643 END
3641 3644
3642 foreach my $runtimeFunc (@enabledPerContextFunctions) { 3645 foreach my $runtimeFunc (@enabledPerContextFunctions) {
3643 my $enableFunction = GetContextEnableFunction($runtimeFunc->signatur e); 3646 my $enableFunction = GetContextEnableFunction($runtimeFunc->signatur e);
3647 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParamet ersCheck($runtimeFunc);
3644 my $conditionalString = $codeGenerator->GenerateConditionalString($r untimeFunc->signature); 3648 my $conditionalString = $codeGenerator->GenerateConditionalString($r untimeFunc->signature);
3645 $code .= "\n#if ${conditionalString}\n" if $conditionalString; 3649 $code .= "\n#if ${conditionalString}\n" if $conditionalString;
3646 $code .= " if (context && context->isDocument() && ${enableFuncti on}(toDocument(context))) {\n"; 3650 $code .= " if (context && context->isDocument() && ${enableFuncti on}(toDocument(context))) {\n";
3647 my $name = $runtimeFunc->signature->name; 3651 my $name = $runtimeFunc->signature->name;
3648 $code .= <<END; 3652 $code .= <<END;
3649 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($ {interfaceName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur e)->GetFunction()); 3653 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($ {interfaceName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur e, $numMandatoryParams)->GetFunction());
3650 END 3654 END
3651 $code .= " }\n"; 3655 $code .= " }\n";
3652 $code .= "#endif // ${conditionalString}\n" if $conditionalString; 3656 $code .= "#endif // ${conditionalString}\n" if $conditionalString;
3653 } 3657 }
3654 3658
3655 $code .= <<END; 3659 $code .= <<END;
3656 } 3660 }
3657 3661
3658 END 3662 END
3659 AddToImplContent($code); 3663 AddToImplContent($code);
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
4861 4865
4862 sub GetPassRefPtrType 4866 sub GetPassRefPtrType
4863 { 4867 {
4864 my $v8InterfaceName = shift; 4868 my $v8InterfaceName = shift;
4865 4869
4866 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; 4870 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : "";
4867 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; 4871 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>";
4868 } 4872 }
4869 4873
4870 1; 4874 1;
OLDNEW
« no previous file with comments | « LayoutTests/fast/js/function-length-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698