2019-12-06 09:36:34 -05:00
|
|
|
use crate::support;
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
fn v8__Value__IsUndefined(this: &Value) -> bool;
|
|
|
|
fn v8__Value__IsNull(this: &Value) -> bool;
|
|
|
|
fn v8__Value__IsNullOrUndefined(this: &Value) -> bool;
|
|
|
|
}
|
|
|
|
|
2019-12-19 14:14:19 +01:00
|
|
|
/// The superclass of all JavaScript values and objects.
|
2019-12-06 09:36:34 -05:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct Value(support::Opaque);
|
|
|
|
|
|
|
|
impl Value {
|
|
|
|
/// Returns true if this value is the undefined value. See ECMA-262 4.3.10.
|
|
|
|
pub fn is_undefined(&self) -> bool {
|
|
|
|
unsafe { v8__Value__IsUndefined(self) }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns true if this value is the null value. See ECMA-262 4.3.11.
|
|
|
|
pub fn is_null(&self) -> bool {
|
|
|
|
unsafe { v8__Value__IsNull(self) }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns true if this value is either the null or the undefined value.
|
|
|
|
/// See ECMA-262 4.3.11. and 4.3.12
|
|
|
|
pub fn is_null_or_undefined(&self) -> bool {
|
|
|
|
unsafe { v8__Value__IsNullOrUndefined(self) }
|
|
|
|
}
|
|
|
|
}
|