Hi,

I'm using JavaScriptCore Framework in a Cocoa program. I'm trying to evaluate a function in the JavaScript code via C, but I'm having problems with figuring out how to get a proper reference to that function. I'm trying to have behavior analogous to the setTimeout() function, which takes a string which will be evaluated after the time has lapsed.

JavaScript:
function AddOne(num) {
  return num + 1;
}

var thirtyThree = myClass.callFunction("AddOne()", 32);


In myClass's callFunction(), I need to convert this passed in string value to a function which will return "true" to JSObjectIsFunction() so that I can then use the JSObjectCallAsFunction() function.

I've tried making a JSValue out of the string passed in and then:
JSObjectRef fnObj = JSValueToObject(globalcontext, fnValue);

but that doesn't come back as a valid function object.

I looked inside of the JavaScriptCore Framework source, WebScriptObject.mm, callWebScriptMethod:withArguments: and it looks like it's looking up the string from a hash table associated with the ExecState, which I don't have access to inside of the public API for the JavaScriptCore Framework.

Any suggestions on how I can accomplish this lookup?

Thanks,
Dan
-----------------------------------------------------------------
Dan Waylonis                    [EMAIL PROTECTED]
nekotech SOFTWARE
http://www.nekotech.com
650.964.2490 Voice / Fax



_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to