-
Notifications
You must be signed in to change notification settings - Fork 110
Exotic methods support #567
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
base: master
Are you sure you want to change the base?
Conversation
We already have this
richarddd
left a comment
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.
Minor suggestions
|
|
||
| let crate_name = format_ident!("{}", crate_ident()?); | ||
| let class_name = get_class_name(&self_ty); | ||
| let module_name = format_ident!("__impl_exotic_{}__", class_name); |
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.
Should we consolidate this with the one in class to avoid duplication?
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 will rework this I am not satisfied. I think I can use the same trick we are using for the constructor with the double ref specialization.
| match crate::util::catch_unwind(f) { | ||
| Ok(x) => x, | ||
| Err(e) => unsafe { | ||
| self.get_opaque().set_panic(e); | ||
| qjs::JS_Throw(self.as_ptr(), qjs::JS_MKVAL(qjs::JS_TAG_EXCEPTION, 0)); | ||
| -1 | ||
| }, | ||
| } |
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.
This is exact duplicate of handle_panic. Can we use an inner method?
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 can check, dont remember why it was done like that.
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.
@Sytten any status on this?
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.
Kinda of in a crunch right now, I need to refactor the macro and the bool into an enum. If you want to help be my guess
DelSkayn
left a comment
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.
Two suggestions.
| flags: qjs::c_int, | ||
| ) -> qjs::JSValue; | ||
|
|
||
| pub(crate) type GetPropertyFunc = for<'a> unsafe fn( |
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.
The for<'a> lifetime bound her seems unused and thus unnecessary.
| const CALLABLE: bool = false; | ||
|
|
||
| /// Is this class exotic (e.g. will exotic_* methods be called with it) | ||
| const EXOTIC: bool = false; | ||
|
|
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.
Since a class can't be both exotic and callable, it is probably better to encode that in the type system, i.e. change these bools to something like const KIND: ClassKind = ClassKind::Plain where ClassKind is something like:
enum ClassKind{
Plain,
Callable,
Exotic,
}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.
Right that is a good idea. Though I dont like the whole system of a single class ID for all rust classes.
Finishes #497