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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111865
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-03-23 Kentaro Hara <haraken@chromium.org>
+
+ 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 <tommyw@google.com>
The JSC code generator doesn't generate correct code for Constructors
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.
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())
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;
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)
{
PROP_CONTENT_DOCUMENT,
PROP_MUTABLE_POINT,
PROP_IMMUTABLE_POINT,
+ PROP_STRAWBERRY,
PROP_STRICT_FLOAT,
PROP_DESCRIPTION,
PROP_ID,
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());
"read-write WebKitDOMSVGPoint* TestObj.immutable-point", /* longer - could do with some extra doc stuff here */
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 */
WEBKIT_API void
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
{ "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 },
{ 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[] =
}
+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));
}
+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);
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&);
- (void)setMutablePoint:(DOMSVGPoint *)newMutablePoint;
- (DOMSVGPoint *)immutablePoint;
- (void)setImmutablePoint:(DOMSVGPoint *)newImmutablePoint;
+- (int)strawberry;
+- (void)setStrawberry:(int)newStrawberry;
- (float)strictFloat;
- (void)setStrictFloat:(float)newStrictFloat;
- (int)descriptionName;
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;
[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)
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");
{"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: '')