Open bptato opened 2 hours ago
Hey there!
Many APIs return 0 for success and -1 for error. I guess we could align it to that. JS_BOOL is indeed probably not the right return type here.
I took a quick look and JS_CLASS_OBJECT does not seem to use the union. That said, what is it that you are using the opaque for? If it's for hiding stuff perhaps a Symbol would do? Or the context / runtime opaque? Since there is only one global...
Many APIs return 0 for success and -1 for error. I guess we could align it to that. JS_BOOL is indeed probably not the right return type here.
Sounds good :)
I took a quick look and JS_CLASS_OBJECT does not seem to use the union. That said, what is it that you are using the opaque for? If it's for hiding stuff perhaps a Symbol would do? Or the context / runtime opaque? Since there is only one global...
It's for object conversion:
I could check if val
is the global object and then override p
with some pointer from the context opaque, but I'd prefer not to add special casing logic if possible. Less code = prettier code :P
Attempting to upgrade to the new version (?), I've noticed some oddities with SetOpaque:
JS_FALSE
(0) on success andJS_TRUE
(1) on failure, which I find somewhat counter-intuitive. Maybe it's not too late to change it?JS_CLASS_OBJECT
which is <JS_CLASS_INIT_COUNT
.The latter one is a bit problematic, because my type conversion functions expect the global object to have an opaque. I would change its class ID if I could, but at least when I was writing my wrapper for qjs I couldn't, and I don't see any changes in -ng that would enable this.
I don't know what the preferred fix is for this one; this patch works for me: