Changeset 239316 in webkit


Ignore:
Timestamp:
Dec 17, 2018 8:17:58 PM (5 years ago)
Author:
Justin Michaud
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:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239315 r239316  
     12018-12-17  Justin Michaud  <justin_michaud@apple.com>
     2
     3        Bindings generator should support Conditional= along with CachedAttribute
     4        https://bugs.webkit.org/show_bug.cgi?id=192721
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Fix a bug where specifying both attributes causes compilation errors because the compile-time
     9        condition is not included in the derived code.
     10
     11        * bindings/scripts/CodeGeneratorJS.pm:
     12        (GenerateImplementation):
     13        * bindings/scripts/test/JS/JSTestObj.cpp:
     14        (WebCore::jsTestObjCachedAttribute3Getter):
     15        (WebCore::jsTestObjCachedAttribute3):
     16        (WebCore::JSTestObj::visitChildren):
     17        * bindings/scripts/test/JS/JSTestObj.h:
     18        * bindings/scripts/test/TestObj.idl:
     19
    1202018-12-17  David Kilzer  <ddkilzer@apple.com>
    221
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r239273 r239316  
    45254525            foreach my $attribute (@{$interface->attributes}) {
    45264526                if ($attribute->extendedAttributes->{CachedAttribute}) {
     4527                    my $conditionalString = $codeGenerator->GenerateConditionalString($attribute);
     4528                    push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
    45274529                    push(@implContent, "    visitor.append(thisObject->m_" . $attribute->name . ");\n");
     4530                    push(@implContent, "#endif\n") if $conditionalString;
    45284531                }
    45294532            }
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r239273 r239316  
    17381738JSC::EncodedJSValue jsTestObjCachedAttribute1(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
    17391739JSC::EncodedJSValue jsTestObjCachedAttribute2(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
     1740#if ENABLE(CONDITION)
     1741JSC::EncodedJSValue jsTestObjCachedAttribute3(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
     1742#endif
    17401743JSC::EncodedJSValue jsTestObjAnyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
    17411744bool setJSTestObjAnyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
     
    20732076    { "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) } },
    20742077    { "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) } },
     2078#if ENABLE(CONDITION)
     2079    { "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) } },
     2080#else
     2081    { 0, 0, NoIntrinsic, { 0, 0 } },
     2082#endif
    20752083    { "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) } },
    20762084    { "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) } },
     
    45444552}
    45454553
     4554#if ENABLE(CONDITION)
     4555static inline JSValue jsTestObjCachedAttribute3Getter(ExecState& state, JSTestObj& thisObject, ThrowScope& throwScope)
     4556{
     4557    UNUSED_PARAM(throwScope);
     4558    UNUSED_PARAM(state);
     4559    if (JSValue cachedValue = thisObject.m_cachedAttribute3.get())
     4560        return cachedValue;
     4561    auto& impl = thisObject.wrapped();
     4562    JSValue result = toJS<IDLAny>(state, throwScope, impl.cachedAttribute3());
     4563    thisObject.m_cachedAttribute3.set(state.vm(), &thisObject, result);
     4564    return result;
     4565}
     4566
     4567EncodedJSValue jsTestObjCachedAttribute3(ExecState* state, EncodedJSValue thisValue, PropertyName)
     4568{
     4569    return IDLAttribute<JSTestObj>::get<jsTestObjCachedAttribute3Getter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cachedAttribute3");
     4570}
     4571
     4572#endif
     4573
    45464574static inline JSValue jsTestObjAnyAttributeGetter(ExecState& state, JSTestObj& thisObject, ThrowScope& throwScope)
    45474575{
     
    84958523    visitor.append(thisObject->m_cachedAttribute1);
    84968524    visitor.append(thisObject->m_cachedAttribute2);
     8525#if ENABLE(CONDITION)
     8526    visitor.append(thisObject->m_cachedAttribute3);
     8527#endif
    84978528}
    84988529
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h

    r239191 r239316  
    6161    mutable JSC::WriteBarrier<JSC::Unknown> m_cachedAttribute1;
    6262    mutable JSC::WriteBarrier<JSC::Unknown> m_cachedAttribute2;
     63#if ENABLE(CONDITION)
     64    mutable JSC::WriteBarrier<JSC::Unknown> m_cachedAttribute3;
     65#endif
    6366    static void visitChildren(JSCell*, JSC::SlotVisitor&);
    6467
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r237717 r239316  
    277277    [CachedAttribute] readonly attribute any cachedAttribute1;
    278278    [CachedAttribute] readonly attribute any cachedAttribute2;
     279    [CachedAttribute, Conditional=CONDITION] readonly attribute any cachedAttribute3;
    279280
    280281    attribute any anyAttribute;
Note: See TracChangeset for help on using the changeset viewer.