diff options
author | bptato <nincsnevem662@gmail.com> | 2023-12-09 20:45:59 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-09 20:46:52 +0100 |
commit | 4ee1a937fad792654277a1eedd35bd0c4f8389c6 (patch) | |
tree | 902128394320b4c666d5bac73df64aa89092f5d6 /src/js | |
parent | 4aa3e24199f0aac97d5541adcbf1ae137f7b64f0 (diff) | |
download | chawan-4ee1a937fad792654277a1eedd35bd0c4f8389c6.tar.gz |
pager: add marks
Default is vi-style, but w3m-style marks work as well; see bonus/w3m.toml.
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/tojs.nim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/js/tojs.nim b/src/js/tojs.nim index 37ad6dbb..60e77d77 100644 --- a/src/js/tojs.nim +++ b/src/js/tojs.nim @@ -28,6 +28,7 @@ proc toJS*[U, V](ctx: JSContext, t: Table[U, V]): JSValue proc toJS*(ctx: JSContext, opt: Option): JSValue proc toJS*[T, E](ctx: JSContext, opt: Result[T, E]): JSValue proc toJS*(ctx: JSContext, s: seq): JSValue +proc toJS*(ctx: JSContext, t: tuple): JSValue proc toJS*(ctx: JSContext, e: enum): JSValue proc toJS*(ctx: JSContext, j: JSValue): JSValue proc toJS*[T](ctx: JSContext, promise: Promise[T]): JSValue @@ -164,6 +165,20 @@ proc toJS(ctx: JSContext, s: seq): JSValue = return JS_EXCEPTION return a +proc toJS(ctx: JSContext, t: tuple): JSValue = + let a = JS_NewArray(ctx) + if not JS_IsException(a): + var i = 0 + for f in t.fields: + let j = toJS(ctx, f) + if JS_IsException(j): + return j + if JS_DefinePropertyValueInt64(ctx, a, int64(i), j, + JS_PROP_C_W_E or JS_PROP_THROW) < 0: + return JS_EXCEPTION + inc i + return a + proc toJSP0(ctx: JSContext, p, tp: pointer, ctor: JSValue, needsref: var bool): JSValue = JS_GetRuntime(ctx).getOpaque().plist.withValue(p, obj): |