2019-12-19 19:15:52 -05:00
|
|
|
use crate::isolate::Isolate;
|
2019-12-30 09:28:39 -05:00
|
|
|
use crate::Boolean;
|
2019-12-05 17:03:18 -05:00
|
|
|
use crate::Local;
|
2019-12-30 09:28:39 -05:00
|
|
|
use crate::Primitive;
|
2019-12-24 18:31:36 -05:00
|
|
|
use crate::ToLocal;
|
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
|
|
|
}
|
|
|
|
|
2020-01-17 02:34:48 -05:00
|
|
|
pub fn null<'sc>(scope: &mut impl ToLocal<'sc>) -> Local<'sc, Primitive> {
|
2019-12-24 18:31:36 -05:00
|
|
|
let ptr = unsafe { v8__Null(scope.isolate()) };
|
|
|
|
unsafe { scope.to_local(ptr) }.unwrap()
|
2019-12-05 17:03:18 -05:00
|
|
|
}
|
|
|
|
|
2020-01-17 02:34:48 -05:00
|
|
|
pub fn undefined<'sc>(scope: &mut impl ToLocal<'sc>) -> Local<'sc, Primitive> {
|
2019-12-24 18:31:36 -05:00
|
|
|
let ptr = unsafe { v8__Undefined(scope.isolate()) };
|
|
|
|
unsafe { scope.to_local(ptr) }.unwrap()
|
2019-12-05 17:03:18 -05:00
|
|
|
}
|
|
|
|
|
2020-01-04 18:08:27 -05:00
|
|
|
impl Boolean {
|
|
|
|
pub fn new<'sc>(
|
|
|
|
scope: &mut impl ToLocal<'sc>,
|
|
|
|
value: bool,
|
|
|
|
) -> Local<'sc, Boolean> {
|
|
|
|
let ptr = unsafe { v8__Boolean__New(scope.isolate(), value) };
|
|
|
|
unsafe { scope.to_local(ptr) }.unwrap()
|
|
|
|
}
|
2019-12-05 17:03:18 -05:00
|
|
|
}
|