Subj : Getting function name with generic function call hook To : netscape.public.mozilla.jseng From : "Sterling Bates" Date : Mon Oct 27 2003 01:00 am I've found a couple others who've claimed to have similar issues, but none of the remedies worked for me. The most applicable response was this: http://groups.google.ca/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3B7779DF.2050105%40meer.net Here's the C code: JSObject *funobj = JSVAL_TO_OBJECT(argv[-2]); JSFunction *fun = (JSFunction *) JS_GetPrivate(cx, funobj); const char *name = JS_GetFunctionName(fun); The following is the Delphi equivalent (to my best understanding): Dec(argv,2); // point to argv[-2] funobj := PJSObject(argv^ or JSTYPE_OBJECT); // JSVAL_TO_OBJECT fun := PJSFunction(JS_GetPrivate(cx,funobj)); // returns nil methodName := JS_GetFunctionName(fun); // won't work... Since |fun| is always nil, no further calls work. Another way I've tried does work, but of course returns the class name: Result := PChar(JS_GetStringBytes(JS_ValueToString(cx,id))); ....where |id| is argv[-2]. This is the method JSClass definition, and my declaration of the method object as a property of its parent: generic_method_class: JSClass = (name: 'CGenericMethod'; flags: JSCLASS_HAS_PRIVATE; addProperty: JS_PropertyStub; delProperty: JS_PropertyStub; getProperty: JS_PropertyStub; setProperty: JS_PropertyStub; enumerate: JS_EnumerateStub; resolve: JS_ResolveStub; convert: JS_ConvertStub; finalize: JS_FinalizeStub; call: Generic_MethodCall); JS_DefineObject(FContext,FJSObject,PChar(name),@generic_method_class,nil,0); Any help with this is very appreciated :-) Sterling .