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

feat(core): Implement v8::XXX args and return #12

Merged
merged 6 commits into from
Jul 4, 2023

Conversation

mmastrac
Copy link
Contributor

@mmastrac mmastrac commented Jul 3, 2023

op2 support for v8::Value and related types. Functions may take arguments of the form &v8::String (or &mut v8::String), v8::Local<v8::String>, or an Option<...> of any of these. Under the hood, the op system will check the type of the argument and automatically throw a type error if it does not match.

Implements:

  • v8::Localv8::XXX for arguments (including automatic casting so v8::String will work)
  • v8::Localv8::XXX for return types
  • Option<v8::Local<...>> for arguments and returns
  • &v8::XXX and Option<&v8:XXX> for arguments (ie: pass a &mut v8::String without a handle)
  • HandleScope

Additional changes:

  • Fixes clippy attributes on ops
  • Refactoring of signature parser to be slightly less tied to our final arg/return types
  • Ensures that lifetimes are properly added to call

@CLAassistant
Copy link

CLAassistant commented Jul 3, 2023

CLA assistant check
All committers have signed the CLA.

@@ -631,4 +637,100 @@ mod tests {
// We don't actually test this one -- we just want it to compile
#[op2(core, fast)]
pub fn op_test_generics<T: Clone>() {}

/// Tests v8 types without a handle scope
#[allow(clippy::needless_lifetimes)]
Copy link
Member

Choose a reason for hiding this comment

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

Can this be handled by the op itself so we don't need to spam these ignores everywhere in our code?

Copy link
Contributor Author

@mmastrac mmastrac Jul 4, 2023

Choose a reason for hiding this comment

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

This is only used here in the tests because the lifetime is useless and I wanted some tests that included it. It works fine without it, but then we're not exercising the lifetime code paths.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM

@mmastrac mmastrac merged commit 69b119a into denoland:main Jul 4, 2023
3 checks passed
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.

3 participants