Subj : [SpiderMonkey] Serializing JSObject To : netscape.public.mozilla.jseng From : Brian Barnes Date : Tue Jun 22 2004 11:41 pm After months of going over different ways to save the scripts that run my game, I'm going with serializing objects. My scripts are all run by events (which pass an object that parallels the game structures), so the only thing that changes while playing is the globals. If I serialize the global for each script, I can just restart the script, put back in the global, and I'm back to the original state (yes, I know there are tricks that can defeat this, but they aren't supported for v1 :) ). Also, I'm only serializing primitives for v1, so it's even easier (most people just need to work within the objects that are passed from the event, so even globals are pretty minimal.) I've got a bulk of this code written, and I've run into something weird. As I parse through the properties for a object, I can get it's property and call JS_TypeOfValue to get it's type and parse out everything but string, number, and boolean. Question one: What is JSTYPE_LIMIT? Question two: Why does JSTYPE's have JSTYPE_NUMBER, but in reality it's either a DOUBLE or an INT (easy enough to figure out.) Nothing else drills down like that. Just wondering. I'll post up the code (in case it's useful to anybody, it would be quite easy to modify it to save objects and recurse through them.) Might be something useful for core. [>] Brian .