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

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

Issue 18398002: Remove IDBNotFoundError ExceptionCode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1414 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1415 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "())) {\n"; 1415 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "())) {\n";
1416 $code .= " v8SetReturnValueNull(info);\n"; 1416 $code .= " v8SetReturnValueNull(info);\n";
1417 $code .= " return;\n"; 1417 $code .= " return;\n";
1418 $code .= " }\n"; 1418 $code .= " }\n";
1419 } 1419 }
1420 1420
1421 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; 1421 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
1422 my $isNullable = $attribute->isNullable; 1422 my $isNullable = $attribute->isNullable;
1423 if ($useExceptions) { 1423 if ($useExceptions) {
1424 AddToImplIncludes("core/dom/ExceptionCode.h"); 1424 AddToImplIncludes("bindings/v8/ExceptionState.h");
1425 $code .= " ExceptionCode ec = 0;\n"; 1425 $code .= " ExceptionState es(info.GetIsolate());\n";
1426 } 1426 }
1427 1427
1428 if ($isNullable) { 1428 if ($isNullable) {
1429 $code .= " bool isNull = false;\n"; 1429 $code .= " bool isNull = false;\n";
1430 } 1430 }
1431 1431
1432 my $returnType = $attribute->type; 1432 my $returnType = $attribute->type;
1433 my $getterString; 1433 my $getterString;
1434 1434
1435 if ($getterStringUsesImp) { 1435 if ($getterStringUsesImp) {
1436 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri bute); 1436 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri bute);
1437 push(@arguments, "isNull") if $isNullable; 1437 push(@arguments, "isNull") if $isNullable;
1438 push(@arguments, "ec") if $useExceptions; 1438 push(@arguments, "es") if $useExceptions;
1439 if ($attribute->extendedAttributes->{"ImplementedBy"}) { 1439 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
1440 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" }; 1440 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" };
1441 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); 1441 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy);
1442 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName)); 1442 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName));
1443 unshift(@arguments, "imp") if !$attribute->isStatic; 1443 unshift(@arguments, "imp") if !$attribute->isStatic;
1444 $functionName = "${implementedByImplName}::${functionName}"; 1444 $functionName = "${implementedByImplName}::${functionName}";
1445 } elsif ($attribute->isStatic) { 1445 } elsif ($attribute->isStatic) {
1446 $functionName = "${implClassName}::${functionName}"; 1446 $functionName = "${implClassName}::${functionName}";
1447 } else { 1447 } else {
1448 $functionName = "imp->${functionName}"; 1448 $functionName = "imp->${functionName}";
(...skipping 20 matching lines...) Expand all
1469 } 1469 }
1470 1470
1471 if ($isNullable) { 1471 if ($isNullable) {
1472 $code .= " if (isNull) {\n"; 1472 $code .= " if (isNull) {\n";
1473 $code .= " v8SetReturnValueNull(info);\n"; 1473 $code .= " v8SetReturnValueNull(info);\n";
1474 $code .= " return;\n"; 1474 $code .= " return;\n";
1475 $code .= " }\n"; 1475 $code .= " }\n";
1476 } 1476 }
1477 1477
1478 if ($useExceptions) { 1478 if ($useExceptions) {
1479 $code .= " if (UNLIKELY(ec)) {\n"; 1479 if ($useExceptions) {
1480 $code .= " setDOMException(ec, info.GetIsolate());\n"; 1480 $code .= " if (UNLIKELY(es.throwIfNeeded()))\n";
1481 $code .= " return;\n"; 1481 $code .= " return;\n";
1482 $code .= " };\n"; 1482 }
1483 1483
1484 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call With"}, "ScriptState")) { 1484 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call With"}, "ScriptState")) {
1485 $code .= " if (state.hadException()) {\n"; 1485 $code .= " if (state.hadException()) {\n";
1486 $code .= " throwError(state.exception(), info.GetIsolate( ));\n"; 1486 $code .= " throwError(state.exception(), info.GetIsolate( ));\n";
1487 $code .= " return;\n"; 1487 $code .= " return;\n";
1488 $code .= " }\n"; 1488 $code .= " }\n";
1489 } 1489 }
1490 } 1490 }
1491 1491
1492 $expression = "v"; 1492 $expression = "v";
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 } 1776 }
1777 1777
1778 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); 1778 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName);
1779 if ($svgNativeType) { 1779 if ($svgNativeType) {
1780 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e); 1780 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e);
1781 if ($svgWrappedNativeType =~ /List$/) { 1781 if ($svgWrappedNativeType =~ /List$/) {
1782 $code .= <<END; 1782 $code .= <<END;
1783 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); 1783 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder());
1784 END 1784 END
1785 } else { 1785 } else {
1786 AddToImplIncludes("core/dom/ExceptionCode.h"); 1786 AddToImplIncludes("bindings/v8/ExceptionState.h");
1787 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf o.Holder());\n"; 1787 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf o.Holder());\n";
1788 $code .= " if (wrapper->isReadOnly()) {\n"; 1788 $code .= " if (wrapper->isReadOnly()) {\n";
1789 $code .= " setDOMException(NoModificationAllowedError, info.G etIsolate());\n"; 1789 $code .= " setDOMException(NoModificationAllowedError, info.G etIsolate());\n";
1790 $code .= " return;\n"; 1790 $code .= " return;\n";
1791 $code .= " }\n"; 1791 $code .= " }\n";
1792 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 1792 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
1793 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 1793 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
1794 } 1794 }
1795 } elsif ($attrExt->{"OnProto"}) { 1795 } elsif ($attrExt->{"OnProto"}) {
1796 $code .= <<END; 1796 $code .= <<END;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 my $returnType = $attribute->type; 1849 my $returnType = $attribute->type;
1850 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) { 1850 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) {
1851 $expression = "WTF::getPtr(" . $expression . ")"; 1851 $expression = "WTF::getPtr(" . $expression . ")";
1852 } 1852 }
1853 1853
1854 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt tributes); 1854 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt tributes);
1855 1855
1856 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; 1856 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
1857 1857
1858 if ($useExceptions) { 1858 if ($useExceptions) {
1859 AddToImplIncludes("core/dom/ExceptionCode.h"); 1859 AddToImplIncludes("bindings/v8/ExceptionState.h");
1860 $code .= " ExceptionCode ec = 0;\n"; 1860 $code .= " ExceptionState es(info.GetIsolate());\n";
1861 } 1861 }
1862 1862
1863 if ($interfaceName eq "SVGNumber") { 1863 if ($interfaceName eq "SVGNumber") {
1864 $code .= " *imp = $expression;\n"; 1864 $code .= " *imp = $expression;\n";
1865 } else { 1865 } else {
1866 if ($attribute->type eq "EventListener") { 1866 if ($attribute->type eq "EventListener") {
1867 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); 1867 my $implSetterFunctionName = FirstLetterToUpperCase($attrName);
1868 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); 1868 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h");
1869 if (!InheritsInterface($interface, "Node")) { 1869 if (!InheritsInterface($interface, "Node")) {
1870 my $attrImplName = GetImplName($attribute); 1870 my $attrImplName = GetImplName($attribute);
1871 $code .= " transferHiddenDependency(info.Holder(), imp->${att rImplName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::e ventListenerCacheIndex, info.GetIsolate());\n"; 1871 $code .= " transferHiddenDependency(info.Holder(), imp->${att rImplName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::e ventListenerCacheIndex, info.GetIsolate());\n";
1872 } 1872 }
1873 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); 1873 AddToImplIncludes("bindings/v8/V8EventListenerList.h");
1874 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalSc ope") and $attribute->name eq "onerror") { 1874 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalSc ope") and $attribute->name eq "onerror") {
1875 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); 1875 AddToImplIncludes("bindings/v8/V8ErrorHandler.h");
1876 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(inf o.GetIsolate()));\n"; 1876 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(inf o.GetIsolate()));\n";
1877 } else { 1877 } else {
1878 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate), isolatedWorldForIsolate( info.GetIsolate()));\n"; 1878 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate), isolatedWorldForIsolate( info.GetIsolate()));\n";
1879 } 1879 }
1880 } else { 1880 } else {
1881 my ($functionName, @arguments) = SetterExpression($interfaceName, $a ttribute); 1881 my ($functionName, @arguments) = SetterExpression($interfaceName, $a ttribute);
1882 push(@arguments, $expression); 1882 push(@arguments, $expression);
1883 push(@arguments, "ec") if $useExceptions; 1883 push(@arguments, "es") if $useExceptions;
1884 if ($attribute->extendedAttributes->{"ImplementedBy"}) { 1884 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
1885 my $implementedBy = $attribute->extendedAttributes->{"Implemente dBy"}; 1885 my $implementedBy = $attribute->extendedAttributes->{"Implemente dBy"};
1886 my $implementedByImplName = GetImplNameFromImplementedBy($implem entedBy); 1886 my $implementedByImplName = GetImplNameFromImplementedBy($implem entedBy);
1887 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple mentedByImplName)); 1887 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple mentedByImplName));
1888 unshift(@arguments, "imp") if !$attribute->isStatic; 1888 unshift(@arguments, "imp") if !$attribute->isStatic;
1889 $functionName = "${implementedByImplName}::${functionName}"; 1889 $functionName = "${implementedByImplName}::${functionName}";
1890 } elsif ($attribute->isStatic) { 1890 } elsif ($attribute->isStatic) {
1891 $functionName = "${implClassName}::${functionName}"; 1891 $functionName = "${implClassName}::${functionName}";
1892 } else { 1892 } else {
1893 $functionName = "imp->${functionName}"; 1893 $functionName = "imp->${functionName}";
1894 } 1894 }
1895 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttribute s->{"SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1 ); 1895 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttribute s->{"SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1 );
1896 $code .= $subCode; 1896 $code .= $subCode;
1897 unshift(@arguments, @$arg); 1897 unshift(@arguments, @$arg);
1898 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; 1898 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n";
1899 } 1899 }
1900 } 1900 }
1901 1901
1902 if ($useExceptions) { 1902 if ($useExceptions) {
1903 $code .= " if (UNLIKELY(ec))\n"; 1903 $code .= " es.throwIfNeeded();\n";
1904 $code .= " setDOMException(ec, info.GetIsolate());\n";
1905 } 1904 }
1906 1905
1907 if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"}, "ScriptState")) { 1906 if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"}, "ScriptState")) {
1908 $code .= " if (state.hadException())\n"; 1907 $code .= " if (state.hadException())\n";
1909 $code .= " throwError(state.exception(), info.GetIsolate());\n"; 1908 $code .= " throwError(state.exception(), info.GetIsolate());\n";
1910 } 1909 }
1911 1910
1912 if ($svgNativeType) { 1911 if ($svgNativeType) {
1913 if ($useExceptions) { 1912 if ($useExceptions) {
1914 $code .= " if (!ec)\n"; 1913 $code .= " if (!es.hadException())\n";
1915 $code .= " wrapper->commitChange();\n"; 1914 $code .= " wrapper->commitChange();\n";
1916 } else { 1915 } else {
1917 $code .= " wrapper->commitChange();\n"; 1916 $code .= " wrapper->commitChange();\n";
1918 } 1917 }
1919 } 1918 }
1920 1919
1921 if ($attribute->type eq "SerializedScriptValue" && $attribute->extendedAttri butes->{"CachedAttribute"}) { 1920 if ($attribute->type eq "SerializedScriptValue" && $attribute->extendedAttri butes->{"CachedAttribute"}) {
1922 $code .= <<END; 1921 $code .= <<END;
1923 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value. 1922 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value.
1924 END 1923 END
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 return; 2170 return;
2172 } 2171 }
2173 2172
2174 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); 2173 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName);
2175 2174
2176 if ($svgNativeType) { 2175 if ($svgNativeType) {
2177 my $nativeClassName = GetNativeType($interfaceName); 2176 my $nativeClassName = GetNativeType($interfaceName);
2178 if ($interfaceName =~ /List$/) { 2177 if ($interfaceName =~ /List$/) {
2179 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(args.H older());\n"; 2178 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(args.H older());\n";
2180 } else { 2179 } else {
2181 AddToImplIncludes("core/dom/ExceptionCode.h"); 2180 AddToImplIncludes("bindings/v8/ExceptionState.h");
2182 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(ar gs.Holder());\n"; 2181 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(ar gs.Holder());\n";
2183 $code .= " if (wrapper->isReadOnly()) {\n"; 2182 $code .= " if (wrapper->isReadOnly()) {\n";
2184 $code .= " setDOMException(NoModificationAllowedError, args.G etIsolate());\n"; 2183 $code .= " setDOMException(NoModificationAllowedError, args.G etIsolate());\n";
2185 $code .= " return;\n"; 2184 $code .= " return;\n";
2186 $code .= " }\n"; 2185 $code .= " }\n";
2187 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName); 2186 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName);
2188 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 2187 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
2189 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 2188 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
2190 } 2189 }
2191 } elsif (!$function->isStatic) { 2190 } elsif (!$function->isStatic) {
(...skipping 18 matching lines...) Expand all
2210 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; 2209 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"};
2211 if (!$raisesExceptions) { 2210 if (!$raisesExceptions) {
2212 foreach my $parameter (@{$function->parameters}) { 2211 foreach my $parameter (@{$function->parameters}) {
2213 if ($parameter->extendedAttributes->{"IsIndex"}) { 2212 if ($parameter->extendedAttributes->{"IsIndex"}) {
2214 $raisesExceptions = 1; 2213 $raisesExceptions = 1;
2215 } 2214 }
2216 } 2215 }
2217 } 2216 }
2218 2217
2219 if ($raisesExceptions) { 2218 if ($raisesExceptions) {
2220 AddToImplIncludes("core/dom/ExceptionCode.h"); 2219 AddToImplIncludes("bindings/v8/ExceptionState.h");
2221 $code .= " ExceptionCode ec = 0;\n"; 2220 $code .= " ExceptionState es(args.GetIsolate());\n";
2222 } 2221 }
2223 2222
2224 if ($function->extendedAttributes->{"CheckSecurityForNode"}) { 2223 if ($function->extendedAttributes->{"CheckSecurityForNode"}) {
2225 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2224 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2226 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(ec))) {\n"; 2225 # FIXME: Change to ExceptionState
2226 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(es))) {\n";
2227 $code .= " v8SetReturnValueNull(args);\n"; 2227 $code .= " v8SetReturnValueNull(args);\n";
2228 $code .= " return;\n"; 2228 $code .= " return;\n";
2229 $code .= " }\n"; 2229 $code .= " }\n";
2230 END 2230 END
2231 } 2231 }
2232 2232
2233 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix); 2233 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix);
2234 $code .= $parameterCheckString; 2234 $code .= $parameterCheckString;
2235 2235
2236 # Build the function call string. 2236 # Build the function call string.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 $parameterCheckString .= $multiLine ? " }\n" : "\n"; 2328 $parameterCheckString .= $multiLine ? " }\n" : "\n";
2329 } 2329 }
2330 2330
2331 my $parameterDefaultPolicy = "DefaultIsUndefined"; 2331 my $parameterDefaultPolicy = "DefaultIsUndefined";
2332 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par ameter->extendedAttributes->{"Default"} : ""; 2332 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par ameter->extendedAttributes->{"Default"} : "";
2333 if ($parameter->isOptional and $default eq "NullString") { 2333 if ($parameter->isOptional and $default eq "NullString") {
2334 $parameterDefaultPolicy = "DefaultIsNullString"; 2334 $parameterDefaultPolicy = "DefaultIsNullString";
2335 } 2335 }
2336 2336
2337 my $parameterName = $parameter->name; 2337 my $parameterName = $parameter->name;
2338 AddToImplIncludes("core/dom/ExceptionCode.h"); 2338 AddToImplIncludes("bindings/v8/ExceptionState.h");
2339 if (IsCallbackInterface($parameter->type)) { 2339 if (IsCallbackInterface($parameter->type)) {
2340 my $v8ClassName = "V8" . $parameter->type; 2340 my $v8ClassName = "V8" . $parameter->type;
2341 AddToImplIncludes("$v8ClassName.h"); 2341 AddToImplIncludes("$v8ClassName.h");
2342 if ($parameter->isOptional) { 2342 if ($parameter->isOptional) {
2343 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n"; 2343 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n";
2344 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; 2344 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n";
2345 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion()) {\n"; 2345 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion()) {\n";
2346 $parameterCheckString .= " throwTypeError(0, args.Get Isolate());\n"; 2346 $parameterCheckString .= " throwTypeError(0, args.Get Isolate());\n";
2347 $parameterCheckString .= " return;\n"; 2347 $parameterCheckString .= " return;\n";
2348 $parameterCheckString .= " }\n"; 2348 $parameterCheckString .= " }\n";
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 $code .= <<END; 2508 $code .= <<END;
2509 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& args) 2509 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& args)
2510 { 2510 {
2511 END 2511 END
2512 2512
2513 if ($function->overloadedIndex == 0) { 2513 if ($function->overloadedIndex == 0) {
2514 $code .= GenerateArgumentsCountCheck($function, $interface); 2514 $code .= GenerateArgumentsCountCheck($function, $interface);
2515 } 2515 }
2516 2516
2517 if ($raisesExceptions) { 2517 if ($raisesExceptions) {
2518 AddToImplIncludes("core/dom/ExceptionCode.h"); 2518 AddToImplIncludes("bindings/v8/ExceptionState.h");
2519 $code .= " ExceptionCode ec = 0;\n"; 2519 $code .= " ExceptionState es(args.GetIsolate());\n";
2520 } 2520 }
2521 2521
2522 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] 2522 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...]
2523 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, ""); 2523 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "");
2524 $code .= $parameterCheckString; 2524 $code .= $parameterCheckString;
2525 2525
2526 if ($interface->extendedAttributes->{"ConstructorCallWith"} && $interface->e xtendedAttributes->{"ConstructorCallWith"} eq "ScriptExecutionContext") { 2526 if ($interface->extendedAttributes->{"ConstructorCallWith"} && $interface->e xtendedAttributes->{"ConstructorCallWith"} eq "ScriptExecutionContext") {
2527 push(@beforeArgumentList, "context"); 2527 push(@beforeArgumentList, "context");
2528 $code .= <<END; 2528 $code .= <<END;
2529 2529
2530 ScriptExecutionContext* context = getScriptExecutionContext(); 2530 ScriptExecutionContext* context = getScriptExecutionContext();
2531 END 2531 END
2532 } 2532 }
2533 2533
2534 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2534 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2535 push(@afterArgumentList, "ec"); 2535 push(@afterArgumentList, "es");
2536 } 2536 }
2537 2537
2538 my @argumentList; 2538 my @argumentList;
2539 my $index = 0; 2539 my $index = 0;
2540 foreach my $parameter (@{$function->parameters}) { 2540 foreach my $parameter (@{$function->parameters}) {
2541 last if $index eq $paramIndex; 2541 last if $index eq $paramIndex;
2542 if ($replacements{$parameter->name}) { 2542 if ($replacements{$parameter->name}) {
2543 push(@argumentList, $replacements{$parameter->name}); 2543 push(@argumentList, $replacements{$parameter->name});
2544 } else { 2544 } else {
2545 push(@argumentList, $parameter->name); 2545 push(@argumentList, $parameter->name);
2546 } 2546 }
2547 $index++; 2547 $index++;
2548 } 2548 }
2549 2549
2550 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2550 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2551 $code .= "\n"; 2551 $code .= "\n";
2552 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n"; 2552 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n";
2553 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2553 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2554 2554
2555 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2555 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2556 $code .= " if (ec) {\n"; 2556 $code .= " if (es.throwIfNeeded())\n";
2557 $code .= " setDOMException(ec, args.GetIsolate());\n";
2558 $code .= " return;\n"; 2557 $code .= " return;\n";
2559 $code .= " }\n";
2560 } 2558 }
2561 2559
2562 $code .= <<END; 2560 $code .= <<END;
2563 2561
2564 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}::in fo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 2562 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}::in fo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
2565 args.GetReturnValue().Set(wrapper); 2563 args.GetReturnValue().Set(wrapper);
2566 } 2564 }
2567 2565
2568 END 2566 END
2569 $implementation{nameSpaceInternal}->add($code); 2567 $implementation{nameSpaceInternal}->add($code);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2781 2779
2782 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance 2780 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance
2783 // may end up being the only node in the map and get garbage-collected prema turely. 2781 // may end up being the only node in the map and get garbage-collected prema turely.
2784 toV8(document, args.Holder(), args.GetIsolate()); 2782 toV8(document, args.Holder(), args.GetIsolate());
2785 2783
2786 END 2784 END
2787 2785
2788 $code .= GenerateArgumentsCountCheck($function, $interface); 2786 $code .= GenerateArgumentsCountCheck($function, $interface);
2789 2787
2790 if ($raisesExceptions) { 2788 if ($raisesExceptions) {
2791 AddToImplIncludes("core/dom/ExceptionCode.h"); 2789 AddToImplIncludes("bindings/v8/ExceptionState.h");
2792 $code .= " ExceptionCode ec = 0;\n"; 2790 $code .= " ExceptionState es(args.GetIsolate());\n";
2793 } 2791 }
2794 2792
2795 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface); 2793 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface);
2796 $code .= $parameterCheckString; 2794 $code .= $parameterCheckString;
2797 2795
2798 push(@beforeArgumentList, "document"); 2796 push(@beforeArgumentList, "document");
2799 2797
2800 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2798 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2801 push(@afterArgumentList, "ec"); 2799 push(@afterArgumentList, "es");
2802 } 2800 }
2803 2801
2804 my @argumentList; 2802 my @argumentList;
2805 my $index = 0; 2803 my $index = 0;
2806 foreach my $parameter (@{$function->parameters}) { 2804 foreach my $parameter (@{$function->parameters}) {
2807 last if $index eq $paramIndex; 2805 last if $index eq $paramIndex;
2808 if ($replacements{$parameter->name}) { 2806 if ($replacements{$parameter->name}) {
2809 push(@argumentList, $replacements{$parameter->name}); 2807 push(@argumentList, $replacements{$parameter->name});
2810 } else { 2808 } else {
2811 push(@argumentList, $parameter->name); 2809 push(@argumentList, $parameter->name);
2812 } 2810 }
2813 $index++; 2811 $index++;
2814 } 2812 }
2815 2813
2816 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2814 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2817 $code .= "\n"; 2815 $code .= "\n";
2818 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; 2816 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n";
2819 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2817 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2820 2818
2821 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2819 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2822 $code .= " if (ec) {\n"; 2820 $code .= " if (es.throwIfNeeded())\n";
2823 $code .= " setDOMException(ec, args.GetIsolate());\n";
2824 $code .= " return;\n"; 2821 $code .= " return;\n";
2825 $code .= " }\n";
2826 } 2822 }
2827 2823
2828 $code .= <<END; 2824 $code .= <<END;
2829 2825
2830 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}Cons tructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 2826 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}Cons tructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
2831 args.GetReturnValue().Set(wrapper); 2827 args.GetReturnValue().Set(wrapper);
2832 } 2828 }
2833 2829
2834 END 2830 END
2835 $implementation{nameSpaceWebCore}->add($code); 2831 $implementation{nameSpaceWebCore}->add($code);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
3229 my $v8ClassName = GetV8ClassName($interface); 3225 my $v8ClassName = GetV8ClassName($interface);
3230 my $methodName = GetImplName($indexedGetterFunction); 3226 my $methodName = GetImplName($indexedGetterFunction);
3231 3227
3232 my $returnType = $indexedGetterFunction->type; 3228 my $returnType = $indexedGetterFunction->type;
3233 my $nativeType = GetNativeType($returnType); 3229 my $nativeType = GetNativeType($returnType);
3234 my $nativeValue = "element"; 3230 my $nativeValue = "element";
3235 $nativeValue .= ".release()" if (IsRefPtrType($returnType)); 3231 $nativeValue .= ".release()" if (IsRefPtrType($returnType));
3236 my $isNull = GenerateIsNullExpression($returnType, "element"); 3232 my $isNull = GenerateIsNullExpression($returnType, "element");
3237 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "", "return"); 3233 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "", "return");
3238 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"}; 3234 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"};
3239 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions); 3235 my $methodCallCode = GenerateMethodCallForPropertyGetter($returnType, "eleme nt", "collection->${methodName}", "index", $raisesExceptions);
3240 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n"; 3236 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n";
3241 $getterCode .= "{\n"; 3237 $getterCode .= "{\n";
3242 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ; 3238 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ;
3243 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n"; 3239 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n";
3244 if ($raisesExceptions) { 3240 if ($raisesExceptions) {
3245 $getterCode .= " ExceptionCode ec = 0;\n"; 3241 $getterCode .= " ExceptionState es(info.GetIsolate());\n";
3246 } 3242 }
3247 $getterCode .= $methodCallCode . "\n"; 3243 $getterCode .= $methodCallCode . "\n";
3248 if ($raisesExceptions) { 3244 if ($raisesExceptions) {
3249 $getterCode .= " if (ec) {\n"; 3245 $getterCode .= " if (es.throwIfNeeded())\n";
3250 $getterCode .= " setDOMException(ec, info.GetIsolate());\n";
3251 $getterCode .= " return;\n"; 3246 $getterCode .= " return;\n";
3252 $getterCode .= " }\n";
3253 } 3247 }
3254 if (IsUnionType($returnType)) { 3248 if (IsUnionType($returnType)) {
3255 $getterCode .= "${returnJSValueCode}\n"; 3249 $getterCode .= "${returnJSValueCode}\n";
3256 $getterCode .= " return;\n"; 3250 $getterCode .= " return;\n";
3257 } else { 3251 } else {
3258 $getterCode .= " if (${isNull})\n"; 3252 $getterCode .= " if (${isNull})\n";
3259 $getterCode .= " return;\n"; 3253 $getterCode .= " return;\n";
3260 $getterCode .= $returnJSValueCode . "\n"; 3254 $getterCode .= $returnJSValueCode . "\n";
3261 } 3255 }
3262 $getterCode .= "}\n\n"; 3256 $getterCode .= "}\n\n";
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3335 my $raisesExceptions = $indexedSetterFunction->extendedAttributes->{"RaisesE xception"}; 3329 my $raisesExceptions = $indexedSetterFunction->extendedAttributes->{"RaisesE xception"};
3336 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttribute s->{"TreatNullAs"}; 3330 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttribute s->{"TreatNullAs"};
3337 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"}; 3331 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"};
3338 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; 3332 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
3339 $code .= "{\n"; 3333 $code .= "{\n";
3340 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3334 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3341 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, "value", "propertyValue", " ", "info.GetIsolate()"); 3335 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, "value", "propertyValue", " ", "info.GetIsolate()");
3342 3336
3343 my $extraArguments = ""; 3337 my $extraArguments = "";
3344 if ($raisesExceptions) { 3338 if ($raisesExceptions) {
3345 $code .= " ExceptionCode ec = 0;\n"; 3339 $code .= " ExceptionState es(info.GetIsolate());\n";
3346 $extraArguments = ", ec"; 3340 $extraArguments = ", es";
3347 } 3341 }
3348 my @conditions = (); 3342 my @conditions = ();
3349 my @statements = (); 3343 my @statements = ();
3350 if ($treatNullAs && $treatNullAs ne "NullString") { 3344 if ($treatNullAs && $treatNullAs ne "NullString") {
3351 push @conditions, "value->IsNull()"; 3345 push @conditions, "value->IsNull()";
3352 push @statements, "collection->${treatNullAs}(index$extraArguments);"; 3346 push @statements, "collection->${treatNullAs}(index$extraArguments);";
3353 } 3347 }
3354 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3348 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3355 push @conditions, "value->IsUndefined()"; 3349 push @conditions, "value->IsUndefined()";
3356 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;"; 3350 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;";
3357 } 3351 }
3358 push @conditions, ""; 3352 push @conditions, "";
3359 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);"; 3353 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);";
3360 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3354 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3361 3355
3362 $code .= " if (!result)\n"; 3356 $code .= " if (!result)\n";
3363 $code .= " return;\n"; 3357 $code .= " return;\n";
3364 if ($raisesExceptions) { 3358 if ($raisesExceptions) {
3365 $code .= " if (ec) {\n"; 3359 $code .= " if (es.throwIfNeeded())\n";
3366 $code .= " setDOMException(ec, info.GetIsolate());\n";
3367 $code .= " return;\n"; 3360 $code .= " return;\n";
3368 $code .= " }\n";
3369 } 3361 }
3370 $code .= " v8SetReturnValue(info, value);\n"; 3362 $code .= " v8SetReturnValue(info, value);\n";
3371 $code .= "}\n\n"; 3363 $code .= "}\n\n";
3372 $implementation{nameSpaceInternal}->add($code); 3364 $implementation{nameSpaceInternal}->add($code);
3373 } 3365 }
3374 3366
3375 sub GenerateImplementationNamedPropertyAccessors 3367 sub GenerateImplementationNamedPropertyAccessors
3376 { 3368 {
3377 my $interface = shift; 3369 my $interface = shift;
3378 3370
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3535 if ($hasCustom) { 3527 if ($hasCustom) {
3536 $code .= " ${v8ClassName}::namedPropertyQueryCustom(name, info);\n"; 3528 $code .= " ${v8ClassName}::namedPropertyQueryCustom(name, info);\n";
3537 } else { 3529 } else {
3538 $code .= " ${implClassName}V8Internal::namedPropertyQuery(name, info) ;\n"; 3530 $code .= " ${implClassName}V8Internal::namedPropertyQuery(name, info) ;\n";
3539 } 3531 }
3540 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; 3532 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n";
3541 $code .= "}\n\n"; 3533 $code .= "}\n\n";
3542 $implementation{nameSpaceInternal}->add($code); 3534 $implementation{nameSpaceInternal}->add($code);
3543 } 3535 }
3544 3536
3545 sub GenerateMethodCall 3537 sub GenerateMethodCallForPropertyGetter
3546 { 3538 {
3547 my $returnType = shift; # string or UnionType 3539 my $returnType = shift; # string or UnionType
3548 my $returnName = shift; 3540 my $returnName = shift;
3549 my $functionExpression = shift; 3541 my $functionExpression = shift;
3550 my $firstArgument = shift; 3542 my $firstArgument = shift;
3551 my $raisesExceptions = shift; 3543 my $raisesExceptions = shift;
3552 3544
3553 my @arguments = (); 3545 my @arguments = ();
3554 push @arguments, $firstArgument; 3546 push @arguments, $firstArgument;
3555 if ($raisesExceptions) { 3547 if ($raisesExceptions) {
3556 push @arguments, "ec"; 3548 push @arguments, "es";
3557 } 3549 }
3558 3550
3559 if (IsUnionType($returnType)) { 3551 if (IsUnionType($returnType)) {
3560 my $code = ""; 3552 my $code = "";
3561 my @extraArguments = (); 3553 my @extraArguments = ();
3562 for my $i (0..scalar(@{$returnType->unionMemberTypes})-1) { 3554 for my $i (0..scalar(@{$returnType->unionMemberTypes})-1) {
3563 my $unionMemberType = $returnType->unionMemberTypes->[$i]; 3555 my $unionMemberType = $returnType->unionMemberTypes->[$i];
3564 my $nativeType = GetNativeType($unionMemberType); 3556 my $nativeType = GetNativeType($unionMemberType);
3565 my $unionMemberVariable = $returnName . $i; 3557 my $unionMemberVariable = $returnName . $i;
3566 my $unionMemberEnabledVariable = $returnName . $i . "Enabled"; 3558 my $unionMemberEnabledVariable = $returnName . $i . "Enabled";
(...skipping 18 matching lines...) Expand all
3585 my $implClassName = GetImplName($interface); 3577 my $implClassName = GetImplName($interface);
3586 my $v8ClassName = GetV8ClassName($interface); 3578 my $v8ClassName = GetV8ClassName($interface);
3587 my $methodName = GetImplName($namedGetterFunction); 3579 my $methodName = GetImplName($namedGetterFunction);
3588 3580
3589 my $returnType = $namedGetterFunction->type; 3581 my $returnType = $namedGetterFunction->type;
3590 my $isNull = GenerateIsNullExpression($returnType, "element"); 3582 my $isNull = GenerateIsNullExpression($returnType, "element");
3591 my $nativeValue = "element"; 3583 my $nativeValue = "element";
3592 $nativeValue .= ".release()" if (IsRefPtrType($returnType)); 3584 $nativeValue .= ".release()" if (IsRefPtrType($returnType));
3593 my $returnJSValueCode = NativeToJSValue($namedGetterFunction->type, $namedGe tterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "in fo.GetIsolate()", "info", "collection", "", "", "return"); 3585 my $returnJSValueCode = NativeToJSValue($namedGetterFunction->type, $namedGe tterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "in fo.GetIsolate()", "info", "collection", "", "", "return");
3594 my $raisesExceptions = $namedGetterFunction->extendedAttributes->{"RaisesExc eption"}; 3586 my $raisesExceptions = $namedGetterFunction->extendedAttributes->{"RaisesExc eption"};
3595 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "propertyName", $raisesExceptions); 3587 my $methodCallCode = GenerateMethodCallForPropertyGetter($returnType, "eleme nt", "collection->${methodName}", "propertyName", $raisesExceptions);
3596 3588
3597 my $code = "static void namedPropertyGetter(v8::Local<v8::String> name, cons t v8::PropertyCallbackInfo<v8::Value>& info)\n"; 3589 my $code = "static void namedPropertyGetter(v8::Local<v8::String> name, cons t v8::PropertyCallbackInfo<v8::Value>& info)\n";
3598 $code .= "{\n"; 3590 $code .= "{\n";
3599 if (!$namedGetterFunction->extendedAttributes->{"OverrideBuiltins"}) { 3591 if (!$namedGetterFunction->extendedAttributes->{"OverrideBuiltins"}) {
3600 $code .= " if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(n ame).IsEmpty())\n"; 3592 $code .= " if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(n ame).IsEmpty())\n";
3601 $code .= " return;\n"; 3593 $code .= " return;\n";
3602 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3594 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3603 $code .= " return;\n"; 3595 $code .= " return;\n";
3604 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3596 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3605 $code .= " return;\n"; 3597 $code .= " return;\n";
3606 } 3598 }
3607 $code .= "\n"; 3599 $code .= "\n";
3608 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n"; 3600 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n";
3609 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3601 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3610 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3602 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3611 if ($raisesExceptions) { 3603 if ($raisesExceptions) {
3612 $code .= " ExceptionCode ec = 0;\n"; 3604 $code .= " ExceptionState es(info.GetIsolate());\n";
3613 } 3605 }
3614 $code .= $methodCallCode . "\n"; 3606 $code .= $methodCallCode . "\n";
3615 if ($raisesExceptions) { 3607 if ($raisesExceptions) {
3616 $code .= " if (ec) {\n"; 3608 $code .= " if (es.throwIfNeeded())\n";
3617 $code .= " setDOMException(ec, info.GetIsolate());\n";
3618 $code .= " return;\n"; 3609 $code .= " return;\n";
3619 $code .= " }\n";
3620 } 3610 }
3621 if (IsUnionType($returnType)) { 3611 if (IsUnionType($returnType)) {
3622 $code .= "${returnJSValueCode}\n"; 3612 $code .= "${returnJSValueCode}\n";
3623 $code .= " return;\n"; 3613 $code .= " return;\n";
3624 } else { 3614 } else {
3625 $code .= " if (${isNull})\n"; 3615 $code .= " if (${isNull})\n";
3626 $code .= " return;\n"; 3616 $code .= " return;\n";
3627 $code .= $returnJSValueCode . "\n"; 3617 $code .= $returnJSValueCode . "\n";
3628 } 3618 }
3629 $code .= "}\n\n"; 3619 $code .= "}\n\n";
(...skipping 20 matching lines...) Expand all
3650 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3640 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3651 $code .= " return;\n"; 3641 $code .= " return;\n";
3652 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3642 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3653 $code .= " return;\n"; 3643 $code .= " return;\n";
3654 } 3644 }
3655 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3645 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3656 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, "name", "propertyName", " ", "in fo.GetIsolate()"); 3646 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, "name", "propertyName", " ", "in fo.GetIsolate()");
3657 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, "value", "propertyValue", " ", " info.GetIsolate()"); 3647 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, "value", "propertyValue", " ", " info.GetIsolate()");
3658 my $extraArguments = ""; 3648 my $extraArguments = "";
3659 if ($raisesExceptions) { 3649 if ($raisesExceptions) {
3660 $code .= " ExceptionCode ec = 0;\n"; 3650 $code .= " ExceptionState es(info.GetIsolate());\n";
3661 $extraArguments = ", ec"; 3651 $extraArguments = ", es";
3662 } 3652 }
3663 3653
3664 my @conditions = (); 3654 my @conditions = ();
3665 my @statements = (); 3655 my @statements = ();
3666 if ($treatNullAs && $treatNullAs ne "NullString") { 3656 if ($treatNullAs && $treatNullAs ne "NullString") {
3667 push @conditions, "value->IsNull()"; 3657 push @conditions, "value->IsNull()";
3668 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);"; 3658 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);";
3669 } 3659 }
3670 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3660 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3671 push @conditions, "value->IsUndefined()"; 3661 push @conditions, "value->IsUndefined()";
3672 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);"; 3662 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);";
3673 } 3663 }
3674 push @conditions, ""; 3664 push @conditions, "";
3675 push @statements, "collection->${methodName}(propertyName, propertyValue$ext raArguments);"; 3665 push @statements, "collection->${methodName}(propertyName, propertyValue$ext raArguments);";
3676 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3666 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3677 3667
3678 $code .= " if (!result)\n"; 3668 $code .= " if (!result)\n";
3679 $code .= " return;\n"; 3669 $code .= " return;\n";
3680 if ($raisesExceptions) { 3670 if ($raisesExceptions) {
3681 $code .= " if (ec) {\n"; 3671 $code .= " if (es.throwIfNeeded())\n";
3682 $code .= " setDOMException(ec, info.GetIsolate());\n";
3683 $code .= " return;\n"; 3672 $code .= " return;\n";
3684 $code .= " }\n";
3685 } 3673 }
3686 $code .= " v8SetReturnValue(info, value);\n"; 3674 $code .= " v8SetReturnValue(info, value);\n";
3687 $code .= "}\n\n"; 3675 $code .= "}\n\n";
3688 $implementation{nameSpaceInternal}->add($code); 3676 $implementation{nameSpaceInternal}->add($code);
3689 } 3677 }
3690 3678
3691 sub GenerateImplementationIndexedPropertyDeleter 3679 sub GenerateImplementationIndexedPropertyDeleter
3692 { 3680 {
3693 my $interface = shift; 3681 my $interface = shift;
3694 my $indexedDeleterFunction = shift; 3682 my $indexedDeleterFunction = shift;
3695 my $implClassName = GetImplName($interface); 3683 my $implClassName = GetImplName($interface);
3696 my $v8ClassName = GetV8ClassName($interface); 3684 my $v8ClassName = GetV8ClassName($interface);
3697 my $methodName = GetImplName($indexedDeleterFunction); 3685 my $methodName = GetImplName($indexedDeleterFunction);
3698 3686
3699 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"}; 3687 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"};
3700 3688
3701 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n"; 3689 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n";
3702 $code .= "{\n"; 3690 $code .= "{\n";
3703 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3691 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3704 my $extraArguments = ""; 3692 my $extraArguments = "";
3705 if ($raisesExceptions) { 3693 if ($raisesExceptions) {
3706 $code .= " ExceptionCode ec = 0;\n"; 3694 $code .= " ExceptionState es(info.GetIsolate());\n";
3707 $extraArguments = ", ec"; 3695 $extraArguments = ", es";
3708 } 3696 }
3709 $code .= " bool result = collection->${methodName}(index$extraArguments); \n"; 3697 $code .= " bool result = collection->${methodName}(index$extraArguments); \n";
3710 if ($raisesExceptions) { 3698 if ($raisesExceptions) {
3711 $code .= " if (ec) {\n"; 3699 $code .= " if (es.throwIfNeeded())\n";
3712 $code .= " setDOMException(ec, info.GetIsolate());\n";
3713 $code .= " return;\n"; 3700 $code .= " return;\n";
3714 $code .= " }\n";
3715 } 3701 }
3716 $code .= " return v8SetReturnValueBool(info, result);\n"; 3702 $code .= " return v8SetReturnValueBool(info, result);\n";
3717 $code .= "}\n\n"; 3703 $code .= "}\n\n";
3718 $implementation{nameSpaceInternal}->add($code); 3704 $implementation{nameSpaceInternal}->add($code);
3719 } 3705 }
3720 3706
3721 sub GenerateImplementationNamedPropertyDeleter 3707 sub GenerateImplementationNamedPropertyDeleter
3722 { 3708 {
3723 my $interface = shift; 3709 my $interface = shift;
3724 my $namedDeleterFunction = shift; 3710 my $namedDeleterFunction = shift;
3725 my $implClassName = GetImplName($interface); 3711 my $implClassName = GetImplName($interface);
3726 my $v8ClassName = GetV8ClassName($interface); 3712 my $v8ClassName = GetV8ClassName($interface);
3727 my $methodName = GetImplName($namedDeleterFunction); 3713 my $methodName = GetImplName($namedDeleterFunction);
3728 3714
3729 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"}; 3715 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"};
3730 3716
3731 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n"; 3717 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n";
3732 $code .= "{\n"; 3718 $code .= "{\n";
3733 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3719 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3734 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3720 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3735 my $extraArguments = ""; 3721 my $extraArguments = "";
3736 if ($raisesExceptions) { 3722 if ($raisesExceptions) {
3737 $code .= " ExceptionCode ec = 0;\n"; 3723 $code .= " ExceptionState es(info.GetIsolate());\n";
3738 $extraArguments = ", ec"; 3724 $extraArguments = ", es";
3739 } 3725 }
3740 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n"; 3726 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n";
3741 if ($raisesExceptions) { 3727 if ($raisesExceptions) {
3742 $code .= " if (ec) {\n"; 3728 $code .= " if (es.throwIfNeeded())\n";
3743 $code .= " setDOMException(ec, info.GetIsolate());\n";
3744 $code .= " return;\n"; 3729 $code .= " return;\n";
3745 $code .= " }\n";
3746 } 3730 }
3747 $code .= " return v8SetReturnValueBool(info, result);\n"; 3731 $code .= " return v8SetReturnValueBool(info, result);\n";
3748 $code .= "}\n\n"; 3732 $code .= "}\n\n";
3749 $implementation{nameSpaceInternal}->add($code); 3733 $implementation{nameSpaceInternal}->add($code);
3750 } 3734 }
3751 3735
3752 sub GenerateImplementationNamedPropertyEnumerator 3736 sub GenerateImplementationNamedPropertyEnumerator
3753 { 3737 {
3754 my $interface = shift; 3738 my $interface = shift;
3755 my $implClassName = GetImplName($interface); 3739 my $implClassName = GetImplName($interface);
3756 my $v8ClassName = GetV8ClassName($interface); 3740 my $v8ClassName = GetV8ClassName($interface);
3757 3741
3758 $implementation{nameSpaceInternal}->add(<<END); 3742 $implementation{nameSpaceInternal}->add(<<END);
3759 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) 3743 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo)
3760 { 3744 {
3761 ExceptionCode ec = 0; 3745 ExceptionState es(info.GetIsolate());
3762 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 3746 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
3763 Vector<String> names; 3747 Vector<String> names;
3764 collection->namedPropertyEnumerator(names, ec); 3748 collection->namedPropertyEnumerator(names, es);
3765 if (ec) { 3749 if (es.throwIfNeeded())
3766 setDOMException(ec, info.GetIsolate());
3767 return; 3750 return;
3768 }
3769 v8::Handle<v8::Array> v8names = v8::Array::New(names.size()); 3751 v8::Handle<v8::Array> v8names = v8::Array::New(names.size());
3770 for (size_t i = 0; i < names.size(); ++i) 3752 for (size_t i = 0; i < names.size(); ++i)
3771 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate())); 3753 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate()));
3772 v8SetReturnValue(info, v8names); 3754 v8SetReturnValue(info, v8names);
3773 } 3755 }
3774 3756
3775 END 3757 END
3776 } 3758 }
3777 3759
3778 sub GenerateImplementationNamedPropertyQuery 3760 sub GenerateImplementationNamedPropertyQuery
3779 { 3761 {
3780 my $interface = shift; 3762 my $interface = shift;
3781 my $implClassName = GetImplName($interface); 3763 my $implClassName = GetImplName($interface);
3782 my $v8ClassName = GetV8ClassName($interface); 3764 my $v8ClassName = GetV8ClassName($interface);
3783 3765
3784 $implementation{nameSpaceInternal}->add(<<END); 3766 $implementation{nameSpaceInternal}->add(<<END);
3785 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info) 3767 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info)
3786 { 3768 {
3787 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 3769 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
3788 AtomicString propertyName = toWebCoreAtomicString(name); 3770 AtomicString propertyName = toWebCoreAtomicString(name);
3789 ExceptionCode ec = 0; 3771 ExceptionState es(info.GetIsolate());
3790 bool result = collection->namedPropertyQuery(propertyName, ec); 3772 bool result = collection->namedPropertyQuery(propertyName, es);
3791 if (ec) { 3773 if (es.throwIfNeeded())
3792 setDOMException(ec, info.GetIsolate());
3793 return; 3774 return;
3794 }
3795 if (!result) 3775 if (!result)
3796 return; 3776 return;
3797 v8SetReturnValueInt(info, v8::None); 3777 v8SetReturnValueInt(info, v8::None);
3798 } 3778 }
3799 3779
3800 END 3780 END
3801 } 3781 }
3802 3782
3803 sub GenerateImplementationLegacyCall 3783 sub GenerateImplementationLegacyCall
3804 { 3784 {
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
4882 $code .= $indent . "}\n"; 4862 $code .= $indent . "}\n";
4883 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") { 4863 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") {
4884 push @arguments, "$paramName.get()"; 4864 push @arguments, "$paramName.get()";
4885 } else { 4865 } else {
4886 push @arguments, $paramName; 4866 push @arguments, $paramName;
4887 } 4867 }
4888 $index++; 4868 $index++;
4889 } 4869 }
4890 4870
4891 if ($function->extendedAttributes->{"RaisesException"}) { 4871 if ($function->extendedAttributes->{"RaisesException"}) {
4892 push @arguments, "ec"; 4872 push @arguments, "es";
4893 } 4873 }
4894 4874
4895 my $functionString = "$functionName(" . join(", ", @arguments) . ")"; 4875 my $functionString = "$functionName(" . join(", ", @arguments) . ")";
4896 4876
4897 my $return = "result"; 4877 my $return = "result";
4898 my $returnIsRef = IsRefPtrType($returnType); 4878 my $returnIsRef = IsRefPtrType($returnType);
4899 4879
4900 if ($returnType eq "void") { 4880 if ($returnType eq "void") {
4901 $code .= $indent . "$functionString;\n"; 4881 $code .= $indent . "$functionString;\n";
4902 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) { 4882 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) {
4903 $code .= $indent . $nativeReturnType . " result = $functionString;\n"; 4883 $code .= $indent . $nativeReturnType . " result = $functionString;\n";
4904 } else { 4884 } else {
4905 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary 4885 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary
4906 $return = $functionString; 4886 $return = $functionString;
4907 $returnIsRef = 0; 4887 $returnIsRef = 0;
4908 4888
4909 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) { 4889 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) {
4910 $return = "WTF::getPtr(" . $return . ")"; 4890 $return = "WTF::getPtr(" . $return . ")";
4911 } 4891 }
4912 } 4892 }
4913 4893
4914 if ($function->extendedAttributes->{"RaisesException"}) { 4894 if ($function->extendedAttributes->{"RaisesException"}) {
4915 $code .= $indent . "if (UNLIKELY(ec)) {\n"; 4895 $code .= $indent . "if (es.throwIfNeeded())\n";
4916 $code .= $indent . " setDOMException(ec, args.GetIsolate());\n";
4917 $code .= $indent . " return;\n"; 4896 $code .= $indent . " return;\n";
4918 $code .= $indent . "}\n";
4919 } 4897 }
4920 4898
4921 if (ExtendedAttributeContains($callWith, "ScriptState")) { 4899 if (ExtendedAttributeContains($callWith, "ScriptState")) {
4922 $code .= $indent . "if (state.hadException()) {\n"; 4900 $code .= $indent . "if (state.hadException()) {\n";
4923 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n"; 4901 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n";
4924 $code .= $indent . " state.clearException();\n"; 4902 $code .= $indent . " state.clearException();\n";
4925 $code .= $indent . " throwError(exception, args.GetIsolate());\n"; 4903 $code .= $indent . " throwError(exception, args.GetIsolate());\n";
4926 $code .= $indent . " return;\n"; 4904 $code .= $indent . " return;\n";
4927 $code .= $indent . "}\n"; 4905 $code .= $indent . "}\n";
4928 } 4906 }
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
6036 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 6014 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
6037 $found = 1; 6015 $found = 1;
6038 } 6016 }
6039 return 1 if $found; 6017 return 1 if $found;
6040 }, 0); 6018 }, 0);
6041 6019
6042 return $found; 6020 return $found;
6043 } 6021 }
6044 6022
6045 1; 6023 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698