#[allow(non_camel_case_types)]
pub type Value = usize;
pub type Uintnat = usize;
#[allow(non_camel_case_types)]
pub type Size = Uintnat;
#[allow(non_camel_case_types)]
pub type Tag = u8; #[allow(non_camel_case_types)]
pub type Color = Uintnat;
#[allow(non_camel_case_types)]
pub type Mark = Uintnat;
pub struct Header {}
#[cfg(target_endian = "big")]
#[macro_export]
macro_rules! tag_val {
($x:expr) => (*(($x as *const u8).offset(-1)));
($x:ident) => (*(($x as *const u8).offset(-1)));
}
#[cfg(target_endian = "little")]
#[macro_export]
macro_rules! tag_val {
($x:expr) => (*(($x as *const u8).offset(-(::std::mem::size_of::<Value>() as isize))));
($x:ident) => (*(($x as *const u8).offset(-(::std::mem::size_of::<Value>() as isize))));
}
#[macro_export]
macro_rules! val_long {
($x:expr) => ((($x as usize) << 1) + 1);
($x:ident) => ((($x as usize) << 1) + 1);
}
#[macro_export]
macro_rules! long_val {
($x:ident) => ($x as usize >> 1);
($x:expr) => ($x as usize >> 1);
}
#[macro_export]
macro_rules! val_int {
($x:expr) => ( val_long!($x) );
($x:ident) => ( val_long!($x) );
}
#[macro_export]
macro_rules! int_val {
($x:ident) => (long_val!($x));
($x:expr) => (long_val!($x));
}
pub fn empty_list() -> Value {
val_int!(0)
}
pub fn is_block(v: Value) -> bool {
(v & 1) == 0
}
pub fn is_long(v: Value) -> bool {
(v & 1) != 0
}
#[macro_export]
macro_rules! field {
($block:expr, $i:expr) => (
($block as *mut $crate::core::mlvalues::Value).offset($i)
);
}
pub unsafe fn field(value: Value, i: usize) -> *mut Value {
field!(value, i as isize)
}
pub const UNIT: Value = val_int!(0);
pub const TRUE: Value = val_int!(0);
pub const FALSE: Value = val_int!(1);
#[macro_export]
macro_rules! bp_val {
($v: expr) => {
$v as *const u8
}
}
#[macro_export]
macro_rules! string_val {
($v:expr) => {
bp_val!($v)
}
}
extern "C" {
pub fn caml_string_length(value: Value) -> Size;
pub fn caml_array_length(value: Value) -> Size;
}