I am using the JavaScriptCore API to get the global context for Javascript. I would like to be able to manipulate the value that I get from Javascript in C. Here is an example of the code that I have that matters:
JSGlobalContextRef jsContext = webkit_web_frame_get_global_context(webkit_web_view_get_main_frame(webView));
JSStringRef script = JSStringCreateWithUTF8CString("ReturnOne()");
JSValueRef val = JSEvaluateScript(jsContext, script, NULL, NULL, 0, NULL);
return JSValueToNumber(jsContext, val, NULL);
The ReturnOne () function is a JavaScript function that looks like this:
function ReturnOne() {
return 1;
}
When I put a warning in a function, it displays, so I know that the function is being called correctly. I try to just print number 1, but instead get a large negative value. Am I misinterpreting JSValueToNumber?
Any advice would be appreciated. Thank.
EDIT: I did some operations and found this stone - https://lists.webkit.org/pipermail/webkit-help/2011-January/001849.html
, , C . Javascript , Javascript- , ( , 1).
, Javascript, , .