0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-02 17:01:55 -05:00
denoland-rusty-v8/src/primitives.rs

36 lines
932 B
Rust
Raw Normal View History

use crate::isolate::Isolate;
2019-12-30 09:28:39 -05:00
use crate::Boolean;
use crate::HandleScope;
use crate::Local;
2019-12-30 09:28:39 -05:00
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;
}
2022-09-20 22:45:33 -04:00
#[inline(always)]
pub fn null<'s>(scope: &mut HandleScope<'s, ()>) -> Local<'s, Primitive> {
unsafe { scope.cast_local(|sd| v8__Null(sd.get_isolate_ptr())) }.unwrap()
}
2022-09-20 22:45:33 -04:00
#[inline(always)]
pub fn undefined<'s>(scope: &mut HandleScope<'s, ()>) -> Local<'s, Primitive> {
unsafe { scope.cast_local(|sd| v8__Undefined(sd.get_isolate_ptr())) }.unwrap()
}
2020-01-04 18:08:27 -05:00
impl Boolean {
2022-09-20 22:45:33 -04:00
#[inline(always)]
pub fn new<'s>(
scope: &mut HandleScope<'s, ()>,
2020-01-04 18:08:27 -05:00
value: bool,
) -> Local<'s, Boolean> {
unsafe {
scope.cast_local(|sd| v8__Boolean__New(sd.get_isolate_ptr(), value))
}
.unwrap()
2020-01-04 18:08:27 -05:00
}
}