JSBool js_XDRAtom(JSXDRState *xdr, JSAtom **atomp) { jsval v; uint32 type; if (xdr->mode == JSXDR_ENCODE) { v = ATOM_KEY(*atomp); return JS_XDRValue(xdr, &v); } /* * Inline JS_XDRValue when decoding to avoid ceation of GC things when * then corresponding atom already exists. See bug 321985. */ if (!JS_XDRUint32(xdr, &type)) return JS_FALSE; if (type == JSVAL_STRING) return js_XDRStringAtom(xdr, atomp); if (type == JSVAL_DOUBLE) { jsdouble d = 0; if (!XDRDoubleValue(xdr, &d)) return JS_FALSE; *atomp = js_AtomizeDouble(xdr->cx, d); return *atomp != NULL; } return XDRValueBody(xdr, type, &v) && js_AtomizePrimitiveValue(xdr->cx, v, atomp); }
JSBool js_XDRAtom(JSXDRState *xdr, JSAtom **atomp) { jsval v; uint32 type; jsdouble d; JSAtom *atom; if (xdr->mode == JSXDR_ENCODE) { v = ATOM_KEY(*atomp); return JS_XDRValue(xdr, &v); } /* * Inline JS_XDRValue when decoding to avoid ceation of GC things when * then corresponding atom already exists. See bug 321985. */ if (!JS_XDRUint32(xdr, &type)) return JS_FALSE; if (type == JSVAL_STRING) return js_XDRStringAtom(xdr, atomp); if (type == JSVAL_DOUBLE) { if (!XDRDoubleValue(xdr, &d)) return JS_FALSE; atom = js_AtomizeDouble(xdr->cx, d, 0); } else { if (!XDRValueBody(xdr, type, &v)) return JS_FALSE; atom = js_AtomizeValue(xdr->cx, v, 0); } if (!atom) return JS_FALSE; *atomp = atom; return JS_TRUE; }