Subj : Re: 'Subclassing' JSClass To : netscape.public.mozilla.jseng From : John Bandhauer Date : Thu Jan 23 2003 03:07 pm Don't use the reserved fields. You're option c is fine. Spidermonkey doesn't care where the JSClass struct lives. The one critical thing is that the JSStruct needs to be alive until the very last object based on that sturucture has been finalized - else it will crash. John. James Turner wrote: > So, in my ongoing path to SpiderMonkey enlightenment.. > > I need to associate some extra data with each JSClass* . My options are) > a lookup table based on the pointer value (yuck), stashing a pointer in > the reserved field of JSClass (liable to break in the future and won't > work if sizeof(void*) > sizeof(jsword), which I'm guessing it may be on > 64-bit archs ).. > > Or finally, option c) > > struct { > JSClass inner; > > // my extra data ... > > } } ExtendedJSClass; > > And pass these around to JS_InitClass and friends. Now, obviously I'm > currently favoring this last options, so I need to know: is there a > better way, and/or is anything likely to break with this method? Eg > internal dense arrays of JSClass structs, etc. It seems unlikely from > looking at code but I'd like to make sure. > > Thanks, > James .