Skip to content
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

Add v8::Value::InstanceOf bindings #879

Merged
merged 11 commits into from
Feb 11, 2022

Conversation

littledivy
Copy link
Member

No description provided.

src/binding.cc Outdated Show resolved Hide resolved
@piscisaureus
Copy link
Member

I am not in favor of implementing deref_mut for Local handles.

@littledivy littledivy marked this pull request as ready for review January 23, 2022 10:59
src/handle.rs Outdated
Comment on lines 115 to 119
impl<'s, T> DerefMut for Local<'s, T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { self.0.as_mut() }
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per @piscisaureus's comment we should remove this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instance_of requires for T to be mutable in v8::Local<T>, hence the deref_mut implementation. I'm not sure how you can do instance_of on a local handle without this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason the InstanceOf function is not marked as const in the c++ api?
Seems counter-intuitive, could this be a mistake in the v8 c++ api?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piscisaureus please advise

@aapoalas
Copy link
Contributor

aapoalas commented Feb 9, 2022

I may well be wrong, but it seems like this binding will be necessary for implementing magic (de)serialiser for FFI-related custom class wrapping ArrayBuffers for passing to native libraries.

@piscisaureus
Copy link
Member

Discussed offline with @littledivy.

  • We will remove the DerefMut impl for Local handles.
  • Method signature will be:
    fn instance_of<'s>(&self, scope: &mut HandleScope<'s>, object: Local<Object>) -> Option<bool>;

src/handle.rs Outdated Show resolved Hide resolved
src/binding.cc Outdated Show resolved Hide resolved
Copy link
Member

@piscisaureus piscisaureus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@littledivy littledivy merged commit 0f34359 into denoland:main Feb 11, 2022
@littledivy littledivy deleted the instance_of_value branch February 11, 2022 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants