From b69d0cd7e7bbde418c4bbb6d50f6c4270d1edf0f Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 24 Jan 2024 12:54:36 +0100 Subject: js: define toStringTag properly --- src/js/tojs.nim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/js/tojs.nim') diff --git a/src/js/tojs.nim b/src/js/tojs.nim index 2936ba28..c79d1bf2 100644 --- a/src/js/tojs.nim +++ b/src/js/tojs.nim @@ -105,6 +105,15 @@ makeToJSP(Result) makeToJSP(JSValue) makeToJSP(JSDict) +proc defineProperty(ctx: JSContext, this: JSValue, name: JSAtom, + prop: JSValue, flags = cint(0)) = + if JS_DefinePropertyValue(ctx, this, name, prop, flags) <= 0: + raise newException(Defect, "Failed to define property string") + +proc definePropertyC*(ctx: JSContext, this: JSValue, name: JSAtom, + prop: JSValue) = + ctx.defineProperty(this, name, prop, JS_PROP_CONFIGURABLE) + proc defineProperty(ctx: JSContext, this: JSValue, name: string, prop: JSValue, flags = cint(0)) = if JS_DefinePropertyValueStr(ctx, this, cstring(name), prop, flags) <= 0: -- cgit 1.4.1-2-gfad0