Title: [204589] trunk/Source/WebCore
Revision
204589
Author
[email protected]
Date
2016-08-17 20:07:31 -0700 (Wed, 17 Aug 2016)

Log Message

[Web IDL] Add support for dictionary members of dictionary types
https://bugs.webkit.org/show_bug.cgi?id=160902

Reviewed by Sam Weinig.

Add support for dictionary members of dictionary types.

No new tests, updated bindings tests.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDictionaryImplementationContent):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::convertDictionary<TestObj::Dictionary>):
(WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>):
* bindings/scripts/test/TestObj.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (204588 => 204589)


--- trunk/Source/WebCore/ChangeLog	2016-08-18 01:35:55 UTC (rev 204588)
+++ trunk/Source/WebCore/ChangeLog	2016-08-18 03:07:31 UTC (rev 204589)
@@ -1,3 +1,21 @@
+2016-08-17  Chris Dumez  <[email protected]>
+
+        [Web IDL] Add support for dictionary members of dictionary types
+        https://bugs.webkit.org/show_bug.cgi?id=160902
+
+        Reviewed by Sam Weinig.
+
+        Add support for dictionary members of dictionary types.
+
+        No new tests, updated bindings tests.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateDictionaryImplementationContent):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::convertDictionary<TestObj::Dictionary>):
+        (WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>):
+        * bindings/scripts/test/TestObj.idl:
+
 2016-08-17  Anders Carlsson  <[email protected]>
 
         Add support for additional networks

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (204588 => 204589)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-08-18 01:35:55 UTC (rev 204588)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-08-18 03:07:31 UTC (rev 204589)
@@ -1000,11 +1000,14 @@
             my $type = $member->type;
             my $name = $member->name;
             my $value = "object->get(&state, Identifier::fromString(&state, \"${name}\"))";
-            if ($codeGenerator->IsWrapperType($member->type)) {
+            if ($codeGenerator->IsWrapperType($type)) {
                 AddToImplIncludes("JS${type}.h");
                 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";
+            } elsif ($codeGenerator->IsDictionaryType($type)) {
+                my $nativeType = GetNativeType($interface, $type);
+                $result .= "    auto $name = convertDictionary<$nativeType>(state, $value);\n";
             } else {
                 my $function = $member->isOptional ? "convertOptional" : "convert";
                 $result .= "    auto $name = ${function}<" . GetNativeTypeFromSignature($interface, $member) . ">(state, $value"
@@ -1020,6 +1023,8 @@
             my $value;
             if ($codeGenerator->IsWrapperType($member->type) && !$member->isNullable) {
                 $value = "*" . $member->name;
+            } elsif ($codeGenerator->IsDictionaryType($member->type)) {
+                $value = $member->name . ".value()";
             } else {
                 $value = "WTFMove(" . $member->name . ")";
             }

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (204588 => 204589)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-08-18 01:35:55 UTC (rev 204588)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-08-18 03:07:31 UTC (rev 204589)
@@ -455,7 +455,7 @@
 template<> Optional<TestObj::Dictionary> convertDictionary<TestObj::Dictionary>(ExecState& state, JSValue value)
 {
     if (value.isUndefinedOrNull())
-        return TestObj::Dictionary { { }, 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);
@@ -552,7 +552,10 @@
     if (UNLIKELY(state.hadException()))
         return Nullopt;
     auto anyTypedefValue = convertOptional<JSC::JSValue>(state, object->get(&state, Identifier::fromString(&state, "anyTypedefValue")), jsUndefined());
-    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(nullab
 leNode), WTFMove(anyValue), WTFMove(anyTypedefValue) };
+    if (UNLIKELY(state.hadException()))
+        return Nullopt;
+    auto dictionaryMember = convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(state, object->get(&state, Identifier::fromString(&state, "dictionaryMember")));
+    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(nullableNode), WTF
 Move(anyValue), WTFMove(anyTypedefValue), dictionaryMember.value() };
 }
 
 template<> Optional<TestObj::DictionaryThatShouldNotTolerateNull> convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(ExecState& state, JSValue value)
@@ -569,7 +572,10 @@
     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 };
+    if (UNLIKELY(state.hadException()))
+        return Nullopt;
+    auto requiredDictionaryMember = convertDictionary<TestObj::Dictionary>(state, object->get(&state, Identifier::fromString(&state, "requiredDictionaryMember")));
+    return TestObj::DictionaryThatShouldNotTolerateNull { WTFMove(requiredEnumerationValue), WTFMove(booleanWithoutDefault), *nonNullableNode, requiredDictionaryMember.value() };
 }
 
 template<> Optional<TestObj::DictionaryThatShouldTolerateNull> convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(ExecState& state, JSValue value)

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (204588 => 204589)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-08-18 01:35:55 UTC (rev 204588)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-08-18 03:07:31 UTC (rev 204589)
@@ -433,6 +433,7 @@
     Node? nullableNode = null;
     any anyValue;
     AnyTypedef anyTypedefValue;
+    TestDictionaryThatShouldTolerateNull dictionaryMember;
 };
 
 dictionary TestDictionaryThatShouldNotTolerateNull {
@@ -439,6 +440,7 @@
     required TestEnumType requiredEnumerationValue;
     boolean booleanWithoutDefault;
     required Node nonNullableNode;
+    required TestDictionary requiredDictionaryMember;
 };
 
 dictionary TestDictionaryThatShouldTolerateNull {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to