Subj : Re: Querying the name of the function being called in the static To : Stephen Jones From : Brendan Eich Date : Wed Mar 12 2003 09:02 am Stephen Jones wrote: >Is it possible to point multiple methods/function to the same static >callback and somehow determine which method is being called? Ideally, I >would like to query the string name of the method. Something like this: > >static JSBool StaticMethod(JSContext *cx, JSObject *obj, uintN argc, jsval >*argv, jsval *rval) >{ > string theName = GetMethodName( ); > Use argv[-2] -- JS_GetFunctionId((JSFunction *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[-2]))) if you must have the (JSString*) identifier, but there's probably a faster way to dispatch. What kind of system are you building that shares a native function among several JS functions, btw? /be > > if ( theName == "foo" ) > { > // do foo > } > > else if ( theName == "bar" ) > { > // do bar > } > > return JS_TRUE; >} > >Thanks, >- Stephen Jones > > > > .