nac3/nac3embedded/src/lib.rs

22 lines
556 B
Rust
Raw Normal View History

2020-12-18 10:09:35 +08:00
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
#[pyfunction]
2020-12-18 23:44:45 +08:00
fn add_host_object(obj: PyObject) -> PyResult<()> {
Python::with_gil(|py| -> PyResult<()> {
let obj: &PyAny = obj.extract(py)?;
let inspect = PyModule::import(py, "inspect")?;
let source = inspect.call1("getsource", (obj.get_type(), ))?;
println!("source:\n{}", source);
Ok(())
})?;
Ok(())
2020-12-18 10:09:35 +08:00
}
#[pymodule]
2020-12-18 23:44:45 +08:00
fn nac3embedded(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(add_host_object, m)?)?;
2020-12-18 10:09:35 +08:00
Ok(())
}