Subj : Re: Storing info in function objects.. To : Chris Tchou From : Brendan Eich Date : Tue Jul 20 2004 09:22 am Chris Tchou wrote: > Is it possible to store information (a number) when defining a JS function > that wraps a native C function, in such a way that the info can be retrieved > from within the native C function? This way one C function could be used > for multiple JS functions. Yes, XPConnect does this, and it motivated the reservation of 2 slots for function objects (see jsfun.c, JSCLASS_HAS_RESERVED_SLOTS(2) in js_FunctionClass.flags). Use JS_SetReservedSlot to set the slot value (a number) in the function object when you define it, and use JS_GetReservedSlot on JSVAL_TO_OBJECT(argv[-2]) when your native hook is called to get the reserved slot value. Reserved slot numbers start at 0, so for function objects, you have reserved slots 0 and 1. /be .