Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastrac committed Apr 22, 2024
1 parent 80ae358 commit 9f98a44
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/fast_api.rs
@@ -1,11 +1,8 @@
use crate::support::Opaque;
use crate::Local;
use crate::UniqueRef;
use crate::Value;
use std::{
ffi::c_void,
mem::align_of,
ptr::{self, NonNull},
};
use std::{ffi::c_void, mem::align_of, ptr};

extern "C" {
fn v8__CTypeInfo__New(ty: CType) -> *mut CTypeInfo;
Expand Down Expand Up @@ -38,8 +35,8 @@ impl CFunctionInfo {
args_len: usize,
return_type: *const CTypeInfo,
repr: Int64Representation,
) -> NonNull<CFunctionInfo> {
NonNull::new_unchecked(v8__CFunctionInfo__New(
) -> UniqueRef<CFunctionInfo> {
UniqueRef::from_raw(v8__CFunctionInfo__New(
return_type,
args_len,
args,
Expand All @@ -60,19 +57,19 @@ pub struct CTypeInfo(Opaque);

impl CTypeInfo {
#[inline(always)]
pub fn new(ty: CType) -> NonNull<CTypeInfo> {
unsafe { NonNull::new_unchecked(v8__CTypeInfo__New(ty)) }
pub fn new(ty: CType) -> UniqueRef<CTypeInfo> {
unsafe { UniqueRef::from_raw(v8__CTypeInfo__New(ty)) }
}

pub fn new_from_slice(types: &[Type]) -> NonNull<CTypeInfo> {
pub fn new_from_slice(types: &[Type]) -> UniqueRef<CTypeInfo> {
let mut structs = vec![];

for type_ in types.iter() {
structs.push(type_.into())
}

unsafe {
NonNull::new_unchecked(v8__CTypeInfo__New__From__Slice(
UniqueRef::from_raw(v8__CTypeInfo__New__From__Slice(
structs.len(),
structs.as_ptr(),
))
Expand Down

0 comments on commit 9f98a44

Please sign in to comment.