[webkit-help] How do i retain a stack in JS callback function

Sumedh vsbhogle at gmail.com
Wed Jul 27 00:19:59 PDT 2011


I am creating a JS function with JSObjectMakeFunctionWithCallback().
Callback signature will be

JSValueRef my_func(JSContextRef ctx, JSObjectRef function, JSObjectRef
thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef

Now instead of serving the request, i want to send a message to windows
message loop (I am working on windows). Here, I need to save the stack of
the argumets[] which is of type JSValueRef, const.

Approach I:

I tried to protect all elements from arguments array, by looping through,
didn't work.

            //Protect the each memeber of the JSValueRef array, Not working
            for(i = 0; i < argumentCount; i++){

                JSValueProtect(ctx, arguments[i]);
            jsObject->arguments = (JSValueRef *) arguments;*/

Approach II:

I simply created a deep copy of the array using memcpy, which worked.

            //Alternate Approach
            //Copy the entire array here
            jsObject->arguments = (JSValueRef
            memcpy(jsObject->arguments, arguments,

NOTE: jsObject is object of my stack struct.

Is it correct?  Is there any other approach to do this?

Dhanyawaad (Thanks)

Sumedh S Bhogle
Mumbai | Mob. 09969085122
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20110727/5a95cb2f/attachment.html>

More information about the webkit-help mailing list