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

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

Issue 13877023: Start putting absolute paths in generated files. Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/scripts/CodeGenerator.pm ('k') | Source/bindings/v8/JavaScriptCallFrame.idl » ('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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 $object->GenerateHeader($interface); 87 $object->GenerateHeader($interface);
88 $object->GenerateImplementation($interface); 88 $object->GenerateImplementation($interface);
89 } 89 }
90 } 90 }
91 91
92 sub AddToImplIncludes 92 sub AddToImplIncludes
93 { 93 {
94 my $header = shift; 94 my $header = shift;
95 my $conditional = shift; 95 my $conditional = shift;
96 96
97 if ($header eq "Storage.h") {
98 print caller;
99 print "foo\n";
100 }
101
97 if (not $conditional) { 102 if (not $conditional) {
98 $implIncludes{$header} = 1; 103 $implIncludes{$header} = 1;
99 } elsif (not exists($implIncludes{$header})) { 104 } elsif (not exists($implIncludes{$header})) {
100 $implIncludes{$header} = $conditional; 105 $implIncludes{$header} = $conditional;
101 } else { 106 } else {
102 my $oldValue = $implIncludes{$header}; 107 my $oldValue = $implIncludes{$header};
103 if ($oldValue ne 1) { 108 if ($oldValue ne 1) {
104 my %newValue = (); 109 my %newValue = ();
105 $newValue{$conditional} = 1; 110 $newValue{$conditional} = 1;
106 foreach my $condition (split(/\|/, $oldValue)) { 111 foreach my $condition (split(/\|/, $oldValue)) {
107 $newValue{$condition} = 1; 112 $newValue{$condition} = 1;
108 } 113 }
109 $implIncludes{$header} = join("|", sort keys %newValue); 114 $implIncludes{$header} = join("|", sort keys %newValue);
110 } 115 }
111 } 116 }
112 } 117 }
113 118
119 sub AddInterfaceToImplIncludes
120 {
121 my $interface = shift;
122 my $include = $codeGenerator->HFileForInterface($interface);
123
124 AddToImplIncludes($include);
125 }
126
114 sub AddToHeader 127 sub AddToHeader
115 { 128 {
116 my $code = shift; 129 my $code = shift;
117 push(@headerContent, $code); 130 push(@headerContent, $code);
118 } 131 }
119 132
120 sub AddToImplContentInternals 133 sub AddToImplContentInternals
121 { 134 {
122 my $code = shift; 135 my $code = shift;
123 push(@implContentInternals, $code); 136 push(@implContentInternals, $code);
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 # Event listeners on DOM nodes are explicitly supported in the GC controller . 687 # Event listeners on DOM nodes are explicitly supported in the GC controller .
675 if (!$codeGenerator->InheritsInterface($interface, "Node") && 688 if (!$codeGenerator->InheritsInterface($interface, "Node") &&
676 $codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) { 689 $codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) {
677 push(@customInternalFields, "eventListenerCacheIndex"); 690 push(@customInternalFields, "eventListenerCacheIndex");
678 } 691 }
679 return @customInternalFields; 692 return @customInternalFields;
680 } 693 }
681 694
682 sub GetHeaderClassInclude 695 sub GetHeaderClassInclude
683 { 696 {
684 my $v8InterfaceName = shift; 697 my $interfaceName = shift;
685 if ($v8InterfaceName =~ /SVGPathSeg/) { 698 if ($interfaceName =~ /SVGPathSeg/) {
686 $v8InterfaceName =~ s/Abs|Rel//; 699 $interfaceName =~ s/Abs|Rel//;
700 return "${interfaceName}.h";
687 } 701 }
688 return "wtf/${v8InterfaceName}.h" if $codeGenerator->IsTypedArrayType($v8Int erfaceName); 702 return "wtf/${interfaceName}.h" if $codeGenerator->IsTypedArrayType($interfa ceName);
689 return "" if ($codeGenerator->SkipIncludeHeader($v8InterfaceName)); 703 return "" if ($codeGenerator->SkipIncludeHeader($interfaceName));
690 return "${v8InterfaceName}.h"; 704 return $codeGenerator->HFileForInterface($interfaceName);
691 } 705 }
692 706
693 sub GenerateHeaderCustomInternalFieldIndices 707 sub GenerateHeaderCustomInternalFieldIndices
694 { 708 {
695 my $interface = shift; 709 my $interface = shift;
696 my @customInternalFields = GetInternalFields($interface); 710 my @customInternalFields = GetInternalFields($interface);
697 my $customFieldCounter = 0; 711 my $customFieldCounter = 0;
698 foreach my $customInternalField (@customInternalFields) { 712 foreach my $customInternalField (@customInternalFields) {
699 AddToHeader(<<END); 713 AddToHeader(<<END);
700 static const int ${customInternalField} = v8DefaultWrapperInternalFieldCount + ${customFieldCounter}; 714 static const int ${customInternalField} = v8DefaultWrapperInternalFieldCount + ${customFieldCounter};
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 1171
1158 my $returnType = $attribute->signature->type; 1172 my $returnType = $attribute->signature->type;
1159 my $getterString; 1173 my $getterString;
1160 1174
1161 if ($getterStringUsesImp) { 1175 if ($getterStringUsesImp) {
1162 my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%impl Includes, $interfaceName, $attribute); 1176 my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%impl Includes, $interfaceName, $attribute);
1163 push(@arguments, "isNull") if $isNullable; 1177 push(@arguments, "isNull") if $isNullable;
1164 push(@arguments, "ec") if $useExceptions; 1178 push(@arguments, "ec") if $useExceptions;
1165 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { 1179 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
1166 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp lementedBy"}; 1180 my $implementedBy = $attribute->signature->extendedAttributes->{"Imp lementedBy"};
1167 AddToImplIncludes("${implementedBy}.h"); 1181 AddInterfaceToImplIncludes($implementedBy);
1168 unshift(@arguments, "imp") if !$attribute->isStatic; 1182 unshift(@arguments, "imp") if !$attribute->isStatic;
1169 $functionName = "${implementedBy}::${functionName}"; 1183 $functionName = "${implementedBy}::${functionName}";
1170 } elsif ($attribute->isStatic) { 1184 } elsif ($attribute->isStatic) {
1171 $functionName = "${interfaceName}::${functionName}"; 1185 $functionName = "${interfaceName}::${functionName}";
1172 } else { 1186 } else {
1173 $functionName = "imp->${functionName}"; 1187 $functionName = "imp->${functionName}";
1174 } 1188 }
1175 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extendedAt tributes->{"CallWith"}, " ", 0); 1189 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extendedAt tributes->{"CallWith"}, " ", 0);
1176 $code .= $subCode; 1190 $code .= $subCode;
1177 unshift(@arguments, @$arg); 1191 unshift(@arguments, @$arg);
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate)"; 1595 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate)";
1582 } 1596 }
1583 $code .= ", ec" if $useExceptions; 1597 $code .= ", ec" if $useExceptions;
1584 $code .= ");\n"; 1598 $code .= ");\n";
1585 } else { 1599 } else {
1586 my ($functionName, @arguments) = $codeGenerator->SetterExpression(\% implIncludes, $interfaceName, $attribute); 1600 my ($functionName, @arguments) = $codeGenerator->SetterExpression(\% implIncludes, $interfaceName, $attribute);
1587 push(@arguments, $expression); 1601 push(@arguments, $expression);
1588 push(@arguments, "ec") if $useExceptions; 1602 push(@arguments, "ec") if $useExceptions;
1589 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) { 1603 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
1590 my $implementedBy = $attribute->signature->extendedAttributes->{ "ImplementedBy"}; 1604 my $implementedBy = $attribute->signature->extendedAttributes->{ "ImplementedBy"};
1591 AddToImplIncludes("${implementedBy}.h"); 1605 AddInterfaceToImplIncludes($implementedBy);
1592 unshift(@arguments, "imp") if !$attribute->isStatic; 1606 unshift(@arguments, "imp") if !$attribute->isStatic;
1593 $functionName = "${implementedBy}::${functionName}"; 1607 $functionName = "${implementedBy}::${functionName}";
1594 } elsif ($attribute->isStatic) { 1608 } elsif ($attribute->isStatic) {
1595 $functionName = "${interfaceName}::${functionName}"; 1609 $functionName = "${interfaceName}::${functionName}";
1596 } else { 1610 } else {
1597 $functionName = "imp->${functionName}"; 1611 $functionName = "imp->${functionName}";
1598 } 1612 }
1599 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extend edAttributes->{"CallWith"}, " ", 1); 1613 my ($arg, $subCode) = GenerateCallWith($attribute->signature->extend edAttributes->{"CallWith"}, " ", 1);
1600 $code .= $subCode; 1614 $code .= $subCode;
1601 unshift(@arguments, @$arg); 1615 unshift(@arguments, @$arg);
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 $has_constants = 1; 3355 $has_constants = 1;
3342 $code .= "static const V8DOMConfiguration::BatchedConstant ${v8Interface Name}Consts[] = {\n"; 3356 $code .= "static const V8DOMConfiguration::BatchedConstant ${v8Interface Name}Consts[] = {\n";
3343 } 3357 }
3344 foreach my $constant (@{$interface->constants}) { 3358 foreach my $constant (@{$interface->constants}) {
3345 my $name = $constant->name; 3359 my $name = $constant->name;
3346 my $value = $constant->value; 3360 my $value = $constant->value;
3347 my $attrExt = $constant->extendedAttributes; 3361 my $attrExt = $constant->extendedAttributes;
3348 my $conditional = $attrExt->{"Conditional"}; 3362 my $conditional = $attrExt->{"Conditional"};
3349 my $implementedBy = $attrExt->{"ImplementedBy"}; 3363 my $implementedBy = $attrExt->{"ImplementedBy"};
3350 if ($implementedBy) { 3364 if ($implementedBy) {
3351 AddToImplIncludes("${implementedBy}.h"); 3365 AddInterfaceToImplIncludes($implementedBy);
3352 } 3366 }
3353 if ($attrExt->{"EnabledAtRuntime"}) { 3367 if ($attrExt->{"EnabledAtRuntime"}) {
3354 push(@constantsEnabledAtRuntime, $constant); 3368 push(@constantsEnabledAtRuntime, $constant);
3355 } else { 3369 } else {
3356 if ($conditional) { 3370 if ($conditional) {
3357 my $conditionalString = $codeGenerator->GenerateConditionalStrin gFromAttributeValue($conditional); 3371 my $conditionalString = $codeGenerator->GenerateConditionalStrin gFromAttributeValue($conditional);
3358 $code .= "#if ${conditionalString}\n"; 3372 $code .= "#if ${conditionalString}\n";
3359 } 3373 }
3360 # If the value we're dealing with is a hex number, preprocess it int o a signed integer 3374 # If the value we're dealing with is a hex number, preprocess it int o a signed integer
3361 # here, rather than running static_cast<signed int> in the generated code. 3375 # here, rather than running static_cast<signed int> in the generated code.
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
3779 my $interfaceName = $interface->name; 3793 my $interfaceName = $interface->name;
3780 my $v8InterfaceName = "V8$interfaceName"; 3794 my $v8InterfaceName = "V8$interfaceName";
3781 3795
3782 3796
3783 # - Add default header template 3797 # - Add default header template
3784 AddToHeader(GenerateHeaderContentHeader($interface)); 3798 AddToHeader(GenerateHeaderContentHeader($interface));
3785 3799
3786 my @unsortedIncludes = (); 3800 my @unsortedIncludes = ();
3787 push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\""); 3801 push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\"");
3788 push(@unsortedIncludes, "#include \"DOMWrapperWorld.h\""); 3802 push(@unsortedIncludes, "#include \"DOMWrapperWorld.h\"");
3789 push(@unsortedIncludes, "#include \"$interfaceName.h\""); 3803 my $interfaceHeader = $codeGenerator->HFileForInterface($interfaceName);
3804 push(@unsortedIncludes, "#include \"$interfaceHeader\"");
3790 push(@unsortedIncludes, "#include \"ScopedPersistent.h\""); 3805 push(@unsortedIncludes, "#include \"ScopedPersistent.h\"");
3791 push(@unsortedIncludes, "#include <v8.h>"); 3806 push(@unsortedIncludes, "#include <v8.h>");
3792 push(@unsortedIncludes, "#include <wtf/Forward.h>"); 3807 push(@unsortedIncludes, "#include <wtf/Forward.h>");
3793 AddToHeader(join("\n", sort @unsortedIncludes)); 3808 AddToHeader(join("\n", sort @unsortedIncludes));
3794 3809
3795 AddToHeader("\n\nnamespace WebCore {\n\n"); 3810 AddToHeader("\n\nnamespace WebCore {\n\n");
3796 AddToHeader("class ScriptExecutionContext;\n\n"); 3811 AddToHeader("class ScriptExecutionContext;\n\n");
3797 AddToHeader("class $v8InterfaceName : public $interfaceName, public ActiveDO MCallback {\n"); 3812 AddToHeader("class $v8InterfaceName : public $interfaceName, public ActiveDO MCallback {\n");
3798 3813
3799 AddToHeader(<<END); 3814 AddToHeader(<<END);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
4193 if ($function->signature->extendedAttributes->{"ImplementedAs"}) { 4208 if ($function->signature->extendedAttributes->{"ImplementedAs"}) {
4194 $name = $function->signature->extendedAttributes->{"ImplementedAs"}; 4209 $name = $function->signature->extendedAttributes->{"ImplementedAs"};
4195 } 4210 }
4196 4211
4197 my $index = 0; 4212 my $index = 0;
4198 4213
4199 my @arguments; 4214 my @arguments;
4200 my $functionName; 4215 my $functionName;
4201 my $implementedBy = $function->signature->extendedAttributes->{"ImplementedB y"}; 4216 my $implementedBy = $function->signature->extendedAttributes->{"ImplementedB y"};
4202 if ($implementedBy) { 4217 if ($implementedBy) {
4203 AddToImplIncludes("${implementedBy}.h"); 4218 AddInterfaceToImplIncludes($implementedBy);
4204 unshift(@arguments, "imp") if !$function->isStatic; 4219 unshift(@arguments, "imp") if !$function->isStatic;
4205 $functionName = "${implementedBy}::${name}"; 4220 $functionName = "${implementedBy}::${name}";
4206 } elsif ($function->isStatic) { 4221 } elsif ($function->isStatic) {
4207 $functionName = "${interfaceName}::${name}"; 4222 $functionName = "${interfaceName}::${name}";
4208 } else { 4223 } else {
4209 $functionName = "imp->${name}"; 4224 $functionName = "imp->${name}";
4210 } 4225 }
4211 4226
4212 my $callWith = $function->signature->extendedAttributes->{"CallWith"}; 4227 my $callWith = $function->signature->extendedAttributes->{"CallWith"};
4213 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 0, $func tion); 4228 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 0, $func tion);
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
4878 4893
4879 sub GetPassRefPtrType 4894 sub GetPassRefPtrType
4880 { 4895 {
4881 my $v8InterfaceName = shift; 4896 my $v8InterfaceName = shift;
4882 4897
4883 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : ""; 4898 my $angleBracketSpace = $v8InterfaceName =~ />$/ ? " " : "";
4884 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>"; 4899 return "PassRefPtr<${v8InterfaceName}${angleBracketSpace}>";
4885 } 4900 }
4886 4901
4887 1; 4902 1;
OLDNEW
« no previous file with comments | « Source/bindings/scripts/CodeGenerator.pm ('k') | Source/bindings/v8/JavaScriptCallFrame.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698