diff --git a/crates/neon/src/object/mod.rs b/crates/neon/src/object/mod.rs index a4f512854..bd36ab44d 100644 --- a/crates/neon/src/object/mod.rs +++ b/crates/neon/src/object/mod.rs @@ -33,7 +33,7 @@ //! [symbol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol use crate::{ - context::Context, + context::{Cx, Context, internal::ContextInternal}, handle::{Handle, Root}, result::{NeonResult, Throw}, sys::{self, raw}, @@ -161,13 +161,13 @@ impl<'a> PropertyKey for &'a str { /// # Ok(cx.string(s)) /// # } /// ``` -pub struct PropOptions<'a, 'cx: 'a, C: Context<'cx>, O: Object, K: PropertyKey> { - pub(crate) cx: &'a mut C, +pub struct PropOptions<'a, 'cx: 'a, O: Object, K: PropertyKey> { + pub(crate) cx: &'a mut Cx<'cx>, pub(crate) this: Handle<'cx, O>, pub(crate) key: K, } -impl<'a, 'cx: 'a, C: Context<'cx>, O: Object, K: PropertyKey> PropOptions<'a, 'cx, C, O, K> { +impl<'a, 'cx: 'a, O: Object, K: PropertyKey> PropOptions<'a, 'cx, O, K> { /// Gets the property from the object and attempts to convert it to a Rust value. /// Equivalent to calling `R::from_js(cx, obj.get(cx)?)`. /// @@ -191,7 +191,7 @@ impl<'a, 'cx: 'a, C: Context<'cx>, O: Object, K: PropertyKey> PropOptions<'a, 'c /// /// May throw an exception either during accessing the property or downcasting it /// to a function. - pub fn bind(&'a mut self) -> NeonResult> { + pub fn bind(&'a mut self) -> NeonResult> { let callee: Handle = self.this.get(self.cx, self.key)?; let mut bind = callee.bind(self.cx); bind.this(self.this); @@ -202,11 +202,11 @@ impl<'a, 'cx: 'a, C: Context<'cx>, O: Object, K: PropertyKey> PropOptions<'a, 'c /// The trait of all object types. pub trait Object: Value { /// Create a [`PropOptions`] for accessing a property. - fn prop<'a, 'cx: 'a, C: Context<'cx>, K: PropertyKey>( + fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, - cx: &'a mut C, + cx: &'a mut Cx<'cx>, key: K, - ) -> PropOptions<'a, 'cx, C, Self, K> { + ) -> PropOptions<'a, 'cx, Self, K> { let this = Handle::new_internal(unsafe { Self::from_local(cx.env(), self.to_local()) }); PropOptions { cx, this, key } } diff --git a/crates/neon/src/types_impl/function/mod.rs b/crates/neon/src/types_impl/function/mod.rs index 45540b988..8025b3aba 100644 --- a/crates/neon/src/types_impl/function/mod.rs +++ b/crates/neon/src/types_impl/function/mod.rs @@ -3,7 +3,7 @@ use smallvec::smallvec; use crate::{ - context::Context, + context::{Context, Cx}, handle::Handle, object::Object, result::{JsResult, NeonResult}, @@ -31,14 +31,14 @@ pub(crate) mod private; /// # Ok(cx.number(x)) /// # } /// ``` -pub struct BindOptions<'a, 'cx: 'a, C: Context<'cx>> { - pub(crate) cx: &'a mut C, +pub struct BindOptions<'a, 'cx: 'a> { + pub(crate) cx: &'a mut Cx<'cx>, pub(crate) callee: Handle<'cx, JsValue>, pub(crate) this: Option>, pub(crate) args: private::ArgsVec<'cx>, } -impl<'a, 'cx: 'a, C: Context<'cx>> BindOptions<'a, 'cx, C> { +impl<'a, 'cx: 'a> BindOptions<'a, 'cx> { /// Set the value of `this` for the function call. pub fn this(&mut self, this: Handle<'cx, V>) -> &mut Self { self.this = Some(this.upcast()); @@ -62,7 +62,7 @@ impl<'a, 'cx: 'a, C: Context<'cx>> BindOptions<'a, 'cx, C> { pub fn arg_with(&mut self, f: F) -> NeonResult<&mut Self> where R: TryIntoJs<'cx>, - F: FnOnce(&mut C) -> NeonResult, + F: FnOnce(&mut Cx<'cx>) -> NeonResult, { let v = f(self.cx)?.try_into_js(self.cx)?; self.args.push(v.upcast()); @@ -187,7 +187,7 @@ impl<'a> ConstructOptions<'a> { pub trait TryIntoArguments<'cx>: private::TryIntoArgumentsInternal<'cx> {} impl<'cx> private::TryIntoArgumentsInternal<'cx> for () { - fn try_into_args_vec>(self, _cx: &mut C) -> NeonResult> { + fn try_into_args_vec(self, _cx: &mut Cx<'cx>) -> NeonResult> { Ok(smallvec![]) } } @@ -204,7 +204,7 @@ macro_rules! impl_into_arguments { } => { $(#[$attr1])? impl<'cx, $($tprefix: TryIntoJs<'cx> + 'cx, )* $tname1: TryIntoJs<'cx> + 'cx> private::TryIntoArgumentsInternal<'cx> for ($($tprefix, )* $tname1, ) { - fn try_into_args_vec>(self, cx: &mut C) -> NeonResult> { + fn try_into_args_vec(self, cx: &mut Cx<'cx>) -> NeonResult> { let ($($vprefix, )* $vname1, ) = self; Ok(smallvec![ $($vprefix.try_into_js(cx)?.upcast(),)* $vname1.try_into_js(cx)?.upcast() ]) } diff --git a/crates/neon/src/types_impl/function/private.rs b/crates/neon/src/types_impl/function/private.rs index 34d90237f..c0b079ec1 100644 --- a/crates/neon/src/types_impl/function/private.rs +++ b/crates/neon/src/types_impl/function/private.rs @@ -1,12 +1,12 @@ use smallvec::SmallVec; -use crate::{context::Context, handle::Handle, result::NeonResult, types::JsValue}; +use crate::{context::Cx, handle::Handle, result::NeonResult, types::JsValue}; pub type ArgsVec<'a> = SmallVec<[Handle<'a, JsValue>; 8]>; /// This type marks the `TryIntoArguments` trait as sealed. pub trait TryIntoArgumentsInternal<'cx> { - fn try_into_args_vec>(self, cx: &mut C) -> NeonResult>; + fn try_into_args_vec(self, cx: &mut Cx<'cx>) -> NeonResult>; } /// This type marks the `Arguments` trait as sealed. diff --git a/crates/neon/src/types_impl/mod.rs b/crates/neon/src/types_impl/mod.rs index a99376c8a..8f42ce8ac 100644 --- a/crates/neon/src/types_impl/mod.rs +++ b/crates/neon/src/types_impl/mod.rs @@ -24,7 +24,7 @@ use std::{ use smallvec::smallvec; use crate::{ - context::{internal::Env, Context, FunctionContext}, + context::{internal::Env, Context, Cx, FunctionContext}, handle::{ internal::{SuperType, TransparentNoCopyWrapper}, Handle, @@ -1248,7 +1248,7 @@ impl JsFunction { } impl JsFunction { - pub fn bind<'a, 'cx: 'a, C: Context<'cx>>(&self, cx: &'a mut C) -> BindOptions<'a, 'cx, C> { + pub fn bind<'a, 'cx: 'a>(&self, cx: &'a mut Cx<'cx>) -> BindOptions<'a, 'cx> { BindOptions { cx, callee: Handle::new_internal(JsValue(self.to_local())), diff --git a/test/napi/lib/bigint.js b/test/napi/lib/bigint.js index ba3c96d0d..a7e9e02e6 100644 --- a/test/napi/lib/bigint.js +++ b/test/napi/lib/bigint.js @@ -1,6 +1,9 @@ const addon = require(".."); describe("JsBigInt", () => { + console.error(`DEBUGGING: addon = ${JSON.stringify(addon)}`); + console.error(`DEBUGGING: addon.bigint_suit = ${addon.bigint_suite}`); + const suite = addon.bigint_suite(); for (const [k, v] of Object.entries(suite)) {