diff options
author | Daniel Carl <danielcarl@gmx.de> | 2014-01-19 02:02:36 +0100 |
---|---|---|
committer | Daniel Carl <danielcarl@gmx.de> | 2014-01-19 02:02:36 +0100 |
commit | afcdae37b3184eac69de8f0871bae12131769608 (patch) | |
tree | 8d7fa3553bf4f991a3be0f1cd6183409a7fc3d38 /src/js.c | |
parent | d877e3ccf04d2fd4e8dd3304bf4855328c69c8e6 (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.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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. |