Changeset 191841 in webkit


Ignore:
Timestamp:
Oct 31, 2015 8:37:03 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

Add the support for Symbol attributes on IDL
https://bugs.webkit.org/show_bug.cgi?id=150586

Reviewed by Ryosuke Niwa.

This patch addes readonly attribute support for Symbols.
It involves the IDL generator functionality converting Native type (PrivateName) to Symbol.

  • bindings/scripts/CodeGeneratorGObject.pm:

(SkipAttribute):
(SkipFunction):

  • bindings/scripts/CodeGeneratorJS.pm:

(NativeToJSValue):

  • bindings/scripts/CodeGeneratorObjC.pm:

(SkipFunction):
(SkipAttribute):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjReadOnlySymbolAttr):
(WebCore::jsTestObjConstructorStaticReadOnlySymbolAttr):

  • bindings/scripts/test/TestObj.idl:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r191832 r191841  
     12015-10-31  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Add the support for Symbol attributes on IDL
     4        https://bugs.webkit.org/show_bug.cgi?id=150586
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        This patch addes readonly attribute support for Symbols.
     9        It involves the IDL generator functionality converting Native type (PrivateName) to Symbol.
     10
     11        * bindings/scripts/CodeGeneratorGObject.pm:
     12        (SkipAttribute):
     13        (SkipFunction):
     14        * bindings/scripts/CodeGeneratorJS.pm:
     15        (NativeToJSValue):
     16        * bindings/scripts/CodeGeneratorObjC.pm:
     17        (SkipFunction):
     18        (SkipAttribute):
     19        * bindings/scripts/test/JS/JSTestObj.cpp:
     20        (WebCore::jsTestObjReadOnlySymbolAttr):
     21        (WebCore::jsTestObjConstructorStaticReadOnlySymbolAttr):
     22        * bindings/scripts/test/TestObj.idl:
     23
    1242015-10-30  Brady Eidson  <beidson@apple.com>
    225
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm

    r191287 r191841  
    263263    return 1 if $attribute->signature->type eq "EventHandler";
    264264
     265    return 1 if $attribute->signature->type eq "Symbol";
     266
    265267    if ($attribute->signature->type eq "MediaQueryListListener") {
    266268        return 1;
     
    371373
    372374    return 1 if $function->signature->type eq "Promise";
     375
     376    return 1 if $function->signature->type eq "Symbol";
    373377
    374378    return 1 if $function->signature->type eq "Date";
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r191587 r191841  
    39393939    "octet" => "uint8_t",
    39403940    "DOMTimeStamp" => "DOMTimeStamp",
     3941    "Symbol" => "PrivateName"
    39413942);
    39423943
     
    41534154    }
    41544155
     4156    if ($type eq "Symbol") {
     4157        AddToImplIncludes("<runtime/Symbol.h>", $conditional);
     4158        return "Symbol::create(state->vm(), *($value).uid())";
     4159    }
     4160
    41554161    if ($signature->extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type eq "unsigned short")) {
    41564162        $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm

    r191287 r191841  
    540540
    541541    return 1 if $function->signature->type eq "Promise";
     542    return 1 if $function->signature->type eq "Symbol";
    542543    return 1 if $function->signature->extendedAttributes->{"CustomBinding"};
    543544
     
    563564    return 1 if $codeGenerator->IsEnumType($type);
    564565    return 1 if $type eq "EventHandler";
     566    return 1 if $type eq "Symbol";
    565567    return 1 if $attribute->isStatic;
    566568
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r191287 r191841  
    6262#include <runtime/JSArray.h>
    6363#include <runtime/JSString.h>
     64#include <runtime/Symbol.h>
    6465#include <wtf/GetPtr.h>
    6566
     
    212213JSC::EncodedJSValue jsTestObjCreate(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
    213214void setJSTestObjCreate(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
     215JSC::EncodedJSValue jsTestObjReadOnlySymbolAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
     216JSC::EncodedJSValue jsTestObjConstructorStaticReadOnlySymbolAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
    214217JSC::EncodedJSValue jsTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
    215218void setJSTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
     
    421424    { "staticStringAttr", DontDelete, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticStringAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjConstructorStaticStringAttr) } },
    422425    { "TestSubObj", DontDelete | ReadOnly, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorTestSubObj), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
     426    { "staticReadOnlySymbolAttr", DontDelete | ReadOnly, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticReadOnlySymbolAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
    423427    { "staticMethodWithCallbackAndOptionalArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionStaticMethodWithCallbackAndOptionalArg), (intptr_t) (0) } },
    424428    { "staticMethodWithCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionStaticMethodWithCallbackArg), (intptr_t) (1) } },
     
    495499    { "XMLObjAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjXMLObjAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjXMLObjAttr) } },
    496500    { "create", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCreate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjCreate) } },
     501    { "readOnlySymbolAttr", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlySymbolAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
    497502    { "reflectedStringAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedStringAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjReflectedStringAttr) } },
    498503    { "reflectedIntegralAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedIntegralAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjReflectedIntegralAttr) } },
     
    10261031
    10271032
     1033EncodedJSValue jsTestObjReadOnlySymbolAttr(ExecState* state, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
     1034{
     1035    UNUSED_PARAM(state);
     1036    UNUSED_PARAM(slotBase);
     1037    UNUSED_PARAM(thisValue);
     1038    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     1039    if (UNLIKELY(!castedThis)) {
     1040        if (jsDynamicCast<JSTestObjPrototype*>(slotBase))
     1041            return reportDeprecatedGetterError(*state, "TestObj", "readOnlySymbolAttr");
     1042        return throwGetterTypeError(*state, "TestObj", "readOnlySymbolAttr");
     1043    }
     1044    auto& impl = castedThis->impl();
     1045    JSValue result = Symbol::create(state->vm(), *(impl.readOnlySymbolAttr()).uid());
     1046    return JSValue::encode(result);
     1047}
     1048
     1049
     1050EncodedJSValue jsTestObjConstructorStaticReadOnlySymbolAttr(ExecState* state, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
     1051{
     1052    UNUSED_PARAM(state);
     1053    UNUSED_PARAM(slotBase);
     1054    UNUSED_PARAM(thisValue);
     1055    JSValue result = Symbol::create(state->vm(), *(TestObj::staticReadOnlySymbolAttr()).uid());
     1056    return JSValue::encode(result);
     1057}
     1058
     1059
    10281060EncodedJSValue jsTestObjReflectedStringAttr(ExecState* state, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
    10291061{
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r191287 r191841  
    6363    attribute boolean                  create;
    6464
     65    // Readonly Symbol typed attributes.
     66    readonly attribute Symbol readOnlySymbolAttr;
     67    static readonly attribute Symbol staticReadOnlySymbolAttr;
     68
    6569    // Reflected DOM attributes
    6670    [Reflect] attribute DOMString reflectedStringAttr;
Note: See TracChangeset for help on using the changeset viewer.