mumu-html 0.1.1

HTML manipulation and tools plugin for the Lava language
Documentation
use mumu::parser::interpreter::{Interpreter, DynamicFnInfo};
use mumu::parser::types::{Value, FunctionValue};
use std::sync::{Arc, Mutex};

mod extract;
pub use extract::*;

#[no_mangle]
pub extern "C" fn Cargo_lock(interp_ptr: *mut std::ffi::c_void, _extra: *const std::ffi::c_void) -> i32 {
    let interp: &mut Interpreter = unsafe { &mut *(interp_ptr as *mut Interpreter) };
    match register_html_functions(interp) {
        Ok(()) => 0,
        Err(_) => 1,
    }
}

pub fn register_html_functions(interp: &mut Interpreter) -> Result<(), String> {
    {
        let func = Arc::new(Mutex::new(extract_text_bridge));
        let info = DynamicFnInfo::new(func.clone(), true);
        interp.register_dynamic_function_ex("html:extract_text", info);
        interp.set_variable(
            "html:extract_text",
            Value::Function(Box::new(FunctionValue::Named("html:extract_text".to_string())))
        );
    }
    Ok(())
}