Subj : Re: object serialization To : Jens Thiele From : Brendan Eich Date : Wed Apr 07 2004 02:51 pm This is a multi-part message in MIME format. --------------030003030008000709040609 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Jens Thiele wrote: > hmm following will crash: > if (!JS_GetObjectId(cx,o,&id)) return JS_FALSE; > if (!JS_IdToValue(cx,id,rval)) return JS_FALSE; > JS_TypeOfValue(cx,*rval); JS_GetObjectId does not return an id that you can convert into a value. It is intended for internal use only, not scripted use. Maybe it should be extended to work as you want it to. Try the attached patch and let me know how it works. /be --------------030003030008000709040609 Content-Type: text/plain; name="ad" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ad" Index: jsapi.c =================================================================== RCS file: /cvsroot/mozilla/js/src/jsapi.c,v retrieving revision 3.164 diff -p -u -8 -r3.164 jsapi.c --- jsapi.c 22 Feb 2004 03:21:15 -0000 3.164 +++ jsapi.c 7 Apr 2004 20:50:31 -0000 @@ -2062,17 +2062,17 @@ JS_GetConstructor(JSContext *cx, JSObjec return NULL; } return JSVAL_TO_OBJECT(cval); } JS_PUBLIC_API(JSBool) JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp) { - *idp = (jsid) obj; + *idp = (jsid) obj | JSVAL_INT; return JS_TRUE; } JS_PUBLIC_API(JSObject *) JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent) { CHECK_REQUEST(cx); if (!clasp) --------------030003030008000709040609-- .