mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Example property ops need to check the class of the incoming objects, bug 700295. r=waldo
This commit is contained in:
parent
9452f6845c
commit
a503daec48
@ -4333,42 +4333,10 @@ enum its_tinyid {
|
||||
};
|
||||
|
||||
static JSBool
|
||||
its_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
jsval *val = (jsval *) JS_GetPrivate(cx, obj);
|
||||
*vp = val ? *val : JSVAL_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
its_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
its_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
|
||||
{
|
||||
jsval *val = (jsval *) JS_GetPrivate(cx, obj);
|
||||
if (val) {
|
||||
*val = *vp;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
val = new jsval;
|
||||
if (!val) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_AddValueRoot(cx, val)) {
|
||||
delete val;
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_SetPrivate(cx, obj, (void*)val)) {
|
||||
JS_RemoveValueRoot(cx, val);
|
||||
delete val;
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*val = *vp;
|
||||
return JS_TRUE;
|
||||
}
|
||||
its_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
|
||||
|
||||
static JSPropertySpec its_props[] = {
|
||||
{"color", ITS_COLOR, JSPROP_ENUMERATE, NULL, NULL},
|
||||
@ -4540,6 +4508,52 @@ static JSClass its_class = {
|
||||
JSCLASS_NO_OPTIONAL_MEMBERS
|
||||
};
|
||||
|
||||
static JSBool
|
||||
its_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
if (JS_GET_CLASS(cx, obj) == &its_class) {
|
||||
jsval *val = (jsval *) JS_GetPrivate(cx, obj);
|
||||
*vp = val ? *val : JSVAL_VOID;
|
||||
} else {
|
||||
*vp = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
its_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
|
||||
{
|
||||
if (JS_GET_CLASS(cx, obj) != &its_class)
|
||||
return JS_TRUE;
|
||||
|
||||
jsval *val = (jsval *) JS_GetPrivate(cx, obj);
|
||||
if (val) {
|
||||
*val = *vp;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
val = new jsval;
|
||||
if (!val) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_AddValueRoot(cx, val)) {
|
||||
delete val;
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_SetPrivate(cx, obj, (void*)val)) {
|
||||
JS_RemoveValueRoot(cx, val);
|
||||
delete val;
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*val = *vp;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSErrorFormatString jsShell_ErrorFormatString[JSErr_Limit] = {
|
||||
#define MSG_DEF(name, number, count, exception, format) \
|
||||
{ format, count, JSEXN_ERR } ,
|
||||
|
Loading…
Reference in New Issue
Block a user