Subj : Storing info in function objects.. To : netscape.public.mozilla.jseng From : Chris Tchou Date : Mon Jul 19 2004 05:11 pm 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. For example: ---------------------------------- JSBool doSomething(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { switch (GetStoredValue()) { case 0: ... break; case 1: ... break; } } JSFunction *func = JS_DefineFunction(cx, obj, "doSomething0", doSomething, 0, 0); StoreValue(func, 0); JSFunction *func = JS_DefineFunction(cx, obj, "doSomething1", doSomething, 0, 0); StoreValue(func, 1); ----------------------------------------------- The private data slot appears to be used already for function objects to store a pointer to an internal function data structure. Is it possible to store and retrieve data on the internal function data structure? Alternatively, is it possible to get the name of the current JavaScript function from within the C function? This wouldn't work if the function was copied in JavaScript, but it would at least work initially. Thanks for your input! -Chris .