summaryrefslogtreecommitdiff
path: root/src/js.c
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2014-01-19 02:02:36 +0100
committerDaniel Carl <danielcarl@gmx.de>2014-01-19 02:02:36 +0100
commitafcdae37b3184eac69de8f0871bae12131769608 (patch)
tree8d7fa3553bf4f991a3be0f1cd6183409a7fc3d38 /src/js.c
parentd877e3ccf04d2fd4e8dd3304bf4855328c69c8e6 (diff)
Fixed nextpattern to js value conversion (#62).
The prev- and nextpatterns can't be given to JavaScript as strings that are split on the ',' to be interpreted as regular expression. So the patterns have to be given as array of RegExp objects instead.
Diffstat (limited to 'src/js.c')
-rw-r--r--src/js.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/js.c b/src/js.c
index cd8e6a0..c54c613 100644
--- a/src/js.c
+++ b/src/js.c
@@ -159,6 +159,19 @@ JSValueRef js_string_to_ref(JSContextRef ctx, const char *string)
}
/**
+ * Retrieves a values reference for given json or array string string.
+ */
+JSValueRef js_object_to_ref(JSContextRef ctx, const char *json)
+{
+ JSValueRef ref = NULL;
+ if (evaluate_string(ctx, json, NULL, &ref)) {
+ return ref;
+ }
+ g_warning("Could not parse %s", json);
+ return NULL;
+}
+
+/**
* Runs a string as JavaScript and returns if the call succeed.
* In case the call succeed, the given *result is filled with the result
* value, else with the value reference of the exception.