diff options
author | bptato <nincsnevem662@gmail.com> | 2023-10-25 14:03:14 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-10-25 14:04:24 +0200 |
commit | aa47707bec6caa024ae1ce8e17461409a3456964 (patch) | |
tree | cbeacb7a686e6e1ff46ee66ddd55a18cbb424aa5 /src/js | |
parent | 3f0a183d48a44cbbe642842fb60b69cca9e83390 (diff) | |
download | chawan-aa47707bec6caa024ae1ce8e17461409a3456964.tar.gz |
js: define global properties as CONFIGURABLE | WRITABLE
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/javascript.nim | 4 | ||||
-rw-r--r-- | src/js/tojs.nim | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim index 12c504a2..fefc3ed8 100644 --- a/src/js/javascript.nim +++ b/src/js/javascript.nim @@ -274,10 +274,10 @@ func newJSClass*(ctx: JSContext, cdef: JSClassDefConst, tname: string, if not nointerface: if JS_IsNull(namespace): let global = JS_GetGlobalObject(ctx) - ctx.defineProperty(global, $cdef.class_name, jctor) + ctx.definePropertyCW(global, $cdef.class_name, jctor) JS_FreeValue(ctx, global) else: - ctx.defineProperty(namespace, $cdef.class_name, jctor) + ctx.definePropertyCW(namespace, $cdef.class_name, jctor) type FuncParam = tuple[name: string, t: NimNode, val: Option[NimNode], generic: Option[NimNode]] diff --git a/src/js/tojs.nim b/src/js/tojs.nim index bf2bfe61..6d953e44 100644 --- a/src/js/tojs.nim +++ b/src/js/tojs.nim @@ -76,6 +76,11 @@ proc definePropertyE*[T](ctx: JSContext, this: JSValue, name: string, prop: T) = defineProperty(ctx, this, name, prop, JS_PROP_ENUMERABLE) +proc definePropertyCW*[T](ctx: JSContext, this: JSValue, name: string, + prop: T) = + defineProperty(ctx, this, name, prop, JS_PROP_CONFIGURABLE or + JS_PROP_WRITABLE) + proc definePropertyCWE*[T](ctx: JSContext, this: JSValue, name: string, prop: T) = defineProperty(ctx, this, name, prop, JS_PROP_C_W_E) |