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

Unified Diff: Source/bindings/scripts/CodeGeneratorV8.pm

Issue 18398002: Remove IDBNotFoundError ExceptionCode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge Created 7 years, 6 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 cc61c0014a74af66d6fb3e53bc41ac660613cb63..7dee51007322763c187b792538375e3281bf985e 100644
--- a/Source/bindings/scripts/CodeGeneratorV8.pm
+++ b/Source/bindings/scripts/CodeGeneratorV8.pm
@@ -1425,8 +1425,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) {
@@ -1439,7 +1439,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);
@@ -1480,10 +1480,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";
@@ -1793,7 +1793,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(NO_MODIFICATION_ALLOWED_ERR, info.GetIsolate());\n";
@@ -1877,8 +1877,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") {
@@ -1901,7 +1901,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);
@@ -1921,8 +1921,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")) {
@@ -1932,7 +1931,7 @@ END
if ($svgNativeType) {
if ($useExceptions) {
- $code .= " if (!ec)\n";
+ $code .= " if (!es.hadException())\n";
$code .= " wrapper->commitChange();\n";
} else {
$code .= " wrapper->commitChange();\n";
@@ -2203,7 +2202,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(NO_MODIFICATION_ALLOWED_ERR, args.GetIsolate());\n";
@@ -2242,13 +2241,14 @@ 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";
+ # FIXME: Change to ExceptionState
+ $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . GetImplName($function) . "(es))) {\n";
$code .= " v8SetReturnValueNull(args);\n";
$code .= " return;\n";
$code .= " }\n";
@@ -2360,7 +2360,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");
@@ -2544,8 +2544,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=...]
@@ -2561,7 +2561,7 @@ END
}
if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
- push(@afterArgumentList, "ec");
+ push(@afterArgumentList, "es");
}
my @argumentList;
@@ -2582,10 +2582,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;
@@ -2799,8 +2797,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);
@@ -2809,7 +2807,7 @@ END
push(@beforeArgumentList, "document");
if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
- push(@afterArgumentList, "ec");
+ push(@afterArgumentList, "es");
}
my @argumentList;
@@ -2830,10 +2828,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;
@@ -3247,20 +3243,18 @@ sub GenerateImplementationIndexedPropertyGetter
my $isNull = GenerateIsNullExpression($returnType, "element");
my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $indexedGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "", "return");
my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesException"};
- my $methodCallCode = GenerateMethodCall($returnType, "element", "collection->${methodName}", "index", $raisesExceptions);
+ my $methodCallCode = GenerateMethodCallForPropertyGetter($returnType, "element", "collection->${methodName}", "index", $raisesExceptions);
my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
$getterCode .= "{\n";
$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";
@@ -3347,8 +3341,8 @@ sub GenerateImplementationIndexedPropertySetter
my $extraArguments = "";
if ($raisesExceptions) {
- $code .= " ExceptionCode ec = 0;\n";
- $extraArguments = ", ec";
+ $code .= " ExceptionState es(info.GetIsolate());\n";
+ $extraArguments = ", es";
}
my $passNativeValue = "propertyValue";
$passNativeValue .= ".release()" if (IsRefPtrType($type));
@@ -3370,10 +3364,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";
@@ -3540,7 +3532,7 @@ sub GenerateImplementationNamedPropertyQueryCallback
$implementation{nameSpaceInternal}->add($code);
}
-sub GenerateMethodCall
+sub GenerateMethodCallForPropertyGetter
{
my $returnType = shift; # string or UnionType
my $returnName = shift;
@@ -3551,7 +3543,7 @@ sub GenerateMethodCall
my @arguments = ();
push @arguments, $firstArgument;
if ($raisesExceptions) {
- push @arguments, "ec";
+ push @arguments, "es";
}
if (IsUnionType($returnType)) {
@@ -3590,7 +3582,7 @@ sub GenerateImplementationNamedPropertyGetter
$nativeValue .= ".release()" if (IsRefPtrType($returnType));
my $returnJSValueCode = NativeToJSValue($namedGetterFunction->type, $namedGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "", "return");
my $raisesExceptions = $namedGetterFunction->extendedAttributes->{"RaisesException"};
- my $methodCallCode = GenerateMethodCall($returnType, "element", "collection->${methodName}", "propertyName", $raisesExceptions);
+ my $methodCallCode = GenerateMethodCallForPropertyGetter($returnType, "element", "collection->${methodName}", "propertyName", $raisesExceptions);
my $code = "static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
$code .= "{\n";
@@ -3607,14 +3599,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";
@@ -3683,8 +3673,8 @@ sub GenerateImplementationNamedPropertySetter
$code .= GenerateNativeValueDefinition($namedSetterFunction, $namedSetterFunction->parameters->[1], "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 = ();
@@ -3704,10 +3694,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";
@@ -3729,15 +3717,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";
@@ -3760,15 +3746,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";
@@ -3784,14 +3768,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()));
@@ -3812,12 +3794,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);
@@ -4908,7 +4888,7 @@ sub GenerateFunctionCallString
}
if ($function->extendedAttributes->{"RaisesException"}) {
- push @arguments, "ec";
+ push @arguments, "es";
}
my $functionString = "$functionName(" . join(", ", @arguments) . ")";
@@ -4931,10 +4911,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