Log Message
Add support for dictionary members of non nullable wrapper types https://bugs.webkit.org/show_bug.cgi?id=160876
Reviewed by Darin Adler. Add support for dictionary members of non nullable wrapper types. We only supported nullable wrapper types as dictionary members so far. No new tests, updated bindings tests. * bindings/js/JSDOMConvert.h: * bindings/scripts/CodeGeneratorJS.pm: (GenerateDictionaryImplementationContent): (GenerateParametersCheck): (JSValueToNative): (GenerateConstructorDefinition): * bindings/scripts/test/JS/JSTestInterface.cpp: (WebCore::JSTestInterfaceConstructor::construct): * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: (WebCore::JSTestNamedConstructorNamedConstructor::construct): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::convertDictionary<TestObj::Dictionary>): (WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>): (WebCore::convertDictionary<TestObj::DictionaryThatShouldTolerateNull>): (WebCore::jsTestObjPrototypeFunctionAttachShadowRoot): * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp: (WebCore::constructJSTestOverloadedConstructors4): (WebCore::constructJSTestOverloadedConstructors5): * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefsConstructor::construct): * bindings/scripts/test/TestObj.idl:
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/bindings/js/JSDOMConvert.h
- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp
- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
Diff
Modified: trunk/Source/WebCore/ChangeLog (204496 => 204497)
--- trunk/Source/WebCore/ChangeLog 2016-08-16 05:14:17 UTC (rev 204496)
+++ trunk/Source/WebCore/ChangeLog 2016-08-16 06:24:39 UTC (rev 204497)
@@ -1,5 +1,39 @@
2016-08-15 Chris Dumez <[email protected]>
+ Add support for dictionary members of non nullable wrapper types
+ https://bugs.webkit.org/show_bug.cgi?id=160876
+
+ Reviewed by Darin Adler.
+
+ Add support for dictionary members of non nullable wrapper types. We
+ only supported nullable wrapper types as dictionary members so far.
+
+ No new tests, updated bindings tests.
+
+ * bindings/js/JSDOMConvert.h:
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateDictionaryImplementationContent):
+ (GenerateParametersCheck):
+ (JSValueToNative):
+ (GenerateConstructorDefinition):
+ * bindings/scripts/test/JS/JSTestInterface.cpp:
+ (WebCore::JSTestInterfaceConstructor::construct):
+ * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
+ (WebCore::JSTestNamedConstructorNamedConstructor::construct):
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::convertDictionary<TestObj::Dictionary>):
+ (WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>):
+ (WebCore::convertDictionary<TestObj::DictionaryThatShouldTolerateNull>):
+ (WebCore::jsTestObjPrototypeFunctionAttachShadowRoot):
+ * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+ (WebCore::constructJSTestOverloadedConstructors4):
+ (WebCore::constructJSTestOverloadedConstructors5):
+ * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+ (WebCore::JSTestTypedefsConstructor::construct):
+ * bindings/scripts/test/TestObj.idl:
+
+2016-08-15 Chris Dumez <[email protected]>
+
Drop unused EventTarget::hasActiveEventListeners()
https://bugs.webkit.org/show_bug.cgi?id=160869
Modified: trunk/Source/WebCore/bindings/js/JSDOMConvert.h (204496 => 204497)
--- trunk/Source/WebCore/bindings/js/JSDOMConvert.h 2016-08-16 05:14:17 UTC (rev 204496)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvert.h 2016-08-16 06:24:39 UTC (rev 204497)
@@ -49,6 +49,8 @@
template<typename T, typename U> EnableIfIntegralType<T> convertOptional(JSC::ExecState&, JSC::JSValue, IntegerConversionConfiguration, U&& defaultValue);
template<typename T, typename U> EnableIfFloatingPointType<T> convertOptional(JSC::ExecState&, JSC::JSValue, ShouldAllowNonFinite, U&& defaultValue);
+template<typename T> Optional<T> convertDictionary(JSC::ExecState&, JSC::JSValue);
+
enum class IsNullable { No, Yes };
template<typename T, typename JST> T* convertWrapperType(JSC::ExecState&, JSC::JSValue, IsNullable);
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (204496 => 204497)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-08-16 05:14:17 UTC (rev 204496)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-08-16 06:24:39 UTC (rev 204497)
@@ -980,14 +980,14 @@
$comma = ", ";
}
- $result .= "template<> $className convert<$className>(ExecState& state, JSValue value)\n";
+ $result .= "template<> Optional<$className> convertDictionary<$className>(ExecState& state, JSValue value)\n";
$result .= "{\n";
$result .= " if (value.isUndefinedOrNull())\n" if $defaultValues;
- $result .= " return { " . $defaultValues . " };\n" if $defaultValues;
+ $result .= " return $className { " . $defaultValues . " };\n" if $defaultValues;
$result .= " auto* object = value.getObject();\n";
$result .= " if (UNLIKELY(!object || object->type() == RegExpObjectType)) {\n";
$result .= " throwTypeError(&state);\n";
- $result .= " return { };\n";
+ $result .= " return Nullopt;\n";
$result .= " }\n";
my $needExceptionCheck = 0;
@@ -994,7 +994,7 @@
foreach my $member (@{$dictionary->members}) {
if ($needExceptionCheck) {
$result .= " if (UNLIKELY(state.hadException()))\n";
- $result .= " return { };\n";
+ $result .= " return Nullopt;\n";
}
# FIXME: Eventually we will want this to share a lot more code with JSValueToNative.
my $type = $member->type;
@@ -1001,9 +1001,10 @@
my $name = $member->name;
my $value = "object->get(&state, Identifier::fromString(&state, \"${name}\"))";
if ($codeGenerator->IsWrapperType($member->type)) {
- die "Dictionary member of non-nullable wrapper types are not supported yet" unless $member->isNullable;
AddToImplIncludes("JS${type}.h");
- $result .= " auto* $name = convertWrapperType<$type, JS${type}>(state, $value, IsNullable::Yes);\n";
+ die "Dictionary members of non-nullable wrapper types must be marked as required" if !$member->isNullable && $member->isOptional;
+ my $nullableParameter = $member->isNullable ? "IsNullable::Yes" : "IsNullable::No";
+ $result .= " auto* $name = convertWrapperType<$type, JS${type}>(state, $value, $nullableParameter);\n";
} else {
my $function = $member->isOptional ? "convertOptional" : "convert";
$result .= " auto $name = ${function}<" . GetNativeTypeFromSignature($interface, $member) . ">(state, $value"
@@ -1016,11 +1017,17 @@
my $arguments = "";
$comma = "";
foreach my $member (@{$dictionary->members}) {
- $arguments .= $comma . "WTFMove(" . $member->name . ")";
+ my $value;
+ if ($codeGenerator->IsWrapperType($member->type) && !$member->isNullable) {
+ $value = "*" . $member->name;
+ } else {
+ $value = "WTFMove(" . $member->name . ")";
+ }
+ $arguments .= $comma . $value;
$comma = ", ";
}
- $result .= " return { " . $arguments . " };\n";
+ $result .= " return $className { " . $arguments . " };\n";
$result .= "}\n\n";
$result .= "#endif\n\n" if $conditionalString;
@@ -4007,6 +4014,8 @@
if ($codeGenerator->IsTypedArrayType($type) and $parameter->type ne "ArrayBuffer") {
$value = $shouldPassByReference ? "$name.releaseNonNull()" : "WTFMove($name)";
+ } elsif ($codeGenerator->IsDictionaryType($type)) {
+ $value = "${name}.value()";
}
}
@@ -4678,7 +4687,7 @@
return ("to$type($value)", 1) if $codeGenerator->IsTypedArrayType($type);
return ("parse<" . GetEnumerationClassName($interface, $type) . ">(*state, $value)", 1) if $codeGenerator->IsEnumType($type);
- return ("convert<" . GetDictionaryClassName($interface, $type) . ">(*state, $value)", 1) if $codeGenerator->IsDictionaryType($type);
+ return ("convertDictionary<" . GetDictionaryClassName($interface, $type) . ">(*state, $value)", 1) if $codeGenerator->IsDictionaryType($type);
AddToImplIncludes("JS$type.h", $conditional);
@@ -5308,8 +5317,10 @@
last if $index eq $paramIndex;
if (ShouldPassWrapperByReference($parameter, $interface)) {
push(@constructorArgList, "*" . $parameter->name);
+ } elsif ($codeGenerator->IsDictionaryType($parameter->type)) {
+ push(@constructorArgList, $parameter->name . ".value()");
} else {
- push(@constructorArgList, $parameter->name);
+ push(@constructorArgList, "WTFMove(" . $parameter->name . ")");
}
$index++;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (204496 => 204497)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp 2016-08-16 05:14:17 UTC (rev 204496)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp 2016-08-16 06:24:39 UTC (rev 204497)
@@ -235,7 +235,7 @@
ScriptExecutionContext* context = castedThis->scriptExecutionContext();
if (UNLIKELY(!context))
return throwConstructorDocumentUnavailableError(*state, "TestInterface");
- auto object = TestInterface::create(*context, str1, str2, ec);
+ auto object = TestInterface::create(*context, WTFMove(str1), WTFMove(str2), ec);
if (UNLIKELY(ec)) {
setDOMException(state, ec);
return JSValue::encode(JSValue());
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp (204496 => 204497)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp 2016-08-16 05:14:17 UTC (rev 204496)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp 2016-08-16 06:24:39 UTC (rev 204497)
@@ -95,7 +95,7 @@
auto str3 = state->argument(2).isUndefined() ? String() : state->uncheckedArgument(2).toWTFString(state);
if (UNLIKELY(state->hadException()))
return JSValue::encode(jsUndefined());
- auto object = TestNamedConstructor::createForJSConstructor(*castedThis->document(), str1, str2, str3, ec);
+ auto object = TestNamedConstructor::createForJSConstructor(*castedThis->document(), WTFMove(str1), WTFMove(str2), WTFMove(str3), ec);
if (UNLIKELY(ec)) {
setDOMException(state, ec);
return JSValue::encode(JSValue());
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (204496 => 204497)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2016-08-16 05:14:17 UTC (rev 204496)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2016-08-16 06:24:39 UTC (rev 204497)
@@ -452,137 +452,140 @@
return "\"high\", \"kinda-low\"";
}
-template<> TestObj::Dictionary convert<TestObj::Dictionary>(ExecState& state, JSValue value)
+template<> Optional<TestObj::Dictionary> convertDictionary<TestObj::Dictionary>(ExecState& state, JSValue value)
{
if (value.isUndefinedOrNull())
- return { { }, TestObj::EnumType::EnumValue1, TestObj::EnumType::EmptyString, "defaultString", { }, false, { }, { }, { }, { }, 0, 0, { }, { }, 0, 0, { }, { }, { }, 0, { }, 0, { }, 0, { }, 0, { }, 0, nullptr, jsUndefined(), jsUndefined() };
+ return TestObj::Dictionary { { }, TestObj::EnumType::EnumValue1, TestObj::EnumType::EmptyString, "defaultString", { }, false, { }, { }, { }, { }, 0, 0, { }, { }, 0, 0, { }, { }, { }, 0, { }, 0, { }, 0, { }, 0, { }, 0, nullptr, jsUndefined(), jsUndefined() };
auto* object = value.getObject();
if (UNLIKELY(!object || object->type() == RegExpObjectType)) {
throwTypeError(&state);
- return { };
+ return Nullopt;
}
auto enumerationValueWithoutDefault = convertOptional<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "enumerationValueWithoutDefault")));
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto enumerationValueWithDefault = convertOptional<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "enumerationValueWithDefault")), TestObj::EnumType::EnumValue1);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto enumerationValueWithEmptyStringDefault = convertOptional<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "enumerationValueWithEmptyStringDefault")), TestObj::EnumType::EmptyString);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto stringWithDefault = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "stringWithDefault")), "defaultString");
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto stringWithoutDefault = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "stringWithoutDefault")));
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto booleanWithDefault = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "booleanWithDefault")), false);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto booleanWithoutDefault = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")));
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto sequenceOfStrings = convertOptional<Vector<String>>(state, object->get(&state, Identifier::fromString(&state, "sequenceOfStrings")));
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto restrictedDouble = convertOptional<double>(state, object->get(&state, Identifier::fromString(&state, "restrictedDouble")), ShouldAllowNonFinite::No);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto unrestrictedDouble = convertOptional<double>(state, object->get(&state, Identifier::fromString(&state, "unrestrictedDouble")), ShouldAllowNonFinite::Yes);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto restrictedDoubleWithDefault = convertOptional<double>(state, object->get(&state, Identifier::fromString(&state, "restrictedDoubleWithDefault")), ShouldAllowNonFinite::No, 0);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto unrestrictedDoubleWithDefault = convertOptional<double>(state, object->get(&state, Identifier::fromString(&state, "unrestrictedDoubleWithDefault")), ShouldAllowNonFinite::Yes, 0);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto restrictedFloat = convertOptional<float>(state, object->get(&state, Identifier::fromString(&state, "restrictedFloat")), ShouldAllowNonFinite::No);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto unrestrictedFloat = convertOptional<float>(state, object->get(&state, Identifier::fromString(&state, "unrestrictedFloat")), ShouldAllowNonFinite::Yes);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto restrictedFloatWithDefault = convertOptional<float>(state, object->get(&state, Identifier::fromString(&state, "restrictedFloatWithDefault")), ShouldAllowNonFinite::No, 0);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto unrestrictedFloatWithDefault = convertOptional<float>(state, object->get(&state, Identifier::fromString(&state, "unrestrictedFloatWithDefault")), ShouldAllowNonFinite::Yes, 0);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto smallIntegerClamped = convertOptional<int8_t>(state, object->get(&state, Identifier::fromString(&state, "smallIntegerClamped")), Clamp);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto smallIntegerWithDefault = convertOptional<int8_t>(state, object->get(&state, Identifier::fromString(&state, "smallIntegerWithDefault")), NormalConversion);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto smallUnsignedIntegerEnforcedRange = convertOptional<uint8_t>(state, object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerEnforcedRange")), EnforceRange);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto smallUnsignedIntegerWithDefault = convertOptional<uint8_t>(state, object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerWithDefault")), NormalConversion, 0);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto integer = convertOptional<int32_t>(state, object->get(&state, Identifier::fromString(&state, "integer")), NormalConversion);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto integerWithDefault = convertOptional<int32_t>(state, object->get(&state, Identifier::fromString(&state, "integerWithDefault")), NormalConversion, 0);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto unsignedInteger = convertOptional<uint32_t>(state, object->get(&state, Identifier::fromString(&state, "unsignedInteger")), NormalConversion);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto unsignedIntegerWithDefault = convertOptional<uint32_t>(state, object->get(&state, Identifier::fromString(&state, "unsignedIntegerWithDefault")), NormalConversion, 0);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto largeInteger = convertOptional<int64_t>(state, object->get(&state, Identifier::fromString(&state, "largeInteger")), NormalConversion);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto largeIntegerWithDefault = convertOptional<int64_t>(state, object->get(&state, Identifier::fromString(&state, "largeIntegerWithDefault")), NormalConversion, 0);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto unsignedLargeInteger = convertOptional<uint64_t>(state, object->get(&state, Identifier::fromString(&state, "unsignedLargeInteger")), NormalConversion);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto unsignedLargeIntegerWithDefault = convertOptional<uint64_t>(state, object->get(&state, Identifier::fromString(&state, "unsignedLargeIntegerWithDefault")), NormalConversion, 0);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto* nullableNode = convertWrapperType<Node, JSNode>(state, object->get(&state, Identifier::fromString(&state, "nullableNode")), IsNullable::Yes);
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto anyValue = convertOptional<JSC::JSValue>(state, object->get(&state, Identifier::fromString(&state, "anyValue")), jsUndefined());
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto anyTypedefValue = convertOptional<JSC::JSValue>(state, object->get(&state, Identifier::fromString(&state, "anyTypedefValue")), jsUndefined());
- return { WTFMove(enumerationValueWithoutDefault), WTFMove(enumerationValueWithDefault), WTFMove(enumerationValueWithEmptyStringDefault), WTFMove(stringWithDefault), WTFMove(stringWithoutDefault), WTFMove(booleanWithDefault), WTFMove(booleanWithoutDefault), WTFMove(sequenceOfStrings), WTFMove(restrictedDouble), WTFMove(unrestrictedDouble), WTFMove(restrictedDoubleWithDefault), WTFMove(unrestrictedDoubleWithDefault), WTFMove(restrictedFloat), WTFMove(unrestrictedFloat), WTFMove(restrictedFloatWithDefault), WTFMove(unrestrictedFloatWithDefault), WTFMove(smallIntegerClamped), WTFMove(smallIntegerWithDefault), WTFMove(smallUnsignedIntegerEnforcedRange), WTFMove(smallUnsignedIntegerWithDefault), WTFMove(integer), WTFMove(integerWithDefault), WTFMove(unsignedInteger), WTFMove(unsignedIntegerWithDefault), WTFMove(largeInteger), WTFMove(largeIntegerWithDefault), WTFMove(unsignedLargeInteger), WTFMove(unsignedLargeIntegerWithDefault), WTFMove(nullableNode), WTFMove(any
Value), WTFMove(anyTypedefValue) };
+ return TestObj::Dictionary { WTFMove(enumerationValueWithoutDefault), WTFMove(enumerationValueWithDefault), WTFMove(enumerationValueWithEmptyStringDefault), WTFMove(stringWithDefault), WTFMove(stringWithoutDefault), WTFMove(booleanWithDefault), WTFMove(booleanWithoutDefault), WTFMove(sequenceOfStrings), WTFMove(restrictedDouble), WTFMove(unrestrictedDouble), WTFMove(restrictedDoubleWithDefault), WTFMove(unrestrictedDoubleWithDefault), WTFMove(restrictedFloat), WTFMove(unrestrictedFloat), WTFMove(restrictedFloatWithDefault), WTFMove(unrestrictedFloatWithDefault), WTFMove(smallIntegerClamped), WTFMove(smallIntegerWithDefault), WTFMove(smallUnsignedIntegerEnforcedRange), WTFMove(smallUnsignedIntegerWithDefault), WTFMove(integer), WTFMove(integerWithDefault), WTFMove(unsignedInteger), WTFMove(unsignedIntegerWithDefault), WTFMove(largeInteger), WTFMove(largeIntegerWithDefault), WTFMove(unsignedLargeInteger), WTFMove(unsignedLargeIntegerWithDefault), WTFMove(nullabl
eNode), WTFMove(anyValue), WTFMove(anyTypedefValue) };
}
-template<> TestObj::DictionaryThatShouldNotTolerateNull convert<TestObj::DictionaryThatShouldNotTolerateNull>(ExecState& state, JSValue value)
+template<> Optional<TestObj::DictionaryThatShouldNotTolerateNull> convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(ExecState& state, JSValue value)
{
auto* object = value.getObject();
if (UNLIKELY(!object || object->type() == RegExpObjectType)) {
throwTypeError(&state);
- return { };
+ return Nullopt;
}
auto requiredEnumerationValue = convert<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "requiredEnumerationValue")));
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto booleanWithoutDefault = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")));
- return { WTFMove(requiredEnumerationValue), WTFMove(booleanWithoutDefault) };
+ if (UNLIKELY(state.hadException()))
+ return Nullopt;
+ auto* nonNullableNode = convertWrapperType<Node, JSNode>(state, object->get(&state, Identifier::fromString(&state, "nonNullableNode")), IsNullable::No);
+ return TestObj::DictionaryThatShouldNotTolerateNull { WTFMove(requiredEnumerationValue), WTFMove(booleanWithoutDefault), *nonNullableNode };
}
-template<> TestObj::DictionaryThatShouldTolerateNull convert<TestObj::DictionaryThatShouldTolerateNull>(ExecState& state, JSValue value)
+template<> Optional<TestObj::DictionaryThatShouldTolerateNull> convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(ExecState& state, JSValue value)
{
if (value.isUndefinedOrNull())
- return { { }, { } };
+ return TestObj::DictionaryThatShouldTolerateNull { { }, { } };
auto* object = value.getObject();
if (UNLIKELY(!object || object->type() == RegExpObjectType)) {
throwTypeError(&state);
- return { };
+ return Nullopt;
}
auto enumerationValue = convertOptional<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "enumerationValue")));
if (UNLIKELY(state.hadException()))
- return { };
+ return Nullopt;
auto booleanWithoutDefault = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")));
- return { WTFMove(enumerationValue), WTFMove(booleanWithoutDefault) };
+ return TestObj::DictionaryThatShouldTolerateNull { WTFMove(enumerationValue), WTFMove(booleanWithoutDefault) };
}
// Functions
@@ -6392,10 +6395,10 @@
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, createNotEnoughArgumentsError(state));
- auto init = convert<TestObj::Dictionary>(*state, state->argument(0));
+ auto init = convertDictionary<TestObj::Dictionary>(*state, state->argument(0));
if (UNLIKELY(state->hadException()))
return JSValue::encode(jsUndefined());
- impl.attachShadowRoot(WTFMove(init));
+ impl.attachShadowRoot(init.value());
return JSValue::encode(jsUndefined());
}
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (204496 => 204497)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp 2016-08-16 05:14:17 UTC (rev 204496)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp 2016-08-16 06:24:39 UTC (rev 204497)
@@ -113,7 +113,7 @@
auto string = state->argument(0).toWTFString(state);
if (UNLIKELY(state->hadException()))
return JSValue::encode(jsUndefined());
- auto object = TestOverloadedConstructors::create(string);
+ auto object = TestOverloadedConstructors::create(WTFMove(string));
return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
}
@@ -123,7 +123,7 @@
Vector<int32_t> longArgs = toNativeArguments<int32_t>(*state, 0);
if (UNLIKELY(state->hadException()))
return JSValue::encode(jsUndefined());
- auto object = TestOverloadedConstructors::create(longArgs);
+ auto object = TestOverloadedConstructors::create(WTFMove(longArgs));
return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
}
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (204496 => 204497)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp 2016-08-16 05:14:17 UTC (rev 204496)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp 2016-08-16 06:24:39 UTC (rev 204497)
@@ -133,7 +133,7 @@
if (UNLIKELY(!state->argument(1).isObject()))
return throwArgumentMustBeFunctionError(*state, 1, "testCallback", "TestTypedefs", nullptr);
auto testCallback = JSTestCallback::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
- auto object = TestTypedefs::create(hello, *testCallback);
+ auto object = TestTypedefs::create(WTFMove(hello), *testCallback);
return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
}
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (204496 => 204497)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2016-08-16 05:14:17 UTC (rev 204496)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2016-08-16 06:24:39 UTC (rev 204497)
@@ -438,6 +438,7 @@
dictionary TestDictionaryThatShouldNotTolerateNull {
required TestEnumType requiredEnumerationValue;
boolean booleanWithoutDefault;
+ required Node nonNullableNode;
};
dictionary TestDictionaryThatShouldTolerateNull {
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
