OLD | NEW |
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 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2159 my $value = "info[$parameterIndex]"; | 2159 my $value = "info[$parameterIndex]"; |
2160 my $type = $parameter->type; | 2160 my $type = $parameter->type; |
2161 | 2161 |
2162 # Only DOMString or wrapper types are checked. | 2162 # Only DOMString or wrapper types are checked. |
2163 # For DOMString with StrictTypeChecking only Null, Undefined and Object | 2163 # For DOMString with StrictTypeChecking only Null, Undefined and Object |
2164 # are accepted for compatibility. Otherwise, no restrictions are made to | 2164 # are accepted for compatibility. Otherwise, no restrictions are made to |
2165 # match the non-overloaded behavior. | 2165 # match the non-overloaded behavior. |
2166 # FIXME: Implement WebIDL overload resolution algorithm. | 2166 # FIXME: Implement WebIDL overload resolution algorithm. |
2167 if ($type eq "DOMString") { | 2167 if ($type eq "DOMString") { |
2168 if ($parameter->extendedAttributes->{"StrictTypeChecking"}) { | 2168 if ($parameter->extendedAttributes->{"StrictTypeChecking"}) { |
2169 push(@andExpression, "${value}->IsNull() || ${value}->IsUndefine
d() || ${value}->IsString() || ${value}->IsObject()"); | 2169 push(@andExpression, "isUndefinedOrNull(${value}) || ${value}->I
sString() || ${value}->IsObject()"); |
2170 } | 2170 } |
2171 } elsif (IsCallbackInterface($parameter->type)) { | 2171 } elsif (IsCallbackInterface($parameter->type)) { |
2172 # For Callbacks only checks if the value is null or object. | 2172 # For Callbacks only checks if the value is null or object. |
2173 push(@andExpression, "${value}->IsNull() || ${value}->IsFunction()")
; | 2173 push(@andExpression, "${value}->IsNull() || ${value}->IsFunction()")
; |
2174 } elsif (GetArrayOrSequenceType($type)) { | 2174 } elsif (GetArrayOrSequenceType($type)) { |
2175 if ($parameter->isNullable) { | 2175 if ($parameter->isNullable) { |
2176 push(@andExpression, "${value}->IsNull() || ${value}->IsArray()"
); | 2176 push(@andExpression, "${value}->IsNull() || ${value}->IsArray()"
); |
2177 } else { | 2177 } else { |
2178 push(@andExpression, "${value}->IsArray()"); | 2178 push(@andExpression, "${value}->IsArray()"); |
2179 } | 2179 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2449 if ($function->extendedAttributes->{"CheckSecurity"}) { | 2449 if ($function->extendedAttributes->{"CheckSecurity"}) { |
2450 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2450 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
2451 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get
ImplName($function) . "(exceptionState), exceptionState)) {\n"; | 2451 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get
ImplName($function) . "(exceptionState), exceptionState)) {\n"; |
2452 $code .= " v8SetReturnValueNull(info);\n"; | 2452 $code .= " v8SetReturnValueNull(info);\n"; |
2453 $code .= " exceptionState.throwIfNeeded();\n"; | 2453 $code .= " exceptionState.throwIfNeeded();\n"; |
2454 $code .= " return;\n"; | 2454 $code .= " return;\n"; |
2455 $code .= " }\n"; | 2455 $code .= " }\n"; |
2456 END | 2456 END |
2457 } | 2457 } |
2458 | 2458 |
2459 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, $forMainWorldSuffix); | 2459 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, $forMainWorldSuffix, $hasExceptionState); |
2460 $code .= $parameterCheckString; | 2460 $code .= $parameterCheckString; |
2461 | 2461 |
2462 # Build the function call string. | 2462 # Build the function call string. |
2463 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa
ce, $forMainWorldSuffix, %replacements); | 2463 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa
ce, $forMainWorldSuffix, %replacements); |
2464 $code .= "}\n"; | 2464 $code .= "}\n"; |
2465 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 2465 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
2466 $code .= "\n"; | 2466 $code .= "\n"; |
2467 $implementation{nameSpaceInternal}->add($code); | 2467 $implementation{nameSpaceInternal}->add($code); |
2468 } | 2468 } |
2469 | 2469 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2538 $argumentsCountCheckString .= " }\n"; | 2538 $argumentsCountCheckString .= " }\n"; |
2539 } | 2539 } |
2540 return $argumentsCountCheckString; | 2540 return $argumentsCountCheckString; |
2541 } | 2541 } |
2542 | 2542 |
2543 sub GenerateParametersCheck | 2543 sub GenerateParametersCheck |
2544 { | 2544 { |
2545 my $function = shift; | 2545 my $function = shift; |
2546 my $interface = shift; | 2546 my $interface = shift; |
2547 my $forMainWorldSuffix = shift; | 2547 my $forMainWorldSuffix = shift; |
| 2548 my $hasExceptionState = shift; |
2548 my $style = shift || "new"; | 2549 my $style = shift || "new"; |
2549 | 2550 |
2550 my $functionName = $function->name; | 2551 my $functionName = $function->name; |
2551 my $interfaceName = $interface->name; | 2552 my $interfaceName = $interface->name; |
2552 my $implClassName = GetImplName($interface); | 2553 my $implClassName = GetImplName($interface); |
2553 | 2554 |
2554 my $parameterCheckString = ""; | 2555 my $parameterCheckString = ""; |
2555 my $paramIndex = 0; | 2556 my $paramIndex = 0; |
2556 my %replacements = (); | 2557 my %replacements = (); |
2557 | 2558 |
(...skipping 13 matching lines...) Expand all Loading... |
2571 } | 2572 } |
2572 END | 2573 END |
2573 } | 2574 } |
2574 | 2575 |
2575 my $parameterName = $parameter->name; | 2576 my $parameterName = $parameter->name; |
2576 if (IsCallbackInterface($parameter->type)) { | 2577 if (IsCallbackInterface($parameter->type)) { |
2577 my $v8ClassName = "V8" . $parameter->type; | 2578 my $v8ClassName = "V8" . $parameter->type; |
2578 AddToImplIncludes("$v8ClassName.h"); | 2579 AddToImplIncludes("$v8ClassName.h"); |
2579 if ($parameter->isOptional) { | 2580 if ($parameter->isOptional) { |
2580 $parameterCheckString .= " OwnPtr<" . $parameter->type . "> $
parameterName;\n"; | 2581 $parameterCheckString .= " OwnPtr<" . $parameter->type . "> $
parameterName;\n"; |
2581 $parameterCheckString .= " if (info.Length() > $paramIndex &&
!info[$paramIndex]->IsNull() && !info[$paramIndex]->IsUndefined()) {\n"; | 2582 $parameterCheckString .= " if (info.Length() > $paramIndex &&
!isUndefinedOrNull(info[$paramIndex])) {\n"; |
2582 $parameterCheckString .= " if (!info[$paramIndex]->IsFunc
tion()) {\n"; | 2583 $parameterCheckString .= " if (!info[$paramIndex]->IsFunc
tion()) {\n"; |
2583 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback pr
ovided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate()
);\n"; | 2584 if ($hasExceptionState) { |
| 2585 $parameterCheckString .= " exceptionState.throwTy
peError(\"The callback provided as parameter $humanFriendlyIndex is not a functi
on.\");\n"; |
| 2586 $parameterCheckString .= " exceptionState.throwIf
Needed();\n"; |
| 2587 } else { |
| 2588 $parameterCheckString .= " throwTypeError(Excepti
onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callbac
k provided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsola
te());\n"; |
| 2589 } |
2584 $parameterCheckString .= " return;\n"; | 2590 $parameterCheckString .= " return;\n"; |
2585 $parameterCheckString .= " }\n"; | 2591 $parameterCheckString .= " }\n"; |
2586 $parameterCheckString .= " $parameterName = ${v8ClassName
}::create(v8::Handle<v8::Function>::Cast(info[$paramIndex]), getExecutionContext
());\n"; | 2592 $parameterCheckString .= " $parameterName = ${v8ClassName
}::create(v8::Handle<v8::Function>::Cast(info[$paramIndex]), getExecutionContext
());\n"; |
2587 $parameterCheckString .= " }\n"; | 2593 $parameterCheckString .= " }\n"; |
2588 } else { | 2594 } else { |
2589 $parameterCheckString .= " if (info.Length() <= $paramIndex |
| "; | 2595 $parameterCheckString .= " if (info.Length() <= $paramIndex |
| "; |
2590 if ($parameter->isNullable) { | 2596 if ($parameter->isNullable) { |
2591 $parameterCheckString .= "!(info[$paramIndex]->IsFunction()
|| info[$paramIndex]->IsNull())"; | 2597 $parameterCheckString .= "!(info[$paramIndex]->IsFunction()
|| info[$paramIndex]->IsNull())"; |
2592 } else { | 2598 } else { |
2593 $parameterCheckString .= "!info[$paramIndex]->IsFunction()"; | 2599 $parameterCheckString .= "!info[$paramIndex]->IsFunction()"; |
2594 } | 2600 } |
2595 $parameterCheckString .= ") {\n"; | 2601 $parameterCheckString .= ") {\n"; |
2596 $parameterCheckString .= " throwTypeError(ExceptionMessag
es::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provid
ed as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n
"; | 2602 if ($hasExceptionState) { |
| 2603 $parameterCheckString .= " exceptionState.throwTypeEr
ror(\"The callback provided as parameter $humanFriendlyIndex is not a function.\
");\n"; |
| 2604 $parameterCheckString .= " exceptionState.throwIfNeed
ed();\n"; |
| 2605 } else { |
| 2606 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback pr
ovided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate()
);\n"; |
| 2607 } |
2597 $parameterCheckString .= " return;\n"; | 2608 $parameterCheckString .= " return;\n"; |
2598 $parameterCheckString .= " }\n"; | 2609 $parameterCheckString .= " }\n"; |
2599 $parameterCheckString .= " OwnPtr<" . $parameter->type . "> $
parameterName = "; | 2610 $parameterCheckString .= " OwnPtr<" . $parameter->type . "> $
parameterName = "; |
2600 $parameterCheckString .= "info[$paramIndex]->IsNull() ? nullptr
: " if $parameter->isNullable; | 2611 $parameterCheckString .= "info[$paramIndex]->IsNull() ? nullptr
: " if $parameter->isNullable; |
2601 $parameterCheckString .= "${v8ClassName}::create(v8::Handle<v8::
Function>::Cast(info[$paramIndex]), getExecutionContext());\n"; | 2612 $parameterCheckString .= "${v8ClassName}::create(v8::Handle<v8::
Function>::Cast(info[$paramIndex]), getExecutionContext());\n"; |
2602 } | 2613 } |
2603 } elsif ($parameter->extendedAttributes->{"Clamp"}) { | 2614 } elsif ($parameter->extendedAttributes->{"Clamp"}) { |
2604 my $nativeValue = "${parameterName}NativeValue"; | 2615 my $nativeValue = "${parameterName}NativeValue"; |
2605 my $idlType = $parameter->type; | 2616 my $idlType = $parameter->type; |
2606 $parameterCheckString .= " $nativeType $parameterName = 0;\n"
; | 2617 $parameterCheckString .= " $nativeType $parameterName = 0;\n"
; |
2607 $parameterCheckString .= " V8TRYCATCH_VOID(double, $nativeVal
ue, info[$paramIndex]->NumberValue());\n"; | 2618 $parameterCheckString .= " V8TRYCATCH_VOID(double, $nativeVal
ue, info[$paramIndex]->NumberValue());\n"; |
2608 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; | 2619 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; |
2609 $parameterCheckString .= " $parameterName = clampTo<$idlT
ype>($nativeValue);\n"; | 2620 $parameterCheckString .= " $parameterName = clampTo<$idlT
ype>($nativeValue);\n"; |
2610 } elsif ($parameter->type eq "SerializedScriptValue") { | 2621 } elsif ($parameter->type eq "SerializedScriptValue") { |
2611 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 2622 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
2612 $parameterCheckString .= " bool ${parameterName}DidThrow = false;
\n"; | 2623 if ($hasExceptionState) { |
2613 $parameterCheckString .= " $nativeType $parameterName = Serialize
dScriptValue::create(info[$paramIndex], 0, 0, ${parameterName}DidThrow, info.Get
Isolate());\n"; | 2624 $parameterCheckString .= " $nativeType $parameterName = Seria
lizedScriptValue::create(info[$paramIndex], 0, 0, exceptionState, info.GetIsolat
e());\n"; |
2614 $parameterCheckString .= " if (${parameterName}DidThrow)\n"; | 2625 $parameterCheckString .= " if (exceptionState.throwIfNeeded()
)\n"; |
| 2626 } else { |
| 2627 $parameterCheckString .= " bool ${parameterName}DidThrow = fa
lse;\n"; |
| 2628 $parameterCheckString .= " $nativeType $parameterName = Seria
lizedScriptValue::create(info[$paramIndex], 0, 0, ${parameterName}DidThrow, info
.GetIsolate());\n"; |
| 2629 $parameterCheckString .= " if (${parameterName}DidThrow)\n"; |
| 2630 } |
2615 $parameterCheckString .= " return;\n"; | 2631 $parameterCheckString .= " return;\n"; |
2616 } elsif ($parameter->isVariadic) { | 2632 } elsif ($parameter->isVariadic) { |
2617 my $nativeElementType = GetNativeType($parameter->type); | 2633 my $nativeElementType = GetNativeType($parameter->type); |
2618 if ($nativeElementType =~ />$/) { | 2634 if ($nativeElementType =~ />$/) { |
2619 $nativeElementType .= " "; | 2635 $nativeElementType .= " "; |
2620 } | 2636 } |
2621 | 2637 |
2622 my $argType = $parameter->type; | 2638 my $argType = $parameter->type; |
2623 if (IsWrapperType($argType)) { | 2639 if (IsWrapperType($argType)) { |
2624 $parameterCheckString .= " Vector<$nativeElementType> $parame
terName;\n"; | 2640 $parameterCheckString .= " Vector<$nativeElementType> $parame
terName;\n"; |
2625 $parameterCheckString .= " for (int i = $paramIndex; i < info
.Length(); ++i) {\n"; | 2641 $parameterCheckString .= " for (int i = $paramIndex; i < info
.Length(); ++i) {\n"; |
2626 $parameterCheckString .= " if (!V8${argType}::hasInstance
(info[i], info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; | 2642 $parameterCheckString .= " if (!V8${argType}::hasInstance
(info[i], info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; |
2627 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $huma
nFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; | 2643 if ($hasExceptionState) { |
| 2644 $parameterCheckString .= " exceptionState.throwTy
peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n"; |
| 2645 $parameterCheckString .= " exceptionState.throwIf
Needed();\n"; |
| 2646 } else { |
| 2647 $parameterCheckString .= " throwTypeError(Excepti
onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $
humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; |
| 2648 } |
2628 $parameterCheckString .= " return;\n"; | 2649 $parameterCheckString .= " return;\n"; |
2629 $parameterCheckString .= " }\n"; | 2650 $parameterCheckString .= " }\n"; |
2630 $parameterCheckString .= " $parameterName.append(V8${argT
ype}::toNative(v8::Handle<v8::Object>::Cast(info[i])));\n"; | 2651 $parameterCheckString .= " $parameterName.append(V8${argT
ype}::toNative(v8::Handle<v8::Object>::Cast(info[i])));\n"; |
2631 $parameterCheckString .= " }\n"; | 2652 $parameterCheckString .= " }\n"; |
2632 } else { | 2653 } else { |
2633 $parameterCheckString .= " V8TRYCATCH_VOID(Vector<$nativeElem
entType>, $parameterName, toNativeArguments<$nativeElementType>(info, $paramInde
x));\n"; | 2654 $parameterCheckString .= " V8TRYCATCH_VOID(Vector<$nativeElem
entType>, $parameterName, toNativeArguments<$nativeElementType>(info, $paramInde
x));\n"; |
2634 } | 2655 } |
2635 } elsif ($nativeType =~ /^V8StringResource/) { | 2656 } elsif ($nativeType =~ /^V8StringResource/) { |
2636 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; | 2657 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; |
2637 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(info, $paramIndex)" : "info[$paramIndex]"; | 2658 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(info, $paramIndex)" : "info[$paramIndex]"; |
2638 my $stringResourceParameterName = $parameterName; | 2659 my $stringResourceParameterName = $parameterName; |
2639 my $isNullable = IsNullableParameter($parameter); | 2660 my $isNullable = IsNullableParameter($parameter); |
2640 if ($isNullable) { | 2661 if ($isNullable) { |
2641 $parameterCheckString .= " bool ${parameterName}IsNull = $jsV
alue->IsNull();\n"; | 2662 $parameterCheckString .= " bool ${parameterName}IsNull = $jsV
alue->IsNull();\n"; |
2642 $stringResourceParameterName .= "StringResource"; | 2663 $stringResourceParameterName .= "StringResource"; |
2643 } | 2664 } |
2644 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $humanFriendlyIndex, $jsValue, $stringResourcePa
rameterName, " ", "info.GetIsolate()"); | 2665 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $humanFriendlyIndex, $jsValue, $stringResourcePa
rameterName, " ", "info.GetIsolate()"); |
2645 $parameterCheckString .= " String $parameterName = $stringResourc
eParameterName;\n" if $isNullable; | 2666 $parameterCheckString .= " String $parameterName = $stringResourc
eParameterName;\n" if $isNullable; |
2646 if (IsEnumType($parameter->type)) { | 2667 if (IsEnumType($parameter->type)) { |
2647 my @enumValues = ValidEnumValues($parameter->type); | 2668 my @enumValues = ValidEnumValues($parameter->type); |
2648 my @validEqualities = (); | 2669 my @validEqualities = (); |
2649 foreach my $enumValue (@enumValues) { | 2670 foreach my $enumValue (@enumValues) { |
2650 push(@validEqualities, "string == \"$enumValue\""); | 2671 push(@validEqualities, "string == \"$enumValue\""); |
2651 } | 2672 } |
2652 my $enumValidationExpression = join(" || ", @validEqualities); | 2673 my $enumValidationExpression = join(" || ", @validEqualities); |
2653 $parameterCheckString .= " String string = $parameterName;\n
"; | 2674 $parameterCheckString .= " String string = $parameterName;\n
"; |
2654 $parameterCheckString .= " if (!($enumValidationExpression))
{\n"; | 2675 $parameterCheckString .= " if (!($enumValidationExpression))
{\n"; |
2655 $parameterCheckString .= " throwTypeError(ExceptionMessag
es::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $humanFri
endlyIndex (\'\" + string + \"\') is not a valid enum value.\"), info.GetIsolate
());\n"; | 2676 if ($hasExceptionState) { |
| 2677 $parameterCheckString .= " exceptionState.throwTypeEr
ror(\"parameter $humanFriendlyIndex (\'\" + string + \"\') is not a valid enum v
alue.\");\n"; |
| 2678 $parameterCheckString .= " exceptionState.throwIfNeed
ed();\n"; |
| 2679 } else { |
| 2680 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $huma
nFriendlyIndex (\'\" + string + \"\') is not a valid enum value.\"), info.GetIso
late());\n"; |
| 2681 } |
2656 $parameterCheckString .= " return;\n"; | 2682 $parameterCheckString .= " return;\n"; |
2657 $parameterCheckString .= " }\n"; | 2683 $parameterCheckString .= " }\n"; |
2658 } | 2684 } |
2659 } else { | 2685 } else { |
2660 # If the "StrictTypeChecking" extended attribute is present, and the
argument's type is an | 2686 # If the "StrictTypeChecking" extended attribute is present, and the
argument's type is an |
2661 # interface type, then if the incoming value does not implement that
interface, a TypeError | 2687 # interface type, then if the incoming value does not implement that
interface, a TypeError |
2662 # is thrown rather than silently passing NULL to the C++ code. | 2688 # is thrown rather than silently passing NULL to the C++ code. |
2663 # Per the Web IDL and ECMAScript specifications, incoming values can
always be converted | 2689 # Per the Web IDL and ECMAScript specifications, incoming values can
always be converted |
2664 # to both strings and numbers, so do not throw TypeError if the argu
ment is of these | 2690 # to both strings and numbers, so do not throw TypeError if the argu
ment is of these |
2665 # types. | 2691 # types. |
2666 if ($function->extendedAttributes->{"StrictTypeChecking"}) { | 2692 if ($function->extendedAttributes->{"StrictTypeChecking"}) { |
2667 my $argValue = "info[$paramIndex]"; | 2693 my $argValue = "info[$paramIndex]"; |
2668 my $argType = $parameter->type; | 2694 my $argType = $parameter->type; |
2669 if (IsWrapperType($argType)) { | 2695 if (IsWrapperType($argType)) { |
2670 $parameterCheckString .= " if (info.Length() > $paramInde
x && !isUndefinedOrNull($argValue) && !V8${argType}::hasInstance($argValue, info
.GetIsolate(), worldType(info.GetIsolate()))) {\n"; | 2696 $parameterCheckString .= " if (info.Length() > $paramInde
x && !isUndefinedOrNull($argValue) && !V8${argType}::hasInstance($argValue, info
.GetIsolate(), worldType(info.GetIsolate()))) {\n"; |
2671 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $huma
nFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; | 2697 if ($hasExceptionState) { |
| 2698 $parameterCheckString .= " exceptionState.throwTy
peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n"; |
| 2699 $parameterCheckString .= " exceptionState.throwIf
Needed();\n"; |
| 2700 }else { |
| 2701 $parameterCheckString .= " throwTypeError(Excepti
onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $
humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; |
| 2702 } |
2672 $parameterCheckString .= " return;\n"; | 2703 $parameterCheckString .= " return;\n"; |
2673 $parameterCheckString .= " }\n"; | 2704 $parameterCheckString .= " }\n"; |
2674 } | 2705 } |
2675 } | 2706 } |
2676 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; | 2707 my $default = defined $parameter->extendedAttributes->{"Default"} ?
$parameter->extendedAttributes->{"Default"} : ""; |
2677 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(info, $paramIndex)" : "info[$paramIndex]"; | 2708 my $jsValue = $parameter->isOptional && $default eq "NullString" ? "
argumentOrNull(info, $paramIndex)" : "info[$paramIndex]"; |
2678 my $isNullable = IsNullableParameter($parameter); | 2709 my $isNullable = IsNullableParameter($parameter); |
2679 $parameterCheckString .= " bool ${parameterName}IsNull = $jsValue
->IsNull();\n" if $isNullable; | 2710 $parameterCheckString .= " bool ${parameterName}IsNull = $jsValue
->IsNull();\n" if $isNullable; |
2680 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $humanFriendlyIndex, $jsValue, $parameterName, "
", "info.GetIsolate()"); | 2711 $parameterCheckString .= JSValueToNativeStatement($parameter->type,
$parameter->extendedAttributes, $humanFriendlyIndex, $jsValue, $parameterName, "
", "info.GetIsolate()"); |
2681 if ($nativeType eq 'Dictionary' or $nativeType eq 'ScriptPromise') { | 2712 if ($nativeType eq 'Dictionary' or $nativeType eq 'ScriptPromise') { |
2682 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN
ull() && !$parameterName.isObject()) {\n"; | 2713 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN
ull() && !$parameterName.isObject()) {\n"; |
2683 if ($functionName eq "Constructor") { | 2714 if ($hasExceptionState) { |
| 2715 $parameterCheckString .= " exceptionState.throwTypeEr
ror(\"parameter ${humanFriendlyIndex} ('${parameterName}') is not an object.\");
\n"; |
| 2716 $parameterCheckString .= " exceptionState.throwIfNeed
ed();\n"; |
| 2717 } elsif ($functionName eq "Constructor") { |
2684 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToConstruct(\"$interfaceName\", \"parameter ${humanFriendlyIndex}
('${parameterName}') is not an object.\"), info.GetIsolate());\n"; | 2718 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToConstruct(\"$interfaceName\", \"parameter ${humanFriendlyIndex}
('${parameterName}') is not an object.\"), info.GetIsolate());\n"; |
2685 } else { | 2719 } else { |
2686 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter ${hum
anFriendlyIndex} ('${parameterName}') is not an object.\"), info.GetIsolate());\
n"; | 2720 $parameterCheckString .= " throwTypeError(ExceptionMe
ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter ${hum
anFriendlyIndex} ('${parameterName}') is not an object.\"), info.GetIsolate());\
n"; |
2687 } | 2721 } |
2688 $parameterCheckString .= " return;\n"; | 2722 $parameterCheckString .= " return;\n"; |
2689 $parameterCheckString .= " }\n"; | 2723 $parameterCheckString .= " }\n"; |
2690 } | 2724 } |
2691 } | 2725 } |
2692 | 2726 |
2693 $paramIndex++; | 2727 $paramIndex++; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2772 if ($function->overloadedIndex == 0) { | 2806 if ($function->overloadedIndex == 0) { |
2773 my $hasExceptionState = 0; | 2807 my $hasExceptionState = 0; |
2774 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptio
nState); | 2808 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptio
nState); |
2775 } | 2809 } |
2776 | 2810 |
2777 if ($raisesExceptions) { | 2811 if ($raisesExceptions) { |
2778 $code .= " ExceptionState exceptionState(ExceptionState::Construction
Context, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; | 2812 $code .= " ExceptionState exceptionState(ExceptionState::Construction
Context, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
2779 } | 2813 } |
2780 | 2814 |
2781 # FIXME: Currently [Constructor(...)] does not yet support optional argument
s without [Default=...] | 2815 # FIXME: Currently [Constructor(...)] does not yet support optional argument
s without [Default=...] |
2782 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, ""); | 2816 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, "", $raisesExceptions); |
2783 $code .= $parameterCheckString; | 2817 $code .= $parameterCheckString; |
2784 | 2818 |
2785 if ($interface->extendedAttributes->{"ConstructorCallWith"}) { | 2819 if ($interface->extendedAttributes->{"ConstructorCallWith"}) { |
2786 if (ExtendedAttributeContains($interface->extendedAttributes->{"Construc
torCallWith"}, "ExecutionContext")) { | 2820 if (ExtendedAttributeContains($interface->extendedAttributes->{"Construc
torCallWith"}, "ExecutionContext")) { |
2787 push(@beforeArgumentList, "context"); | 2821 push(@beforeArgumentList, "context"); |
2788 $code .= " ExecutionContext* context = getExecutionContext();\n"; | 2822 $code .= " ExecutionContext* context = getExecutionContext();\n"; |
2789 } | 2823 } |
2790 if (ExtendedAttributeContains($interface->extendedAttributes->{"Construc
torCallWith"}, "Document")) { | 2824 if (ExtendedAttributeContains($interface->extendedAttributes->{"Construc
torCallWith"}, "Document")) { |
2791 push(@beforeArgumentList, "document"); | 2825 push(@beforeArgumentList, "document"); |
2792 $code .= " Document& document = *toDocument(getExecutionContext()
);\n"; | 2826 $code .= " Document& document = *toDocument(getExecutionContext()
);\n"; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3095 | 3129 |
3096 END | 3130 END |
3097 | 3131 |
3098 if ($raisesExceptions) { | 3132 if ($raisesExceptions) { |
3099 $code .= " ExceptionState exceptionState(ExceptionState::Construction
Context, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; | 3133 $code .= " ExceptionState exceptionState(ExceptionState::Construction
Context, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
3100 } | 3134 } |
3101 | 3135 |
3102 my $hasExceptionState = $raisesExceptions; | 3136 my $hasExceptionState = $raisesExceptions; |
3103 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionSta
te); | 3137 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionSta
te); |
3104 | 3138 |
3105 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface); | 3139 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, "", $raisesExceptions); |
3106 $code .= $parameterCheckString; | 3140 $code .= $parameterCheckString; |
3107 | 3141 |
3108 push(@beforeArgumentList, "*document"); | 3142 push(@beforeArgumentList, "*document"); |
3109 | 3143 |
3110 if ($constructorRaisesException) { | 3144 if ($constructorRaisesException) { |
3111 push(@afterArgumentList, "exceptionState"); | 3145 push(@afterArgumentList, "exceptionState"); |
3112 } | 3146 } |
3113 | 3147 |
3114 my @argumentList; | 3148 my @argumentList; |
3115 my $index = 0; | 3149 my $index = 0; |
(...skipping 3235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6351 | 6385 |
6352 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust
om"}, "ToV8"); | 6386 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust
om"}, "ToV8"); |
6353 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust
om"}, "Wrap"); | 6387 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust
om"}, "Wrap"); |
6354 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6388 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
6355 return 1 if InheritsInterface($interface, "Document"); | 6389 return 1 if InheritsInterface($interface, "Document"); |
6356 | 6390 |
6357 return 0; | 6391 return 0; |
6358 } | 6392 } |
6359 | 6393 |
6360 1; | 6394 1; |
OLD | NEW |