0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-27 01:29:19 -05:00
denoland-rusty-v8/src/external.rs

36 lines
767 B
Rust
Raw Normal View History

2021-02-13 07:31:18 -05:00
// Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.
use std::ffi::c_void;
use crate::External;
use crate::HandleScope;
use crate::Isolate;
use crate::Local;
extern "C" {
fn v8__External__New(
isolate: *mut Isolate,
value: *mut c_void,
) -> *const External;
fn v8__External__Value(this: *const External) -> *mut c_void;
}
impl External {
2022-09-20 22:45:33 -04:00
#[inline(always)]
2022-12-20 18:11:23 -05:00
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn new<'s>(
scope: &mut HandleScope<'s, ()>,
value: *mut c_void,
) -> Local<'s, Self> {
unsafe {
scope.cast_local(|sd| v8__External__New(sd.get_isolate_ptr(), value))
}
.unwrap()
}
2022-09-20 22:45:33 -04:00
#[inline(always)]
pub fn value(&self) -> *mut c_void {
unsafe { v8__External__Value(self) }
}
}