| 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 9cac0b41728a4eb89c22963048583cb87f6694bb..09842632d9f4e6f34bae01d2a984363d0b05d694 100644
|
| --- a/Source/bindings/scripts/code_generator_v8.pm
|
| +++ b/Source/bindings/scripts/code_generator_v8.pm
|
| @@ -2166,7 +2166,7 @@ sub GenerateParametersCheckExpression
|
| # FIXME: Implement WebIDL overload resolution algorithm.
|
| if ($type eq "DOMString") {
|
| if ($parameter->extendedAttributes->{"StrictTypeChecking"}) {
|
| - push(@andExpression, "${value}->IsNull() || ${value}->IsUndefined() || ${value}->IsString() || ${value}->IsObject()");
|
| + push(@andExpression, "isUndefinedOrNull(${value}) || ${value}->IsString() || ${value}->IsObject()");
|
| }
|
| } elsif (IsCallbackInterface($parameter->type)) {
|
| # For Callbacks only checks if the value is null or object.
|
| @@ -2456,7 +2456,7 @@ END
|
| END
|
| }
|
|
|
| - my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interface, $forMainWorldSuffix);
|
| + my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interface, $forMainWorldSuffix, $hasExceptionState);
|
| $code .= $parameterCheckString;
|
|
|
| # Build the function call string.
|
| @@ -2545,6 +2545,7 @@ sub GenerateParametersCheck
|
| my $function = shift;
|
| my $interface = shift;
|
| my $forMainWorldSuffix = shift;
|
| + my $hasExceptionState = shift;
|
| my $style = shift || "new";
|
|
|
| my $functionName = $function->name;
|
| @@ -2578,9 +2579,14 @@ END
|
| AddToImplIncludes("$v8ClassName.h");
|
| if ($parameter->isOptional) {
|
| $parameterCheckString .= " OwnPtr<" . $parameter->type . "> $parameterName;\n";
|
| - $parameterCheckString .= " if (info.Length() > $paramIndex && !info[$paramIndex]->IsNull() && !info[$paramIndex]->IsUndefined()) {\n";
|
| + $parameterCheckString .= " if (info.Length() > $paramIndex && !isUndefinedOrNull(info[$paramIndex])) {\n";
|
| $parameterCheckString .= " if (!info[$paramIndex]->IsFunction()) {\n";
|
| - $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n";
|
| + if ($hasExceptionState) {
|
| + $parameterCheckString .= " exceptionState.throwTypeError(\"The callback provided as parameter $humanFriendlyIndex is not a function.\");\n";
|
| + $parameterCheckString .= " exceptionState.throwIfNeeded();\n";
|
| + } else {
|
| + $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n";
|
| + }
|
| $parameterCheckString .= " return;\n";
|
| $parameterCheckString .= " }\n";
|
| $parameterCheckString .= " $parameterName = ${v8ClassName}::create(v8::Handle<v8::Function>::Cast(info[$paramIndex]), getExecutionContext());\n";
|
| @@ -2593,7 +2599,12 @@ END
|
| $parameterCheckString .= "!info[$paramIndex]->IsFunction()";
|
| }
|
| $parameterCheckString .= ") {\n";
|
| - $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n";
|
| + if ($hasExceptionState) {
|
| + $parameterCheckString .= " exceptionState.throwTypeError(\"The callback provided as parameter $humanFriendlyIndex is not a function.\");\n";
|
| + $parameterCheckString .= " exceptionState.throwIfNeeded();\n";
|
| + } else {
|
| + $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n";
|
| + }
|
| $parameterCheckString .= " return;\n";
|
| $parameterCheckString .= " }\n";
|
| $parameterCheckString .= " OwnPtr<" . $parameter->type . "> $parameterName = ";
|
| @@ -2609,9 +2620,14 @@ END
|
| $parameterCheckString .= " $parameterName = clampTo<$idlType>($nativeValue);\n";
|
| } elsif ($parameter->type eq "SerializedScriptValue") {
|
| AddToImplIncludes("bindings/v8/SerializedScriptValue.h");
|
| - $parameterCheckString .= " bool ${parameterName}DidThrow = false;\n";
|
| - $parameterCheckString .= " $nativeType $parameterName = SerializedScriptValue::create(info[$paramIndex], 0, 0, ${parameterName}DidThrow, info.GetIsolate());\n";
|
| - $parameterCheckString .= " if (${parameterName}DidThrow)\n";
|
| + if ($hasExceptionState) {
|
| + $parameterCheckString .= " $nativeType $parameterName = SerializedScriptValue::create(info[$paramIndex], 0, 0, exceptionState, info.GetIsolate());\n";
|
| + $parameterCheckString .= " if (exceptionState.throwIfNeeded())\n";
|
| + } else {
|
| + $parameterCheckString .= " bool ${parameterName}DidThrow = false;\n";
|
| + $parameterCheckString .= " $nativeType $parameterName = SerializedScriptValue::create(info[$paramIndex], 0, 0, ${parameterName}DidThrow, info.GetIsolate());\n";
|
| + $parameterCheckString .= " if (${parameterName}DidThrow)\n";
|
| + }
|
| $parameterCheckString .= " return;\n";
|
| } elsif ($parameter->isVariadic) {
|
| my $nativeElementType = GetNativeType($parameter->type);
|
| @@ -2624,7 +2640,12 @@ END
|
| $parameterCheckString .= " Vector<$nativeElementType> $parameterName;\n";
|
| $parameterCheckString .= " for (int i = $paramIndex; i < info.Length(); ++i) {\n";
|
| $parameterCheckString .= " if (!V8${argType}::hasInstance(info[i], info.GetIsolate(), worldType(info.GetIsolate()))) {\n";
|
| - $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n";
|
| + if ($hasExceptionState) {
|
| + $parameterCheckString .= " exceptionState.throwTypeError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n";
|
| + $parameterCheckString .= " exceptionState.throwIfNeeded();\n";
|
| + } else {
|
| + $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n";
|
| + }
|
| $parameterCheckString .= " return;\n";
|
| $parameterCheckString .= " }\n";
|
| $parameterCheckString .= " $parameterName.append(V8${argType}::toNative(v8::Handle<v8::Object>::Cast(info[i])));\n";
|
| @@ -2652,7 +2673,12 @@ END
|
| my $enumValidationExpression = join(" || ", @validEqualities);
|
| $parameterCheckString .= " String string = $parameterName;\n";
|
| $parameterCheckString .= " if (!($enumValidationExpression)) {\n";
|
| - $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $humanFriendlyIndex (\'\" + string + \"\') is not a valid enum value.\"), info.GetIsolate());\n";
|
| + if ($hasExceptionState) {
|
| + $parameterCheckString .= " exceptionState.throwTypeError(\"parameter $humanFriendlyIndex (\'\" + string + \"\') is not a valid enum value.\");\n";
|
| + $parameterCheckString .= " exceptionState.throwIfNeeded();\n";
|
| + } else {
|
| + $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $humanFriendlyIndex (\'\" + string + \"\') is not a valid enum value.\"), info.GetIsolate());\n";
|
| + }
|
| $parameterCheckString .= " return;\n";
|
| $parameterCheckString .= " }\n";
|
| }
|
| @@ -2668,7 +2694,12 @@ END
|
| my $argType = $parameter->type;
|
| if (IsWrapperType($argType)) {
|
| $parameterCheckString .= " if (info.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !V8${argType}::hasInstance($argValue, info.GetIsolate(), worldType(info.GetIsolate()))) {\n";
|
| - $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n";
|
| + if ($hasExceptionState) {
|
| + $parameterCheckString .= " exceptionState.throwTypeError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n";
|
| + $parameterCheckString .= " exceptionState.throwIfNeeded();\n";
|
| + }else {
|
| + $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n";
|
| + }
|
| $parameterCheckString .= " return;\n";
|
| $parameterCheckString .= " }\n";
|
| }
|
| @@ -2680,7 +2711,10 @@ END
|
| $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $humanFriendlyIndex, $jsValue, $parameterName, " ", "info.GetIsolate()");
|
| if ($nativeType eq 'Dictionary' or $nativeType eq 'ScriptPromise') {
|
| $parameterCheckString .= " if (!$parameterName.isUndefinedOrNull() && !$parameterName.isObject()) {\n";
|
| - if ($functionName eq "Constructor") {
|
| + if ($hasExceptionState) {
|
| + $parameterCheckString .= " exceptionState.throwTypeError(\"parameter ${humanFriendlyIndex} ('${parameterName}') is not an object.\");\n";
|
| + $parameterCheckString .= " exceptionState.throwIfNeeded();\n";
|
| + } elsif ($functionName eq "Constructor") {
|
| $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToConstruct(\"$interfaceName\", \"parameter ${humanFriendlyIndex} ('${parameterName}') is not an object.\"), info.GetIsolate());\n";
|
| } else {
|
| $parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter ${humanFriendlyIndex} ('${parameterName}') is not an object.\"), info.GetIsolate());\n";
|
| @@ -2779,7 +2813,7 @@ END
|
| }
|
|
|
| # FIXME: Currently [Constructor(...)] does not yet support optional arguments without [Default=...]
|
| - my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interface, "");
|
| + my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interface, "", $raisesExceptions);
|
| $code .= $parameterCheckString;
|
|
|
| if ($interface->extendedAttributes->{"ConstructorCallWith"}) {
|
| @@ -3102,7 +3136,7 @@ END
|
| my $hasExceptionState = $raisesExceptions;
|
| $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionState);
|
|
|
| - my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interface);
|
| + my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $interface, "", $raisesExceptions);
|
| $code .= $parameterCheckString;
|
|
|
| push(@beforeArgumentList, "*document");
|
|
|