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

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

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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
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 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 } 1603 }
1604 1604
1605 my $getterString; 1605 my $getterString;
1606 my ($functionName, @arguments) = GetterExpression($interfaceName, $attribute ); 1606 my ($functionName, @arguments) = GetterExpression($interfaceName, $attribute );
1607 push(@arguments, "isNull") if $isNullable; 1607 push(@arguments, "isNull") if $isNullable;
1608 push(@arguments, "exceptionState") if $useExceptions; 1608 push(@arguments, "exceptionState") if $useExceptions;
1609 if ($attribute->extendedAttributes->{"ImplementedBy"}) { 1609 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
1610 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; 1610 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
1611 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ; 1611 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ;
1612 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName)); 1612 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName));
1613 unshift(@arguments, "imp") if !$attribute->isStatic; 1613 if (!$attribute->isStatic) {
1614 $code .= " ASSERT(imp);\n";
1615 unshift(@arguments, "*imp");
1616 }
1614 $functionName = "${implementedByImplName}::${functionName}"; 1617 $functionName = "${implementedByImplName}::${functionName}";
1615 } elsif ($attribute->isStatic) { 1618 } elsif ($attribute->isStatic) {
1616 $functionName = "${implClassName}::${functionName}"; 1619 $functionName = "${implClassName}::${functionName}";
1617 } else { 1620 } else {
1618 $functionName = "imp->${functionName}"; 1621 $functionName = "imp->${functionName}";
1619 } 1622 }
1620 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{"Cal lWith"}, " ", 0); 1623 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{"Cal lWith"}, " ", 0);
1621 $code .= $subCode; 1624 $code .= $subCode;
1622 unshift(@arguments, @$arg); 1625 unshift(@arguments, @$arg);
1623 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; 1626 $getterString = "${functionName}(" . join(", ", @arguments) . ")";
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 END 1763 END
1761 } 1764 }
1762 } elsif ($attribute->type eq "EventHandler") { 1765 } elsif ($attribute->type eq "EventHandler") {
1763 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); 1766 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h");
1764 # FIXME: Pass the main world ID for main-world-only getters. 1767 # FIXME: Pass the main world ID for main-world-only getters.
1765 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri bute); 1768 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri bute);
1766 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; 1769 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
1767 if ($implementedBy) { 1770 if ($implementedBy) {
1768 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); 1771 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy);
1769 $functionName = "${implementedByImplName}::${functionName}"; 1772 $functionName = "${implementedByImplName}::${functionName}";
1770 push(@arguments, "imp"); 1773 $code .= " ASSERT(imp);\n";
1774 push(@arguments, "*imp");
1771 } else { 1775 } else {
1772 $functionName = "imp->${functionName}"; 1776 $functionName = "imp->${functionName}";
1773 } 1777 }
1774 $code .= " EventListener* jsValue = ${functionName}(" . join(", ", @a rguments) . ");\n"; 1778 $code .= " EventListener* jsValue = ${functionName}(" . join(", ", @a rguments) . ");\n";
1775 $code .= " v8SetReturnValue(info, jsValue ? v8::Handle<v8::Value>(V8A bstractEventListener::cast(jsValue)->getListenerObject(imp->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n"; 1779 $code .= " v8SetReturnValue(info, jsValue ? v8::Handle<v8::Value>(V8A bstractEventListener::cast(jsValue)->getListenerObject(imp->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n";
1776 } else { 1780 } else {
1777 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended Attributes, $expression, " ", "", "info.GetIsolate()", "info", "imp", $forMai nWorldSuffix, "return"); 1781 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended Attributes, $expression, " ", "", "info.GetIsolate()", "info", "imp", $forMai nWorldSuffix, "return");
1778 $code .= "${nativeValue}\n"; 1782 $code .= "${nativeValue}\n";
1779 } 1783 }
1780 1784
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; 2115 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
2112 my $implementedByImplName; 2116 my $implementedByImplName;
2113 if ($implementedBy) { 2117 if ($implementedBy) {
2114 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy ); 2118 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy );
2115 } 2119 }
2116 if (!InheritsInterface($interface, "Node")) { 2120 if (!InheritsInterface($interface, "Node")) {
2117 my $attrImplName = GetImplName($attribute); 2121 my $attrImplName = GetImplName($attribute);
2118 my @arguments; 2122 my @arguments;
2119 if ($implementedBy) { 2123 if ($implementedBy) {
2120 $attrImplName = "${implementedByImplName}::${attrImplName}"; 2124 $attrImplName = "${implementedByImplName}::${attrImplName}";
2121 push(@arguments, "imp"); 2125 $code .= " ASSERT(imp);\n";
2126 push(@arguments, "*imp");
2122 } else { 2127 } else {
2123 $attrImplName = "imp->${attrImplName}"; 2128 $attrImplName = "imp->${attrImplName}";
2124 } 2129 }
2125 $code .= " moveEventListenerToNewWrapper(info.Holder(), ${attrImp lName}(" . join(", ", @arguments) . "), jsValue, ${v8ClassName}::eventListenerCa cheIndex, info.GetIsolate());\n"; 2130 $code .= " moveEventListenerToNewWrapper(info.Holder(), ${attrImp lName}(" . join(", ", @arguments) . "), jsValue, ${v8ClassName}::eventListenerCa cheIndex, info.GetIsolate());\n";
2126 } 2131 }
2127 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute); 2132 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute);
2128 if ($implementedBy) { 2133 if ($implementedBy) {
2134 $code .= " ASSERT(imp);\n";
2129 $functionName = "${implementedByImplName}::${functionName}"; 2135 $functionName = "${implementedByImplName}::${functionName}";
2130 push(@arguments, "imp"); 2136 push(@arguments, "*imp");
2131 } else { 2137 } else {
2132 $functionName = "imp->${functionName}"; 2138 $functionName = "imp->${functionName}";
2133 } 2139 }
2134 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalScope" ) and $attribute->name eq "onerror") { 2140 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalScope" ) and $attribute->name eq "onerror") {
2135 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); 2141 AddToImplIncludes("bindings/v8/V8ErrorHandler.h");
2136 push(@arguments, "V8EventListenerList::findOrCreateWrapper<V8ErrorHa ndler>(jsValue, true, info.GetIsolate())"); 2142 push(@arguments, "V8EventListenerList::findOrCreateWrapper<V8ErrorHa ndler>(jsValue, true, info.GetIsolate())");
2137 } else { 2143 } else {
2138 push(@arguments, "V8EventListenerList::getEventListener(jsValue, tru e, ListenerFindOrCreate)"); 2144 push(@arguments, "V8EventListenerList::getEventListener(jsValue, tru e, ListenerFindOrCreate)");
2139 } 2145 }
2140 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; 2146 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n";
2141 } else { 2147 } else {
2142 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute); 2148 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute);
2143 push(@arguments, $expression); 2149 push(@arguments, $expression);
2144 push(@arguments, "exceptionState") if $useExceptions; 2150 push(@arguments, "exceptionState") if $useExceptions;
2145 if ($attribute->extendedAttributes->{"ImplementedBy"}) { 2151 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
2146 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" }; 2152 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" };
2147 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); 2153 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy);
2148 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName)); 2154 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName));
2149 unshift(@arguments, "imp") if !$attribute->isStatic; 2155 if (!$attribute->isStatic) {
2156 $code .= " ASSERT(imp);\n";
2157 unshift(@arguments, "*imp");
2158 }
2150 $functionName = "${implementedByImplName}::${functionName}"; 2159 $functionName = "${implementedByImplName}::${functionName}";
2151 } elsif ($attribute->isStatic) { 2160 } elsif ($attribute->isStatic) {
2152 $functionName = "${implClassName}::${functionName}"; 2161 $functionName = "${implClassName}::${functionName}";
2153 } else { 2162 } else {
2154 $functionName = "imp->${functionName}"; 2163 $functionName = "imp->${functionName}";
2155 } 2164 }
2156 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{ "SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1); 2165 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{ "SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1);
2157 $code .= $subCode; 2166 $code .= $subCode;
2158 unshift(@arguments, @$arg); 2167 unshift(@arguments, @$arg);
2159 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; 2168 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n";
(...skipping 3124 matching lines...) Expand 10 before | Expand all | Expand 10 after
5284 5293
5285 my $index = 0; 5294 my $index = 0;
5286 my $humanFriendlyIndex = $index + 1; 5295 my $humanFriendlyIndex = $index + 1;
5287 5296
5288 my @arguments; 5297 my @arguments;
5289 my $functionName; 5298 my $functionName;
5290 my $implementedBy = $function->extendedAttributes->{"ImplementedBy"}; 5299 my $implementedBy = $function->extendedAttributes->{"ImplementedBy"};
5291 if ($implementedBy) { 5300 if ($implementedBy) {
5292 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ; 5301 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ;
5293 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName)); 5302 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName));
5294 unshift(@arguments, "imp") if !$function->isStatic; 5303 if (!$function->isStatic) {
5304 $code .= " ASSERT(imp);\n";
5305 unshift(@arguments, "*imp");
5306 }
5295 $functionName = "${implementedByImplName}::${name}"; 5307 $functionName = "${implementedByImplName}::${name}";
5296 } elsif ($function->isStatic) { 5308 } elsif ($function->isStatic) {
5297 $functionName = "${implClassName}::${name}"; 5309 $functionName = "${implClassName}::${name}";
5298 } else { 5310 } else {
5299 $functionName = "imp->${name}"; 5311 $functionName = "imp->${name}";
5300 } 5312 }
5301 5313
5302 my $callWith = $function->extendedAttributes->{"CallWith"}; 5314 my $callWith = $function->extendedAttributes->{"CallWith"};
5303 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 1, $func tion); 5315 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 1, $func tion);
5304 $code .= $subCode; 5316 $code .= $subCode;
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
6486 if ($parameter->type eq "SerializedScriptValue") { 6498 if ($parameter->type eq "SerializedScriptValue") {
6487 return 1; 6499 return 1;
6488 } elsif (IsIntegerType($parameter->type)) { 6500 } elsif (IsIntegerType($parameter->type)) {
6489 return 1; 6501 return 1;
6490 } 6502 }
6491 } 6503 }
6492 return 0; 6504 return 0;
6493 } 6505 }
6494 6506
6495 1; 6507 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698