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

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

Issue 143943020: Replace [TreatNullAs=functionName] with [StrictTypeChecking] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update tests, Python, and IDLExtendedAttributes.txt Created 6 years, 11 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
« no previous file with comments | « Source/bindings/IDLExtendedAttributes.txt ('k') | Source/bindings/scripts/unstable/v8_interface.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0989b9075bf56bf034b1754cc90cbc35495d2f27..ffd92ed701093edc585546f959b9853b25a1392d 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -3788,19 +3788,17 @@ sub GenerateImplementationIndexedPropertySetter
$code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());\n";
$code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->type, $indexedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "propertyValue", " ", "info.GetIsolate()");
- my @conditions = ();
- my @statements = ();
- if ($treatNullAs && $treatNullAs ne "NullString") {
- push @conditions, "jsValue->IsNull()";
- push @statements, "collection->${treatNullAs}(index$extraArguments);";
+ if ($indexedSetterFunction->extendedAttributes->{"StrictTypeChecking"} && IsWrapperType($type)) {
+ $code .= <<END;
+ if (!isUndefinedOrNull(jsValue) && !V8${type}::hasInstance(jsValue, info.GetIsolate())) {
+ exceptionState.throwTypeError("The provided value is not of type '$type'.");
+ exceptionState.throwIfNeeded();
+ return;
}
- if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
- push @conditions, "jsValue->IsUndefined()";
- push @statements, "collection->${treatUndefinedAs}(index$extraArguments);";
+END
}
- push @conditions, "";
- push @statements, "collection->${methodName}(index, propertyValue$extraArguments);";
- $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statements);
+
+ $code .= " bool result = collection->${methodName}(index, propertyValue$extraArguments);\n";
if ($raisesExceptions) {
$code .= " if (exceptionState.throwIfNeeded())\n";
@@ -4121,20 +4119,7 @@ sub GenerateImplementationNamedPropertySetter
$code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->type, $namedSetterFunction->extendedAttributes, $asSetterValue, "name", "propertyName", " ", "info.GetIsolate()");
$code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->type, $namedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "propertyValue", " ", "info.GetIsolate()");
- my @conditions = ();
- my @statements = ();
- if ($treatNullAs && $treatNullAs ne "NullString") {
- push @conditions, "jsValue->IsNull()";
- push @statements, "collection->${treatNullAs}(propertyName$extraArguments);";
- }
- if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
- push @conditions, "jsValue->IsUndefined()";
- push @statements, "collection->${treatUndefinedAs}(propertyName$extraArguments);";
- }
- push @conditions, "";
- push @statements, "collection->${methodName}(propertyName, propertyValue$extraArguments);";
- $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statements);
-
+ $code .= " bool result = collection->$methodName(propertyName, propertyValue$extraArguments);\n";
$code .= " if (!result)\n";
$code .= " return;\n";
if ($raisesExceptions) {
« no previous file with comments | « Source/bindings/IDLExtendedAttributes.txt ('k') | Source/bindings/scripts/unstable/v8_interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698