[webkit-dev] JSObjectMakeFunction question

Jack Wootton jackwootton at gmail.com
Mon Jun 1 06:07:23 PDT 2009


Hi all,

I'm attempting to use the function JSObjectMakeFunction described here:

http://gemma.apple.com/documentation/Carbon/Reference/WebKit_JavaScriptCore_Ref/JSObjectRef/index.html

I would like to call a JavaScript function from C.  I assume the
following is required:

1. Create a function using JSObjectMakeFunction.
2. Add it as a property of the Window JSObjectRef.
3. Call it using JSObjectCallAsFunction.

However JSObjectMakeFunction has the following signature:

JSObjectRef JSObjectMakeFunction(
    JSContextRef ctx,
    JSStringRef name,
    unsigned parameterCount,
    const JSStringRef parameterNames[],
    JSStringRef body,
    JSStringRef sourceURL,
    int startingLineNumber,
    JSValueRef *exception);

My question is about the parameters to this function:

JSStringRef body - Since I wish to call a JavaScript function from C,
why would I specify the body of the function.  Surely this would be
implemented by the JavaScript developer?  I don't understand this
parameter in the context of calling a user defined JavaScript function
from within C.

Can anyone help?

Cheers,
Jack


More information about the webkit-dev mailing list