https://bugs.webkit.org/show_bug.cgi?id=38699
Reviewed by Adam Barth.
Change both JSC and V8 generators to introduce "ConvertScriptString"
attribute to allow converting from ScriptString. Also updated the
bindings test result.
These changes are necessary in order to avoid adding custom binding codes
when we add the FileReader interface.
* bindings/scripts/CodeGeneratorJS.pm:
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
(webkit_dom_test_obj_get_script_string_attr):
(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::jsTestObjScriptStringAttr):
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
(-[DOMTestObj scriptStringAttr]):
* bindings/scripts/test/TestObj.idl:
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjInternal::scriptStringAttrAttrGetter):
(WebCore::):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@58921
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
Reviewed by Adam Barth.
+ Improve code generator scripts to support converting ScriptString.
+ https://bugs.webkit.org/show_bug.cgi?id=38699
+
+ Change both JSC and V8 generators to introduce "ConvertScriptString"
+ attribute to allow converting from ScriptString. Also updated the
+ bindings test result.
+
+ These changes are necessary in order to avoid adding custom binding codes
+ when we add the FileReader interface.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ * bindings/scripts/CodeGeneratorV8.pm:
+ * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+ (webkit_dom_test_obj_get_script_string_attr):
+ (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::jsTestObjScriptStringAttr):
+ * bindings/scripts/test/JS/JSTestObj.h:
+ * bindings/scripts/test/ObjC/DOMTestObj.h:
+ * bindings/scripts/test/ObjC/DOMTestObj.mm:
+ (-[DOMTestObj scriptStringAttr]):
+ * bindings/scripts/test/TestObj.idl:
+ * bindings/scripts/test/V8/V8TestObj.cpp:
+ (WebCore::TestObjInternal::scriptStringAttrAttrGetter):
+ (WebCore::):
+
+2010-05-06 Jian Li <jianli@chromium.org>
+
+ Reviewed by Adam Barth.
+
Improve code generator scripts to pass additional ScriptExecutionContext
argument to the constructor.
https://bugs.webkit.org/show_bug.cgi?id=38687
die "Unknown value for ConvertNullStringTo extended attribute";
}
+ $conv = $signature->extendedAttributes->{"ConvertScriptString"};
+ return "jsOwnedStringOrNull(exec, $value)" if $conv;
$implIncludes{"<runtime/JSString.h>"} = 1;
return "jsString(exec, $value)";
}
die "Unknown value for ConvertNullStringTo extended attribute";
}
+ $conv = $signature->extendedAttributes->{"ConvertScriptString"};
+ return "v8StringOrNull(exec, $value)" if $conv;
return "return v8String($value)";
}
}
+gchar*
+webkit_dom_test_obj_get_script_string_attr (WebKitDOMTestObj *self)
+{
+ g_return_val_if_fail (self, 0);
+ WebCore::TestObj * item = WebKit::core(self);
+ gchar* res = convertToUTF8String(item->scriptStringAttr());
+ return res;
+
+}
+
G_DEFINE_TYPE(WebKitDOMTestObj, webkit_dom_test_obj, WEBKIT_TYPE_DOM_OBJECT)
PROP_ATTR_WITH_SETTER_EXCEPTION,
PROP_ATTR_WITH_GETTER_EXCEPTION,
PROP_CUSTOM_ATTR,
+ PROP_SCRIPT_STRING_ATTR,
};
g_value_set_long(value, coreSelf->attrWithGetterException());
break;
}
+ case PROP_SCRIPT_STRING_ATTR:
+ {
+ g_value_take_string(value, convertToUTF8String(coreSelf->scriptStringAttr()));
+ break;
+ }
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
G_MAXLONG, /* max */
0, /* default */
WEBKIT_PARAM_READWRITE));
+ g_object_class_install_property(gobjectClass,
+ PROP_SCRIPT_STRING_ATTR,
+ g_param_spec_string("script-string-attr", /* name */
+ "test_obj_script-string-attr", /* short description */
+ "read-only gchar* TestObj.script-string-attr", /* longer - could do with some extra doc stuff here */
+ "", /* default */
+ WEBKIT_PARAM_READABLE));
WEBKIT_API void
webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value);
+WEBKIT_API gchar*
+webkit_dom_test_obj_get_script_string_attr (WebKitDOMTestObj *self);
+
G_END_DECLS
#endif /* WebKitDOMTestObj_h */
#define THUNK_GENERATOR(generator)
#endif
-static const HashTableValue JSTestObjTableValues[14] =
+static const HashTableValue JSTestObjTableValues[15] =
{
{ "readOnlyIntAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyIntAttr), (intptr_t)0 THUNK_GENERATOR(0) },
{ "readOnlyStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyStringAttr), (intptr_t)0 THUNK_GENERATOR(0) },
{ "attrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t)setJSTestObjAttrWithSetterException THUNK_GENERATOR(0) },
{ "attrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithGetterException), (intptr_t)setJSTestObjAttrWithGetterException THUNK_GENERATOR(0) },
{ "customAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCustomAttr), (intptr_t)setJSTestObjCustomAttr THUNK_GENERATOR(0) },
+ { "scriptStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjScriptStringAttr), (intptr_t)0 THUNK_GENERATOR(0) },
{ "constructor", DontEnum|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
{ 0, 0, 0, 0 THUNK_GENERATOR(0) }
};
return castedThis->customAttr(exec);
}
+JSValue jsTestObjScriptStringAttr(ExecState* exec, JSValue slotBase, const Identifier&)
+{
+ JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
+ UNUSED_PARAM(exec);
+ TestObj* imp = static_cast<TestObj*>(castedThis->impl());
+ JSValue result = jsOwnedStringOrNull(exec, imp->scriptStringAttr());
+ return result;
+}
+
JSValue jsTestObjConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSTestObj* domObject = static_cast<JSTestObj*>(asObject(slotBase));
void setJSTestObjAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
JSC::JSValue jsTestObjCustomAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
void setJSTestObjCustomAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
+JSC::JSValue jsTestObjScriptStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
JSC::JSValue jsTestObjConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
} // namespace WebCore
- (void)setAttrWithGetterException:(int)newAttrWithGetterException;
- (int)customAttr;
- (void)setCustomAttr:(int)newCustomAttr;
+- (NSString *)scriptStringAttr;
- (void)voidMethod;
- (void)voidMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg;
- (int)intMethod;
IMPL->setCustomAttr(newCustomAttr);
}
+- (NSString *)scriptStringAttr
+{
+ return IMPL->scriptStringAttr();
+}
+
- (void)voidMethod
{
IMPL->voidMethod();
void methodWithNonOptionalArgAndOptionalArg(in long nonOpt, in [Optional] long opt);
void methodWithNonOptionalArgAndTwoOptionalArgs(in long nonOpt, in [Optional] long opt1, in long opt2);
+ // 'ConvertScriptString' extended attribute
+ readonly attribute [ConvertScriptString] DOMString scriptStringAttr;
+
#ifdef TESTING_V8
// Overloads
void overloadedMethod(in TestObj objArg, in DOMString strArg);
return;
}
+static v8::Handle<v8::Value> scriptStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+ INC_STATS("DOM.TestObj.scriptStringAttr._get");
+ TestObj* imp = V8TestObj::toNative(info.Holder());
+ v8StringOrNull(exec, imp->scriptStringAttr());
+}
+
static v8::Handle<v8::Value> voidMethodCallback(const v8::Arguments& args)
{
INC_STATS("DOM.TestObj.voidMethod");
{"attrWithGetterException", TestObjInternal::attrWithGetterExceptionAttrGetter, TestObjInternal::attrWithGetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
// Attribute 'customAttr' (Type: 'attribute' ExtAttr: 'Custom')
{"customAttr", V8TestObj::customAttrAccessorGetter, V8TestObj::customAttrAccessorSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
+ // Attribute 'scriptStringAttr' (Type: 'readonly attribute' ExtAttr: 'ConvertScriptString')
+ {"scriptStringAttr", TestObjInternal::scriptStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
};
static const BatchedCallback TestObjCallbacks[] = {
{"voidMethod", TestObjInternal::voidMethodCallback},