Use embedding api in python extension (#569)
Now embedding API is used in the Python extension, this allows us to remove ModuleData::invoke() from wasmtime-interface-types
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
//! Utility functions to handle values conversion between abstractions/targets.
|
||||
|
||||
use core::ptr;
|
||||
use cranelift_codegen::ir;
|
||||
use pyo3::exceptions::Exception;
|
||||
use pyo3::prelude::*;
|
||||
use pyo3::types::PyAny;
|
||||
@@ -38,23 +36,3 @@ pub fn value_to_pyobj(py: Python, value: Value) -> PyResult<PyObject> {
|
||||
Value::String(i) => i.into_py(py),
|
||||
})
|
||||
}
|
||||
|
||||
pub unsafe fn read_value_from(py: Python, ptr: *mut i64, ty: ir::Type) -> PyObject {
|
||||
match ty {
|
||||
ir::types::I32 => ptr::read(ptr as *const i32).into_py(py),
|
||||
ir::types::I64 => ptr::read(ptr as *const i64).into_py(py),
|
||||
ir::types::F32 => ptr::read(ptr as *const f32).into_py(py),
|
||||
ir::types::F64 => ptr::read(ptr as *const f64).into_py(py),
|
||||
_ => panic!("TODO add PyResult to read_value_from"),
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn write_value_to(py: Python, ptr: *mut i64, ty: ir::Type, val: PyObject) {
|
||||
match ty {
|
||||
ir::types::I32 => ptr::write(ptr as *mut i32, val.extract::<i32>(py).expect("i32")),
|
||||
ir::types::I64 => ptr::write(ptr as *mut i64, val.extract::<i64>(py).expect("i64")),
|
||||
ir::types::F32 => ptr::write(ptr as *mut f32, val.extract::<f32>(py).expect("f32")),
|
||||
ir::types::F64 => ptr::write(ptr as *mut f64, val.extract::<f64>(py).expect("f64")),
|
||||
_ => panic!("TODO add PyResult to write_value_to"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user