Subj : Re: Persisting a JSScript To : netscape.public.mozilla.jseng From : "Sterling Bates" Date : Wed Aug 13 2003 08:57 pm > >Basically I didn't spend enough time examining the XDR APIs. If I'm now > >right, I can get the bytes out for streaming from JS_XDRMemGetData, with lp > >being the length of the pointer result. > > > > Right. Works like a charm :) For those who might benefit, here's the Delphi code (easily ported to C): Deserialize: xdr := JS_XDRNewMem(fcontext,JSXDR_DECODE); if (xdr <> nil) then begin JS_XDRMemSetData(xdr,data,len); Result := (JS_XDRScript(xdr,script) = JS_TRUE); end; // data is char *, script is JSScript *, len is size_t, and xdr is JSXDRState * Serialize: xdr := JS_XDRNewMem(fcontext,JSXDR_ENCODE); if (xdr <> nil) and (JS_XDRScript(xdr,fscript) = JS_TRUE) then data := JS_XDRMemGetData(xdr,@len); // here data is just void * Many thanks Brendan :) Sterling .