diff options
author | portix <none@none> | 2012-09-25 11:28:42 +0200 |
---|---|---|
committer | portix <none@none> | 2012-09-25 11:28:42 +0200 |
commit | 3766f55ac54b228782f82e981416cc06f9b30bb8 (patch) | |
tree | 59a9556d6e3c24176f7525747bc6ed4bde772340 /src/js.c | |
parent | f0a3b9d7f5c3ed6cfc067ae7da8c35af334a7b47 (diff) | |
download | dwb-3766f55ac54b228782f82e981416cc06f9b30bb8.zip |
Optional argument for inject function
Diffstat (limited to 'src/js.c')
-rw-r--r-- | src/js.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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 |