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