Skip to content

Commit

Permalink
Move bigint impl blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvalencik committed Feb 17, 2023
1 parent 6ea9a68 commit bd4fbd9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 40 deletions.
41 changes: 35 additions & 6 deletions crates/neon/src/types_impl/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
use std::{error, fmt, mem::MaybeUninit};

use crate::prelude::NeonResult;
use crate::{
context::Context,
handle::Handle,
result::ResultExt,
sys::{self},
types::JsBigInt,
context::{internal::Env, Context},
handle::{internal::TransparentNoCopyWrapper, Handle, Managed},
result::{NeonResult, ResultExt},
sys::{self, raw},
types::{private, JsBigInt, Value},
};

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -417,3 +416,33 @@ impl JsBigInt {
self.read_digits_le(cx, &mut []).1
}
}

impl Value for JsBigInt {}

unsafe impl TransparentNoCopyWrapper for JsBigInt {
type Inner = raw::Local;

fn into_inner(self) -> Self::Inner {
self.0
}
}

impl Managed for JsBigInt {
fn to_raw(&self) -> raw::Local {
self.0
}

fn from_raw(_: Env, h: raw::Local) -> Self {
Self(h)
}
}

impl private::ValueInternal for JsBigInt {
fn name() -> String {
"BigInt".to_string()
}

fn is_typeof<Other: Value>(env: Env, other: &Other) -> bool {
unsafe { sys::tag::is_bigint(env.to_raw(), other.to_raw()) }
}
}
34 changes: 0 additions & 34 deletions crates/neon/src/types_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,37 +1281,3 @@ impl<T: Object> private::ValueInternal for JsFunction<T> {
/// }
/// ```
pub struct JsBigInt(raw::Local);

#[cfg(feature = "napi-6")]
impl Value for JsBigInt {}

#[cfg(feature = "napi-6")]
unsafe impl TransparentNoCopyWrapper for JsBigInt {
type Inner = raw::Local;

fn into_inner(self) -> Self::Inner {
self.0
}
}

#[cfg(feature = "napi-6")]
impl Managed for JsBigInt {
fn to_raw(&self) -> raw::Local {
self.0
}

fn from_raw(_: Env, h: raw::Local) -> Self {
Self(h)
}
}

#[cfg(feature = "napi-6")]
impl private::ValueInternal for JsBigInt {
fn name() -> String {
"BigInt".to_string()
}

fn is_typeof<Other: Value>(env: Env, other: &Other) -> bool {
unsafe { sys::tag::is_bigint(env.to_raw(), other.to_raw()) }
}
}

0 comments on commit bd4fbd9

Please sign in to comment.