about summary refs log tree commit diff stats
path: root/src/js
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-05-08 18:59:37 +0200
committerbptato <nincsnevem662@gmail.com>2024-05-08 18:59:37 +0200
commitcaf1acc77ac74cf1e47c1a450922b9db2da1bdd8 (patch)
tree81617a8a2fdf04a73871c1e693aeb96c2ce2f137 /src/js
parent1aca7ec77c965c8428361472bd7cb0d522238813 (diff)
downloadchawan-caf1acc77ac74cf1e47c1a450922b9db2da1bdd8.tar.gz
js: clean up eval wrappers
Diffstat (limited to 'src/js')
-rw-r--r--src/js/javascript.nim10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim
index 58b80c6f..7bbf2419 100644
--- a/src/js/javascript.nim
+++ b/src/js/javascript.nim
@@ -1687,17 +1687,15 @@ proc getMemoryUsage*(rt: JSRuntime): string =
       $m.binary_object_size
   return s
 
-proc eval*(ctx: JSContext; s: string; file: string; eval_flags: int): JSValue =
+proc eval*(ctx: JSContext; s, file: string; eval_flags: int): JSValue =
   return JS_Eval(ctx, cstring(s), csize_t(s.len), cstring(file),
     cint(eval_flags))
 
-proc compileScript*(ctx: JSContext; s: string; file: cstring): JSValue =
-  return JS_Eval(ctx, cstring(s), csize_t(s.len), file,
-    cint(JS_EVAL_FLAG_COMPILE_ONLY))
+proc compileScript*(ctx: JSContext; s, file: string): JSValue =
+  return ctx.eval(s, file, JS_EVAL_FLAG_COMPILE_ONLY)
 
 proc compileModule*(ctx: JSContext; s: string; file: cstring): JSValue =
-  return JS_Eval(ctx, cstring(s), csize_t(s.len), file,
-    cint(JS_EVAL_TYPE_MODULE or JS_EVAL_FLAG_COMPILE_ONLY))
+  return ctx.eval(s, file, JS_EVAL_TYPE_MODULE or JS_EVAL_FLAG_COMPILE_ONLY)
 
 proc evalFunction*(ctx: JSContext; val: JSValue): JSValue =
   return JS_EvalFunction(ctx, val)