Subj : Re: question about javascript functions To : netscape.public.mozilla.jseng From : Matthew Mondor Date : Fri Feb 18 2005 05:07 pm On Wed, 16 Feb 2005 15:43:19 +0100 "Béatrice Philippe" wrote: > Thank you Matt, you are right !! > with js_enumerate in c++, we can retrieve all parameter names of the > function (parameters appear at the top of the enumeration). > Now, i just need to give parameter values to my > js_callFunctionValue(). I think js_convert() should be > the right solution ?! Hmm I'm not sure I understand... So you obtain the arguments and their types of a user created function, using JS_Evaluate(), so that you can then call that user/script function with the proper arguments from C? I guess that JS_ConvertArguments() could serve perhaps, if it's what you meant, but the arguments are simply passed as an array of jsval, of course (argv) with the number of elements of the array in argc. It appears that in javascript the value types can easily be converted as well automatically in many cases... This is also true with SpiderMonkey when using JS_ValueTo*() functions rather than strict JSVAL_IS_*() followed by conditional JSVAL_TO_*() macros (which are probably good for performance and to ensure proper types though). Also, you can attempt to call a JS function from C which is assumed to have been defined with the expected arguments. Very possibly there is a simple way to then detect if the function wasn't declared as it had to be when doing so (I would have to write a little test and see to confirm this though). Sorry if I'm way off, I couldn't clearly understand the question Matt .