Title: [111865] trunk/Source/WebCore
Revision
111865
Author
[email protected]
Date
2012-03-23 08:46:23 -0700 (Fri, 23 Mar 2012)

Log Message

Support [ImplementedAs] for attributes
https://bugs.webkit.org/show_bug.cgi?id=81605

Reviewed by Adam Barth.

[ImplementedAs] just supports methods. [ImplementedAs] should support
attributes too.

Explained here: https://trac.webkit.org/wiki/WebKitIDL#ImplementedAs

Test: bindings/scripts/test/TestObj.idl

* bindings/scripts/CodeGenerator.pm: Modified to support [ImplementedAs] for attributes.
(AttributeNameForGetterAndSetter):

* bindings/scripts/test/TestObj.idl: Added a test case.

* bindings/scripts/test/CPP/WebDOMTestObj.cpp: Updated run-bindings-tests results.
(WebDOMTestObj::strawberry):
(WebDOMTestObj::setStrawberry):
* bindings/scripts/test/CPP/WebDOMTestObj.h:
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
(webkit_dom_test_obj_get_strawberry):
(webkit_dom_test_obj_set_strawberry):
(webkit_dom_test_obj_get_property):
(webkit_dom_test_obj_class_init):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore):
(WebCore::jsTestObjStrawberry):
(WebCore::setJSTestObjStrawberry):
* bindings/scripts/test/JS/JSTestObj.h:
(WebCore):
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
(-[DOMTestObj strawberry]):
(-[DOMTestObj setStrawberry:]):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjInternal::strawberryAttrGetter):
(TestObjInternal):
(WebCore::TestObjInternal::strawberryAttrSetter):
(WebCore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111864 => 111865)


--- trunk/Source/WebCore/ChangeLog	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/ChangeLog	2012-03-23 15:46:23 UTC (rev 111865)
@@ -1,3 +1,48 @@
+2012-03-23  Kentaro Hara  <[email protected]>
+
+        Support [ImplementedAs] for attributes
+        https://bugs.webkit.org/show_bug.cgi?id=81605
+
+        Reviewed by Adam Barth.
+
+        [ImplementedAs] just supports methods. [ImplementedAs] should support
+        attributes too.
+
+        Explained here: https://trac.webkit.org/wiki/WebKitIDL#ImplementedAs
+
+        Test: bindings/scripts/test/TestObj.idl
+
+        * bindings/scripts/CodeGenerator.pm: Modified to support [ImplementedAs] for attributes.
+        (AttributeNameForGetterAndSetter):
+
+        * bindings/scripts/test/TestObj.idl: Added a test case.
+
+        * bindings/scripts/test/CPP/WebDOMTestObj.cpp: Updated run-bindings-tests results.
+        (WebDOMTestObj::strawberry):
+        (WebDOMTestObj::setStrawberry):
+        * bindings/scripts/test/CPP/WebDOMTestObj.h:
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+        (webkit_dom_test_obj_get_strawberry):
+        (webkit_dom_test_obj_set_strawberry):
+        (webkit_dom_test_obj_get_property):
+        (webkit_dom_test_obj_class_init):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore):
+        (WebCore::jsTestObjStrawberry):
+        (WebCore::setJSTestObjStrawberry):
+        * bindings/scripts/test/JS/JSTestObj.h:
+        (WebCore):
+        * bindings/scripts/test/ObjC/DOMTestObj.h:
+        * bindings/scripts/test/ObjC/DOMTestObj.mm:
+        (-[DOMTestObj strawberry]):
+        (-[DOMTestObj setStrawberry:]):
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::TestObjInternal::strawberryAttrGetter):
+        (TestObjInternal):
+        (WebCore::TestObjInternal::strawberryAttrSetter):
+        (WebCore):
+
 2012-03-23  Tommy Widenflycht  <[email protected]>
 
         The JSC code generator doesn't generate correct code for Constructors

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (111864 => 111865)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2012-03-23 15:46:23 UTC (rev 111865)
@@ -514,6 +514,9 @@
     my ($generator, $attribute) = @_;
 
     my $attributeName = $attribute->signature->name;
+    if ($attribute->signature->extendedAttributes->{"ImplementedAs"}) {
+        $attributeName = $attribute->signature->extendedAttributes->{"ImplementedAs"};
+    }
     my $attributeType = $generator->StripModule($attribute->signature->type);
 
     # Avoid clash with C++ keyword.

Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp (111864 => 111865)


--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp	2012-03-23 15:46:23 UTC (rev 111865)
@@ -583,6 +583,22 @@
     impl()->setImmutablePoint(toWebCore(newImmutablePoint));
 }
 
+int WebDOMTestObj::strawberry() const
+{
+    if (!impl())
+        return 0;
+
+    return impl()->blueberry();
+}
+
+void WebDOMTestObj::setStrawberry(int newStrawberry)
+{
+    if (!impl())
+        return;
+
+    impl()->setBlueberry(newStrawberry);
+}
+
 float WebDOMTestObj::strictFloat() const
 {
     if (!impl())

Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h (111864 => 111865)


--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h	2012-03-23 15:46:23 UTC (rev 111865)
@@ -135,6 +135,8 @@
     void setMutablePoint(const WebDOMSVGPoint&);
     WebDOMSVGPoint immutablePoint() const;
     void setImmutablePoint(const WebDOMSVGPoint&);
+    int strawberry() const;
+    void setStrawberry(int);
     float strictFloat() const;
     void setStrictFloat(float);
     int description() const;

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp (111864 => 111865)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp	2012-03-23 15:46:23 UTC (rev 111865)
@@ -1469,6 +1469,25 @@
     item->setImmutablePoint(converted_value);
 }
 
+gint
+webkit_dom_test_obj_get_strawberry(WebKitDOMTestObj* self)
+{
+    g_return_val_if_fail(self, 0);
+    WebCore::JSMainThreadNullState state;
+    WebCore::TestObj * item = WebKit::core(self);
+    gint res = item->blueberry();
+    return res;
+}
+
+void
+webkit_dom_test_obj_set_strawberry(WebKitDOMTestObj* self, gint value)
+{
+    g_return_if_fail(self);
+    WebCore::JSMainThreadNullState state;
+    WebCore::TestObj * item = WebKit::core(self);
+    item->setBlueberry(value);
+}
+
 gfloat
 webkit_dom_test_obj_get_strict_float(WebKitDOMTestObj* self)
 {
@@ -1590,6 +1609,7 @@
     PROP_CONTENT_DOCUMENT,
     PROP_MUTABLE_POINT,
     PROP_IMMUTABLE_POINT,
+    PROP_STRAWBERRY,
     PROP_STRICT_FLOAT,
     PROP_DESCRIPTION,
     PROP_ID,
@@ -1981,6 +2001,11 @@
         g_value_set_object(value, WebKit::kit(ptr.get()));
         break;
     }
+    case PROP_STRAWBERRY:
+    {
+        g_value_set_int(value, coreSelf->blueberry());
+        break;
+    }
     case PROP_STRICT_FLOAT:
     {
         g_value_set_float(value, coreSelf->strictFloat());
@@ -2333,6 +2358,15 @@
                                                            WEBKIT_TYPE_DOM_SVG_POINT, /* gobject type */
                                                            WEBKIT_PARAM_READWRITE));
     g_object_class_install_property(gobjectClass,
+                                    PROP_STRAWBERRY,
+                                    g_param_spec_int("strawberry", /* name */
+                                                           "test_obj_strawberry", /* short description */
+                                                           "read-write  gint TestObj.strawberry", /* longer - could do with some extra doc stuff here */
+                                                           G_MININT, /* min */
+G_MAXINT, /* max */
+0, /* default */
+                                                           WEBKIT_PARAM_READWRITE));
+    g_object_class_install_property(gobjectClass,
                                     PROP_STRICT_FLOAT,
                                     g_param_spec_float("strict-float", /* name */
                                                            "test_obj_strict-float", /* short description */

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h (111864 => 111865)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h	2012-03-23 15:46:23 UTC (rev 111865)
@@ -1275,6 +1275,27 @@
 webkit_dom_test_obj_set_immutable_point(WebKitDOMTestObj* self, WebKitDOMSVGPoint* value);
 
 /**
+ * webkit_dom_test_obj_get_strawberry:
+ * @self: A #WebKitDOMTestObj
+ *
+ * Returns:
+ *
+**/
+WEBKIT_API gint
+webkit_dom_test_obj_get_strawberry(WebKitDOMTestObj* self);
+
+/**
+ * webkit_dom_test_obj_set_strawberry:
+ * @self: A #WebKitDOMTestObj
+ * @value: A #gint
+ *
+ * Returns:
+ *
+**/
+WEBKIT_API void
+webkit_dom_test_obj_set_strawberry(WebKitDOMTestObj* self, gint value);
+
+/**
  * webkit_dom_test_obj_get_strict_float:
  * @self: A #WebKitDOMTestObj
  *

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-03-23 15:46:23 UTC (rev 111865)
@@ -138,6 +138,7 @@
     { "contentDocument", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjContentDocument), (intptr_t)0, NoIntrinsic },
     { "mutablePoint", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjMutablePoint), (intptr_t)setJSTestObjMutablePoint, NoIntrinsic },
     { "immutablePoint", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjImmutablePoint), (intptr_t)setJSTestObjImmutablePoint, NoIntrinsic },
+    { "strawberry", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStrawberry), (intptr_t)setJSTestObjStrawberry, NoIntrinsic },
     { "strictFloat", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStrictFloat), (intptr_t)setJSTestObjStrictFloat, NoIntrinsic },
     { "description", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjDescription), (intptr_t)0, NoIntrinsic },
     { "id", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjId), (intptr_t)setJSTestObjId, NoIntrinsic },
@@ -146,7 +147,7 @@
     { 0, 0, 0, 0, NoIntrinsic }
 };
 
-static const HashTable JSTestObjTable = { 137, 127, JSTestObjTableValues, 0 };
+static const HashTable JSTestObjTable = { 138, 127, JSTestObjTableValues, 0 };
 /* Hash table for constructor */
 
 static const HashTableValue JSTestObjConstructorTableValues[] =
@@ -860,6 +861,16 @@
 }
 
 
+JSValue jsTestObjStrawberry(ExecState* exec, JSValue slotBase, const Identifier&)
+{
+    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
+    UNUSED_PARAM(exec);
+    TestObj* impl = static_cast<TestObj*>(castedThis->impl());
+    JSValue result = jsNumber(impl->blueberry());
+    return result;
+}
+
+
 JSValue jsTestObjStrictFloat(ExecState* exec, JSValue slotBase, const Identifier&)
 {
     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
@@ -1270,6 +1281,14 @@
 }
 
 
+void setJSTestObjStrawberry(ExecState* exec, JSObject* thisObject, JSValue value)
+{
+    JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
+    TestObj* impl = static_cast<TestObj*>(castedThis->impl());
+    impl->setBlueberry(toint(value));
+}
+
+
 void setJSTestObjStrictFloat(ExecState* exec, JSObject* thisObject, JSValue value)
 {
     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2012-03-23 15:46:23 UTC (rev 111865)
@@ -314,6 +314,8 @@
 void setJSTestObjMutablePoint(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
 JSC::JSValue jsTestObjImmutablePoint(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
 void setJSTestObjImmutablePoint(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
+JSC::JSValue jsTestObjStrawberry(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
+void setJSTestObjStrawberry(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
 JSC::JSValue jsTestObjStrictFloat(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
 void setJSTestObjStrictFloat(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
 JSC::JSValue jsTestObjDescription(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);

Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h (111864 => 111865)


--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h	2012-03-23 15:46:23 UTC (rev 111865)
@@ -163,6 +163,8 @@
 - (void)setMutablePoint:(DOMSVGPoint *)newMutablePoint;
 - (DOMSVGPoint *)immutablePoint;
 - (void)setImmutablePoint:(DOMSVGPoint *)newImmutablePoint;
+- (int)strawberry;
+- (void)setStrawberry:(int)newStrawberry;
 - (float)strictFloat;
 - (void)setStrictFloat:(float)newStrictFloat;
 - (int)descriptionName;

Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm (111864 => 111865)


--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm	2012-03-23 15:46:23 UTC (rev 111865)
@@ -677,6 +677,18 @@
     IMPL->setImmutablePoint(core(newImmutablePoint));
 }
 
+- (int)strawberry
+{
+    WebCore::JSMainThreadNullState state;
+    return IMPL->blueberry();
+}
+
+- (void)setStrawberry:(int)newStrawberry
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->setBlueberry(newStrawberry);
+}
+
 - (float)strictFloat
 {
     WebCore::JSMainThreadNullState state;

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


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2012-03-23 15:46:23 UTC (rev 111865)
@@ -216,6 +216,7 @@
         [Immutable] SVGPoint immutablePointFunction();
 
         [ImplementedAs=banana] void orange();
+        attribute [ImplementedAs=blueberry] int strawberry;
 
         attribute [StrictTypeChecking] float strictFloat;
         [StrictTypeChecking] bool strictFunction(in DOMString str, in float a, in int b)

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (111864 => 111865)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-03-23 15:43:39 UTC (rev 111864)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-03-23 15:46:23 UTC (rev 111865)
@@ -941,6 +941,22 @@
     return;
 }
 
+static v8::Handle<v8::Value> strawberryAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+    INC_STATS("DOM.TestObj.strawberry._get");
+    TestObj* imp = V8TestObj::toNative(info.Holder());
+    return v8::Integer::New(imp->blueberry());
+}
+
+static void strawberryAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+{
+    INC_STATS("DOM.TestObj.strawberry._set");
+    TestObj* imp = V8TestObj::toNative(info.Holder());
+    int v = V8int::HasInstance(value) ? V8int::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
+    imp->setBlueberry(v);
+    return;
+}
+
 static v8::Handle<v8::Value> strictFloatAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 {
     INC_STATS("DOM.TestObj.strictFloat._get");
@@ -1889,6 +1905,8 @@
     {"mutablePoint", TestObjInternal::mutablePointAttrGetter, TestObjInternal::mutablePointAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
     // Attribute 'immutablePoint' (Type: 'attribute' ExtAttr: 'Immutable')
     {"immutablePoint", TestObjInternal::immutablePointAttrGetter, TestObjInternal::immutablePointAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
+    // Attribute 'strawberry' (Type: 'attribute' ExtAttr: 'ImplementedAs')
+    {"strawberry", TestObjInternal::strawberryAttrGetter, TestObjInternal::strawberryAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
     // Attribute 'strictFloat' (Type: 'attribute' ExtAttr: 'StrictTypeChecking')
     {"strictFloat", TestObjInternal::strictFloatAttrGetter, TestObjInternal::strictFloatAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
     // Attribute 'description' (Type: 'readonly attribute' ExtAttr: '')
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to