-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Improve JSClass
and add JSClassBuilder
#23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Improve JSClass
and add JSClassBuilder
#23
Conversation
JSClass::new
and JSClass::instantiate
JSClass
and add JSClassBuilder
CI has been broken by |
It was a bug in the CI script. I've pushed to |
This patch is twofold. First off, it implements `JSClass::new`, along with the `constructor_callback` procedural macro for a better developer experience. Second, it implements `JSClass::instantiate` to instantiate the object (note that it doesn't call the constructor, `JSObject::call_as_constructor` must be used).
This patch improves the tests about `new_function` can checking a function can run from within a script too.
1608188
to
4ac4bb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a number of questions while reading these changes and then went back over them and decided against them ... I'm inclined to merge this now and maybe then lay out what some of the next steps might be to doing a release with it.
I'd like to see some of the APIs get more ergonomic and less boilerplate ...
I guess if you have the time, rebasing the clippy fix back into the originating commit (ea94cab right now) would be nice, so that the whole history is cleanly building. |
This patch revamps `JSClass` by introducing `JSClassBuilder`. A `JSClass` is kind of rich, and providing a clean API is difficult, hence the `JSClassBuilder` which brings a nice API for building any kind of `JSClass`. For now, only the classname and the constructor callback can be set, but this pattern is easily extendable. This patch also adds documentation and improves the tests a little bit.
This patch implements `Display` and `Error` for `JSException`.
5ead2c1
to
9db000e
Compare
Don't want to push you. If you want to improve this, please share your ideas. It can be done as a next PR though. |
This PR should be reviewed commit-by-commit.
Basically:
#[constructor_callback]
JSClassBuilder
JSClass::builder
andJSClass::new_object
.So far,
JSClassBuilder
only allows to set the class name and the class constructor, but this pattern is easily extendable to cover all features provided bysys::JSClassDefinition
.