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

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

Issue 18398002: Remove IDBNotFoundError ExceptionCode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing include in code gen wich causes win compile failure 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 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1451 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1452 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "())) {\n"; 1452 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "())) {\n";
1453 $code .= " v8SetReturnValueNull(info);\n"; 1453 $code .= " v8SetReturnValueNull(info);\n";
1454 $code .= " return;\n"; 1454 $code .= " return;\n";
1455 $code .= " }\n"; 1455 $code .= " }\n";
1456 } 1456 }
1457 1457
1458 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; 1458 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
1459 my $isNullable = $attribute->isNullable; 1459 my $isNullable = $attribute->isNullable;
1460 if ($useExceptions) { 1460 if ($useExceptions) {
1461 AddToImplIncludes("core/dom/ExceptionCode.h"); 1461 AddToImplIncludes("bindings/v8/ExceptionState.h");
1462 $code .= " ExceptionCode ec = 0;\n"; 1462 $code .= " ExceptionState es(info.GetIsolate());\n";
1463 } 1463 }
1464 1464
1465 if ($isNullable) { 1465 if ($isNullable) {
1466 $code .= " bool isNull = false;\n"; 1466 $code .= " bool isNull = false;\n";
1467 } 1467 }
1468 1468
1469 my $returnType = $attribute->type; 1469 my $returnType = $attribute->type;
1470 my $getterString; 1470 my $getterString;
1471 1471
1472 if ($getterStringUsesImp) { 1472 if ($getterStringUsesImp) {
1473 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri bute); 1473 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri bute);
1474 push(@arguments, "isNull") if $isNullable; 1474 push(@arguments, "isNull") if $isNullable;
1475 push(@arguments, "ec") if $useExceptions; 1475 push(@arguments, "es") if $useExceptions;
1476 if ($attribute->extendedAttributes->{"ImplementedBy"}) { 1476 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
1477 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" }; 1477 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" };
1478 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); 1478 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy);
1479 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName)); 1479 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName));
1480 unshift(@arguments, "imp") if !$attribute->isStatic; 1480 unshift(@arguments, "imp") if !$attribute->isStatic;
1481 $functionName = "${implementedByImplName}::${functionName}"; 1481 $functionName = "${implementedByImplName}::${functionName}";
1482 } elsif ($attribute->isStatic) { 1482 } elsif ($attribute->isStatic) {
1483 $functionName = "${implClassName}::${functionName}"; 1483 $functionName = "${implClassName}::${functionName}";
1484 } else { 1484 } else {
1485 $functionName = "imp->${functionName}"; 1485 $functionName = "imp->${functionName}";
(...skipping 20 matching lines...) Expand all
1506 } 1506 }
1507 1507
1508 if ($isNullable) { 1508 if ($isNullable) {
1509 $code .= " if (isNull) {\n"; 1509 $code .= " if (isNull) {\n";
1510 $code .= " v8SetReturnValueNull(info);\n"; 1510 $code .= " v8SetReturnValueNull(info);\n";
1511 $code .= " return;\n"; 1511 $code .= " return;\n";
1512 $code .= " }\n"; 1512 $code .= " }\n";
1513 } 1513 }
1514 1514
1515 if ($useExceptions) { 1515 if ($useExceptions) {
1516 $code .= " if (UNLIKELY(ec)) {\n"; 1516 if ($useExceptions) {
1517 $code .= " setDOMException(ec, info.GetIsolate());\n"; 1517 $code .= " if (UNLIKELY(es.throwIfNeeded()))\n";
1518 $code .= " return;\n"; 1518 $code .= " return;\n";
1519 $code .= " };\n"; 1519 }
1520 1520
1521 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call With"}, "ScriptState")) { 1521 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call With"}, "ScriptState")) {
1522 $code .= " if (state.hadException()) {\n"; 1522 $code .= " if (state.hadException()) {\n";
1523 $code .= " throwError(state.exception(), info.GetIsolate( ));\n"; 1523 $code .= " throwError(state.exception(), info.GetIsolate( ));\n";
1524 $code .= " return;\n"; 1524 $code .= " return;\n";
1525 $code .= " }\n"; 1525 $code .= " }\n";
1526 } 1526 }
1527 } 1527 }
1528 1528
1529 $expression = "v"; 1529 $expression = "v";
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 } 1814 }
1815 1815
1816 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); 1816 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName);
1817 if ($svgNativeType) { 1817 if ($svgNativeType) {
1818 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e); 1818 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e);
1819 if ($svgWrappedNativeType =~ /List$/) { 1819 if ($svgWrappedNativeType =~ /List$/) {
1820 $code .= <<END; 1820 $code .= <<END;
1821 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); 1821 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder());
1822 END 1822 END
1823 } else { 1823 } else {
1824 AddToImplIncludes("core/dom/ExceptionCode.h"); 1824 AddToImplIncludes("bindings/v8/ExceptionState.h");
1825 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf o.Holder());\n"; 1825 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf o.Holder());\n";
1826 $code .= " if (wrapper->isReadOnly()) {\n"; 1826 $code .= " if (wrapper->isReadOnly()) {\n";
1827 $code .= " setDOMException(NoModificationAllowedError, info.G etIsolate());\n"; 1827 $code .= " setDOMException(NoModificationAllowedError, info.G etIsolate());\n";
1828 $code .= " return;\n"; 1828 $code .= " return;\n";
1829 $code .= " }\n"; 1829 $code .= " }\n";
1830 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 1830 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
1831 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 1831 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
1832 } 1832 }
1833 } elsif ($attrExt->{"OnProto"}) { 1833 } elsif ($attrExt->{"OnProto"}) {
1834 $code .= <<END; 1834 $code .= <<END;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 my $returnType = $attribute->type; 1887 my $returnType = $attribute->type;
1888 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) { 1888 if (IsRefPtrType($returnType) && !GetArrayType($returnType)) {
1889 $expression = "WTF::getPtr(" . $expression . ")"; 1889 $expression = "WTF::getPtr(" . $expression . ")";
1890 } 1890 }
1891 1891
1892 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt tributes); 1892 $code .= GenerateCustomElementInvocationScopeIfNeeded($attribute->extendedAt tributes);
1893 1893
1894 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; 1894 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
1895 1895
1896 if ($useExceptions) { 1896 if ($useExceptions) {
1897 AddToImplIncludes("core/dom/ExceptionCode.h"); 1897 AddToImplIncludes("bindings/v8/ExceptionState.h");
1898 $code .= " ExceptionCode ec = 0;\n"; 1898 $code .= " ExceptionState es(info.GetIsolate());\n";
1899 } 1899 }
1900 1900
1901 if ($interfaceName eq "SVGNumber") { 1901 if ($interfaceName eq "SVGNumber") {
1902 $code .= " *imp = $expression;\n"; 1902 $code .= " *imp = $expression;\n";
1903 } else { 1903 } else {
1904 if ($attribute->type eq "EventListener") { 1904 if ($attribute->type eq "EventListener") {
1905 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); 1905 my $implSetterFunctionName = FirstLetterToUpperCase($attrName);
1906 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); 1906 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h");
1907 if (!InheritsInterface($interface, "Node")) { 1907 if (!InheritsInterface($interface, "Node")) {
1908 my $attrImplName = GetImplName($attribute); 1908 my $attrImplName = GetImplName($attribute);
1909 $code .= " transferHiddenDependency(info.Holder(), imp->${att rImplName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::e ventListenerCacheIndex, info.GetIsolate());\n"; 1909 $code .= " transferHiddenDependency(info.Holder(), imp->${att rImplName}(isolatedWorldForIsolate(info.GetIsolate())), value, ${v8ClassName}::e ventListenerCacheIndex, info.GetIsolate());\n";
1910 } 1910 }
1911 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); 1911 AddToImplIncludes("bindings/v8/V8EventListenerList.h");
1912 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalSc ope") and $attribute->name eq "onerror") { 1912 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalSc ope") and $attribute->name eq "onerror") {
1913 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); 1913 AddToImplIncludes("bindings/v8/V8ErrorHandler.h");
1914 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(inf o.GetIsolate()));\n"; 1914 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::findOrCreateWrapper<V8ErrorHandler>(value, true), isolatedWorldForIsolate(inf o.GetIsolate()));\n";
1915 } else { 1915 } else {
1916 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate), isolatedWorldForIsolate( info.GetIsolate()));\n"; 1916 $code .= " imp->set$implSetterFunctionName(V8EventListenerLis t::getEventListener(value, true, ListenerFindOrCreate), isolatedWorldForIsolate( info.GetIsolate()));\n";
1917 } 1917 }
1918 } else { 1918 } else {
1919 my ($functionName, @arguments) = SetterExpression($interfaceName, $a ttribute); 1919 my ($functionName, @arguments) = SetterExpression($interfaceName, $a ttribute);
1920 push(@arguments, $expression); 1920 push(@arguments, $expression);
1921 push(@arguments, "ec") if $useExceptions; 1921 push(@arguments, "es") if $useExceptions;
1922 if ($attribute->extendedAttributes->{"ImplementedBy"}) { 1922 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
1923 my $implementedBy = $attribute->extendedAttributes->{"Implemente dBy"}; 1923 my $implementedBy = $attribute->extendedAttributes->{"Implemente dBy"};
1924 my $implementedByImplName = GetImplNameFromImplementedBy($implem entedBy); 1924 my $implementedByImplName = GetImplNameFromImplementedBy($implem entedBy);
1925 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple mentedByImplName)); 1925 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple mentedByImplName));
1926 unshift(@arguments, "imp") if !$attribute->isStatic; 1926 unshift(@arguments, "imp") if !$attribute->isStatic;
1927 $functionName = "${implementedByImplName}::${functionName}"; 1927 $functionName = "${implementedByImplName}::${functionName}";
1928 } elsif ($attribute->isStatic) { 1928 } elsif ($attribute->isStatic) {
1929 $functionName = "${implClassName}::${functionName}"; 1929 $functionName = "${implClassName}::${functionName}";
1930 } else { 1930 } else {
1931 $functionName = "imp->${functionName}"; 1931 $functionName = "imp->${functionName}";
1932 } 1932 }
1933 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttribute s->{"SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1 ); 1933 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttribute s->{"SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1 );
1934 $code .= $subCode; 1934 $code .= $subCode;
1935 unshift(@arguments, @$arg); 1935 unshift(@arguments, @$arg);
1936 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; 1936 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n";
1937 } 1937 }
1938 } 1938 }
1939 1939
1940 if ($useExceptions) { 1940 if ($useExceptions) {
1941 $code .= " if (UNLIKELY(ec))\n"; 1941 $code .= " es.throwIfNeeded();\n";
1942 $code .= " setDOMException(ec, info.GetIsolate());\n";
1943 } 1942 }
1944 1943
1945 if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"}, "ScriptState")) { 1944 if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"}, "ScriptState")) {
1946 $code .= " if (state.hadException())\n"; 1945 $code .= " if (state.hadException())\n";
1947 $code .= " throwError(state.exception(), info.GetIsolate());\n"; 1946 $code .= " throwError(state.exception(), info.GetIsolate());\n";
1948 } 1947 }
1949 1948
1950 if ($svgNativeType) { 1949 if ($svgNativeType) {
1951 if ($useExceptions) { 1950 if ($useExceptions) {
1952 $code .= " if (!ec)\n"; 1951 $code .= " if (!es.hadException())\n";
1953 $code .= " wrapper->commitChange();\n"; 1952 $code .= " wrapper->commitChange();\n";
1954 } else { 1953 } else {
1955 $code .= " wrapper->commitChange();\n"; 1954 $code .= " wrapper->commitChange();\n";
1956 } 1955 }
1957 } 1956 }
1958 1957
1959 if ($attribute->type eq "SerializedScriptValue" && $attribute->extendedAttri butes->{"CachedAttribute"}) { 1958 if ($attribute->type eq "SerializedScriptValue" && $attribute->extendedAttri butes->{"CachedAttribute"}) {
1960 $code .= <<END; 1959 $code .= <<END;
1961 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value. 1960 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value.
1962 END 1961 END
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 return; 2208 return;
2210 } 2209 }
2211 2210
2212 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); 2211 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName);
2213 2212
2214 if ($svgNativeType) { 2213 if ($svgNativeType) {
2215 my $nativeClassName = GetNativeType($interfaceName); 2214 my $nativeClassName = GetNativeType($interfaceName);
2216 if ($interfaceName =~ /List$/) { 2215 if ($interfaceName =~ /List$/) {
2217 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(args.H older());\n"; 2216 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(args.H older());\n";
2218 } else { 2217 } else {
2218 AddToImplIncludes("bindings/v8/ExceptionState.h");
2219 AddToImplIncludes("core/dom/ExceptionCode.h"); 2219 AddToImplIncludes("core/dom/ExceptionCode.h");
2220 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(ar gs.Holder());\n"; 2220 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(ar gs.Holder());\n";
2221 $code .= " if (wrapper->isReadOnly()) {\n"; 2221 $code .= " if (wrapper->isReadOnly()) {\n";
2222 $code .= " setDOMException(NoModificationAllowedError, args.G etIsolate());\n"; 2222 $code .= " setDOMException(NoModificationAllowedError, args.G etIsolate());\n";
2223 $code .= " return;\n"; 2223 $code .= " return;\n";
2224 $code .= " }\n"; 2224 $code .= " }\n";
2225 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName); 2225 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName);
2226 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 2226 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
2227 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 2227 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
2228 } 2228 }
(...skipping 19 matching lines...) Expand all
2248 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; 2248 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"};
2249 if (!$raisesExceptions) { 2249 if (!$raisesExceptions) {
2250 foreach my $parameter (@{$function->parameters}) { 2250 foreach my $parameter (@{$function->parameters}) {
2251 if ($parameter->extendedAttributes->{"IsIndex"}) { 2251 if ($parameter->extendedAttributes->{"IsIndex"}) {
2252 $raisesExceptions = 1; 2252 $raisesExceptions = 1;
2253 } 2253 }
2254 } 2254 }
2255 } 2255 }
2256 2256
2257 if ($raisesExceptions) { 2257 if ($raisesExceptions) {
2258 AddToImplIncludes("core/dom/ExceptionCode.h"); 2258 AddToImplIncludes("bindings/v8/ExceptionState.h");
2259 $code .= " ExceptionCode ec = 0;\n"; 2259 $code .= " ExceptionState es(args.GetIsolate());\n";
2260 } 2260 }
2261 2261
2262 if ($function->extendedAttributes->{"CheckSecurityForNode"}) { 2262 if ($function->extendedAttributes->{"CheckSecurityForNode"}) {
2263 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2263 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2264 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(ec))) {\n"; 2264 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(es))) {\n";
2265 $code .= " v8SetReturnValueNull(args);\n"; 2265 $code .= " v8SetReturnValueNull(args);\n";
2266 $code .= " return;\n"; 2266 $code .= " return;\n";
2267 $code .= " }\n"; 2267 $code .= " }\n";
2268 END 2268 END
2269 } 2269 }
2270 2270
2271 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix); 2271 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix);
2272 $code .= $parameterCheckString; 2272 $code .= $parameterCheckString;
2273 2273
2274 # Build the function call string. 2274 # Build the function call string.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 $parameterCheckString .= $multiLine ? " }\n" : "\n"; 2366 $parameterCheckString .= $multiLine ? " }\n" : "\n";
2367 } 2367 }
2368 2368
2369 my $parameterDefaultPolicy = "DefaultIsUndefined"; 2369 my $parameterDefaultPolicy = "DefaultIsUndefined";
2370 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par ameter->extendedAttributes->{"Default"} : ""; 2370 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par ameter->extendedAttributes->{"Default"} : "";
2371 if ($parameter->isOptional and $default eq "NullString") { 2371 if ($parameter->isOptional and $default eq "NullString") {
2372 $parameterDefaultPolicy = "DefaultIsNullString"; 2372 $parameterDefaultPolicy = "DefaultIsNullString";
2373 } 2373 }
2374 2374
2375 my $parameterName = $parameter->name; 2375 my $parameterName = $parameter->name;
2376 AddToImplIncludes("core/dom/ExceptionCode.h"); 2376 AddToImplIncludes("bindings/v8/ExceptionState.h");
2377 if (IsCallbackInterface($parameter->type)) { 2377 if (IsCallbackInterface($parameter->type)) {
2378 my $v8ClassName = "V8" . $parameter->type; 2378 my $v8ClassName = "V8" . $parameter->type;
2379 AddToImplIncludes("$v8ClassName.h"); 2379 AddToImplIncludes("$v8ClassName.h");
2380 if ($parameter->isOptional) { 2380 if ($parameter->isOptional) {
2381 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n"; 2381 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n";
2382 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; 2382 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n";
2383 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion()) {\n"; 2383 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion()) {\n";
2384 $parameterCheckString .= " throwTypeError(0, args.Get Isolate());\n"; 2384 $parameterCheckString .= " throwTypeError(0, args.Get Isolate());\n";
2385 $parameterCheckString .= " return;\n"; 2385 $parameterCheckString .= " return;\n";
2386 $parameterCheckString .= " }\n"; 2386 $parameterCheckString .= " }\n";
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2464 $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola te()"); 2464 $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola te()");
2465 if ($nativeType eq 'Dictionary') { 2465 if ($nativeType eq 'Dictionary') {
2466 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN ull() && !$parameterName.isObject()) {\n"; 2466 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN ull() && !$parameterName.isObject()) {\n";
2467 $parameterCheckString .= " throwTypeError(\"Not an object .\", args.GetIsolate());\n"; 2467 $parameterCheckString .= " throwTypeError(\"Not an object .\", args.GetIsolate());\n";
2468 $parameterCheckString .= " return;\n"; 2468 $parameterCheckString .= " return;\n";
2469 $parameterCheckString .= " }\n"; 2469 $parameterCheckString .= " }\n";
2470 } 2470 }
2471 } 2471 }
2472 2472
2473 if ($parameter->extendedAttributes->{"IsIndex"}) { 2473 if ($parameter->extendedAttributes->{"IsIndex"}) {
2474 AddToImplIncludes("core/dom/ExceptionCode.h");
2474 $parameterCheckString .= " if (UNLIKELY($parameterName < 0)) {\n" ; 2475 $parameterCheckString .= " if (UNLIKELY($parameterName < 0)) {\n" ;
2475 $parameterCheckString .= " setDOMException(IndexSizeError, ar gs.GetIsolate());\n"; 2476 $parameterCheckString .= " setDOMException(IndexSizeError, ar gs.GetIsolate());\n";
2476 $parameterCheckString .= " return;\n"; 2477 $parameterCheckString .= " return;\n";
2477 $parameterCheckString .= " }\n"; 2478 $parameterCheckString .= " }\n";
2478 } 2479 }
2479 2480
2480 $paramIndex++; 2481 $paramIndex++;
2481 } 2482 }
2482 return ($parameterCheckString, $paramIndex, %replacements); 2483 return ($parameterCheckString, $paramIndex, %replacements);
2483 } 2484 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 $code .= <<END; 2547 $code .= <<END;
2547 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& args) 2548 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& args)
2548 { 2549 {
2549 END 2550 END
2550 2551
2551 if ($function->overloadedIndex == 0) { 2552 if ($function->overloadedIndex == 0) {
2552 $code .= GenerateArgumentsCountCheck($function, $interface); 2553 $code .= GenerateArgumentsCountCheck($function, $interface);
2553 } 2554 }
2554 2555
2555 if ($raisesExceptions) { 2556 if ($raisesExceptions) {
2556 AddToImplIncludes("core/dom/ExceptionCode.h"); 2557 AddToImplIncludes("bindings/v8/ExceptionState.h");
2557 $code .= " ExceptionCode ec = 0;\n"; 2558 $code .= " ExceptionState es(args.GetIsolate());\n";
2558 } 2559 }
2559 2560
2560 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] 2561 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...]
2561 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, ""); 2562 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "");
2562 $code .= $parameterCheckString; 2563 $code .= $parameterCheckString;
2563 2564
2564 if ($interface->extendedAttributes->{"ConstructorCallWith"} && $interface->e xtendedAttributes->{"ConstructorCallWith"} eq "ScriptExecutionContext") { 2565 if ($interface->extendedAttributes->{"ConstructorCallWith"} && $interface->e xtendedAttributes->{"ConstructorCallWith"} eq "ScriptExecutionContext") {
2565 push(@beforeArgumentList, "context"); 2566 push(@beforeArgumentList, "context");
2566 $code .= <<END; 2567 $code .= <<END;
2567 2568
2568 ScriptExecutionContext* context = getScriptExecutionContext(); 2569 ScriptExecutionContext* context = getScriptExecutionContext();
2569 END 2570 END
2570 } 2571 }
2571 2572
2572 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2573 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2573 push(@afterArgumentList, "ec"); 2574 push(@afterArgumentList, "es");
2574 } 2575 }
2575 2576
2576 my @argumentList; 2577 my @argumentList;
2577 my $index = 0; 2578 my $index = 0;
2578 foreach my $parameter (@{$function->parameters}) { 2579 foreach my $parameter (@{$function->parameters}) {
2579 last if $index eq $paramIndex; 2580 last if $index eq $paramIndex;
2580 if ($replacements{$parameter->name}) { 2581 if ($replacements{$parameter->name}) {
2581 push(@argumentList, $replacements{$parameter->name}); 2582 push(@argumentList, $replacements{$parameter->name});
2582 } else { 2583 } else {
2583 push(@argumentList, $parameter->name); 2584 push(@argumentList, $parameter->name);
2584 } 2585 }
2585 $index++; 2586 $index++;
2586 } 2587 }
2587 2588
2588 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2589 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2589 $code .= "\n"; 2590 $code .= "\n";
2590 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n"; 2591 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n";
2591 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2592 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2592 2593
2593 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2594 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2594 $code .= " if (ec) {\n"; 2595 $code .= " if (es.throwIfNeeded())\n";
2595 $code .= " setDOMException(ec, args.GetIsolate());\n";
2596 $code .= " return;\n"; 2596 $code .= " return;\n";
2597 $code .= " }\n";
2598 } 2597 }
2599 2598
2600 $code .= <<END; 2599 $code .= <<END;
2601 2600
2602 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent) ; 2601 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent) ;
2603 args.GetReturnValue().Set(wrapper); 2602 args.GetReturnValue().Set(wrapper);
2604 } 2603 }
2605 2604
2606 END 2605 END
2607 $implementation{nameSpaceInternal}->add($code); 2606 $implementation{nameSpaceInternal}->add($code);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2819 2818
2820 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance 2819 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance
2821 // may end up being the only node in the map and get garbage-collected prema turely. 2820 // may end up being the only node in the map and get garbage-collected prema turely.
2822 toV8(document, args.Holder(), args.GetIsolate()); 2821 toV8(document, args.Holder(), args.GetIsolate());
2823 2822
2824 END 2823 END
2825 2824
2826 $code .= GenerateArgumentsCountCheck($function, $interface); 2825 $code .= GenerateArgumentsCountCheck($function, $interface);
2827 2826
2828 if ($raisesExceptions) { 2827 if ($raisesExceptions) {
2829 AddToImplIncludes("core/dom/ExceptionCode.h"); 2828 AddToImplIncludes("bindings/v8/ExceptionState.h");
2830 $code .= " ExceptionCode ec = 0;\n"; 2829 $code .= " ExceptionState es(args.GetIsolate());\n";
2831 } 2830 }
2832 2831
2833 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface); 2832 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface);
2834 $code .= $parameterCheckString; 2833 $code .= $parameterCheckString;
2835 2834
2836 push(@beforeArgumentList, "document"); 2835 push(@beforeArgumentList, "document");
2837 2836
2838 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2837 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2839 push(@afterArgumentList, "ec"); 2838 push(@afterArgumentList, "es");
2840 } 2839 }
2841 2840
2842 my @argumentList; 2841 my @argumentList;
2843 my $index = 0; 2842 my $index = 0;
2844 foreach my $parameter (@{$function->parameters}) { 2843 foreach my $parameter (@{$function->parameters}) {
2845 last if $index eq $paramIndex; 2844 last if $index eq $paramIndex;
2846 if ($replacements{$parameter->name}) { 2845 if ($replacements{$parameter->name}) {
2847 push(@argumentList, $replacements{$parameter->name}); 2846 push(@argumentList, $replacements{$parameter->name});
2848 } else { 2847 } else {
2849 push(@argumentList, $parameter->name); 2848 push(@argumentList, $parameter->name);
2850 } 2849 }
2851 $index++; 2850 $index++;
2852 } 2851 }
2853 2852
2854 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2853 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2855 $code .= "\n"; 2854 $code .= "\n";
2856 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; 2855 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n";
2857 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2856 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2858 2857
2859 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2858 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2860 $code .= " if (ec) {\n"; 2859 $code .= " if (es.throwIfNeeded())\n";
2861 $code .= " setDOMException(ec, args.GetIsolate());\n";
2862 $code .= " return;\n"; 2860 $code .= " return;\n";
2863 $code .= " }\n";
2864 } 2861 }
2865 2862
2866 $code .= <<END; 2863 $code .= <<END;
2867 2864
2868 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::info, wrapper, args.GetIsolate(), WrapperConfiguration: :Dependent); 2865 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::info, wrapper, args.GetIsolate(), WrapperConfiguration: :Dependent);
2869 args.GetReturnValue().Set(wrapper); 2866 args.GetReturnValue().Set(wrapper);
2870 } 2867 }
2871 2868
2872 END 2869 END
2873 $implementation{nameSpaceWebCore}->add($code); 2870 $implementation{nameSpaceWebCore}->add($code);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 $nativeValue .= ".release()" if (IsRefPtrType($returnType)); 3270 $nativeValue .= ".release()" if (IsRefPtrType($returnType));
3274 my $isNull = GenerateIsNullExpression($returnType, "element"); 3271 my $isNull = GenerateIsNullExpression($returnType, "element");
3275 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "", "return"); 3272 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "", "return");
3276 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"}; 3273 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"};
3277 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions); 3274 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions);
3278 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n"; 3275 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n";
3279 $getterCode .= "{\n"; 3276 $getterCode .= "{\n";
3280 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ; 3277 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ;
3281 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n"; 3278 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n";
3282 if ($raisesExceptions) { 3279 if ($raisesExceptions) {
3283 $getterCode .= " ExceptionCode ec = 0;\n"; 3280 $getterCode .= " ExceptionState es(info.GetIsolate());\n";
3284 } 3281 }
3285 $getterCode .= $methodCallCode . "\n"; 3282 $getterCode .= $methodCallCode . "\n";
3286 if ($raisesExceptions) { 3283 if ($raisesExceptions) {
3287 $getterCode .= " if (ec) {\n"; 3284 $getterCode .= " if (es.throwIfNeeded())\n";
3288 $getterCode .= " setDOMException(ec, info.GetIsolate());\n";
3289 $getterCode .= " return;\n"; 3285 $getterCode .= " return;\n";
3290 $getterCode .= " }\n";
3291 } 3286 }
3292 if (IsUnionType($returnType)) { 3287 if (IsUnionType($returnType)) {
3293 $getterCode .= "${returnJSValueCode}\n"; 3288 $getterCode .= "${returnJSValueCode}\n";
3294 $getterCode .= " return;\n"; 3289 $getterCode .= " return;\n";
3295 } else { 3290 } else {
3296 $getterCode .= " if (${isNull})\n"; 3291 $getterCode .= " if (${isNull})\n";
3297 $getterCode .= " return;\n"; 3292 $getterCode .= " return;\n";
3298 $getterCode .= $returnJSValueCode . "\n"; 3293 $getterCode .= $returnJSValueCode . "\n";
3299 } 3294 }
3300 $getterCode .= "}\n\n"; 3295 $getterCode .= "}\n\n";
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 my $raisesExceptions = $indexedSetterFunction->extendedAttributes->{"RaisesE xception"}; 3368 my $raisesExceptions = $indexedSetterFunction->extendedAttributes->{"RaisesE xception"};
3374 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttribute s->{"TreatNullAs"}; 3369 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttribute s->{"TreatNullAs"};
3375 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"}; 3370 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"};
3376 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; 3371 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
3377 $code .= "{\n"; 3372 $code .= "{\n";
3378 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3373 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3379 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, "value", "propertyValue", " ", "info.GetIsolate()"); 3374 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, "value", "propertyValue", " ", "info.GetIsolate()");
3380 3375
3381 my $extraArguments = ""; 3376 my $extraArguments = "";
3382 if ($raisesExceptions) { 3377 if ($raisesExceptions) {
3383 $code .= " ExceptionCode ec = 0;\n"; 3378 $code .= " ExceptionState es(info.GetIsolate());\n";
3384 $extraArguments = ", ec"; 3379 $extraArguments = ", es";
3385 } 3380 }
3386 my @conditions = (); 3381 my @conditions = ();
3387 my @statements = (); 3382 my @statements = ();
3388 if ($treatNullAs && $treatNullAs ne "NullString") { 3383 if ($treatNullAs && $treatNullAs ne "NullString") {
3389 push @conditions, "value->IsNull()"; 3384 push @conditions, "value->IsNull()";
3390 push @statements, "collection->${treatNullAs}(index$extraArguments);"; 3385 push @statements, "collection->${treatNullAs}(index$extraArguments);";
3391 } 3386 }
3392 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3387 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3393 push @conditions, "value->IsUndefined()"; 3388 push @conditions, "value->IsUndefined()";
3394 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;"; 3389 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;";
3395 } 3390 }
3396 push @conditions, ""; 3391 push @conditions, "";
3397 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);"; 3392 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);";
3398 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3393 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3399 3394
3400 $code .= " if (!result)\n"; 3395 $code .= " if (!result)\n";
3401 $code .= " return;\n"; 3396 $code .= " return;\n";
3402 if ($raisesExceptions) { 3397 if ($raisesExceptions) {
3403 $code .= " if (ec) {\n"; 3398 $code .= " if (es.throwIfNeeded())\n";
3404 $code .= " setDOMException(ec, info.GetIsolate());\n";
3405 $code .= " return;\n"; 3399 $code .= " return;\n";
3406 $code .= " }\n";
3407 } 3400 }
3408 $code .= " v8SetReturnValue(info, value);\n"; 3401 $code .= " v8SetReturnValue(info, value);\n";
3409 $code .= "}\n\n"; 3402 $code .= "}\n\n";
3410 $implementation{nameSpaceInternal}->add($code); 3403 $implementation{nameSpaceInternal}->add($code);
3411 } 3404 }
3412 3405
3413 sub GenerateImplementationNamedPropertyAccessors 3406 sub GenerateImplementationNamedPropertyAccessors
3414 { 3407 {
3415 my $interface = shift; 3408 my $interface = shift;
3416 3409
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
3584 { 3577 {
3585 my $returnType = shift; # string or UnionType 3578 my $returnType = shift; # string or UnionType
3586 my $returnName = shift; 3579 my $returnName = shift;
3587 my $functionExpression = shift; 3580 my $functionExpression = shift;
3588 my $firstArgument = shift; 3581 my $firstArgument = shift;
3589 my $raisesExceptions = shift; 3582 my $raisesExceptions = shift;
3590 3583
3591 my @arguments = (); 3584 my @arguments = ();
3592 push @arguments, $firstArgument; 3585 push @arguments, $firstArgument;
3593 if ($raisesExceptions) { 3586 if ($raisesExceptions) {
3594 push @arguments, "ec"; 3587 push @arguments, "es";
3595 } 3588 }
3596 3589
3597 if (IsUnionType($returnType)) { 3590 if (IsUnionType($returnType)) {
3598 my $code = ""; 3591 my $code = "";
3599 my @extraArguments = (); 3592 my @extraArguments = ();
3600 for my $i (0..scalar(@{$returnType->unionMemberTypes})-1) { 3593 for my $i (0..scalar(@{$returnType->unionMemberTypes})-1) {
3601 my $unionMemberType = $returnType->unionMemberTypes->[$i]; 3594 my $unionMemberType = $returnType->unionMemberTypes->[$i];
3602 my $nativeType = GetNativeType($unionMemberType); 3595 my $nativeType = GetNativeType($unionMemberType);
3603 my $unionMemberVariable = $returnName . $i; 3596 my $unionMemberVariable = $returnName . $i;
3604 my $unionMemberEnabledVariable = $returnName . $i . "Enabled"; 3597 my $unionMemberEnabledVariable = $returnName . $i . "Enabled";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3640 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3633 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3641 $code .= " return;\n"; 3634 $code .= " return;\n";
3642 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3635 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3643 $code .= " return;\n"; 3636 $code .= " return;\n";
3644 } 3637 }
3645 $code .= "\n"; 3638 $code .= "\n";
3646 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n"; 3639 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n";
3647 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3640 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3648 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3641 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3649 if ($raisesExceptions) { 3642 if ($raisesExceptions) {
3650 $code .= " ExceptionCode ec = 0;\n"; 3643 $code .= " ExceptionState es(info.GetIsolate());\n";
3651 } 3644 }
3652 $code .= $methodCallCode . "\n"; 3645 $code .= $methodCallCode . "\n";
3653 if ($raisesExceptions) { 3646 if ($raisesExceptions) {
3654 $code .= " if (ec) {\n"; 3647 $code .= " if (es.throwIfNeeded())\n";
3655 $code .= " setDOMException(ec, info.GetIsolate());\n";
3656 $code .= " return;\n"; 3648 $code .= " return;\n";
3657 $code .= " }\n";
3658 } 3649 }
3659 if (IsUnionType($returnType)) { 3650 if (IsUnionType($returnType)) {
3660 $code .= "${returnJSValueCode}\n"; 3651 $code .= "${returnJSValueCode}\n";
3661 $code .= " return;\n"; 3652 $code .= " return;\n";
3662 } else { 3653 } else {
3663 $code .= " if (${isNull})\n"; 3654 $code .= " if (${isNull})\n";
3664 $code .= " return;\n"; 3655 $code .= " return;\n";
3665 $code .= $returnJSValueCode . "\n"; 3656 $code .= $returnJSValueCode . "\n";
3666 } 3657 }
3667 $code .= "}\n\n"; 3658 $code .= "}\n\n";
(...skipping 20 matching lines...) Expand all
3688 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3679 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3689 $code .= " return;\n"; 3680 $code .= " return;\n";
3690 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3681 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3691 $code .= " return;\n"; 3682 $code .= " return;\n";
3692 } 3683 }
3693 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3684 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3694 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, "name", "propertyName", " ", "in fo.GetIsolate()"); 3685 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, "name", "propertyName", " ", "in fo.GetIsolate()");
3695 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, "value", "propertyValue", " ", " info.GetIsolate()"); 3686 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, "value", "propertyValue", " ", " info.GetIsolate()");
3696 my $extraArguments = ""; 3687 my $extraArguments = "";
3697 if ($raisesExceptions) { 3688 if ($raisesExceptions) {
3698 $code .= " ExceptionCode ec = 0;\n"; 3689 $code .= " ExceptionState es(info.GetIsolate());\n";
3699 $extraArguments = ", ec"; 3690 $extraArguments = ", es";
3700 } 3691 }
3701 3692
3702 my @conditions = (); 3693 my @conditions = ();
3703 my @statements = (); 3694 my @statements = ();
3704 if ($treatNullAs && $treatNullAs ne "NullString") { 3695 if ($treatNullAs && $treatNullAs ne "NullString") {
3705 push @conditions, "value->IsNull()"; 3696 push @conditions, "value->IsNull()";
3706 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);"; 3697 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);";
3707 } 3698 }
3708 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3699 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3709 push @conditions, "value->IsUndefined()"; 3700 push @conditions, "value->IsUndefined()";
3710 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);"; 3701 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);";
3711 } 3702 }
3712 push @conditions, ""; 3703 push @conditions, "";
3713 push @statements, "collection->${methodName}(propertyName, propertyValue$ext raArguments);"; 3704 push @statements, "collection->${methodName}(propertyName, propertyValue$ext raArguments);";
3714 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3705 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3715 3706
3716 $code .= " if (!result)\n"; 3707 $code .= " if (!result)\n";
3717 $code .= " return;\n"; 3708 $code .= " return;\n";
3718 if ($raisesExceptions) { 3709 if ($raisesExceptions) {
3719 $code .= " if (ec) {\n"; 3710 $code .= " if (es.throwIfNeeded())\n";
3720 $code .= " setDOMException(ec, info.GetIsolate());\n";
3721 $code .= " return;\n"; 3711 $code .= " return;\n";
3722 $code .= " }\n";
3723 } 3712 }
3724 $code .= " v8SetReturnValue(info, value);\n"; 3713 $code .= " v8SetReturnValue(info, value);\n";
3725 $code .= "}\n\n"; 3714 $code .= "}\n\n";
3726 $implementation{nameSpaceInternal}->add($code); 3715 $implementation{nameSpaceInternal}->add($code);
3727 } 3716 }
3728 3717
3729 sub GenerateImplementationIndexedPropertyDeleter 3718 sub GenerateImplementationIndexedPropertyDeleter
3730 { 3719 {
3731 my $interface = shift; 3720 my $interface = shift;
3732 my $indexedDeleterFunction = shift; 3721 my $indexedDeleterFunction = shift;
3733 my $implClassName = GetImplName($interface); 3722 my $implClassName = GetImplName($interface);
3734 my $v8ClassName = GetV8ClassName($interface); 3723 my $v8ClassName = GetV8ClassName($interface);
3735 my $methodName = GetImplName($indexedDeleterFunction); 3724 my $methodName = GetImplName($indexedDeleterFunction);
3736 3725
3737 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"}; 3726 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"};
3738 3727
3739 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n"; 3728 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n";
3740 $code .= "{\n"; 3729 $code .= "{\n";
3741 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3730 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3742 my $extraArguments = ""; 3731 my $extraArguments = "";
3743 if ($raisesExceptions) { 3732 if ($raisesExceptions) {
3744 $code .= " ExceptionCode ec = 0;\n"; 3733 $code .= " ExceptionState es(info.GetIsolate());\n";
3745 $extraArguments = ", ec"; 3734 $extraArguments = ", es";
3746 } 3735 }
3747 $code .= " bool result = collection->${methodName}(index$extraArguments); \n"; 3736 $code .= " bool result = collection->${methodName}(index$extraArguments); \n";
3748 if ($raisesExceptions) { 3737 if ($raisesExceptions) {
3749 $code .= " if (ec) {\n"; 3738 $code .= " if (es.throwIfNeeded())\n";
3750 $code .= " setDOMException(ec, info.GetIsolate());\n";
3751 $code .= " return;\n"; 3739 $code .= " return;\n";
3752 $code .= " }\n";
3753 } 3740 }
3754 $code .= " return v8SetReturnValueBool(info, result);\n"; 3741 $code .= " return v8SetReturnValueBool(info, result);\n";
3755 $code .= "}\n\n"; 3742 $code .= "}\n\n";
3756 $implementation{nameSpaceInternal}->add($code); 3743 $implementation{nameSpaceInternal}->add($code);
3757 } 3744 }
3758 3745
3759 sub GenerateImplementationNamedPropertyDeleter 3746 sub GenerateImplementationNamedPropertyDeleter
3760 { 3747 {
3761 my $interface = shift; 3748 my $interface = shift;
3762 my $namedDeleterFunction = shift; 3749 my $namedDeleterFunction = shift;
3763 my $implClassName = GetImplName($interface); 3750 my $implClassName = GetImplName($interface);
3764 my $v8ClassName = GetV8ClassName($interface); 3751 my $v8ClassName = GetV8ClassName($interface);
3765 my $methodName = GetImplName($namedDeleterFunction); 3752 my $methodName = GetImplName($namedDeleterFunction);
3766 3753
3767 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"}; 3754 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"};
3768 3755
3769 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n"; 3756 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n";
3770 $code .= "{\n"; 3757 $code .= "{\n";
3771 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3758 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3772 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3759 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3773 my $extraArguments = ""; 3760 my $extraArguments = "";
3774 if ($raisesExceptions) { 3761 if ($raisesExceptions) {
3775 $code .= " ExceptionCode ec = 0;\n"; 3762 $code .= " ExceptionState es(info.GetIsolate());\n";
3776 $extraArguments = ", ec"; 3763 $extraArguments = ", es";
3777 } 3764 }
3778 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n"; 3765 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n";
3779 if ($raisesExceptions) { 3766 if ($raisesExceptions) {
3780 $code .= " if (ec) {\n"; 3767 $code .= " if (es.throwIfNeeded())\n";
3781 $code .= " setDOMException(ec, info.GetIsolate());\n";
3782 $code .= " return;\n"; 3768 $code .= " return;\n";
3783 $code .= " }\n";
3784 } 3769 }
3785 $code .= " return v8SetReturnValueBool(info, result);\n"; 3770 $code .= " return v8SetReturnValueBool(info, result);\n";
3786 $code .= "}\n\n"; 3771 $code .= "}\n\n";
3787 $implementation{nameSpaceInternal}->add($code); 3772 $implementation{nameSpaceInternal}->add($code);
3788 } 3773 }
3789 3774
3790 sub GenerateImplementationNamedPropertyEnumerator 3775 sub GenerateImplementationNamedPropertyEnumerator
3791 { 3776 {
3792 my $interface = shift; 3777 my $interface = shift;
3793 my $implClassName = GetImplName($interface); 3778 my $implClassName = GetImplName($interface);
3794 my $v8ClassName = GetV8ClassName($interface); 3779 my $v8ClassName = GetV8ClassName($interface);
3795 3780
3796 $implementation{nameSpaceInternal}->add(<<END); 3781 $implementation{nameSpaceInternal}->add(<<END);
3797 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) 3782 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo)
3798 { 3783 {
3799 ExceptionCode ec = 0; 3784 ExceptionState es(info.GetIsolate());
3800 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 3785 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
3801 Vector<String> names; 3786 Vector<String> names;
3802 collection->namedPropertyEnumerator(names, ec); 3787 collection->namedPropertyEnumerator(names, es);
3803 if (ec) { 3788 if (es.throwIfNeeded())
3804 setDOMException(ec, info.GetIsolate());
3805 return; 3789 return;
3806 }
3807 v8::Handle<v8::Array> v8names = v8::Array::New(names.size()); 3790 v8::Handle<v8::Array> v8names = v8::Array::New(names.size());
3808 for (size_t i = 0; i < names.size(); ++i) 3791 for (size_t i = 0; i < names.size(); ++i)
3809 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate())); 3792 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate()));
3810 v8SetReturnValue(info, v8names); 3793 v8SetReturnValue(info, v8names);
3811 } 3794 }
3812 3795
3813 END 3796 END
3814 } 3797 }
3815 3798
3816 sub GenerateImplementationNamedPropertyQuery 3799 sub GenerateImplementationNamedPropertyQuery
3817 { 3800 {
3818 my $interface = shift; 3801 my $interface = shift;
3819 my $implClassName = GetImplName($interface); 3802 my $implClassName = GetImplName($interface);
3820 my $v8ClassName = GetV8ClassName($interface); 3803 my $v8ClassName = GetV8ClassName($interface);
3821 3804
3822 $implementation{nameSpaceInternal}->add(<<END); 3805 $implementation{nameSpaceInternal}->add(<<END);
3823 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info) 3806 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info)
3824 { 3807 {
3825 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 3808 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
3826 AtomicString propertyName = toWebCoreAtomicString(name); 3809 AtomicString propertyName = toWebCoreAtomicString(name);
3827 ExceptionCode ec = 0; 3810 ExceptionState es(info.GetIsolate());
3828 bool result = collection->namedPropertyQuery(propertyName, ec); 3811 bool result = collection->namedPropertyQuery(propertyName, es);
3829 if (ec) { 3812 if (es.throwIfNeeded())
3830 setDOMException(ec, info.GetIsolate());
3831 return; 3813 return;
3832 }
3833 if (!result) 3814 if (!result)
3834 return; 3815 return;
3835 v8SetReturnValueInt(info, v8::None); 3816 v8SetReturnValueInt(info, v8::None);
3836 } 3817 }
3837 3818
3838 END 3819 END
3839 } 3820 }
3840 3821
3841 sub GenerateImplementationLegacyCall 3822 sub GenerateImplementationLegacyCall
3842 { 3823 {
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
4905 last; 4886 last;
4906 } 4887 }
4907 my $paramName = $parameter->name; 4888 my $paramName = $parameter->name;
4908 my $paramType = $parameter->type; 4889 my $paramType = $parameter->type;
4909 4890
4910 if ($replacements{$paramName}) { 4891 if ($replacements{$paramName}) {
4911 push @arguments, $replacements{$paramName}; 4892 push @arguments, $replacements{$paramName};
4912 } elsif ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathN SResolver") { 4893 } elsif ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathN SResolver") {
4913 push @arguments, "$paramName.get()"; 4894 push @arguments, "$paramName.get()";
4914 } elsif (IsSVGTypeNeedingTearOff($parameter->type) and not $interfaceNam e =~ /List$/) { 4895 } elsif (IsSVGTypeNeedingTearOff($parameter->type) and not $interfaceNam e =~ /List$/) {
4896 AddToImplIncludes("core/dom/ExceptionCode.h");
4915 push @arguments, "$paramName->propertyReference()"; 4897 push @arguments, "$paramName->propertyReference()";
4916 $code .= $indent . "if (!$paramName) {\n"; 4898 $code .= $indent . "if (!$paramName) {\n";
4917 $code .= $indent . " setDOMException(WebCore::TypeMismatchError, args.GetIsolate());\n"; 4899 $code .= $indent . " setDOMException(WebCore::TypeMismatchError, args.GetIsolate());\n";
4918 $code .= $indent . " return;\n"; 4900 $code .= $indent . " return;\n";
4919 $code .= $indent . "}\n"; 4901 $code .= $indent . "}\n";
4920 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") { 4902 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") {
4921 push @arguments, "$paramName.get()"; 4903 push @arguments, "$paramName.get()";
4922 } else { 4904 } else {
4923 push @arguments, $paramName; 4905 push @arguments, $paramName;
4924 } 4906 }
4925 $index++; 4907 $index++;
4926 } 4908 }
4927 4909
4928 if ($function->extendedAttributes->{"RaisesException"}) { 4910 if ($function->extendedAttributes->{"RaisesException"}) {
4929 push @arguments, "ec"; 4911 push @arguments, "es";
4930 } 4912 }
4931 4913
4932 my $functionString = "$functionName(" . join(", ", @arguments) . ")"; 4914 my $functionString = "$functionName(" . join(", ", @arguments) . ")";
4933 4915
4934 my $return = "result"; 4916 my $return = "result";
4935 my $returnIsRef = IsRefPtrType($returnType); 4917 my $returnIsRef = IsRefPtrType($returnType);
4936 4918
4937 if ($returnType eq "void") { 4919 if ($returnType eq "void") {
4938 $code .= $indent . "$functionString;\n"; 4920 $code .= $indent . "$functionString;\n";
4939 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) { 4921 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) {
4940 $code .= $indent . $nativeReturnType . " result = $functionString;\n"; 4922 $code .= $indent . $nativeReturnType . " result = $functionString;\n";
4941 } else { 4923 } else {
4942 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary 4924 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary
4943 $return = $functionString; 4925 $return = $functionString;
4944 $returnIsRef = 0; 4926 $returnIsRef = 0;
4945 4927
4946 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) { 4928 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) {
4947 $return = "WTF::getPtr(" . $return . ")"; 4929 $return = "WTF::getPtr(" . $return . ")";
4948 } 4930 }
4949 } 4931 }
4950 4932
4951 if ($function->extendedAttributes->{"RaisesException"}) { 4933 if ($function->extendedAttributes->{"RaisesException"}) {
4952 $code .= $indent . "if (UNLIKELY(ec)) {\n"; 4934 $code .= $indent . "if (es.throwIfNeeded())\n";
4953 $code .= $indent . " setDOMException(ec, args.GetIsolate());\n";
4954 $code .= $indent . " return;\n"; 4935 $code .= $indent . " return;\n";
4955 $code .= $indent . "}\n";
4956 } 4936 }
4957 4937
4958 if (ExtendedAttributeContains($callWith, "ScriptState")) { 4938 if (ExtendedAttributeContains($callWith, "ScriptState")) {
4959 $code .= $indent . "if (state.hadException()) {\n"; 4939 $code .= $indent . "if (state.hadException()) {\n";
4960 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n"; 4940 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n";
4961 $code .= $indent . " state.clearException();\n"; 4941 $code .= $indent . " state.clearException();\n";
4962 $code .= $indent . " throwError(exception, args.GetIsolate());\n"; 4942 $code .= $indent . " throwError(exception, args.GetIsolate());\n";
4963 $code .= $indent . " return;\n"; 4943 $code .= $indent . " return;\n";
4964 $code .= $indent . "}\n"; 4944 $code .= $indent . "}\n";
4965 } 4945 }
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
6073 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 6053 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
6074 $found = 1; 6054 $found = 1;
6075 } 6055 }
6076 return 1 if $found; 6056 return 1 if $found;
6077 }, 0); 6057 }, 0);
6078 6058
6079 return $found; 6059 return $found;
6080 } 6060 }
6081 6061
6082 1; 6062 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698