diff options
author | portix <none@none> | 2012-05-28 00:09:10 +0200 |
---|---|---|
committer | portix <none@none> | 2012-05-28 00:09:10 +0200 |
commit | b34f4909ac9b9463b558a027905fef3e43d0f9b3 (patch) | |
tree | 7e282e67fc8569cdb845347cca59b00759541adf /src/js.c | |
parent | 2dd1f76e542b6204b3ea18d4a0fc9cb203892865 (diff) | |
download | dwb-b34f4909ac9b9463b558a027905fef3e43d0f9b3.zip |
New function sendRequestSync
Diffstat (limited to 'src/js.c')
-rw-r--r-- | src/js.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -31,6 +31,14 @@ js_make_exception(JSContextRef ctx, JSValueRef *exception, const gchar *format, va_end(arg_list); *exception = js_char_to_value(ctx, message); } + +void +js_set_object_property(JSContextRef ctx, JSObjectRef arg, const char *name, const char *value, JSValueRef *exc) { + JSStringRef js_key = JSStringCreateWithUTF8CString(name); + JSValueRef js_value = js_char_to_value(ctx, value); + JSObjectSetProperty(ctx, arg, js_key, js_value, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly, exc); + JSStringRelease(js_key); +} /* js_get_object_property {{{*/ JSObjectRef js_get_object_property(JSContextRef ctx, JSObjectRef arg, const char *name) { @@ -235,6 +243,13 @@ js_value_to_json(JSContextRef ctx, JSValueRef value, size_t limit, JSValueRef *e JSStringRelease(js_json); return json; } +JSValueRef +js_json_to_value(JSContextRef ctx, const char *text) { + JSStringRef json = JSStringCreateWithUTF8CString(text == NULL || *text == 0 ? "{}" : text); + JSValueRef ret = JSValueMakeFromJSONString(ctx, json); + JSStringRelease(json); + return ret; +} JSValueRef js_execute(JSContextRef ctx, const char *script, JSValueRef *exc) { JSObjectRef function = js_make_function(ctx, script); |