#illusory0x0/native

    #Description

    A native FFI utility library.

    Provides functions for interoperability with C, such as pointer arithmetic, CString, C arrays, Moonbit RC management, and memory allocation functions.

    The publicly available interfaces can be viewed in the native.mbti interface file

    #Installation

    #Install from mooncake

    moon add illusory0x0/native

    #License

    Distributed under the Apache License. See LICENSE.txt for more information.

    Getter

    trait Getter

    impl Getter for Byte
    impl Getter for Char
    impl Getter for Int
    impl Getter for Int16
    impl Getter for Int64
    impl Getter for UInt
    impl Getter for UInt16
    impl Getter for UInt64
    impl Getter for Float
    impl Getter for Double

    Setter

    trait Setter

    impl Setter for Byte
    impl Setter for Char
    impl Setter for Int
    impl Setter for Int16
    impl Setter for Int64
    impl Setter for UInt
    impl Setter for UInt16
    impl Setter for UInt64
    impl Setter for Float
    impl Setter for Double

    Sized

    trait Sized

    impl Sized for Byte
    impl Sized for Char
    impl Sized for Int
    impl Sized for Int16
    impl Sized for Int64
    impl Sized for UInt
    impl Sized for UInt16
    impl Sized for UInt64
    impl Sized for Float
    impl Sized for Double

    CStr

    type CStr

    CStr::from_bytes

    fn CStr::from_bytes(bytes : Bytes) -> (CStr, Rc[Bytes])

    CStr::reinterpret_as_const_byte_ptr

    fn CStr::reinterpret_as_const_byte_ptr(self : CStr) -> ConstPtr[Byte]

    CStr::to_bytes

    fn CStr::to_bytes(self : CStr) -> Bytes

    CStr::unsafe_from_byte_ptr

    fn CStr::unsafe_from_byte_ptr(ptr : Ptr[Byte]) -> CStr

    CStr::unsafe_from_const_byte_ptr

    fn CStr::unsafe_from_const_byte_ptr(ptr : ConstPtr[Byte]) -> CStr

    ConstPtr

    type ConstPtr[T]

    ConstPtr::add

    fn[T : Sized] ConstPtr::add(self : ConstPtr[T], offset : Int64) -> ConstPtr[T]

    ConstPtr::compare

    fn[T] ConstPtr::compare(self : ConstPtr[T], other : ConstPtr[T]) -> Int

    ConstPtr::from_rc_bytes

    fn[T] ConstPtr::from_rc_bytes(rc : Rc[Bytes]) -> ConstPtr[T]

    ConstPtr::from_rc_fixedarray

    fn[T] ConstPtr::from_rc_fixedarray(rc : Rc[FixedArray[T]]) -> ConstPtr[T]

    ConstPtr::from_rc_string

    fn[T] ConstPtr::from_rc_string(rc : Rc[String]) -> ConstPtr[T]

    ConstPtr::get

    fn[T : Getter] ConstPtr::get(self : ConstPtr[T]) -> T

    ConstPtr::is_null

    fn[T] ConstPtr::is_null(self : ConstPtr[T]) -> Bool

    ConstPtr::null_pointer

    fn[T] ConstPtr::null_pointer() -> ConstPtr[T]

    ConstPtr::reinterpret_as_const_byte_ptr

    fn[T] ConstPtr::reinterpret_as_const_byte_ptr(self : ConstPtr[T]) -> ConstPtr[Byte]

    ConstPtr::reinterpret_as_int64

    fn[T] ConstPtr::reinterpret_as_int64(self : ConstPtr[T]) -> Int64

    ConstPtr::reinterpret_as_uint64

    fn[T] ConstPtr::reinterpret_as_uint64(self : ConstPtr[T]) -> UInt64

    ConstPtr::sub

    fn[T : Sized] ConstPtr::sub(self : ConstPtr[T], other : ConstPtr[T]) -> Int64

    Ptr

    type Ptr[T]

    Ptr::add

    fn[T : Sized] Ptr::add(self : Ptr[T], offset : Int64) -> Ptr[T]

    Ptr::compare

    fn[T] Ptr::compare(self : Ptr[T], other : Ptr[T]) -> Int

    Ptr::from_rc_fixedarray

    fn[T] Ptr::from_rc_fixedarray(rc : Rc[FixedArray[T]]) -> Ptr[T]

    Ptr::get

    fn[T : Getter] Ptr::get(self : Ptr[T]) -> T

    Ptr::is_null

    fn[T] Ptr::is_null(self : Ptr[T]) -> Bool

    Ptr::null_pointer

    fn[T] Ptr::null_pointer() -> Ptr[T]

    Ptr::reinterpret_as_byte_ptr

    fn[T] Ptr::reinterpret_as_byte_ptr(self : Ptr[T]) -> Ptr[Byte]

    Ptr::reinterpret_as_const_byte_ptr

    fn[T] Ptr::reinterpret_as_const_byte_ptr(self : Ptr[T]) -> ConstPtr[Byte]

    Ptr::reinterpret_as_int64

    fn[T] Ptr::reinterpret_as_int64(self : Ptr[T]) -> Int64

    Ptr::reinterpret_as_uint64

    fn[T] Ptr::reinterpret_as_uint64(self : Ptr[T]) -> UInt64

    Ptr::set

    fn[T : Setter] Ptr::set(self : Ptr[T], x : T) -> Unit

    Ptr::sub

    fn[T : Sized] Ptr::sub(self : Ptr[T], other : Ptr[T]) -> Int64

    Ptr::to_const_ptr

    fn[T] Ptr::to_const_ptr(self : Ptr[T]) -> ConstPtr[T]

    type Rc[T]

    Rc::from_bytes

    fn Rc::from_bytes(xs : Bytes) -> Rc[Bytes]

    Rc::from_fixedarray

    fn[T] Rc::from_fixedarray(xs : FixedArray[T]) -> Rc[FixedArray[T]]

    Rc::release

    fn[T] Rc::release(self : Rc[T]) -> Unit

    Rc::scope_bytes

    fn[R] Rc::scope_bytes(xs : Bytes, f : (ConstPtr[Byte], Int) -> R) -> R

    Rc::scope_fixedarray

    fn[T, R] Rc::scope_fixedarray(xs : FixedArray[T], f : (Ptr[T], Int) -> R) -> R

    free

    fn free(ptr : Ptr[Byte]) -> Unit

    malloc

    fn malloc(count : UInt64) -> Ptr[Byte]

    memcmp

    fn memcmp(a : ConstPtr[Byte], b : ConstPtr[Byte], count : UInt64) -> Int

    memcpy

    fn memcpy(dest : Ptr[Byte], src : ConstPtr[Byte], count : UInt64) -> Unit

    memmove

    fn memmove(dest : Ptr[Byte], src : ConstPtr[Byte], count : UInt64) -> Unit

    memset

    fn memset(ptr : Ptr[Byte], val : Byte, count : UInt64) -> Unit

    realloc

    fn realloc(ptr : Ptr[Byte], count : UInt64) -> Ptr[Byte]

    size_of_byte

    let size_of_byte : Int64

    size_of_char

    let size_of_char : Int64

    size_of_double

    let size_of_double : Int64

    size_of_float

    let size_of_float : Int64

    size_of_int

    let size_of_int : Int64

    size_of_int16

    let size_of_int16 : Int64

    size_of_int64

    let size_of_int64 : Int64

    size_of_uint

    let size_of_uint : Int64

    size_of_uint16

    let size_of_uint16 : Int64

    size_of_uint64

    let size_of_uint64 : Int64

    try_finally

    fn[V, E : Error] try_finally(f : () -> V raise E, finally_~ : () -> Unit) -> V raise E

    unsafe_coerce

    fn[A, B] unsafe_coerce(x : A) -> B