summaryrefslogtreecommitdiff
path: root/src/js.c
diff options
context:
space:
mode:
authorportix <none@none>2012-09-25 11:28:42 +0200
committerportix <none@none>2012-09-25 11:28:42 +0200
commit3766f55ac54b228782f82e981416cc06f9b30bb8 (patch)
tree59a9556d6e3c24176f7525747bc6ed4bde772340 /src/js.c
parentf0a3b9d7f5c3ed6cfc067ae7da8c35af334a7b47 (diff)
downloaddwb-3766f55ac54b228782f82e981416cc06f9b30bb8.zip
Optional argument for inject function
Diffstat (limited to 'src/js.c')
-rw-r--r--src/js.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/js.c b/src/js.c
index ce566175..548d1f13 100644
--- a/src/js.c
+++ b/src/js.c
@@ -114,6 +114,23 @@ js_string_to_char(JSContextRef ctx, JSStringRef jsstring, size_t size) {
return ret;
}/*}}}*/
+JSValueRef
+js_context_change(JSContextRef source_ctx, JSContextRef dest_ctx, JSValueRef val, JSValueRef *exc) {
+ char *c_val = js_value_to_json(source_ctx, val, -1, exc);
+ if (c_val == NULL)
+ return JSValueMakeNull(dest_ctx);
+
+ JSStringRef json = JSStringCreateWithUTF8CString(c_val);
+ JSValueRef ret = JSValueMakeFromJSONString(dest_ctx, json);
+
+ g_free(c_val);
+ JSStringRelease(json);
+
+ if (ret == NULL)
+ return JSValueMakeNull(dest_ctx);
+ return ret;
+}
+
/* js_create_object(WebKitWebFrame *frame, const char *)
*
* Executes a script in a function scope, should return an object with