1mod conn;
2mod bridge;
3mod iterator;
4
5use std::ffi::c_void;
6use mumu::parser::interpreter::Interpreter;
7use mumu::parser::types::{Value, FunctionValue};
8
9#[export_name = "Cargo_lock"]
10pub unsafe extern "C" fn cargo_lock(interp_ptr: *mut c_void, _extra: *const c_void) -> i32 {
11 if interp_ptr.is_null() {
12 return 1;
13 }
14 let interp = &mut *(interp_ptr as *mut Interpreter);
15
16 use mumu::parser::interpreter::{DynamicFn, DynamicFnInfo};
17 use crate::bridge::{sqlite_open_bridge, sqlite_query_bridge, sqlite_close_bridge};
18
19 let open_fn: DynamicFn = std::sync::Arc::new(std::sync::Mutex::new(sqlite_open_bridge));
20 interp.register_dynamic_function_ex("sqlite:open", DynamicFnInfo::new(open_fn, true));
21 interp.set_variable(
22 "sqlite:open",
23 Value::Function(Box::new(FunctionValue::Named("sqlite:open".to_string()))),
24 );
25
26 let query_fn: DynamicFn = std::sync::Arc::new(std::sync::Mutex::new(sqlite_query_bridge));
27 interp.register_dynamic_function_ex("sqlite:query", DynamicFnInfo::new(query_fn, true));
28 interp.set_variable(
29 "sqlite:query",
30 Value::Function(Box::new(FunctionValue::Named("sqlite:query".to_string()))),
31 );
32
33 let close_fn: DynamicFn = std::sync::Arc::new(std::sync::Mutex::new(sqlite_close_bridge));
34 interp.register_dynamic_function_ex("sqlite:close", DynamicFnInfo::new(close_fn, true));
35 interp.set_variable(
36 "sqlite:close",
37 Value::Function(Box::new(FunctionValue::Named("sqlite:close".to_string()))),
38 );
39
40 0
41}