[][src]Macro ocaml_interop::ocaml_alloc

macro_rules! ocaml_alloc {
    ( $(($obj:expr).)?$($fn:ident).+($gc:ident $(,)?) ) => { ... };
    ( $(($obj:expr).)?$($fn:ident).+($gc:ident, $($arg:expr),+ $(,)? ) ) => { ... };
    ( $obj:literal.$($fn:ident).+($gc:ident $(,)?) ) => { ... };
    ( $obj:literal.$($fn:ident).+($gc:ident, $($arg:expr),+ $(,)?) ) => { ... };
}

Calls an OCaml allocator function.

Useful for calling functions that construct new values and never raise an exception.

It is used internally by the to_ocaml! macro, and may be used directly only in rare occasions.

Examples

    let hello_string = "hello OCaml!";
    ocaml_frame!(gc, {
        let ocaml_string: OCaml<String> = ocaml_alloc!(hello_string.to_ocaml(gc));
        // ...
    });