2019-12-19 19:15:52 -05:00
|
|
|
use crate::isolate::Isolate;
|
2019-12-30 09:28:39 -05:00
|
|
|
use crate::Boolean;
|
2020-06-03 01:38:34 -04:00
|
|
|
use crate::HandleScope;
|
2019-12-05 17:03:18 -05:00
|
|
|
use crate::Local;
|
2019-12-30 09:28:39 -05:00
|
|
|
use crate::Primitive;
|
2019-12-05 17:03:18 -05:00
|
|
|
|
|
|
|
extern "C" {
|
2020-04-13 08:43:56 -04:00
|
|
|
fn v8__Null(isolate: *mut Isolate) -> *const Primitive;
|
|
|
|
fn v8__Undefined(isolate: *mut Isolate) -> *const Primitive;
|
2019-12-05 17:03:18 -05:00
|
|
|
|
2020-04-13 08:43:56 -04:00
|
|
|
fn v8__Boolean__New(isolate: *mut Isolate, value: bool) -> *const Boolean;
|
2019-12-05 17:03:18 -05:00
|
|
|
}
|
|
|
|
|
2022-09-20 22:45:33 -04:00
|
|
|
#[inline(always)]
|
2020-06-03 01:38:34 -04:00
|
|
|
pub fn null<'s>(scope: &mut HandleScope<'s, ()>) -> Local<'s, Primitive> {
|
|
|
|
unsafe { scope.cast_local(|sd| v8__Null(sd.get_isolate_ptr())) }.unwrap()
|
2019-12-05 17:03:18 -05:00
|
|
|
}
|
|
|
|
|
2022-09-20 22:45:33 -04:00
|
|
|
#[inline(always)]
|
2020-06-03 01:38:34 -04:00
|
|
|
pub fn undefined<'s>(scope: &mut HandleScope<'s, ()>) -> Local<'s, Primitive> {
|
|
|
|
unsafe { scope.cast_local(|sd| v8__Undefined(sd.get_isolate_ptr())) }.unwrap()
|
2019-12-05 17:03:18 -05:00
|
|
|
}
|
|
|
|
|
2020-01-04 18:08:27 -05:00
|
|
|
impl Boolean {
|
2022-09-20 22:45:33 -04:00
|
|
|
#[inline(always)]
|
2020-06-03 01:38:34 -04:00
|
|
|
pub fn new<'s>(
|
|
|
|
scope: &mut HandleScope<'s, ()>,
|
2020-01-04 18:08:27 -05:00
|
|
|
value: bool,
|
2020-06-03 01:38:34 -04:00
|
|
|
) -> Local<'s, Boolean> {
|
2020-05-31 09:00:23 -04:00
|
|
|
unsafe {
|
2020-06-03 01:38:34 -04:00
|
|
|
scope.cast_local(|sd| v8__Boolean__New(sd.get_isolate_ptr(), value))
|
2020-05-31 09:00:23 -04:00
|
|
|
}
|
|
|
|
.unwrap()
|
2020-01-04 18:08:27 -05:00
|
|
|
}
|
2019-12-05 17:03:18 -05:00
|
|
|
}
|