Subj : Re: object serialization To : netscape.public.mozilla.jseng From : Jens Thiele Date : Thu Apr 08 2004 10:48 pm > My patch should work better. Your patch will cast o to an integer type, > shift it left, and | 1 with it to tag it as an int jsval, which might at > the limit create an id that aliases two objects. Very unlikely, but not > fully general. > > The patch I posted is general, because object pointers are guaranteed to > be aligned on 0 mod 8 boundaries, so |'ing 1 loses no data; nothing is > shifted. seems to work i added an assert ;-) JS_PUBLIC_API(JSBool) JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp) { JS_ASSERT( ( (jsid) obj & 7 ) == 0 ); *idp = (jsid) obj | JSVAL_INT; return JS_TRUE; } and now use this as hash function (for objects) thanks! .