Fix dropProperty crash. This is needed because the JSObjects used by xpconnect wrapped natives need to act both as host objects with non-slot properties and as a plain JSObjects using the default JSOps and all that entails. So, we can't be passing the host-style props to dropProperty though we do still need to do so for other props. This has only been working up to now by luck. r=brendan@mozilla.org a=brendan@mozilla.org

This commit is contained in:
jband%netscape.com 2000-07-14 05:34:46 +00:00
parent fabe933429
commit cc7bff60f8

View File

@ -336,6 +336,8 @@ WrappedNative_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
}
}
#define XPC_BUILT_IN_PROPERTY ((JSProperty*)1)
JS_STATIC_DLL_CALLBACK(JSBool)
WrappedNative_LookupProperty(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp
@ -356,7 +358,7 @@ WrappedNative_LookupProperty(JSContext *cx, JSObject *obj, jsid id,
if(clazz->LookupMemberByID(id))
{
*objp = obj;
*propp = (JSProperty*)1;
*propp = XPC_BUILT_IN_PROPERTY;
return JS_TRUE;
}
else if(nsnull != (ds = wrapper->GetDynamicScriptable()) &&
@ -695,6 +697,20 @@ WrappedNative_Finalize(JSContext *cx, JSObject *obj)
wrapper->JSObjectFinalized(cx, obj);
}
JS_STATIC_DLL_CALLBACK(void)
WrappedNative_DropProperty(JSContext *cx, JSObject *obj, JSProperty *prop)
{
/* If this is not one of our 'built-in' native properties AND
* the JS engine has a callback to handle dropProperty then call it.
*/
if(prop != XPC_BUILT_IN_PROPERTY)
{
JSPropertyRefOp drop = js_ObjectOps.dropProperty;
if(drop)
drop(cx, obj, prop);
}
}
/*
* We have two classes - one with and one without call and construct. We use
* the one without for any object without an nsIXPCScriptable so that the
@ -718,7 +734,7 @@ static JSObjectOps WrappedNative_ops = {
/* Optionally non-null members start here. */
nsnull, /* thisObject */
nsnull, /* dropProperty */
WrappedNative_DropProperty, /* dropProperty */
nsnull, /* call */
nsnull, /* construct */
nsnull, /* xdrObject */
@ -745,7 +761,7 @@ static JSObjectOps WrappedNativeWithCall_ops = {
/* Optionally non-null members start here. */
nsnull, /* thisObject */
nsnull, /* dropProperty */
WrappedNative_DropProperty, /* dropProperty */
WrappedNative_Call, /* call */
WrappedNative_Construct, /* construct */
nsnull, /* xdrObject */
@ -806,11 +822,9 @@ JSBool xpc_InitWrappedNativeJSOps()
{
WrappedNative_ops.newObjectMap = js_ObjectOps.newObjectMap;
WrappedNative_ops.destroyObjectMap = js_ObjectOps.destroyObjectMap;
WrappedNative_ops.dropProperty = js_ObjectOps.dropProperty;
WrappedNativeWithCall_ops.newObjectMap = js_ObjectOps.newObjectMap;
WrappedNativeWithCall_ops.destroyObjectMap = js_ObjectOps.destroyObjectMap;
WrappedNativeWithCall_ops.dropProperty = js_ObjectOps.dropProperty;
}
return JS_TRUE;
}