1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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))
    }
  }
}