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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/scripts/CodeGeneratorV8.pm
diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm
index ef6a546e3c5939369f7c2493e60a6c780ebac793..07623fb4f017cb577a547c8d2e28abae6f601aac 100644
--- a/Source/bindings/scripts/CodeGeneratorV8.pm
+++ b/Source/bindings/scripts/CodeGeneratorV8.pm
@@ -1421,8 +1421,8 @@ END
my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesException"} || $attribute->extendedAttributes->{"RaisesException"};
my $isNullable = $attribute->isNullable;
if ($useExceptions) {
- AddToImplIncludes("core/dom/ExceptionCode.h");
- $code .= " ExceptionCode ec = 0;\n";
+ AddToImplIncludes("bindings/v8/ExceptionState.h");
+ $code .= " ExceptionState es(info.GetIsolate());\n";
}
if ($isNullable) {
@@ -1435,7 +1435,7 @@ END
if ($getterStringUsesImp) {
my ($functionName, @arguments) = GetterExpression($interfaceName, $attribute);
push(@arguments, "isNull") if $isNullable;
- push(@arguments, "ec") if $useExceptions;
+ push(@arguments, "es") if $useExceptions;
if ($attribute->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy);
@@ -1476,10 +1476,10 @@ END
}
if ($useExceptions) {
- $code .= " if (UNLIKELY(ec)) {\n";
- $code .= " setDOMException(ec, info.GetIsolate());\n";
- $code .= " return;\n";
- $code .= " };\n";
+ if ($useExceptions) {
+ $code .= " if (UNLIKELY(es.throwIfNeeded()))\n";
+ $code .= " return;\n";
+ }
if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"}, "ScriptState")) {
$code .= " if (state.hadException()) {\n";
@@ -1783,7 +1783,7 @@ sub GenerateNormalAttrSetter
$svgNativeType* imp = ${v8ClassName}::toNative(info.Holder());
END
} else {
- AddToImplIncludes("core/dom/ExceptionCode.h");
+ AddToImplIncludes("bindings/v8/ExceptionState.h");
$code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(info.Holder());\n";
$code .= " if (wrapper->isReadOnly()) {\n";
$code .= " setDOMException(NoModificationAllowedError, info.GetIsolate());\n";
@@ -1856,8 +1856,8 @@ END
my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesException"} || $attribute->extendedAttributes->{"RaisesException"};
if ($useExceptions) {
- AddToImplIncludes("core/dom/ExceptionCode.h");
- $code .= " ExceptionCode ec = 0;\n";
+ AddToImplIncludes("bindings/v8/ExceptionState.h");
+ $code .= " ExceptionState es(info.GetIsolate());\n";
}
if ($interfaceName eq "SVGNumber") {
@@ -1880,7 +1880,7 @@ END
} else {
my ($functionName, @arguments) = SetterExpression($interfaceName, $attribute);
push(@arguments, $expression);
- push(@arguments, "ec") if $useExceptions;
+ push(@arguments, "es") if $useExceptions;
if ($attribute->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy);
@@ -1900,8 +1900,7 @@ END
}
if ($useExceptions) {
- $code .= " if (UNLIKELY(ec))\n";
- $code .= " setDOMException(ec, info.GetIsolate());\n";
+ $code .= " es.throwIfNeeded();\n";
}
if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"}, "ScriptState")) {
@@ -1911,7 +1910,7 @@ END
if ($svgNativeType) {
if ($useExceptions) {
- $code .= " if (!ec)\n";
+ $code .= " if (!es.hadException())\n";
$code .= " wrapper->commitChange();\n";
} else {
$code .= " wrapper->commitChange();\n";
@@ -2178,7 +2177,7 @@ END
if ($interfaceName =~ /List$/) {
$code .= " $nativeClassName imp = ${v8ClassName}::toNative(args.Holder());\n";
} else {
- AddToImplIncludes("core/dom/ExceptionCode.h");
+ AddToImplIncludes("bindings/v8/ExceptionState.h");
$code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(args.Holder());\n";
$code .= " if (wrapper->isReadOnly()) {\n";
$code .= " setDOMException(NoModificationAllowedError, args.GetIsolate());\n";
@@ -2217,13 +2216,13 @@ END
}
if ($raisesExceptions) {
- AddToImplIncludes("core/dom/ExceptionCode.h");
- $code .= " ExceptionCode ec = 0;\n";
+ AddToImplIncludes("bindings/v8/ExceptionState.h");
+ $code .= " ExceptionState es(args.GetIsolate());\n";
}
if ($function->extendedAttributes->{"CheckSecurityForNode"}) {
AddToImplIncludes("bindings/v8/BindingSecurity.h");
- $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . GetImplName($function) . "(ec))) {\n";
+ $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . GetImplName($function) . "(es))) {\n";
$code .= " v8SetReturnValueNull(args);\n";
$code .= " return;\n";
$code .= " }\n";
@@ -2335,7 +2334,7 @@ sub GenerateParametersCheck
}
my $parameterName = $parameter->name;
- AddToImplIncludes("core/dom/ExceptionCode.h");
+ AddToImplIncludes("bindings/v8/ExceptionState.h");
if (IsCallbackInterface($parameter->type)) {
my $v8ClassName = "V8" . $parameter->type;
AddToImplIncludes("$v8ClassName.h");
@@ -2515,8 +2514,8 @@ END
}
if ($raisesExceptions) {
- AddToImplIncludes("core/dom/ExceptionCode.h");
- $code .= " ExceptionCode ec = 0;\n";
+ AddToImplIncludes("bindings/v8/ExceptionState.h");
+ $code .= " ExceptionState es(args.GetIsolate());\n";
}
# FIXME: Currently [Constructor(...)] does not yet support optional arguments without [Default=...]
@@ -2532,7 +2531,7 @@ END
}
if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
- push(@afterArgumentList, "ec");
+ push(@afterArgumentList, "es");
}
my @argumentList;
@@ -2553,10 +2552,8 @@ END
$code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
- $code .= " if (ec) {\n";
- $code .= " setDOMException(ec, args.GetIsolate());\n";
+ $code .= " if (es.throwIfNeeded())\n";
$code .= " return;\n";
- $code .= " }\n";
}
$code .= <<END;
@@ -2788,8 +2785,8 @@ END
$code .= GenerateArgumentsCountCheck($function, $interface);
if ($raisesExceptions) {
- AddToImplIncludes("core/dom/ExceptionCode.h");
- $code .= " ExceptionCode ec = 0;\n";
+ AddToImplIncludes("bindings/v8/ExceptionState.h");
+ $code .= " ExceptionState es(args.GetIsolate());\n";
}
my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interface);
@@ -2798,7 +2795,7 @@ END
push(@beforeArgumentList, "document");
if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
- push(@afterArgumentList, "ec");
+ push(@afterArgumentList, "es");
}
my @argumentList;
@@ -2819,10 +2816,8 @@ END
$code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
- $code .= " if (ec) {\n";
- $code .= " setDOMException(ec, args.GetIsolate());\n";
+ $code .= " if (es.throwIfNeeded())\n";
$code .= " return;\n";
- $code .= " }\n";
}
$code .= <<END;
@@ -3242,14 +3237,12 @@ sub GenerateImplementationIndexedPropertyGetter
$getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n";
$getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());\n";
if ($raisesExceptions) {
- $getterCode .= " ExceptionCode ec = 0;\n";
+ $getterCode .= " ExceptionState es(info.GetIsolate());\n";
}
$getterCode .= $methodCallCode . "\n";
if ($raisesExceptions) {
- $getterCode .= " if (ec) {\n";
- $getterCode .= " setDOMException(ec, info.GetIsolate());\n";
+ $getterCode .= " if (es.throwIfNeeded())\n";
$getterCode .= " return;\n";
- $getterCode .= " }\n";
}
if (IsUnionType($returnType)) {
$getterCode .= "${returnJSValueCode}\n";
@@ -3342,8 +3335,8 @@ sub GenerateImplementationIndexedPropertySetter
my $extraArguments = "";
if ($raisesExceptions) {
- $code .= " ExceptionCode ec = 0;\n";
- $extraArguments = ", ec";
+ $code .= " ExceptionState es(info.GetIsolate());\n";
+ $extraArguments = ", es";
}
my @conditions = ();
my @statements = ();
@@ -3362,10 +3355,8 @@ sub GenerateImplementationIndexedPropertySetter
$code .= " if (!result)\n";
$code .= " return;\n";
if ($raisesExceptions) {
- $code .= " if (ec) {\n";
- $code .= " setDOMException(ec, info.GetIsolate());\n";
+ $code .= " if (es.throwIfNeeded())\n";
$code .= " return;\n";
- $code .= " }\n";
}
$code .= " v8SetReturnValue(info, value);\n";
$code .= "}\n\n";
@@ -3553,7 +3544,7 @@ sub GenerateMethodCall
my @arguments = ();
push @arguments, $firstArgument;
if ($raisesExceptions) {
- push @arguments, "ec";
+ push @arguments, "es";
}
if (IsUnionType($returnType)) {
@@ -3609,14 +3600,12 @@ sub GenerateImplementationNamedPropertyGetter
$code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());\n";
$code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
if ($raisesExceptions) {
- $code .= " ExceptionCode ec = 0;\n";
+ $code .= " ExceptionState es(info.GetIsolate());\n";
}
$code .= $methodCallCode . "\n";
if ($raisesExceptions) {
- $code .= " if (ec) {\n";
- $code .= " setDOMException(ec, info.GetIsolate());\n";
+ $code .= " if (es.throwIfNeeded())\n";
$code .= " return;\n";
- $code .= " }\n";
}
if (IsUnionType($returnType)) {
$code .= "${returnJSValueCode}\n";
@@ -3657,8 +3646,8 @@ sub GenerateImplementationNamedPropertySetter
$code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->type, $namedSetterFunction->extendedAttributes, "value", "propertyValue", " ", "info.GetIsolate()");
my $extraArguments = "";
if ($raisesExceptions) {
- $code .= " ExceptionCode ec = 0;\n";
- $extraArguments = ", ec";
+ $code .= " ExceptionState es(info.GetIsolate());\n";
+ $extraArguments = ", es";
}
my @conditions = ();
@@ -3678,10 +3667,8 @@ sub GenerateImplementationNamedPropertySetter
$code .= " if (!result)\n";
$code .= " return;\n";
if ($raisesExceptions) {
- $code .= " if (ec) {\n";
- $code .= " setDOMException(ec, info.GetIsolate());\n";
+ $code .= " if (es.throwIfNeeded())\n";
$code .= " return;\n";
- $code .= " }\n";
}
$code .= " v8SetReturnValue(info, value);\n";
$code .= "}\n\n";
@@ -3703,15 +3690,13 @@ sub GenerateImplementationIndexedPropertyDeleter
$code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());\n";
my $extraArguments = "";
if ($raisesExceptions) {
- $code .= " ExceptionCode ec = 0;\n";
- $extraArguments = ", ec";
+ $code .= " ExceptionState es(info.GetIsolate());\n";
+ $extraArguments = ", es";
}
$code .= " bool result = collection->${methodName}(index$extraArguments);\n";
if ($raisesExceptions) {
- $code .= " if (ec) {\n";
- $code .= " setDOMException(ec, info.GetIsolate());\n";
+ $code .= " if (es.throwIfNeeded())\n";
$code .= " return;\n";
- $code .= " }\n";
}
$code .= " return v8SetReturnValueBool(info, result);\n";
$code .= "}\n\n";
@@ -3734,15 +3719,13 @@ sub GenerateImplementationNamedPropertyDeleter
$code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
my $extraArguments = "";
if ($raisesExceptions) {
- $code .= " ExceptionCode ec = 0;\n";
- $extraArguments = ", ec";
+ $code .= " ExceptionState es(info.GetIsolate());\n";
+ $extraArguments = ", es";
}
$code .= " bool result = collection->${methodName}(propertyName$extraArguments);\n";
if ($raisesExceptions) {
- $code .= " if (ec) {\n";
- $code .= " setDOMException(ec, info.GetIsolate());\n";
+ $code .= " if (es.throwIfNeeded())\n";
$code .= " return;\n";
- $code .= " }\n";
}
$code .= " return v8SetReturnValueBool(info, result);\n";
$code .= "}\n\n";
@@ -3758,14 +3741,12 @@ sub GenerateImplementationNamedPropertyEnumerator
$implementation{nameSpaceInternal}->add(<<END);
static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
{
- ExceptionCode ec = 0;
+ ExceptionState es(info.GetIsolate());
${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
Vector<String> names;
- collection->namedPropertyEnumerator(names, ec);
- if (ec) {
- setDOMException(ec, info.GetIsolate());
+ collection->namedPropertyEnumerator(names, es);
+ if (es.throwIfNeeded())
return;
- }
v8::Handle<v8::Array> v8names = v8::Array::New(names.size());
for (size_t i = 0; i < names.size(); ++i)
v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate()));
@@ -3786,12 +3767,10 @@ static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
{
${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
AtomicString propertyName = toWebCoreAtomicString(name);
- ExceptionCode ec = 0;
- bool result = collection->namedPropertyQuery(propertyName, ec);
- if (ec) {
- setDOMException(ec, info.GetIsolate());
+ ExceptionState es(info.GetIsolate());
+ bool result = collection->namedPropertyQuery(propertyName, es);
+ if (es.throwIfNeeded())
return;
- }
if (!result)
return;
v8SetReturnValueInt(info, v8::None);
@@ -4889,7 +4868,7 @@ sub GenerateFunctionCallString
}
if ($function->extendedAttributes->{"RaisesException"}) {
- push @arguments, "ec";
+ push @arguments, "es";
}
my $functionString = "$functionName(" . join(", ", @arguments) . ")";
@@ -4912,10 +4891,8 @@ sub GenerateFunctionCallString
}
if ($function->extendedAttributes->{"RaisesException"}) {
- $code .= $indent . "if (UNLIKELY(ec)) {\n";
- $code .= $indent . " setDOMException(ec, args.GetIsolate());\n";
+ $code .= $indent . "if (es.throwIfNeeded())\n";
$code .= $indent . " return;\n";
- $code .= $indent . "}\n";
}
if (ExtendedAttributeContains($callWith, "ScriptState")) {

Powered by Google App Engine
This is Rietveld 408576698