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

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 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(es))) {\n";
2227 $code .= " v8SetReturnValueNull(args);\n"; 2226 $code .= " v8SetReturnValueNull(args);\n";
2228 $code .= " return;\n"; 2227 $code .= " return;\n";
2229 $code .= " }\n"; 2228 $code .= " }\n";
2230 END 2229 END
2231 } 2230 }
2232 2231
2233 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix); 2232 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix);
2234 $code .= $parameterCheckString; 2233 $code .= $parameterCheckString;
2235 2234
2236 # Build the function call string. 2235 # Build the function call string.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 $parameterCheckString .= $multiLine ? " }\n" : "\n"; 2327 $parameterCheckString .= $multiLine ? " }\n" : "\n";
2329 } 2328 }
2330 2329
2331 my $parameterDefaultPolicy = "DefaultIsUndefined"; 2330 my $parameterDefaultPolicy = "DefaultIsUndefined";
2332 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par ameter->extendedAttributes->{"Default"} : ""; 2331 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par ameter->extendedAttributes->{"Default"} : "";
2333 if ($parameter->isOptional and $default eq "NullString") { 2332 if ($parameter->isOptional and $default eq "NullString") {
2334 $parameterDefaultPolicy = "DefaultIsNullString"; 2333 $parameterDefaultPolicy = "DefaultIsNullString";
2335 } 2334 }
2336 2335
2337 my $parameterName = $parameter->name; 2336 my $parameterName = $parameter->name;
2338 AddToImplIncludes("core/dom/ExceptionCode.h"); 2337 AddToImplIncludes("bindings/v8/ExceptionState.h");
2339 if (IsCallbackInterface($parameter->type)) { 2338 if (IsCallbackInterface($parameter->type)) {
2340 my $v8ClassName = "V8" . $parameter->type; 2339 my $v8ClassName = "V8" . $parameter->type;
2341 AddToImplIncludes("$v8ClassName.h"); 2340 AddToImplIncludes("$v8ClassName.h");
2342 if ($parameter->isOptional) { 2341 if ($parameter->isOptional) {
2343 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n"; 2342 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n";
2344 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; 2343 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n";
2345 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion()) {\n"; 2344 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion()) {\n";
2346 $parameterCheckString .= " throwTypeError(0, args.Get Isolate());\n"; 2345 $parameterCheckString .= " throwTypeError(0, args.Get Isolate());\n";
2347 $parameterCheckString .= " return;\n"; 2346 $parameterCheckString .= " return;\n";
2348 $parameterCheckString .= " }\n"; 2347 $parameterCheckString .= " }\n";
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 $code .= <<END; 2507 $code .= <<END;
2509 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& args) 2508 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& args)
2510 { 2509 {
2511 END 2510 END
2512 2511
2513 if ($function->overloadedIndex == 0) { 2512 if ($function->overloadedIndex == 0) {
2514 $code .= GenerateArgumentsCountCheck($function, $interface); 2513 $code .= GenerateArgumentsCountCheck($function, $interface);
2515 } 2514 }
2516 2515
2517 if ($raisesExceptions) { 2516 if ($raisesExceptions) {
2518 AddToImplIncludes("core/dom/ExceptionCode.h"); 2517 AddToImplIncludes("bindings/v8/ExceptionState.h");
2519 $code .= " ExceptionCode ec = 0;\n"; 2518 $code .= " ExceptionState es(args.GetIsolate());\n";
2520 } 2519 }
2521 2520
2522 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] 2521 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...]
2523 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, ""); 2522 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "");
2524 $code .= $parameterCheckString; 2523 $code .= $parameterCheckString;
2525 2524
2526 if ($interface->extendedAttributes->{"ConstructorCallWith"} && $interface->e xtendedAttributes->{"ConstructorCallWith"} eq "ScriptExecutionContext") { 2525 if ($interface->extendedAttributes->{"ConstructorCallWith"} && $interface->e xtendedAttributes->{"ConstructorCallWith"} eq "ScriptExecutionContext") {
2527 push(@beforeArgumentList, "context"); 2526 push(@beforeArgumentList, "context");
2528 $code .= <<END; 2527 $code .= <<END;
2529 2528
2530 ScriptExecutionContext* context = getScriptExecutionContext(); 2529 ScriptExecutionContext* context = getScriptExecutionContext();
2531 END 2530 END
2532 } 2531 }
2533 2532
2534 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2533 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2535 push(@afterArgumentList, "ec"); 2534 push(@afterArgumentList, "es");
2536 } 2535 }
2537 2536
2538 my @argumentList; 2537 my @argumentList;
2539 my $index = 0; 2538 my $index = 0;
2540 foreach my $parameter (@{$function->parameters}) { 2539 foreach my $parameter (@{$function->parameters}) {
2541 last if $index eq $paramIndex; 2540 last if $index eq $paramIndex;
2542 if ($replacements{$parameter->name}) { 2541 if ($replacements{$parameter->name}) {
2543 push(@argumentList, $replacements{$parameter->name}); 2542 push(@argumentList, $replacements{$parameter->name});
2544 } else { 2543 } else {
2545 push(@argumentList, $parameter->name); 2544 push(@argumentList, $parameter->name);
2546 } 2545 }
2547 $index++; 2546 $index++;
2548 } 2547 }
2549 2548
2550 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2549 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2551 $code .= "\n"; 2550 $code .= "\n";
2552 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n"; 2551 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n";
2553 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2552 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2554 2553
2555 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2554 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2556 $code .= " if (ec) {\n"; 2555 $code .= " if (es.throwIfNeeded())\n";
2557 $code .= " setDOMException(ec, args.GetIsolate());\n";
2558 $code .= " return;\n"; 2556 $code .= " return;\n";
2559 $code .= " }\n";
2560 } 2557 }
2561 2558
2562 $code .= <<END; 2559 $code .= <<END;
2563 2560
2564 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}::in fo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 2561 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}::in fo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
2565 args.GetReturnValue().Set(wrapper); 2562 args.GetReturnValue().Set(wrapper);
2566 } 2563 }
2567 2564
2568 END 2565 END
2569 $implementation{nameSpaceInternal}->add($code); 2566 $implementation{nameSpaceInternal}->add($code);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2781 2778
2782 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance 2779 // 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. 2780 // may end up being the only node in the map and get garbage-collected prema turely.
2784 toV8(document, args.Holder(), args.GetIsolate()); 2781 toV8(document, args.Holder(), args.GetIsolate());
2785 2782
2786 END 2783 END
2787 2784
2788 $code .= GenerateArgumentsCountCheck($function, $interface); 2785 $code .= GenerateArgumentsCountCheck($function, $interface);
2789 2786
2790 if ($raisesExceptions) { 2787 if ($raisesExceptions) {
2791 AddToImplIncludes("core/dom/ExceptionCode.h"); 2788 AddToImplIncludes("bindings/v8/ExceptionState.h");
2792 $code .= " ExceptionCode ec = 0;\n"; 2789 $code .= " ExceptionState es(args.GetIsolate());\n";
2793 } 2790 }
2794 2791
2795 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface); 2792 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface);
2796 $code .= $parameterCheckString; 2793 $code .= $parameterCheckString;
2797 2794
2798 push(@beforeArgumentList, "document"); 2795 push(@beforeArgumentList, "document");
2799 2796
2800 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2797 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2801 push(@afterArgumentList, "ec"); 2798 push(@afterArgumentList, "es");
2802 } 2799 }
2803 2800
2804 my @argumentList; 2801 my @argumentList;
2805 my $index = 0; 2802 my $index = 0;
2806 foreach my $parameter (@{$function->parameters}) { 2803 foreach my $parameter (@{$function->parameters}) {
2807 last if $index eq $paramIndex; 2804 last if $index eq $paramIndex;
2808 if ($replacements{$parameter->name}) { 2805 if ($replacements{$parameter->name}) {
2809 push(@argumentList, $replacements{$parameter->name}); 2806 push(@argumentList, $replacements{$parameter->name});
2810 } else { 2807 } else {
2811 push(@argumentList, $parameter->name); 2808 push(@argumentList, $parameter->name);
2812 } 2809 }
2813 $index++; 2810 $index++;
2814 } 2811 }
2815 2812
2816 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2813 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2817 $code .= "\n"; 2814 $code .= "\n";
2818 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; 2815 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n";
2819 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2816 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2820 2817
2821 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2818 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2822 $code .= " if (ec) {\n"; 2819 $code .= " if (es.throwIfNeeded())\n";
2823 $code .= " setDOMException(ec, args.GetIsolate());\n";
2824 $code .= " return;\n"; 2820 $code .= " return;\n";
2825 $code .= " }\n";
2826 } 2821 }
2827 2822
2828 $code .= <<END; 2823 $code .= <<END;
2829 2824
2830 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}Cons tructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 2825 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}Cons tructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
2831 args.GetReturnValue().Set(wrapper); 2826 args.GetReturnValue().Set(wrapper);
2832 } 2827 }
2833 2828
2834 END 2829 END
2835 $implementation{nameSpaceWebCore}->add($code); 2830 $implementation{nameSpaceWebCore}->add($code);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 $nativeValue .= ".release()" if (IsRefPtrType($returnType)); 3230 $nativeValue .= ".release()" if (IsRefPtrType($returnType));
3236 my $isNull = GenerateIsNullExpression($returnType, "element"); 3231 my $isNull = GenerateIsNullExpression($returnType, "element");
3237 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "", "return"); 3232 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "", "return");
3238 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"}; 3233 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"};
3239 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions); 3234 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions);
3240 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n"; 3235 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n";
3241 $getterCode .= "{\n"; 3236 $getterCode .= "{\n";
3242 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ; 3237 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ;
3243 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n"; 3238 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n";
3244 if ($raisesExceptions) { 3239 if ($raisesExceptions) {
3245 $getterCode .= " ExceptionCode ec = 0;\n"; 3240 $getterCode .= " ExceptionState es(info.GetIsolate());\n";
3246 } 3241 }
3247 $getterCode .= $methodCallCode . "\n"; 3242 $getterCode .= $methodCallCode . "\n";
3248 if ($raisesExceptions) { 3243 if ($raisesExceptions) {
3249 $getterCode .= " if (ec) {\n"; 3244 $getterCode .= " if (es.throwIfNeeded())\n";
3250 $getterCode .= " setDOMException(ec, info.GetIsolate());\n";
3251 $getterCode .= " return;\n"; 3245 $getterCode .= " return;\n";
3252 $getterCode .= " }\n";
3253 } 3246 }
3254 if (IsUnionType($returnType)) { 3247 if (IsUnionType($returnType)) {
3255 $getterCode .= "${returnJSValueCode}\n"; 3248 $getterCode .= "${returnJSValueCode}\n";
3256 $getterCode .= " return;\n"; 3249 $getterCode .= " return;\n";
3257 } else { 3250 } else {
3258 $getterCode .= " if (${isNull})\n"; 3251 $getterCode .= " if (${isNull})\n";
3259 $getterCode .= " return;\n"; 3252 $getterCode .= " return;\n";
3260 $getterCode .= $returnJSValueCode . "\n"; 3253 $getterCode .= $returnJSValueCode . "\n";
3261 } 3254 }
3262 $getterCode .= "}\n\n"; 3255 $getterCode .= "}\n\n";
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3335 my $raisesExceptions = $indexedSetterFunction->extendedAttributes->{"RaisesE xception"}; 3328 my $raisesExceptions = $indexedSetterFunction->extendedAttributes->{"RaisesE xception"};
3336 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttribute s->{"TreatNullAs"}; 3329 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttribute s->{"TreatNullAs"};
3337 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"}; 3330 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"; 3331 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
3339 $code .= "{\n"; 3332 $code .= "{\n";
3340 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3333 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3341 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, "value", "propertyValue", " ", "info.GetIsolate()"); 3334 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, "value", "propertyValue", " ", "info.GetIsolate()");
3342 3335
3343 my $extraArguments = ""; 3336 my $extraArguments = "";
3344 if ($raisesExceptions) { 3337 if ($raisesExceptions) {
3345 $code .= " ExceptionCode ec = 0;\n"; 3338 $code .= " ExceptionState es(info.GetIsolate());\n";
3346 $extraArguments = ", ec"; 3339 $extraArguments = ", es";
3347 } 3340 }
3348 my @conditions = (); 3341 my @conditions = ();
3349 my @statements = (); 3342 my @statements = ();
3350 if ($treatNullAs && $treatNullAs ne "NullString") { 3343 if ($treatNullAs && $treatNullAs ne "NullString") {
3351 push @conditions, "value->IsNull()"; 3344 push @conditions, "value->IsNull()";
3352 push @statements, "collection->${treatNullAs}(index$extraArguments);"; 3345 push @statements, "collection->${treatNullAs}(index$extraArguments);";
3353 } 3346 }
3354 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3347 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3355 push @conditions, "value->IsUndefined()"; 3348 push @conditions, "value->IsUndefined()";
3356 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;"; 3349 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;";
3357 } 3350 }
3358 push @conditions, ""; 3351 push @conditions, "";
3359 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);"; 3352 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);";
3360 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3353 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3361 3354
3362 $code .= " if (!result)\n"; 3355 $code .= " if (!result)\n";
3363 $code .= " return;\n"; 3356 $code .= " return;\n";
3364 if ($raisesExceptions) { 3357 if ($raisesExceptions) {
3365 $code .= " if (ec) {\n"; 3358 $code .= " if (es.throwIfNeeded())\n";
3366 $code .= " setDOMException(ec, info.GetIsolate());\n";
3367 $code .= " return;\n"; 3359 $code .= " return;\n";
3368 $code .= " }\n";
3369 } 3360 }
3370 $code .= " v8SetReturnValue(info, value);\n"; 3361 $code .= " v8SetReturnValue(info, value);\n";
3371 $code .= "}\n\n"; 3362 $code .= "}\n\n";
3372 $implementation{nameSpaceInternal}->add($code); 3363 $implementation{nameSpaceInternal}->add($code);
3373 } 3364 }
3374 3365
3375 sub GenerateImplementationNamedPropertyAccessors 3366 sub GenerateImplementationNamedPropertyAccessors
3376 { 3367 {
3377 my $interface = shift; 3368 my $interface = shift;
3378 3369
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
3546 { 3537 {
3547 my $returnType = shift; # string or UnionType 3538 my $returnType = shift; # string or UnionType
3548 my $returnName = shift; 3539 my $returnName = shift;
3549 my $functionExpression = shift; 3540 my $functionExpression = shift;
3550 my $firstArgument = shift; 3541 my $firstArgument = shift;
3551 my $raisesExceptions = shift; 3542 my $raisesExceptions = shift;
3552 3543
3553 my @arguments = (); 3544 my @arguments = ();
3554 push @arguments, $firstArgument; 3545 push @arguments, $firstArgument;
3555 if ($raisesExceptions) { 3546 if ($raisesExceptions) {
3556 push @arguments, "ec"; 3547 push @arguments, "es";
3557 } 3548 }
3558 3549
3559 if (IsUnionType($returnType)) { 3550 if (IsUnionType($returnType)) {
3560 my $code = ""; 3551 my $code = "";
3561 my @extraArguments = (); 3552 my @extraArguments = ();
3562 for my $i (0..scalar(@{$returnType->unionMemberTypes})-1) { 3553 for my $i (0..scalar(@{$returnType->unionMemberTypes})-1) {
3563 my $unionMemberType = $returnType->unionMemberTypes->[$i]; 3554 my $unionMemberType = $returnType->unionMemberTypes->[$i];
3564 my $nativeType = GetNativeType($unionMemberType); 3555 my $nativeType = GetNativeType($unionMemberType);
3565 my $unionMemberVariable = $returnName . $i; 3556 my $unionMemberVariable = $returnName . $i;
3566 my $unionMemberEnabledVariable = $returnName . $i . "Enabled"; 3557 my $unionMemberEnabledVariable = $returnName . $i . "Enabled";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3602 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3593 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3603 $code .= " return;\n"; 3594 $code .= " return;\n";
3604 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3595 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3605 $code .= " return;\n"; 3596 $code .= " return;\n";
3606 } 3597 }
3607 $code .= "\n"; 3598 $code .= "\n";
3608 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n"; 3599 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n";
3609 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3600 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3610 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3601 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3611 if ($raisesExceptions) { 3602 if ($raisesExceptions) {
3612 $code .= " ExceptionCode ec = 0;\n"; 3603 $code .= " ExceptionState es(info.GetIsolate());\n";
3613 } 3604 }
3614 $code .= $methodCallCode . "\n"; 3605 $code .= $methodCallCode . "\n";
3615 if ($raisesExceptions) { 3606 if ($raisesExceptions) {
3616 $code .= " if (ec) {\n"; 3607 $code .= " if (es.throwIfNeeded())\n";
3617 $code .= " setDOMException(ec, info.GetIsolate());\n";
3618 $code .= " return;\n"; 3608 $code .= " return;\n";
3619 $code .= " }\n";
3620 } 3609 }
3621 if (IsUnionType($returnType)) { 3610 if (IsUnionType($returnType)) {
3622 $code .= "${returnJSValueCode}\n"; 3611 $code .= "${returnJSValueCode}\n";
3623 $code .= " return;\n"; 3612 $code .= " return;\n";
3624 } else { 3613 } else {
3625 $code .= " if (${isNull})\n"; 3614 $code .= " if (${isNull})\n";
3626 $code .= " return;\n"; 3615 $code .= " return;\n";
3627 $code .= $returnJSValueCode . "\n"; 3616 $code .= $returnJSValueCode . "\n";
3628 } 3617 }
3629 $code .= "}\n\n"; 3618 $code .= "}\n\n";
(...skipping 20 matching lines...) Expand all
3650 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3639 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3651 $code .= " return;\n"; 3640 $code .= " return;\n";
3652 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3641 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3653 $code .= " return;\n"; 3642 $code .= " return;\n";
3654 } 3643 }
3655 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3644 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3656 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, "name", "propertyName", " ", "in fo.GetIsolate()"); 3645 $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()"); 3646 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, "value", "propertyValue", " ", " info.GetIsolate()");
3658 my $extraArguments = ""; 3647 my $extraArguments = "";
3659 if ($raisesExceptions) { 3648 if ($raisesExceptions) {
3660 $code .= " ExceptionCode ec = 0;\n"; 3649 $code .= " ExceptionState es(info.GetIsolate());\n";
3661 $extraArguments = ", ec"; 3650 $extraArguments = ", es";
3662 } 3651 }
3663 3652
3664 my @conditions = (); 3653 my @conditions = ();
3665 my @statements = (); 3654 my @statements = ();
3666 if ($treatNullAs && $treatNullAs ne "NullString") { 3655 if ($treatNullAs && $treatNullAs ne "NullString") {
3667 push @conditions, "value->IsNull()"; 3656 push @conditions, "value->IsNull()";
3668 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);"; 3657 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);";
3669 } 3658 }
3670 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3659 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3671 push @conditions, "value->IsUndefined()"; 3660 push @conditions, "value->IsUndefined()";
3672 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);"; 3661 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);";
3673 } 3662 }
3674 push @conditions, ""; 3663 push @conditions, "";
3675 push @statements, "collection->${methodName}(propertyName, propertyValue$ext raArguments);"; 3664 push @statements, "collection->${methodName}(propertyName, propertyValue$ext raArguments);";
3676 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3665 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3677 3666
3678 $code .= " if (!result)\n"; 3667 $code .= " if (!result)\n";
3679 $code .= " return;\n"; 3668 $code .= " return;\n";
3680 if ($raisesExceptions) { 3669 if ($raisesExceptions) {
3681 $code .= " if (ec) {\n"; 3670 $code .= " if (es.throwIfNeeded())\n";
3682 $code .= " setDOMException(ec, info.GetIsolate());\n";
3683 $code .= " return;\n"; 3671 $code .= " return;\n";
3684 $code .= " }\n";
3685 } 3672 }
3686 $code .= " v8SetReturnValue(info, value);\n"; 3673 $code .= " v8SetReturnValue(info, value);\n";
3687 $code .= "}\n\n"; 3674 $code .= "}\n\n";
3688 $implementation{nameSpaceInternal}->add($code); 3675 $implementation{nameSpaceInternal}->add($code);
3689 } 3676 }
3690 3677
3691 sub GenerateImplementationIndexedPropertyDeleter 3678 sub GenerateImplementationIndexedPropertyDeleter
3692 { 3679 {
3693 my $interface = shift; 3680 my $interface = shift;
3694 my $indexedDeleterFunction = shift; 3681 my $indexedDeleterFunction = shift;
3695 my $implClassName = GetImplName($interface); 3682 my $implClassName = GetImplName($interface);
3696 my $v8ClassName = GetV8ClassName($interface); 3683 my $v8ClassName = GetV8ClassName($interface);
3697 my $methodName = GetImplName($indexedDeleterFunction); 3684 my $methodName = GetImplName($indexedDeleterFunction);
3698 3685
3699 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"}; 3686 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"};
3700 3687
3701 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n"; 3688 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n";
3702 $code .= "{\n"; 3689 $code .= "{\n";
3703 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3690 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3704 my $extraArguments = ""; 3691 my $extraArguments = "";
3705 if ($raisesExceptions) { 3692 if ($raisesExceptions) {
3706 $code .= " ExceptionCode ec = 0;\n"; 3693 $code .= " ExceptionState es(info.GetIsolate());\n";
3707 $extraArguments = ", ec"; 3694 $extraArguments = ", es";
3708 } 3695 }
3709 $code .= " bool result = collection->${methodName}(index$extraArguments); \n"; 3696 $code .= " bool result = collection->${methodName}(index$extraArguments); \n";
3710 if ($raisesExceptions) { 3697 if ($raisesExceptions) {
3711 $code .= " if (ec) {\n"; 3698 $code .= " if (es.throwIfNeeded())\n";
3712 $code .= " setDOMException(ec, info.GetIsolate());\n";
3713 $code .= " return;\n"; 3699 $code .= " return;\n";
3714 $code .= " }\n";
3715 } 3700 }
3716 $code .= " return v8SetReturnValueBool(info, result);\n"; 3701 $code .= " return v8SetReturnValueBool(info, result);\n";
3717 $code .= "}\n\n"; 3702 $code .= "}\n\n";
3718 $implementation{nameSpaceInternal}->add($code); 3703 $implementation{nameSpaceInternal}->add($code);
3719 } 3704 }
3720 3705
3721 sub GenerateImplementationNamedPropertyDeleter 3706 sub GenerateImplementationNamedPropertyDeleter
3722 { 3707 {
3723 my $interface = shift; 3708 my $interface = shift;
3724 my $namedDeleterFunction = shift; 3709 my $namedDeleterFunction = shift;
3725 my $implClassName = GetImplName($interface); 3710 my $implClassName = GetImplName($interface);
3726 my $v8ClassName = GetV8ClassName($interface); 3711 my $v8ClassName = GetV8ClassName($interface);
3727 my $methodName = GetImplName($namedDeleterFunction); 3712 my $methodName = GetImplName($namedDeleterFunction);
3728 3713
3729 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"}; 3714 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"};
3730 3715
3731 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n"; 3716 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n";
3732 $code .= "{\n"; 3717 $code .= "{\n";
3733 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3718 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3734 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3719 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3735 my $extraArguments = ""; 3720 my $extraArguments = "";
3736 if ($raisesExceptions) { 3721 if ($raisesExceptions) {
3737 $code .= " ExceptionCode ec = 0;\n"; 3722 $code .= " ExceptionState es(info.GetIsolate());\n";
3738 $extraArguments = ", ec"; 3723 $extraArguments = ", es";
3739 } 3724 }
3740 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n"; 3725 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n";
3741 if ($raisesExceptions) { 3726 if ($raisesExceptions) {
3742 $code .= " if (ec) {\n"; 3727 $code .= " if (es.throwIfNeeded())\n";
3743 $code .= " setDOMException(ec, info.GetIsolate());\n";
3744 $code .= " return;\n"; 3728 $code .= " return;\n";
3745 $code .= " }\n";
3746 } 3729 }
3747 $code .= " return v8SetReturnValueBool(info, result);\n"; 3730 $code .= " return v8SetReturnValueBool(info, result);\n";
3748 $code .= "}\n\n"; 3731 $code .= "}\n\n";
3749 $implementation{nameSpaceInternal}->add($code); 3732 $implementation{nameSpaceInternal}->add($code);
3750 } 3733 }
3751 3734
3752 sub GenerateImplementationNamedPropertyEnumerator 3735 sub GenerateImplementationNamedPropertyEnumerator
3753 { 3736 {
3754 my $interface = shift; 3737 my $interface = shift;
3755 my $implClassName = GetImplName($interface); 3738 my $implClassName = GetImplName($interface);
3756 my $v8ClassName = GetV8ClassName($interface); 3739 my $v8ClassName = GetV8ClassName($interface);
3757 3740
3758 $implementation{nameSpaceInternal}->add(<<END); 3741 $implementation{nameSpaceInternal}->add(<<END);
3759 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) 3742 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo)
3760 { 3743 {
3761 ExceptionCode ec = 0; 3744 ExceptionState es(info.GetIsolate());
3762 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 3745 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
3763 Vector<String> names; 3746 Vector<String> names;
3764 collection->namedPropertyEnumerator(names, ec); 3747 collection->namedPropertyEnumerator(names, es);
3765 if (ec) { 3748 if (es.throwIfNeeded())
3766 setDOMException(ec, info.GetIsolate());
3767 return; 3749 return;
3768 }
3769 v8::Handle<v8::Array> v8names = v8::Array::New(names.size()); 3750 v8::Handle<v8::Array> v8names = v8::Array::New(names.size());
3770 for (size_t i = 0; i < names.size(); ++i) 3751 for (size_t i = 0; i < names.size(); ++i)
3771 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate())); 3752 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate()));
3772 v8SetReturnValue(info, v8names); 3753 v8SetReturnValue(info, v8names);
3773 } 3754 }
3774 3755
3775 END 3756 END
3776 } 3757 }
3777 3758
3778 sub GenerateImplementationNamedPropertyQuery 3759 sub GenerateImplementationNamedPropertyQuery
3779 { 3760 {
3780 my $interface = shift; 3761 my $interface = shift;
3781 my $implClassName = GetImplName($interface); 3762 my $implClassName = GetImplName($interface);
3782 my $v8ClassName = GetV8ClassName($interface); 3763 my $v8ClassName = GetV8ClassName($interface);
3783 3764
3784 $implementation{nameSpaceInternal}->add(<<END); 3765 $implementation{nameSpaceInternal}->add(<<END);
3785 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info) 3766 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info)
3786 { 3767 {
3787 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 3768 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
3788 AtomicString propertyName = toWebCoreAtomicString(name); 3769 AtomicString propertyName = toWebCoreAtomicString(name);
3789 ExceptionCode ec = 0; 3770 ExceptionState es(info.GetIsolate());
3790 bool result = collection->namedPropertyQuery(propertyName, ec); 3771 bool result = collection->namedPropertyQuery(propertyName, es);
3791 if (ec) { 3772 if (es.throwIfNeeded())
3792 setDOMException(ec, info.GetIsolate());
3793 return; 3773 return;
3794 }
3795 if (!result) 3774 if (!result)
3796 return; 3775 return;
3797 v8SetReturnValueInt(info, v8::None); 3776 v8SetReturnValueInt(info, v8::None);
3798 } 3777 }
3799 3778
3800 END 3779 END
3801 } 3780 }
3802 3781
3803 sub GenerateImplementationLegacyCall 3782 sub GenerateImplementationLegacyCall
3804 { 3783 {
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
4882 $code .= $indent . "}\n"; 4861 $code .= $indent . "}\n";
4883 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") { 4862 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") {
4884 push @arguments, "$paramName.get()"; 4863 push @arguments, "$paramName.get()";
4885 } else { 4864 } else {
4886 push @arguments, $paramName; 4865 push @arguments, $paramName;
4887 } 4866 }
4888 $index++; 4867 $index++;
4889 } 4868 }
4890 4869
4891 if ($function->extendedAttributes->{"RaisesException"}) { 4870 if ($function->extendedAttributes->{"RaisesException"}) {
4892 push @arguments, "ec"; 4871 push @arguments, "es";
4893 } 4872 }
4894 4873
4895 my $functionString = "$functionName(" . join(", ", @arguments) . ")"; 4874 my $functionString = "$functionName(" . join(", ", @arguments) . ")";
4896 4875
4897 my $return = "result"; 4876 my $return = "result";
4898 my $returnIsRef = IsRefPtrType($returnType); 4877 my $returnIsRef = IsRefPtrType($returnType);
4899 4878
4900 if ($returnType eq "void") { 4879 if ($returnType eq "void") {
4901 $code .= $indent . "$functionString;\n"; 4880 $code .= $indent . "$functionString;\n";
4902 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) { 4881 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) {
4903 $code .= $indent . $nativeReturnType . " result = $functionString;\n"; 4882 $code .= $indent . $nativeReturnType . " result = $functionString;\n";
4904 } else { 4883 } else {
4905 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary 4884 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary
4906 $return = $functionString; 4885 $return = $functionString;
4907 $returnIsRef = 0; 4886 $returnIsRef = 0;
4908 4887
4909 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) { 4888 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) {
4910 $return = "WTF::getPtr(" . $return . ")"; 4889 $return = "WTF::getPtr(" . $return . ")";
4911 } 4890 }
4912 } 4891 }
4913 4892
4914 if ($function->extendedAttributes->{"RaisesException"}) { 4893 if ($function->extendedAttributes->{"RaisesException"}) {
4915 $code .= $indent . "if (UNLIKELY(ec)) {\n"; 4894 $code .= $indent . "if (es.throwIfNeeded())\n";
4916 $code .= $indent . " setDOMException(ec, args.GetIsolate());\n";
4917 $code .= $indent . " return;\n"; 4895 $code .= $indent . " return;\n";
4918 $code .= $indent . "}\n";
4919 } 4896 }
4920 4897
4921 if (ExtendedAttributeContains($callWith, "ScriptState")) { 4898 if (ExtendedAttributeContains($callWith, "ScriptState")) {
4922 $code .= $indent . "if (state.hadException()) {\n"; 4899 $code .= $indent . "if (state.hadException()) {\n";
4923 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n"; 4900 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n";
4924 $code .= $indent . " state.clearException();\n"; 4901 $code .= $indent . " state.clearException();\n";
4925 $code .= $indent . " throwError(exception, args.GetIsolate());\n"; 4902 $code .= $indent . " throwError(exception, args.GetIsolate());\n";
4926 $code .= $indent . " return;\n"; 4903 $code .= $indent . " return;\n";
4927 $code .= $indent . "}\n"; 4904 $code .= $indent . "}\n";
4928 } 4905 }
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
6036 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 6013 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
6037 $found = 1; 6014 $found = 1;
6038 } 6015 }
6039 return 1 if $found; 6016 return 1 if $found;
6040 }, 0); 6017 }, 0);
6041 6018
6042 return $found; 6019 return $found;
6043 } 6020 }
6044 6021
6045 1; 6022 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698