From fcf7cb315a95bbfbd5479d98bd4f1699bd8bbc88 Mon Sep 17 00:00:00 2001 From: Charlotte McElwain Date: Sat, 16 Nov 2024 23:28:52 -0800 Subject: [PATCH] Finish pyo3. --- Cargo.lock | 1 - plugins/chop/python/src/lib.rs | 44 ++---- td-rs-base/Cargo.toml | 3 +- td-rs-base/src/lib.rs | 97 +++++++----- td-rs-base/src/param.rs | 4 +- td-rs-base/src/py.rs | 281 +-------------------------------- td-rs-derive-py/src/lib.rs | 34 ++-- 7 files changed, 97 insertions(+), 367 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4aeefc8..47063a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3735,7 +3735,6 @@ dependencies = [ "derive_more", "miette", "pyo3", - "pyo3-ffi", "ref-cast", "rgb", "td-rs-autocxx-build", diff --git a/plugins/chop/python/src/lib.rs b/plugins/chop/python/src/lib.rs index f8101af..09eb225 100644 --- a/plugins/chop/python/src/lib.rs +++ b/plugins/chop/python/src/lib.rs @@ -2,9 +2,8 @@ use pyo3::impl_::pyclass::{PyClassImpl, PyMethods}; use pyo3::prelude::PyAnyMethods; -use pyo3::{pyclass, pymethods, Bound, PyAny, PyResult}; +use pyo3::{pyclass, pymethods, Bound, PyAny, PyResult, Python}; use std::pin::Pin; -use std::sync::{Arc, Mutex}; use td_rs_chop::cxx::AsPlugin; use td_rs_chop::*; use td_rs_derive::*; @@ -31,9 +30,9 @@ struct PythonChopParams { } #[derive(PyOp)] -#[pyclass] +#[pyclass(unsendable)] pub struct PythonChop { - info: Arc>, + info: NodeInfo, #[pyo3(get, set)] speed: f32, #[pyo3(get)] @@ -60,7 +59,7 @@ impl PythonChop { impl OpNew for PythonChop { fn new(info: NodeInfo) -> Self { Self { - info: Arc::new(Mutex::new(info)), + info, speed: 1.0, execute_count: 0, offset: 0.0, @@ -133,29 +132,20 @@ impl Chop for PythonChop { // Apply Python class modifications self.params.speed *= self.speed; - let info = self.info.lock().unwrap(); - let arg_tuple = info - .context() - .create_arguments_tuple(1); - - unsafe { - pyo3_ffi::PyTuple_SET_ITEM( - arg_tuple, - 1, - pyo3_ffi::PyFloat_FromDouble(self.params.speed as std::ffi::c_double), - ); - let res = info.context().call_python_callback( + Python::with_gil(|py| { + self.info.context().call_python_callback( + py, "getSpeedAdjust", - arg_tuple, - std::ptr::null_mut(), - ); - if !res.is_null() { - if pyo3_ffi::PyFloat_Check(res) != 0 { - self.params.speed = pyo3_ffi::PyFloat_AsDouble(res) as f32; - } - pyo3_ffi::Py_DECREF(res); - } - } + (self.speed,), + None, + |py, res| { + if let Ok(speed) = res.extract::(py) { + self.params.speed *= speed; + } + }, + ) + }) + .unwrap(); let phase = 2.0 * std::f32::consts::PI / output.num_channels() as f32; let num_samples = output.num_samples(); diff --git a/td-rs-base/Cargo.toml b/td-rs-base/Cargo.toml index a467d46..079eadb 100644 --- a/td-rs-base/Cargo.toml +++ b/td-rs-base/Cargo.toml @@ -15,7 +15,6 @@ ref-cast = "1.0" auto_ops = "0.3.0" derive_more = { version = "1", features = ["full"] } pyo3 = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"], optional = true } -pyo3-ffi = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"], optional = true } tracing-base = { package = "tracing", version = "0.1", optional = true} tracing-subscriber = { version = "0.3", optional = true } tokio-core = { package = "tokio", version = "1", optional = true } @@ -27,6 +26,6 @@ miette = { version = "5", features = [ "fancy" ] } [features] default = [] -python = ["pyo3-ffi"] +python = ["pyo3"] tracing = ["tracing-base", "tracing-subscriber", "tracing-subscriber/env-filter"] tokio = ["tokio-core", "tokio-core/rt-multi-thread"] \ No newline at end of file diff --git a/td-rs-base/src/lib.rs b/td-rs-base/src/lib.rs index 7b5180d..b43ea6a 100644 --- a/td-rs-base/src/lib.rs +++ b/td-rs-base/src/lib.rs @@ -1,23 +1,28 @@ #![feature(associated_type_defaults)] #![feature(min_specialization)] +pub use param::*; +#[cfg(feature = "python")] +pub use py::*; +#[cfg(feature = "python")] +use pyo3::prelude::*; +use pyo3::types::{IntoPyDict, PyTuple}; +use pyo3::BoundObject; use std::ffi; +use std::ffi::c_int; use std::fmt::Formatter; use std::ops::Index; use std::pin::Pin; use std::sync::Mutex; -pub use param::*; -#[cfg(feature = "python")] -pub use py::*; - #[cfg(feature = "tokio")] -pub static RUNTIME: std::sync::LazyLock = std::sync::LazyLock::new(|| { - tokio_core::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .expect("Failed to create tokio runtime") -}); +pub static RUNTIME: std::sync::LazyLock = + std::sync::LazyLock::new(|| { + tokio_core::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .expect("Failed to create tokio runtime") + }); pub mod chop; pub mod cxx; @@ -139,35 +144,47 @@ pub struct Context { impl Context { #[cfg(feature = "python")] - pub fn create_arguments_tuple(&self, nargs: usize) -> *mut pyo3_ffi::PyObject { - let obj = unsafe { - let mut ctx = Pin::new_unchecked(&mut *self.context); - let tuple = ctx - .createArgumentsTuple(autocxx::c_int(nargs as i32), std::ptr::null_mut()); - tuple - }; - obj as *mut pyo3_ffi::PyObject - } - - #[cfg(feature = "python")] - pub fn call_python_callback( + pub fn call_python_callback<'py, F>( &self, + py: Python<'py>, callback: &str, - args: *mut pyo3_ffi::PyObject, - kw: *mut pyo3_ffi::PyObject, - ) -> *mut pyo3_ffi::PyObject { - let callback = ffi::CString::new(callback).unwrap(); - let obj = unsafe { + args: impl IntoPyObject<'py, Target = PyTuple>, + kwargs: Option<&Bound<'py, pyo3::types::PyDict>>, + f: F, + ) -> PyResult<()> + where + F: FnOnce(Python, &PyObject), + { + unsafe { + let callback = ffi::CString::new(callback)?; + let args = args.into_pyobject(py).map_err(Into::into)?.into_bound(); + let mut ctx = Pin::new_unchecked(&mut *self.context); + let op_tuple = ctx.createArgumentsTuple(autocxx::c_int(1), std::ptr::null_mut()); + let op_tuple = op_tuple as *mut pyo3::ffi::PyObject; + let op_tuple = PyObject::from_owned_ptr(py, op_tuple); + let op_tuple = op_tuple.downcast_bound::(py)?; + let op = op_tuple.get_item(0)?; + let mut args_elements = vec![op]; + + for args in args.iter() { + args_elements.push(args); + } + let args = PyTuple::new(py, &args_elements)?; + let mut ctx = Pin::new_unchecked(&mut *self.context); + let args = args.as_ptr(); + let kwargs = kwargs.map(|kw| kw.as_ptr()).unwrap_or(std::ptr::null_mut()); let res = ctx.callPythonCallback( callback.as_ptr(), args as *mut cxx::_object, - kw as *mut cxx::_object, + kwargs as *mut cxx::_object, std::ptr::null_mut(), ); - res - }; - obj as *mut pyo3_ffi::PyObject + let res = res as *mut pyo3::ffi::PyObject; + let res = PyObject::from_owned_ptr(py, res); + f(py, &res); + Ok(()) + } } } @@ -332,7 +349,7 @@ impl<'cook> ParamInputs<'cook> { } #[cfg(feature = "python")] - fn get_python(&self, name: &str) -> *mut pyo3_ffi::PyObject { + fn get_python(&self, name: &str) -> *mut pyo3::ffi::PyObject { unsafe { let python = self .inputs @@ -340,7 +357,7 @@ impl<'cook> ParamInputs<'cook> { if python.is_null() { std::ptr::null_mut() } else { - python as *mut pyo3_ffi::PyObject + python as *mut pyo3::ffi::PyObject } } } @@ -533,8 +550,8 @@ pub fn op_init() { { use tracing_subscriber::fmt; use tracing_subscriber::layer::SubscriberExt; - use tracing_subscriber::EnvFilter; use tracing_subscriber::util::{SubscriberInitExt, TryInitError}; + use tracing_subscriber::EnvFilter; let fmt_layer = if cfg!(target_os = "windows") { let mut f = fmt::layer(); @@ -549,14 +566,12 @@ pub fn op_init() { .try_init(); match init { Ok(_) => {} - Err(err) => { - match err { - TryInitError { .. } => {} - _ => { - eprintln!("Failed to initialize tracing: {}", err); - } + Err(err) => match err { + TryInitError { .. } => {} + _ => { + eprintln!("Failed to initialize tracing: {}", err); } - } + }, } } } diff --git a/td-rs-base/src/param.rs b/td-rs-base/src/param.rs index 3687054..0ca6d7d 100644 --- a/td-rs-base/src/param.rs +++ b/td-rs-base/src/param.rs @@ -673,7 +673,7 @@ impl DatParam { } #[cfg(feature = "python")] -impl Param for *mut pyo3_ffi::PyObject { +impl Param for *mut pyo3::ffi::PyObject { fn register(&self, options: ParamOptions, parameter_manager: &mut ParameterManager) { let param = options.into(); parameter_manager.append_python(param); @@ -682,7 +682,7 @@ impl Param for *mut pyo3_ffi::PyObject { fn update(&mut self, name: &str, inputs: &ParamInputs) { // Ensure that the old object is decref'd unsafe { - pyo3_ffi::Py_XDECREF(*self); + pyo3::ffi::Py_XDECREF(*self); } *self = inputs.get_python(name); } diff --git a/td-rs-base/src/py.rs b/td-rs-base/src/py.rs index dc7f66b..2520d46 100644 --- a/td-rs-base/src/py.rs +++ b/td-rs-base/src/py.rs @@ -1,12 +1,12 @@ -use pyo3_ffi::PyGetSetDef; +use pyo3::ffi::PyGetSetDef; use crate::Op; pub trait PyOp : Op { - + } pub trait PyGetSets { - fn get_get_sets() -> &'static [pyo3_ffi::PyGetSetDef]; + fn get_get_sets() -> &'static [pyo3::ffi::PyGetSetDef]; } impl PyGetSets for T { @@ -16,11 +16,11 @@ impl PyGetSets for T { } pub trait PyMethods { - fn get_methods() -> &'static [pyo3_ffi::PyMethodDef]; + fn get_methods() -> &'static [pyo3::ffi::PyMethodDef]; } impl PyMethods for T { - default fn get_methods() -> &'static [pyo3_ffi::PyMethodDef] { + default fn get_methods() -> &'static [pyo3::ffi::PyMethodDef] { &[] } } @@ -37,274 +37,3 @@ pub(crate) unsafe fn py_op_info( let gs_arr = get_sets.as_ptr() as *mut autocxx::prelude::c_void; crate::cxx::setPyInfo(op_info, m_arr, m_len, gs_arr, gs_len); } - -pub trait FromPyObj { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self; -} - -pub trait ToPyObj { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject; -} - -pub trait CheckPyObj { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool; -} - -#[cfg(windows)] -impl FromPyObj for u32 { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyLong_AsUnsignedLong(obj) as u32 - } -} - -impl FromPyObj for usize { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyLong_AsUnsignedLong(obj) as usize - } -} - -#[cfg(target_os = "macos")] -impl ToPyObj for usize { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromUnsignedLong(self as u64) - } -} - -#[cfg(target_os = "windows")] -impl ToPyObj for usize { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromUnsignedLong(self as u32) - } -} - -impl CheckPyObj for usize { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyLong_Check(obj) != 0 - } -} - -impl FromPyObj for isize { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyLong_AsLong(obj) as isize - } -} - -#[cfg(target_os = "macos")] -impl ToPyObj for isize { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromLong(self as i64) - } -} - -#[cfg(target_os = "windows")] -impl ToPyObj for isize { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromLong(self as i32) - } -} - -impl CheckPyObj for isize { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyLong_Check(obj) != 0 - } -} - -#[cfg(target_os = "windows")] -impl FromPyObj for u32 { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyLong_AsUnsignedLong(obj) - } -} - -#[cfg(target_os = "macos")] -impl FromPyObj for u32 { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyLong_AsUnsignedLong(obj) as u32 - } -} - -#[cfg(target_os = "windows")] -impl ToPyObj for u32 { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromUnsignedLong(self) - } -} - -#[cfg(target_os = "macos")] -impl ToPyObj for u32 { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromUnsignedLong(self as u64) - } -} - -impl CheckPyObj for u32 { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyLong_Check(obj) != 0 - } -} - -impl FromPyObj for i32 { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyLong_AsLong(obj) as i32 - } -} - -#[cfg(target_os = "windows")] -impl ToPyObj for i32 { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromLong(self) - } -} - -#[cfg(target_os = "macos")] -impl ToPyObj for i32 { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromLong(self as i64) - } -} - -impl CheckPyObj for i32 { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyLong_Check(obj) != 0 - } -} - -impl FromPyObj for u64 { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyLong_AsUnsignedLongLong(obj) as u64 - } -} - -impl ToPyObj for u64 { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromUnsignedLongLong(self) - } -} - -impl CheckPyObj for u64 { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyLong_Check(obj) != 0 - } -} - -impl FromPyObj for i64 { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyLong_AsLongLong(obj) as i64 - } -} - -impl ToPyObj for i64 { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyLong_FromLongLong(self) - } -} - -impl CheckPyObj for i64 { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyLong_Check(obj) != 0 - } -} - -impl FromPyObj for f32 { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyFloat_AsDouble(obj) as f32 - } -} - -impl ToPyObj for f32 { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyFloat_FromDouble(self as f64) - } -} - -impl CheckPyObj for f32 { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyFloat_Check(obj) != 0 || pyo3_ffi::PyLong_Check(obj) != 0 - } -} - -impl FromPyObj for f64 { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyFloat_AsDouble(obj) - } -} - -impl ToPyObj for f64 { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - pyo3_ffi::PyFloat_FromDouble(self) - } -} - -impl CheckPyObj for f64 { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyFloat_Check(obj) != 0 || pyo3_ffi::PyLong_Check(obj) != 0 - } -} - -impl FromPyObj for bool { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - pyo3_ffi::PyObject_IsTrue(obj) != 0 - } -} - -impl ToPyObj for bool { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - if self { - pyo3_ffi::Py_True() - } else { - pyo3_ffi::Py_False() - } - } -} - -impl CheckPyObj for bool { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyBool_Check(obj) != 0 - } -} - -impl FromPyObj for String { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - // let s = pyo3_ffi::PyUnicode_AsUTF8(obj); - // let s = std::ffi::CStr::from_ptr(s); - // let s = s.to_str().unwrap(); - // s.to_owned() - todo!() - } -} - -impl ToPyObj for String { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - let s = std::ffi::CString::new(self.as_str()).unwrap(); - pyo3_ffi::PyUnicode_FromString(s.as_ptr()) - } -} - -impl CheckPyObj for String { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyUnicode_Check(obj) != 0 - } -} - -impl FromPyObj for &str { - unsafe fn from_py_obj(obj: *mut pyo3_ffi::PyObject) -> Self { - // let s = pyo3_ffi::PyUnicode_AsUTF8(obj); - // let s = std::ffi::CStr::from_ptr(s); - // let s = s.to_str().unwrap(); - // s - todo!() - } -} - -impl ToPyObj for &str { - unsafe fn to_py_obj(self) -> *mut pyo3_ffi::PyObject { - let s = std::ffi::CString::new(self.as_bytes()).unwrap(); - pyo3_ffi::PyUnicode_FromString(s.as_ptr()) - } -} - -impl CheckPyObj for &str { - unsafe fn check_py_obj(obj: *mut pyo3_ffi::PyObject) -> bool { - pyo3_ffi::PyUnicode_Check(obj) != 0 - } -} diff --git a/td-rs-derive-py/src/lib.rs b/td-rs-derive-py/src/lib.rs index 2132dfa..0738236 100644 --- a/td-rs-derive-py/src/lib.rs +++ b/td-rs-derive-py/src/lib.rs @@ -162,12 +162,11 @@ fn impl_py_op(input: &DeriveInput) -> TokenStream { } impl PyGetSets for #struct_name { - fn get_get_sets() -> &'static [pyo3_ffi::PyGetSetDef] { + fn get_get_sets() -> &'static [pyo3::ffi::PyGetSetDef] { let clazz = pyo3::impl_::pyclass::PyClassImplCollector::<#struct_name>::new(); let methods = clazz.py_methods(); let mut getset_builders = std::collections::HashMap::<&std::ffi::CStr, pyo3::pyclass::create_type_object::GetSetDefBuilder>::new(); for method in methods.methods { - println!("method"); let method_def = match method { pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Runtime(m) => &m(), pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Static(m) => m, @@ -193,12 +192,11 @@ fn impl_py_op(input: &DeriveInput) -> TokenStream { let items = #struct_name::items_iter(); for item in items { for method in item.methods { - println!("method"); let method_def = match method { pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Runtime(m) => &m(), pyo3::impl_::pyclass::MaybeRuntimePyMethodDef::Static(m) => m, }; - + match method_def { pyo3::PyMethodDefType::Getter(getter) => { getset_builders @@ -219,7 +217,7 @@ fn impl_py_op(input: &DeriveInput) -> TokenStream { let mut getset_destructors = Vec::with_capacity(getset_builders.len()); - let property_defs: Vec = getset_builders + let property_defs: Vec = getset_builders .iter() .map(|(name, builder)| { let (def, destructor) = builder.as_get_set_def(name); @@ -238,7 +236,7 @@ fn impl_py_op(input: &DeriveInput) -> TokenStream { } impl td_rs_chop::PyMethods for #struct_name { - fn get_methods() -> &'static [pyo3_ffi::PyMethodDef] { + fn get_methods() -> &'static [pyo3::ffi::PyMethodDef] { let clazz = pyo3::impl_::pyclass::PyClassImplCollector::<#struct_name>::new(); let methods = clazz.py_methods(); let mut method_defs = Vec::new(); @@ -292,21 +290,21 @@ pub fn py_op_methods(_attr: TokenStream, item: TokenStream) -> TokenStream { let fn_name = &method.sig.ident; Some(PyMeth { py_meth: quote! { - pyo3_ffi::PyMethodDef { + pyo3::ffi::PyMethodDef { ml_name: concat!(stringify!(#fn_name), '\0').as_ptr().cast::(), - ml_meth: pyo3_ffi::PyMethodDefPointer { + ml_meth: pyo3::ffi::PyMethodDefPointer { _PyCFunctionFast: #fn_name, }, - ml_flags: pyo3_ffi::METH_FASTCALL, + ml_flags: pyo3::ffi::METH_FASTCALL, ml_doc: std::ptr::null_mut(), }, }, fn_body: quote! { pub unsafe extern "C" fn #fn_name( - _self: *mut pyo3_ffi::PyObject, - args: *mut *mut pyo3_ffi::PyObject, - nargs: pyo3_ffi::Py_ssize_t, - ) -> *mut pyo3_ffi::PyObject { + _self: *mut pyo3::ffi::PyObject, + args: *mut *mut pyo3::ffi::PyObject, + nargs: pyo3::ffi::Py_ssize_t, + ) -> *mut pyo3::ffi::PyObject { use cxx::AsPlugin; let py_struct = _self as *mut cxx::PY_Struct; let info = cxx::PY_GetInfo { @@ -316,8 +314,8 @@ pub fn py_op_methods(_attr: TokenStream, item: TokenStream) -> TokenStream { let mut ctx = std::pin::Pin::new_unchecked(&mut*cxx::getPyContext(py_struct));; let me = ctx.getNodeInstance(&info, std::ptr::null_mut()); if me.is_null() { - pyo3_ffi::PyErr_SetString( - pyo3_ffi::PyExc_TypeError, + pyo3::ffi::PyErr_SetString( + pyo3::ffi::PyExc_TypeError, "operator is null\0" .as_ptr() .cast::(), @@ -352,14 +350,14 @@ pub fn py_op_methods(_attr: TokenStream, item: TokenStream) -> TokenStream { #input impl PyMethods for #struct_name { - fn get_methods() -> &'static [pyo3_ffi::PyMethodDef] { + fn get_methods() -> &'static [pyo3::ffi::PyMethodDef] { &METHODS } } - pub const METHODS: [pyo3_ffi::PyMethodDef; #size] = [ + pub const METHODS: [pyo3::ffi::PyMethodDef; #size] = [ #( #methods )* - pyo3_ffi::PyMethodDef::zeroed() + pyo3::ffi::PyMethodDef::zeroed() ]; #( #fns )*