diff options
author | bptato <nincsnevem662@gmail.com> | 2023-02-05 19:14:16 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-02-05 19:14:16 +0100 |
commit | 9742a2b41d374b4eaea44c1c2d715bf704d752af (patch) | |
tree | 9868c388e45dc25b89e360515df3eb8a9a9ab5fe /src/bindings | |
parent | 21178cc60e1d4ba3a6780c5691b9cfb5e7908aa8 (diff) | |
download | chawan-9742a2b41d374b4eaea44c1c2d715bf704d752af.tar.gz |
quickjs: make JSValue distinct on 32-bit
Diffstat (limited to 'src/bindings')
-rw-r--r-- | src/bindings/quickjs.nim | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bindings/quickjs.nim b/src/bindings/quickjs.nim index 2d37a789..648abfb2 100644 --- a/src/bindings/quickjs.nim +++ b/src/bindings/quickjs.nim @@ -47,10 +47,10 @@ const ## all tags with a reference count are negative when sizeof(int) < sizeof(int64): {.passC: "-DJS_NAN_BOXING".} type - JSValue* {.importc, header: qjsheader.} = uint64 + JSValue* {.importc, header: qjsheader.} = distinct uint64 template JS_VALUE_GET_TAG*(v: untyped): int32 = - cast[int32](v shr 32) + cast[int32](cast[uint64](v) shr 32) template JS_VALUE_GET_PTR*(v: untyped): pointer = cast[pointer](v) @@ -60,6 +60,8 @@ when sizeof(int) < sizeof(int64): template JS_MKPTR*(t, p: untyped): JSValue = JSValue((cast[uint64](t) shl 32) or cast[uint](p)) + + proc `==`*(a, b: JSValue): bool {.borrow.} else: type JSValueUnion* {.importc, header: qjsheader, union.} = object |