Subj : Re: Calling functions without the lookup To : mozilla-jseng@mozilla.org From : ggadwa@voyager.net (Brian Barnes) Date : Wed Jan 15 2003 04:19 pm Brendan Eich wrote: > Brian Barnes wrote: > >> jsval myfunc; >> >> JS_GetProperty(cx,obj,"BLECH",&myfunc); >> JS_CallFunctionValue(cx,obj,"BLECH",argc,&argv,&rval); > > > > > You must mean > > JS_CallFunctionValue(cx, obj, > (JSFunction *) JS_GetPrivate(cx, > JSVAL_TO_OBJECT(myfunc), > argc, &argv, &rval); > > a jsval is not a JSFunction*, or even a tagged JSFunction*. Need to not type so fast. What I meant was: JS_CallFunctionValue(cx,obj,myfunc,argc,&argv,&rval); JS_CallFunctionValue takes a jsval, not a JSFunction (from the code). What I did was just to tear JS_CallFunctionName apart, so I could avoid calling the same code (which is basically the JS_GetPrivate) over and over again. So, trying again: jsval myfunc; JS_GetProperty(cx,obj,"BLECH",&myfunc); JS_CallFunctionValue(cx,obj,myfunc,argc,&argv,&rval); Should be equivalent to JS_CallFunctionName with BLECH. It's what the JS_CallFunctionName does. I'm calling into a compiled script and I don't expect somebody to redefine the function (if they do, they will get an error, as they should.) I always miss something super technical when talking with you Brendan! I'm not sure why I need to cast to JSFunction or do the getprivate instead of what I have above. [>] Brian .