0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-01 16:51:32 -05:00
denoland-rusty-v8/src/primitives.rs
2022-10-06 20:44:16 +02:00

39 lines
899 B
Rust

use crate::isolate::Isolate;
use crate::Boolean;
use crate::Local;
use crate::Primitive;
extern "C" {
fn v8__Null(isolate: *mut Isolate) -> *const Primitive;
fn v8__Undefined(isolate: *mut Isolate) -> *const Primitive;
fn v8__Boolean__New(isolate: *mut Isolate, value: bool) -> *const Boolean;
}
#[inline(always)]
pub fn null<'a, R>(scope: &mut R) -> Local<'a, Primitive>
where
R: AsMut<Isolate>,
{
unsafe { Local::from_raw_unchecked(v8__Null(scope.as_mut())) }
}
#[inline(always)]
pub fn undefined<'a, R>(scope: &mut R) -> Local<'a, Primitive>
where
R: AsMut<Isolate>,
{
unsafe { Local::from_raw_unchecked(v8__Undefined(scope.as_mut())) }
}
impl Boolean {
#[inline(always)]
pub fn new<'a, R>(scope: &mut R, value: bool) -> Local<'a, Boolean>
where
R: AsMut<Isolate>,
{
unsafe {
Local::from_raw_unchecked(v8__Boolean__New(scope.as_mut(), value))
}
}
}