flow-mumu 0.1.4

Stream tranform tools plugin for the Lava language
Documentation
// flow/src/lib.rs

use std::ffi::c_void;
use mumu::parser::interpreter::Interpreter;

mod common;
mod trans;
mod compose;
mod slice;
mod to_array;
mod filter;
mod throttle;

// New modules
mod reduce;
mod of;
mod empty;
mod concat;
mod chain;
mod ap;
mod drain;

pub use trans::register_flow_trans;
pub use compose::register_flow_compose;
pub use slice::register_flow_slice;
pub use to_array::register_flow_to_array;
pub use filter::register_flow_filter;
pub use throttle::register_flow_throttle;

// New exports
pub use trans::register_flow_map_alias;
pub use reduce::register_flow_reduce;
pub use of::register_flow_of;
pub use empty::register_flow_empty;
pub use concat::register_flow_concat;
pub use chain::register_flow_chain;
pub use ap::{register_flow_ap_zip, register_flow_ap};
pub use drain::register_flow_drain;

#[export_name = "Cargo_lock"]
pub unsafe extern "C" fn cargo_lock(interp_ptr: *mut c_void, extra_str: *const c_void) -> i32 {
    if interp_ptr.is_null() {
        return 1;
    }
    let interp = &mut *(interp_ptr as *mut Interpreter);

    if interp.is_verbose() {
        eprintln!("[flow:Cargo.lock] => bridging flow plugin...");
        if !extra_str.is_null() {
            use std::ffi::CStr;
            let c_str = CStr::from_ptr(extra_str as *const i8);
            eprintln!("[flow:Cargo.lock] => extra arg='{}'", c_str.to_string_lossy());
        }
    }

    // Existing
    register_flow_trans(interp);
    register_flow_compose(interp);
    register_flow_slice(interp);
    register_flow_to_array(interp);
    register_flow_filter(interp);
    register_flow_throttle(interp);

    // Alias: map ≡ trans
    register_flow_map_alias(interp);

    // New functional set
    register_flow_of(interp);
    register_flow_empty(interp);
    register_flow_concat(interp);
    register_flow_reduce(interp);
    register_flow_chain(interp);
    register_flow_ap_zip(interp);
    register_flow_ap(interp);

    // Side-effect-free sink
    register_flow_drain(interp);

    if interp.is_verbose() {
        eprintln!("[flow:Cargo.lock] => done bridging flow plugin");
    }

    0
}