summaryrefslogtreecommitdiff
path: root/src/js.c
diff options
context:
space:
mode:
authorportix <none@none>2012-05-28 00:09:10 +0200
committerportix <none@none>2012-05-28 00:09:10 +0200
commitb34f4909ac9b9463b558a027905fef3e43d0f9b3 (patch)
tree7e282e67fc8569cdb845347cca59b00759541adf /src/js.c
parent2dd1f76e542b6204b3ea18d4a0fc9cb203892865 (diff)
downloaddwb-b34f4909ac9b9463b558a027905fef3e43d0f9b3.zip
New function sendRequestSync
Diffstat (limited to 'src/js.c')
-rw-r--r--src/js.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/js.c b/src/js.c
index dfcb808f..1ba5fa7b 100644
--- a/src/js.c
+++ b/src/js.c
@@ -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);