From 9742a2b41d374b4eaea44c1c2d715bf704d752af Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 5 Feb 2023 19:14:16 +0100 Subject: quickjs: make JSValue distinct on 32-bit --- src/bindings/quickjs.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/bindings') 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 -- cgit