Nov 13, 2008, в 1:22 PM, Daniel Waylonis написал(а):

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.

You need to evaluate the JavaScript source, then look up the function by name as a global object property:

JS_EXPORT JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)

Here, object will be a result of JSContextGetGlobalObject(), and propertyName will be "AddOne".

- WBR, Alexey Proskuryakov

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

Reply via email to