Index: Source/bindings/scripts/code_generator_v8.pm |
diff --git a/Source/bindings/scripts/code_generator_v8.pm b/Source/bindings/scripts/code_generator_v8.pm |
index 3392def01f3547280fa6520b8d5e6cdebcf1765d..ee64a3908408d799f6bac08b2298533ec4c7a7ef 100644 |
--- a/Source/bindings/scripts/code_generator_v8.pm |
+++ b/Source/bindings/scripts/code_generator_v8.pm |
@@ -2258,12 +2258,15 @@ sub GenerateOverloadedFunction |
my $conditionalString = GenerateConditionalString($function); |
my $leastNumMandatoryParams = 255; |
- my $code = ""; |
- $code .= "#if ${conditionalString}\n\n" if $conditionalString; |
- $code .= <<END; |
+ |
+ my $hasExceptionState = 0; |
+ my $header = ""; |
+ $header .= "#if ${conditionalString}\n\n" if $conditionalString; |
+ $header .= <<END; |
static void ${name}Method${forMainWorldSuffix}(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
END |
+ my $code = ""; |
$code .= GenerateFeatureObservation($function->extendedAttributes->{"MeasureAs"}); |
$code .= GenerateDeprecationNotification($function->extendedAttributes->{"DeprecateAs"}); |
@@ -2277,17 +2280,30 @@ END |
$code .= " }\n"; |
} |
if ($leastNumMandatoryParams >= 1) { |
+ if (!$hasExceptionState) { |
+ AddToImplIncludes("bindings/v8/ExceptionState.h"); |
+ $header .= " ExceptionState exceptionState(ExceptionState::ExecutionContext, \"${name}\", \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
+ $hasExceptionState = 1; |
+ } |
$code .= " if (UNLIKELY(info.Length() < $leastNumMandatoryParams)) {\n"; |
- $code .= " throwTypeError(ExceptionMessages::failedToExecute(\"$name\", \"$interfaceName\", ExceptionMessages::notEnoughArguments($leastNumMandatoryParams, info.Length())), info.GetIsolate());\n"; |
+ $code .= " exceptionState.notEnoughArguments($leastNumMandatoryParams, info.Length());\n"; |
$code .= " return;\n"; |
$code .= " }\n"; |
} |
- $code .= <<END; |
- throwTypeError(ExceptionMessages::failedToExecute(\"$name\", \"$interfaceName\", \"No function was found that matched the signature provided.\"), info.GetIsolate()); |
+ if ($hasExceptionState) { |
+ $code .= <<END; |
+ exceptionState.throwTypeError(\"No function was found that matched the signature provided.\"); |
+ exceptionState.throwIfNeeded(); |
END |
+ } else { |
+ AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
+ $code .=<<END; |
+ throwTypeError(ExceptionMessages::failedToExecute(\"${name}\", \"${interfaceName}\", \"No function was found that matched the signature provided.\"), info.GetIsolate()); |
+END |
+ } |
$code .= "}\n\n"; |
$code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
- $implementation{nameSpaceInternal}->add($code); |
+ $implementation{nameSpaceInternal}->add($header . $code); |
} |
sub GenerateFunctionCallback |
@@ -2366,9 +2382,11 @@ sub GenerateFunction |
my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interfaceName); |
my $isNonListSVGType = $svgNativeType && !($interfaceName =~ /List$/); |
+ my $hasExceptionState = 0; |
if ($raisesExceptions || $isEventListener || $isSecurityCheckNecessary || $isNonListSVGType) { |
AddToImplIncludes("bindings/v8/ExceptionState.h"); |
$code .= " ExceptionState exceptionState(ExceptionState::ExecutionContext, \"${unoverloadedName}\", \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
+ $hasExceptionState = 1; |
} |
if ($isEventListener) { |
@@ -2404,7 +2422,7 @@ END |
return; |
} |
- $code .= GenerateArgumentsCountCheck($function, $interface); |
+ $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionState); |
if ($name eq "set" and IsConstructorTemplate($interface, "TypedArray")) { |
AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); |
@@ -2515,6 +2533,7 @@ sub GenerateArgumentsCountCheck |
{ |
my $function = shift; |
my $interface = shift; |
+ my $hasExceptionState = shift; |
my $functionName = $function->name; |
my $interfaceName = $interface->name; |
@@ -2534,7 +2553,11 @@ sub GenerateArgumentsCountCheck |
my $argumentsCountCheckString = ""; |
if ($numMandatoryParams >= 1) { |
$argumentsCountCheckString .= " if (UNLIKELY(info.Length() < $numMandatoryParams)) {\n"; |
- $argumentsCountCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", ExceptionMessages::notEnoughArguments($numMandatoryParams, info.Length())), info.GetIsolate());\n"; |
+ if ($hasExceptionState) { |
+ $argumentsCountCheckString .= " exceptionState.notEnoughArguments($numMandatoryParams, info.Length());\n"; |
+ } else { |
+ $argumentsCountCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", ExceptionMessages::notEnoughArguments($numMandatoryParams, info.Length())), info.GetIsolate());\n"; |
+ } |
$argumentsCountCheckString .= " return;\n"; |
$argumentsCountCheckString .= " }\n"; |
} |
@@ -2705,11 +2728,13 @@ sub GenerateOverloadedConstructorCallback |
my $interfaceName = $interface->name; |
my $implClassName = GetImplName($interface); |
- my $code = ""; |
- $code .= <<END; |
+ my $hasExceptionState = 0; |
+ my $header = ""; |
+ $header .= <<END; |
static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
END |
+ my $code = ""; |
my $leastNumMandatoryParams = 255; |
foreach my $constructor (@{$interface->constructors}) { |
my $name = "constructor" . $constructor->overloadedIndex; |
@@ -2721,19 +2746,29 @@ END |
$code .= " }\n"; |
} |
if ($leastNumMandatoryParams >= 1) { |
- AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
+ if (!$hasExceptionState) { |
+ AddToImplIncludes("bindings/v8/ExceptionState.h"); |
+ $header .= " ExceptionState exceptionState(ExceptionState::ConstructionContext, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
+ $hasExceptionState = 1; |
+ } |
$code .= " if (UNLIKELY(info.Length() < $leastNumMandatoryParams)) {\n"; |
- |
- $code .= " throwTypeError(ExceptionMessages::failedToConstruct(\"$interfaceName\", ExceptionMessages::notEnoughArguments($leastNumMandatoryParams, info.Length())), info.GetIsolate());\n"; |
+ $code .= " exceptionState.notEnoughArguments($leastNumMandatoryParams, info.Length());\n"; |
$code .= " return;\n"; |
$code .= " }\n"; |
} |
- $code .= <<END; |
- throwTypeError(ExceptionMessages::failedToConstruct(\"$interfaceName\", \"No matching constructor signature.\"), info.GetIsolate()); |
- return; |
+ if ($hasExceptionState) { |
+ $code .= <<END; |
+ exceptionState.throwTypeError(\"No matching constructor signature.\"); |
+ exceptionState.throwIfNeeded(); |
END |
+ } else { |
+ AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
+ $code .= <<END; |
+ throwTypeError(ExceptionMessages::failedToConstruct(\"${interfaceName}\", \"No matching constructor signature.\"), info.GetIsolate()); |
+END |
+ } |
$code .= "}\n\n"; |
- $implementation{nameSpaceInternal}->add($code); |
+ $implementation{nameSpaceInternal}->add($header . $code); |
} |
sub GenerateSingleConstructorCallback |
@@ -2760,7 +2795,8 @@ static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v |
END |
if ($function->overloadedIndex == 0) { |
- $code .= GenerateArgumentsCountCheck($function, $interface); |
+ my $hasExceptionState = 0; |
+ $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionState); |
} |
if ($raisesExceptions) { |
@@ -3103,7 +3139,8 @@ END |
END |
- $code .= GenerateArgumentsCountCheck($function, $interface); |
+ my $hasExceptionState = 0; |
+ $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionState); |
if ($raisesExceptions) { |
AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |