diff options
author | bptato <nincsnevem662@gmail.com> | 2023-06-19 18:13:10 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-06-19 18:15:09 +0200 |
commit | 17097052794aef56bbc55327d3e6c84ae1c67378 (patch) | |
tree | 13b81e1105c07c69d7a8d1e7367a698f41663a01 /src/bindings | |
parent | e372bdaa0344b23c91aefa4da44c578fbf8f49e2 (diff) | |
download | chawan-17097052794aef56bbc55327d3e6c84ae1c67378.tar.gz |
Rework JS exception system
Now we use Result for passing exceptions to JS. As a result, we can finally get rid of the .jserr pragma.
Diffstat (limited to 'src/bindings')
-rw-r--r-- | src/bindings/quickjs.nim | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bindings/quickjs.nim b/src/bindings/quickjs.nim index 306a3b3d..9a76a484 100644 --- a/src/bindings/quickjs.nim +++ b/src/bindings/quickjs.nim @@ -212,12 +212,20 @@ type is_enumerable*: JS_BOOL atom*: JSAtom + JSClassEnum* {.size: sizeof(uint32).} = enum + JS_CLASS_OBJECT = 1 + JS_CLASS_ARRAY + JS_CLASS_ERROR + converter toBool*(js: JS_BOOl): bool {.inline.} = cast[cint](js) != 0 converter toJSBool*(b: bool): JS_BOOL {.inline.} = cast[JS_BOOL](cint(b)) +converter toJSClassID*(e: JSClassEnum): JSClassID {.inline.} = + JSClassID(e) + const JS_NULL* = JS_MKVAL(JS_TAG_NULL, 0) JS_UNDEFINED* = JS_MKVAL(JS_TAG_UNDEFINED, 0) @@ -338,6 +346,7 @@ proc JS_SetClassProto*(ctx: JSContext, class_id: JSClassID, obj: JSValue) proc JS_GetClassProto*(ctx: JSContext, class_id: JSClassID): JSValue proc JS_SetConstructor*(ctx: JSContext, func_obj: JSValue, proto: JSValue) proc JS_SetPrototype*(ctx: JSContext, obj: JSValue, proto_val: JSValue): cint +proc JS_GetPrototype*(ctx: JSContext, val: JSValue): JSValue proc JS_NewBool*(ctx: JSContext, val: JS_BOOL): JSValue proc JS_NewInt32*(ctx: JSContext, val: int32): JSValue @@ -374,6 +383,8 @@ proc JS_GetOwnPropertyNames*(ctx: JSContext, ptab: ptr ptr JSPropertyEnum, plen: proc JS_GetOwnProperty*(ctx: JSContext, desc: ptr JSPropertyDescriptor, obj: JSValue, prop: JSAtom): cint proc JS_Call*(ctx: JSContext, func_obj, this_obj: JSValue, argc: cint, argv: ptr JSValue): JSValue +proc JS_CallConstructor*(ctx: JSContext, func_obj: JSValue, argc: cint, + argv: ptr JSValue): JSValue proc JS_DefineProperty*(ctx: JSContext, this_obj: JSValue, prop: JSAtom, val: JSValue, getter: JSValue, setter: JSValue, flags: cint): cint proc JS_DefinePropertyValue*(ctx: JSContext, this_obj: JSValue, prop: JSAtom, val: JSValue, flags: cint): cint |