Title: [239316] trunk/Source/WebCore
Revision
239316
Author
justin_mich...@apple.com
Date
2018-12-17 20:17:58 -0800 (Mon, 17 Dec 2018)

Log Message

Bindings generator should support Conditional= along with CachedAttribute
https://bugs.webkit.org/show_bug.cgi?id=192721

Reviewed by Ryosuke Niwa.

Fix a bug where specifying both attributes causes compilation errors because the compile-time
condition is not included in the derived code.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjCachedAttribute3Getter):
(WebCore::jsTestObjCachedAttribute3):
(WebCore::JSTestObj::visitChildren):
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/TestObj.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (239315 => 239316)


--- trunk/Source/WebCore/ChangeLog	2018-12-18 04:09:50 UTC (rev 239315)
+++ trunk/Source/WebCore/ChangeLog	2018-12-18 04:17:58 UTC (rev 239316)
@@ -1,3 +1,22 @@
+2018-12-17  Justin Michaud  <justin_mich...@apple.com>
+
+        Bindings generator should support Conditional= along with CachedAttribute
+        https://bugs.webkit.org/show_bug.cgi?id=192721
+
+        Reviewed by Ryosuke Niwa.
+
+        Fix a bug where specifying both attributes causes compilation errors because the compile-time
+        condition is not included in the derived code.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjCachedAttribute3Getter):
+        (WebCore::jsTestObjCachedAttribute3):
+        (WebCore::JSTestObj::visitChildren):
+        * bindings/scripts/test/JS/JSTestObj.h:
+        * bindings/scripts/test/TestObj.idl:
+
 2018-12-17  David Kilzer  <ddkil...@apple.com>
 
         clang-tidy: Fix unnecessary object copy in CPUMonitor::setCPULimit()

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (239315 => 239316)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2018-12-18 04:09:50 UTC (rev 239315)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2018-12-18 04:17:58 UTC (rev 239316)
@@ -4524,7 +4524,10 @@
         if ($numCachedAttributes > 0) {
             foreach my $attribute (@{$interface->attributes}) {
                 if ($attribute->extendedAttributes->{CachedAttribute}) {
+                    my $conditionalString = $codeGenerator->GenerateConditionalString($attribute);
+                    push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
                     push(@implContent, "    visitor.append(thisObject->m_" . $attribute->name . ");\n");
+                    push(@implContent, "#endif\n") if $conditionalString;
                 }
             }
         }

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2018-12-18 04:09:50 UTC (rev 239315)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2018-12-18 04:17:58 UTC (rev 239316)
@@ -1737,6 +1737,9 @@
 #endif
 JSC::EncodedJSValue jsTestObjCachedAttribute1(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 JSC::EncodedJSValue jsTestObjCachedAttribute2(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+#if ENABLE(CONDITION)
+JSC::EncodedJSValue jsTestObjCachedAttribute3(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+#endif
 JSC::EncodedJSValue jsTestObjAnyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjAnyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjObjectAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
@@ -2072,6 +2075,11 @@
 #endif
     { "cachedAttribute1", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCachedAttribute1), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
     { "cachedAttribute2", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCachedAttribute2), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+#if ENABLE(CONDITION)
+    { "cachedAttribute3", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCachedAttribute3), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+#else
+    { 0, 0, NoIntrinsic, { 0, 0 } },
+#endif
     { "anyAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAnyAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAnyAttribute) } },
     { "objectAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjObjectAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjObjectAttribute) } },
     { "contentDocument", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjContentDocument), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
@@ -4543,6 +4551,26 @@
     return IDLAttribute<JSTestObj>::get<jsTestObjCachedAttribute2Getter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cachedAttribute2");
 }
 
+#if ENABLE(CONDITION)
+static inline JSValue jsTestObjCachedAttribute3Getter(ExecState& state, JSTestObj& thisObject, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(state);
+    if (JSValue cachedValue = thisObject.m_cachedAttribute3.get())
+        return cachedValue;
+    auto& impl = thisObject.wrapped();
+    JSValue result = toJS<IDLAny>(state, throwScope, impl.cachedAttribute3());
+    thisObject.m_cachedAttribute3.set(state.vm(), &thisObject, result);
+    return result;
+}
+
+EncodedJSValue jsTestObjCachedAttribute3(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    return IDLAttribute<JSTestObj>::get<jsTestObjCachedAttribute3Getter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cachedAttribute3");
+}
+
+#endif
+
 static inline JSValue jsTestObjAnyAttributeGetter(ExecState& state, JSTestObj& thisObject, ThrowScope& throwScope)
 {
     UNUSED_PARAM(throwScope);
@@ -8494,6 +8522,9 @@
     Base::visitChildren(thisObject, visitor);
     visitor.append(thisObject->m_cachedAttribute1);
     visitor.append(thisObject->m_cachedAttribute2);
+#if ENABLE(CONDITION)
+    visitor.append(thisObject->m_cachedAttribute3);
+#endif
 }
 
 void JSTestObj::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (239315 => 239316)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2018-12-18 04:09:50 UTC (rev 239315)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2018-12-18 04:17:58 UTC (rev 239316)
@@ -60,6 +60,9 @@
     static JSC::JSObject* serialize(JSC::ExecState&, JSTestObj& thisObject, JSDOMGlobalObject&, JSC::ThrowScope&);
     mutable JSC::WriteBarrier<JSC::Unknown> m_cachedAttribute1;
     mutable JSC::WriteBarrier<JSC::Unknown> m_cachedAttribute2;
+#if ENABLE(CONDITION)
+    mutable JSC::WriteBarrier<JSC::Unknown> m_cachedAttribute3;
+#endif
     static void visitChildren(JSCell*, JSC::SlotVisitor&);
 
     static void heapSnapshot(JSCell*, JSC::HeapSnapshotBuilder&);

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


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2018-12-18 04:09:50 UTC (rev 239315)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2018-12-18 04:17:58 UTC (rev 239316)
@@ -276,6 +276,7 @@
 
     [CachedAttribute] readonly attribute any cachedAttribute1;
     [CachedAttribute] readonly attribute any cachedAttribute2;
+    [CachedAttribute, Conditional=CONDITION] readonly attribute any cachedAttribute3;
 
     attribute any anyAttribute;
     attribute object objectAttribute;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to