mod common;
pub mod unary;
pub mod partial;
mod multi;
use mumu::{
parser::interpreter::Interpreter,
parser::types::{Value, FunctionValue},
};
use std::sync::{Arc, Mutex};
#[no_mangle]
pub unsafe extern "C" fn Cargo_lock(
interp_ptr: *mut std::ffi::c_void,
_extra_str: *const std::ffi::c_void,
) -> i32 {
let interp = &mut *(interp_ptr as *mut Interpreter);
macro_rules! reg {
($name:expr, $f:expr) => {{
let func = Arc::new(Mutex::new($f));
interp.register_dynamic_function($name, func);
interp.set_variable($name, Value::Function(Box::new(FunctionValue::Named($name.into()))));
}};
}
reg!("string:lower", unary::string_lower_bridge);
reg!("string:upper", unary::string_upper_bridge);
reg!("string:length", unary::string_length_bridge);
reg!("string:to_string", unary::string_to_string_bridge);
reg!("string:trim", unary::string_trim_bridge);
reg!("string:concat", partial::string_concat_bridge);
reg!("string:split", partial::string_split_bridge);
reg!("string:join", partial::string_join_bridge);
reg!("string:replace", partial::string_replace_bridge);
reg!("string:contains", partial::string_contains_bridge);
reg!("string:starts_with", partial::string_starts_with_bridge);
reg!("string:ends_with", partial::string_ends_with_bridge);
reg!("string:slice", partial::string_slice_bridge);
reg!("string:repeat", partial::string_repeat_bridge);
reg!("string:index_of", partial::string_index_of_bridge);
reg!("string:last_index_of", partial::string_last_index_of_bridge);
0
}