diff options
author | portix <none@none> | 2013-02-25 16:43:26 +0100 |
---|---|---|
committer | portix <none@none> | 2013-02-25 16:43:26 +0100 |
commit | cf51ec02bdb453a642e3a0a468dc67259d2aa904 (patch) | |
tree | 42c77712109084e06fa4c6201bf9bcd9980165c0 /src/js.c | |
parent | b843d5c2abeee780ec3ef2d14c61e185986e9509 (diff) | |
download | dwb-cf51ec02bdb453a642e3a0a468dc67259d2aa904.zip |
Check script syntax before creating the script object; implementing Function.debug
Diffstat (limited to 'src/js.c')
-rw-r--r-- | src/js.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -341,3 +341,18 @@ js_value_to_function(JSContextRef ctx, JSValueRef val, JSValueRef *exc) return NULL; } +gboolean +js_check_syntax(JSContextRef ctx, const char *script, const char *filename, int lineOffset) +{ + JSValueRef exc = NULL; + JSStringRef jsscript = JSStringCreateWithUTF8CString(script); + gboolean correct = JSCheckScriptSyntax(ctx, jsscript, NULL, lineOffset, &exc); + if (!correct) + { + fprintf(stderr, "DWB SCRIPT EXCEPTION: in file %s\n", filename); + js_print_exception(ctx, exc); + } + JSStringRelease(jsscript); + return correct; +} + |