fn impl_wrap_init(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) -> TokenStream {
    let cb = impl_call(cls, name, &spec);
    let output = &spec.output;
    let result_empty: syn::Type = syn::parse_quote!(PyResult<()>);
    let empty: syn::Type = syn::parse_quote!(());
    if output != &result_empty || output != &empty {
        panic!("Constructor must return PyResult<()> or a ()");
    }

    let body = impl_arg_params(&spec, cb);

    quote! {
        #[allow(unused_mut)]
        unsafe extern "C" fn __wrap(
            _slf: *mut pyo3::ffi::PyObject,
            _args: *mut pyo3::ffi::PyObject,
            _kwargs: *mut pyo3::ffi::PyObject) -> pyo3::libc::c_int
        {
            const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
            let _py = pyo3::Python::assume_gil_acquired();
            let _pool = pyo3::GILPool::new(_py);
            let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
            let _args = _py.from_borrowed_ptr::<pyo3::types::PyTuple>(_args);
            let _kwargs: Option<&pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs);

            #body

            match _result {
                Ok(_) => 0,
                Err(e) => {
                    e.restore(_py);
                    -1
                }
            }
        }
    }
}
/// Generate function wrapper for ffi::initproc
Generate function wrapper for ffi::initproc
Generate function wrapper for ffi :: initproc
fn impl_wrap_init(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) -> TokenStream {
    let cb = impl_call(cls, name, &spec);
    let output = &spec.output;
    let result_empty: syn::Type = syn::parse_quote!(PyResult<()>);
    let empty: syn::Type = syn::parse_quote!(());
    if output != &result_empty || output != &empty {
        panic!("Constructor must return PyResult<()> or a ()");
    }
    let body = impl_arg_params(&spec, cb);
    quote! {
        #[allow(unused_mut)]
        unsafe extern "C" fn __wrap(
            _slf: *mut pyo3::ffi::PyObject,
            _args: *mut pyo3::ffi::PyObject,
            _kwargs: *mut pyo3::ffi::PyObject) -> pyo3::libc::c_int
        {
            const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
            let _py = pyo3::Python::assume_gil_acquired();
            let _pool = pyo3::GILPool::new(_py);
            let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
            let _args = _py.from_borrowed_ptr::<pyo3::types::PyTuple>(_args);
            let _kwargs: Option<&pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs);
            #body
            match _result {
                Ok(_) => 0,
                Err(e) => {
                    e.restore(_py);
                    -1
                }
            }
        }
    }
}
fn impl_wrap_init ( cls : & syn :: Type , name : & syn :: Ident , spec : & FnSpec < ' _ > ) -> TokenStream { let cb = impl_call ( cls , name , & spec ) ; let output = & spec . output ; let result_empty : syn :: Type = syn :: parse_quote ! ( PyResult ( ) ) ; let empty : syn :: Type = syn :: parse_quote ! ( ( ) ) ; if output != & result_empty || output != & empty { panic ! ( " " ) ; } let body = impl_arg_params ( & spec , cb ) ; quote ! { [ allow ( unused_mut ) ] unsafe extern " " fn __wrap ( _slf mut pyo3 ffi PyObject _args mut pyo3 ffi PyObject _kwargs mut pyo3 ffi PyObject ) pyo3 libc c_int { const _LOCATION ' static str concat ( stringify ( cls ) " " stringify ( name ) " " ) let _py pyo3 Python assume_gil_acquired ( ) let _pool pyo3 GILPool new ( _py ) let _slf _py mut_from_borrowed_ptr cls ( _slf ) let _args _py from_borrowed_ptr pyo3 types PyTuple ( _args ) let _kwargs Option pyo3 types PyDict _py from_borrowed_ptr_or_opt ( _kwargs ) body match _result { Ok ( ) 0 Err ( e ) { e restore ( _py ) 1 } } } } }
Generate function wrapper for ffi::initproc
Generate function wrapper for ffi :: initproc
cls
&syn::Type
name
&syn::Ident
spec
&FnSpec<'_>
cls
&syn::Type
name
&syn::Ident
spec
&FnSpec<'_>