[webkit-dev] JavaScriptCore question

Rolando Abarca m at rolando.cl
Fri Dec 16 09:05:21 PST 2011


Hi all,

I'm using JavaScriptCore for scripting purposes (isolated from webkit), and
I'm encountering the following problem:

I would like to store a reference to an anonymous function, and later to be
able to call it as a callback, something like this:

---javascript
node.schedule("some name", function () { ... });
---

What I'm doing right now is in the definition of node.schedule, I store the
context and the function (as a JSValueRef), then when I need to call code
in there, I'm doing this:

JSObjectRef func = JSValueToObject(storedContext, storedCallback, NULL);
JSObjectCallAsFunction(cb->context, func, storedObject, 0, NULL, NULL);
It doesn't matter how I store the context/function, it always crashes when
trying to either convert the value to object or call the object as
function. At first I thought that the function was being garbage collected,
but even after protecting it, I still got the crash.

My guess is that the context is not the right one, so another question is:
what context should I be passing here?

What would be the right way to do this?
Thanks,
-- 
Rolando Abarca M.
http://rolando.cl
Phones: +1 (415) 655-1041
+56 (2) 581-4591
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20111216/b97e00bd/attachment.html>


More information about the webkit-dev mailing list