1use mumu::parser::interpreter::{Interpreter, DynamicFnInfo};
2use mumu::parser::types::{Value, FunctionValue};
3use std::sync::{Arc, Mutex};
4
5mod extract;
6pub use extract::*;
7
8#[no_mangle]
9pub extern "C" fn Cargo_lock(interp_ptr: *mut std::ffi::c_void, _extra: *const std::ffi::c_void) -> i32 {
10 let interp: &mut Interpreter = unsafe { &mut *(interp_ptr as *mut Interpreter) };
11 match register_html_functions(interp) {
12 Ok(()) => 0,
13 Err(_) => 1,
14 }
15}
16
17pub fn register_html_functions(interp: &mut Interpreter) -> Result<(), String> {
18 {
19 let func = Arc::new(Mutex::new(extract_text_bridge));
20 let info = DynamicFnInfo::new(func.clone(), true);
21 interp.register_dynamic_function_ex("html:extract_text", info);
22 interp.set_variable(
23 "html:extract_text",
24 Value::Function(Box::new(FunctionValue::Named("html:extract_text".to_string())))
25 );
26 }
27 Ok(())
28}