From:  Carlos Barcellos <>
Date:  19 Oct 2006 20:27:59 Hong Kong Time

Re: JS_DefineFunction


Hi my friend, thanks for the info, but this actually doesn't work for me 
as I need to create all of function under the same global object, so, 
any of these functions I've created will return the same object.

Any other ideas are very much welcome,



Dave Huseby wrote:
>> ...or even better, if there is a way to pass a user pointer
>> to a function and get it back when the C function is called?
> You can use the JS_SetPrivate and JS_GetPrivate functions to set/get a
> user pointer on the object that the JS function is associated with.
> The object the JS function is associated with is the one you passed
> into the JS_DefineFunction function.  When your C function gets called,
> it is passed a context and the object that the JS function was
> associated with.  You would use JS_GetPrivate to get your pointer back
> which inside the C function.
> Dave