Fix proc macro scoping for pyo3

This commit is contained in:
konstin 2018-06-15 22:50:26 +02:00
parent fd6ab73924
commit e374b5dd1d
6 changed files with 189 additions and 197 deletions

View File

@ -149,11 +149,11 @@ pub const CONTEXT: Proto = Proto {
py_methods: &[ py_methods: &[
PyMethod { PyMethod {
name: "__enter__", name: "__enter__",
proto: "_pyo3::class::context::PyContextEnterProtocolImpl", proto: "::pyo3::class::context::PyContextEnterProtocolImpl",
}, },
PyMethod { PyMethod {
name: "__exit__", name: "__exit__",
proto: "_pyo3::class::context::PyContextExitProtocolImpl", proto: "::pyo3::class::context::PyContextExitProtocolImpl",
}, },
], ],
}; };
@ -200,11 +200,11 @@ pub const DESCR: Proto = Proto {
py_methods: &[ py_methods: &[
PyMethod { PyMethod {
name: "__del__", name: "__del__",
proto: "_pyo3::class::context::PyDescrDelProtocolImpl", proto: "::pyo3::class::context::PyDescrDelProtocolImpl",
}, },
PyMethod { PyMethod {
name: "__set_name__", name: "__set_name__",
proto: "_pyo3::class::context::PyDescrNameProtocolImpl", proto: "::pyo3::class::context::PyDescrNameProtocolImpl",
}, },
], ],
}; };
@ -594,51 +594,51 @@ pub const NUM: Proto = Proto {
py_methods: &[ py_methods: &[
PyMethod { PyMethod {
name: "__radd__", name: "__radd__",
proto: "_pyo3::class::number::PyNumberRAddProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRAddProtocolImpl"},
PyMethod { PyMethod {
name: "__rsub__", name: "__rsub__",
proto: "_pyo3::class::number::PyNumberRSubProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRSubProtocolImpl"},
PyMethod { PyMethod {
name: "__rmul__", name: "__rmul__",
proto: "_pyo3::class::number::PyNumberRMulProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRMulProtocolImpl"},
PyMethod { PyMethod {
name: "__rmatmul__", name: "__rmatmul__",
proto: "_pyo3::class::number::PyNumberRMatmulProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRMatmulProtocolImpl"},
PyMethod { PyMethod {
name: "__rtruediv__", name: "__rtruediv__",
proto: "_pyo3::class::number::PyNumberRTruedivProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRTruedivProtocolImpl"},
PyMethod { PyMethod {
name: "__rfloordiv__", name: "__rfloordiv__",
proto: "_pyo3::class::number::PyNumberRFloordivProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRFloordivProtocolImpl"},
PyMethod { PyMethod {
name: "__rmod__", name: "__rmod__",
proto: "_pyo3::class::number::PyNumberRModProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRModProtocolImpl"},
PyMethod { PyMethod {
name: "__rdivmod__", name: "__rdivmod__",
proto: "_pyo3::class::number::PyNumberRDivmodProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRDivmodProtocolImpl"},
PyMethod { PyMethod {
name: "__rpow__", name: "__rpow__",
proto: "_pyo3::class::number::PyNumberRPowProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRPowProtocolImpl"},
PyMethod { PyMethod {
name: "__rlshift__", name: "__rlshift__",
proto: "_pyo3::class::number::PyNumberRLShiftProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRLShiftProtocolImpl"},
PyMethod { PyMethod {
name: "__rrshift__", name: "__rrshift__",
proto: "_pyo3::class::number::PyNumberRRShiftProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRRShiftProtocolImpl"},
PyMethod { PyMethod {
name: "__rand__", name: "__rand__",
proto: "_pyo3::class::number::PyNumberRAndProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRAndProtocolImpl"},
PyMethod { PyMethod {
name: "__rxor__", name: "__rxor__",
proto: "_pyo3::class::number::PyNumberRXorProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRXorProtocolImpl"},
PyMethod { PyMethod {
name: "__ror__", name: "__ror__",
proto: "_pyo3::class::number::PyNumberROrProtocolImpl"}, proto: "::pyo3::class::number::PyNumberROrProtocolImpl"},
PyMethod { PyMethod {
name: "__complex__", name: "__complex__",
proto: "_pyo3::class::number::PyNumberComplexProtocolImpl"}, proto: "::pyo3::class::number::PyNumberComplexProtocolImpl"},
PyMethod { PyMethod {
name: "__round__", name: "__round__",
proto: "_pyo3::class::number::PyNumberRoundProtocolImpl"}, proto: "::pyo3::class::number::PyNumberRoundProtocolImpl"},
] ]
}; };

View File

@ -243,21 +243,20 @@ pub fn add_fn_to_module(
let tokens = quote! { let tokens = quote! {
fn #function_wrapper_ident(py: ::pyo3::Python) -> ::pyo3::PyObject { fn #function_wrapper_ident(py: ::pyo3::Python) -> ::pyo3::PyObject {
use std; use std;
use pyo3 as _pyo3;
#wrapper #wrapper
let _def = _pyo3::class::PyMethodDef { let _def = ::pyo3::class::PyMethodDef {
ml_name: stringify!(#python_name), ml_name: stringify!(#python_name),
ml_meth: _pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap),
ml_flags: _pyo3::ffi::METH_VARARGS | _pyo3::ffi::METH_KEYWORDS, ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS,
ml_doc: #doc, ml_doc: #doc,
}; };
let function = unsafe { let function = unsafe {
_pyo3::PyObject::from_owned_ptr_or_panic( ::pyo3::PyObject::from_owned_ptr_or_panic(
py, py,
_pyo3::ffi::PyCFunction_New( ::pyo3::ffi::PyCFunction_New(
Box::into_raw(Box::new(_def.as_method_def())), Box::into_raw(Box::new(_def.as_method_def())),
std::ptr::null_mut() std::ptr::null_mut()
) )
@ -294,20 +293,20 @@ fn function_c_wrapper(name: &syn::Ident, spec: &method::FnSpec) -> TokenStream {
quote! { quote! {
#[allow(unused_variables, unused_imports)] #[allow(unused_variables, unused_imports)]
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_slf: *mut _pyo3::ffi::PyObject, _slf: *mut ::pyo3::ffi::PyObject,
_args: *mut _pyo3::ffi::PyObject, _args: *mut ::pyo3::ffi::PyObject,
_kwargs: *mut _pyo3::ffi::PyObject) -> *mut _pyo3::ffi::PyObject _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject
{ {
const _LOCATION: &'static str = concat!(stringify!(#name), "()"); const _LOCATION: &'static str = concat!(stringify!(#name), "()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
let _args = _py.from_borrowed_ptr::<_pyo3::PyTuple>(_args); let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = _pyo3::argparse::get_kwargs(_py, _kwargs); let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
#body_to_result #body_to_result
_pyo3::callback::cb_convert( ::pyo3::callback::cb_convert(
_pyo3::callback::PyObjectCallbackConverter, _py, _result) ::pyo3::callback::PyObjectCallbackConverter, _py, _result)
} }
} }
} }

View File

@ -47,7 +47,6 @@ pub fn build_py_class(
unused_qualifications, unused_variables, non_camel_case_types)] unused_qualifications, unused_variables, non_camel_case_types)]
const #dummy_const: () = { const #dummy_const: () = {
use std; use std;
use pyo3 as _pyo3;
#tokens #tokens
}; };
@ -105,36 +104,36 @@ fn impl_class(
let extra = if let Some(token) = token { let extra = if let Some(token) = token {
Some(quote! { Some(quote! {
impl _pyo3::PyObjectWithToken for #cls { impl ::pyo3::PyObjectWithToken for #cls {
#[inline(always)] #[inline(always)]
fn py<'p>(&'p self) -> _pyo3::Python<'p> { fn py<'p>(&'p self) -> ::pyo3::Python<'p> {
self.#token.py() self.#token.py()
} }
} }
impl _pyo3::ToPyObject for #cls { impl ::pyo3::ToPyObject for #cls {
#[inline] #[inline]
fn to_object<'p>(&self, py: _pyo3::Python<'p>) -> _pyo3::PyObject { fn to_object<'p>(&self, py: ::pyo3::Python<'p>) -> ::pyo3::PyObject {
unsafe { _pyo3::PyObject::from_borrowed_ptr(py, self.as_ptr()) } unsafe { ::pyo3::PyObject::from_borrowed_ptr(py, self.as_ptr()) }
} }
} }
impl _pyo3::ToBorrowedObject for #cls { impl ::pyo3::ToBorrowedObject for #cls {
#[inline] #[inline]
fn with_borrowed_ptr<F, R>(&self, _py: _pyo3::Python, f: F) -> R fn with_borrowed_ptr<F, R>(&self, _py: ::pyo3::Python, f: F) -> R
where F: FnOnce(*mut _pyo3::ffi::PyObject) -> R where F: FnOnce(*mut ::pyo3::ffi::PyObject) -> R
{ {
f(self.as_ptr()) f(self.as_ptr())
} }
} }
impl<'a> _pyo3::ToPyObject for &'a mut #cls { impl<'a> ::pyo3::ToPyObject for &'a mut #cls {
#[inline] #[inline]
fn to_object<'p>(&self, py: _pyo3::Python<'p>) -> _pyo3::PyObject { fn to_object<'p>(&self, py: ::pyo3::Python<'p>) -> ::pyo3::PyObject {
unsafe { _pyo3::PyObject::from_borrowed_ptr(py, self.as_ptr()) } unsafe { ::pyo3::PyObject::from_borrowed_ptr(py, self.as_ptr()) }
} }
} }
impl<'a> _pyo3::ToBorrowedObject for &'a mut #cls { impl<'a> ::pyo3::ToBorrowedObject for &'a mut #cls {
#[inline] #[inline]
fn with_borrowed_ptr<F, R>(&self, _py: _pyo3::Python, f: F) -> R fn with_borrowed_ptr<F, R>(&self, _py: ::pyo3::Python, f: F) -> R
where F: FnOnce(*mut _pyo3::ffi::PyObject) -> R where F: FnOnce(*mut ::pyo3::ffi::PyObject) -> R
{ {
f(self.as_ptr()) f(self.as_ptr())
} }
@ -145,12 +144,12 @@ fn impl_class(
unsafe{std::mem::transmute(ob)} unsafe{std::mem::transmute(ob)}
} }
} }
impl _pyo3::ToPyPointer for #cls { impl ::pyo3::ToPyPointer for #cls {
#[inline] #[inline]
fn as_ptr(&self) -> *mut _pyo3::ffi::PyObject { fn as_ptr(&self) -> *mut ::pyo3::ffi::PyObject {
unsafe { unsafe {
{self as *const _ as *mut u8} {self as *const _ as *mut u8}
.offset(-<#cls as _pyo3::typeob::PyTypeInfo>::OFFSET) as *mut _pyo3::ffi::PyObject .offset(-<#cls as ::pyo3::typeob::PyTypeInfo>::OFFSET) as *mut ::pyo3::ffi::PyObject
} }
} }
} }
@ -176,16 +175,16 @@ fn impl_class(
let extra = { let extra = {
if let Some(freelist) = params.get("freelist") { if let Some(freelist) = params.get("freelist") {
Some(quote! { Some(quote! {
impl _pyo3::freelist::PyObjectWithFreeList for #cls { impl ::pyo3::freelist::PyObjectWithFreeList for #cls {
#[inline] #[inline]
fn get_free_list() -> &'static mut _pyo3::freelist::FreeList<*mut _pyo3::ffi::PyObject> { fn get_free_list() -> &'static mut ::pyo3::freelist::FreeList<*mut ::pyo3::ffi::PyObject> {
static mut FREELIST: *mut _pyo3::freelist::FreeList<*mut _pyo3::ffi::PyObject> = 0 as *mut _; static mut FREELIST: *mut ::pyo3::freelist::FreeList<*mut ::pyo3::ffi::PyObject> = 0 as *mut _;
unsafe { unsafe {
if FREELIST.is_null() { if FREELIST.is_null() {
FREELIST = Box::into_raw(Box::new( FREELIST = Box::into_raw(Box::new(
_pyo3::freelist::FreeList::with_capacity(#freelist))); ::pyo3::freelist::FreeList::with_capacity(#freelist)));
<#cls as _pyo3::typeob::PyTypeObject>::init_type(); <#cls as ::pyo3::typeob::PyTypeObject>::init_type();
} }
&mut *FREELIST &mut *FREELIST
} }
@ -215,26 +214,26 @@ fn impl_class(
let mut has_dict = false; let mut has_dict = false;
for f in flags.iter() { for f in flags.iter() {
if let syn::Expr::Path(ref epath) = f { if let syn::Expr::Path(ref epath) = f {
if epath.path == parse_quote!{_pyo3::typeob::PY_TYPE_FLAG_WEAKREF} { if epath.path == parse_quote!{::pyo3::typeob::PY_TYPE_FLAG_WEAKREF} {
has_weakref = true; has_weakref = true;
} else if epath.path == parse_quote!{_pyo3::typeob::PY_TYPE_FLAG_DICT} { } else if epath.path == parse_quote!{::pyo3::typeob::PY_TYPE_FLAG_DICT} {
has_dict = true; has_dict = true;
} }
} }
} }
let weakref = if has_weakref { let weakref = if has_weakref {
quote!{std::mem::size_of::<*const _pyo3::ffi::PyObject>()} quote!{std::mem::size_of::<*const ::pyo3::ffi::PyObject>()}
} else { } else {
quote!{0} quote!{0}
}; };
let dict = if has_dict { let dict = if has_dict {
quote!{std::mem::size_of::<*const _pyo3::ffi::PyObject>()} quote!{std::mem::size_of::<*const ::pyo3::ffi::PyObject>()}
} else { } else {
quote!{0} quote!{0}
}; };
quote! { quote! {
impl _pyo3::typeob::PyTypeInfo for #cls { impl ::pyo3::typeob::PyTypeInfo for #cls {
type Type = #cls; type Type = #cls;
type BaseType = #base; type BaseType = #base;
@ -249,35 +248,35 @@ fn impl_class(
const OFFSET: isize = { const OFFSET: isize = {
// round base_size up to next multiple of align // round base_size up to next multiple of align
( (
(<#base as _pyo3::typeob::PyTypeInfo>::SIZE + (<#base as ::pyo3::typeob::PyTypeInfo>::SIZE +
std::mem::align_of::<#cls>() - 1) / std::mem::align_of::<#cls>() - 1) /
std::mem::align_of::<#cls>() * std::mem::align_of::<#cls>() std::mem::align_of::<#cls>() * std::mem::align_of::<#cls>()
) as isize ) as isize
}; };
#[inline] #[inline]
unsafe fn type_object() -> &'static mut _pyo3::ffi::PyTypeObject { unsafe fn type_object() -> &'static mut ::pyo3::ffi::PyTypeObject {
static mut TYPE_OBJECT: _pyo3::ffi::PyTypeObject = _pyo3::ffi::PyTypeObject_INIT; static mut TYPE_OBJECT: ::pyo3::ffi::PyTypeObject = ::pyo3::ffi::PyTypeObject_INIT;
&mut TYPE_OBJECT &mut TYPE_OBJECT
} }
} }
impl _pyo3::typeob::PyTypeObject for #cls { impl ::pyo3::typeob::PyTypeObject for #cls {
#[inline(always)] #[inline(always)]
fn init_type() { fn init_type() {
static START: std::sync::Once = std::sync::ONCE_INIT; static START: std::sync::Once = std::sync::ONCE_INIT;
START.call_once(|| { START.call_once(|| {
let ty = unsafe{<#cls as _pyo3::typeob::PyTypeInfo>::type_object()}; let ty = unsafe{<#cls as ::pyo3::typeob::PyTypeInfo>::type_object()};
if (ty.tp_flags & _pyo3::ffi::Py_TPFLAGS_READY) == 0 { if (ty.tp_flags & ::pyo3::ffi::Py_TPFLAGS_READY) == 0 {
let gil = _pyo3::Python::acquire_gil(); let gil = ::pyo3::Python::acquire_gil();
let py = gil.python(); let py = gil.python();
// automatically initialize the class on-demand // automatically initialize the class on-demand
_pyo3::typeob::initialize_type::<#cls>(py, None) ::pyo3::typeob::initialize_type::<#cls>(py, None)
.map_err(|e| e.print(py)) .map_err(|e| e.print(py))
.expect(format!("An error occurred while initializing class {}", .expect(format!("An error occurred while initializing class {}",
<#cls as _pyo3::typeob::PyTypeInfo>::NAME).as_ref()); <#cls as ::pyo3::typeob::PyTypeInfo>::NAME).as_ref());
} }
}); });
} }
@ -299,7 +298,7 @@ fn impl_descriptors(
FnType::Getter(_) => { FnType::Getter(_) => {
quote! { quote! {
impl #cls { impl #cls {
fn #name(&self) -> _pyo3::PyResult<#field_ty> { fn #name(&self) -> ::pyo3::PyResult<#field_ty> {
Ok(self.#name.clone()) Ok(self.#name.clone())
} }
} }
@ -309,7 +308,7 @@ fn impl_descriptors(
let setter_name = syn::Ident::new(&format!("set_{}", name), Span::call_site()); let setter_name = syn::Ident::new(&format!("set_{}", name), Span::call_site());
quote! { quote! {
impl #cls { impl #cls {
fn #setter_name(&mut self, value: #field_ty) -> _pyo3::PyResult<()> { fn #setter_name(&mut self, value: #field_ty) -> ::pyo3::PyResult<()> {
self.#name = value; self.#name = value;
Ok(()) Ok(())
} }
@ -364,9 +363,9 @@ fn impl_descriptors(
let tokens = quote! { let tokens = quote! {
#(#methods)* #(#methods)*
impl _pyo3::class::methods::PyPropMethodsProtocolImpl for #cls { impl ::pyo3::class::methods::PyPropMethodsProtocolImpl for #cls {
fn py_methods() -> &'static [_pyo3::class::PyMethodDefType] { fn py_methods() -> &'static [::pyo3::class::PyMethodDefType] {
static METHODS: &'static [_pyo3::class::PyMethodDefType] = &[ static METHODS: &'static [::pyo3::class::PyMethodDefType] = &[
#(#py_methods),* #(#py_methods),*
]; ];
METHODS METHODS
@ -381,14 +380,12 @@ fn impl_descriptors(
_ => "CLS_METHODS".to_string() _ => "CLS_METHODS".to_string()
}; };
let dummy_const = syn::Ident::new(&format!("_IMPL_PYO3_DESCRIPTORS_{}", n), Span::call_site()); let dummy_const = syn::Ident::new(&format!("_IMPL_pyo3_DESCRIPTORS_{}", n), Span::call_site());
quote! { quote! {
#[feature(specialization)] #[feature(specialization)]
#[allow(non_upper_case_globals, unused_attributes, #[allow(non_upper_case_globals, unused_attributes,
unused_qualifications, unused_variables, unused_imports)] unused_qualifications, unused_variables, unused_imports)]
const #dummy_const: () = { const #dummy_const: () = {
use pyo3 as _pyo3;
#tokens #tokens
}; };
} }
@ -416,7 +413,7 @@ fn parse_attribute(
let mut params = HashMap::new(); let mut params = HashMap::new();
let mut flags = vec![syn::Expr::Lit(parse_quote!{0})]; let mut flags = vec![syn::Expr::Lit(parse_quote!{0})];
let mut base: syn::TypePath = parse_quote!{_pyo3::PyObjectRef}; let mut base: syn::TypePath = parse_quote!{::pyo3::PyObjectRef};
for expr in args.iter() { for expr in args.iter() {
match expr { match expr {
@ -425,16 +422,16 @@ fn parse_attribute(
syn::Expr::Path(ref exp) if exp.path.segments.len() == 1 => { syn::Expr::Path(ref exp) if exp.path.segments.len() == 1 => {
match exp.path.segments.first().unwrap().value().ident.to_string().as_str() { match exp.path.segments.first().unwrap().value().ident.to_string().as_str() {
"gc" => { "gc" => {
flags.push(syn::Expr::Path(parse_quote!{_pyo3::typeob::PY_TYPE_FLAG_GC})); flags.push(syn::Expr::Path(parse_quote!{::pyo3::typeob::PY_TYPE_FLAG_GC}));
} }
"weakref" => { "weakref" => {
flags.push(syn::Expr::Path(parse_quote!{_pyo3::typeob::PY_TYPE_FLAG_WEAKREF})); flags.push(syn::Expr::Path(parse_quote!{::pyo3::typeob::PY_TYPE_FLAG_WEAKREF}));
} }
"subclass" => { "subclass" => {
flags.push(syn::Expr::Path(parse_quote!{_pyo3::typeob::PY_TYPE_FLAG_BASETYPE})); flags.push(syn::Expr::Path(parse_quote!{::pyo3::typeob::PY_TYPE_FLAG_BASETYPE}));
} }
"dict" => { "dict" => {
flags.push(syn::Expr::Path(parse_quote!{_pyo3::typeob::PY_TYPE_FLAG_DICT})); flags.push(syn::Expr::Path(parse_quote!{::pyo3::typeob::PY_TYPE_FLAG_DICT}));
} }
param => { param => {
println!("Unsupported parameter: {}", param); println!("Unsupported parameter: {}", param);

View File

@ -26,9 +26,9 @@ pub fn impl_methods(ty: &syn::Type, impls: &mut Vec<syn::ImplItem>) -> TokenStre
} }
let tokens = quote! { let tokens = quote! {
impl _pyo3::class::methods::PyMethodsProtocolImpl for #ty { impl ::pyo3::class::methods::PyMethodsProtocolImpl for #ty {
fn py_methods() -> &'static [_pyo3::class::PyMethodDefType] { fn py_methods() -> &'static [::pyo3::class::PyMethodDefType] {
static METHODS: &'static [_pyo3::class::PyMethodDefType] = &[ static METHODS: &'static [::pyo3::class::PyMethodDefType] = &[
#(#methods),* #(#methods),*
]; ];
METHODS METHODS
@ -48,8 +48,6 @@ pub fn impl_methods(ty: &syn::Type, impls: &mut Vec<syn::ImplItem>) -> TokenStre
#[allow(non_upper_case_globals, unused_attributes, #[allow(non_upper_case_globals, unused_attributes,
unused_qualifications, unused_variables, unused_imports)] unused_qualifications, unused_variables, unused_imports)]
const #dummy_const: () = { const #dummy_const: () = {
use pyo3 as _pyo3;
#tokens #tokens
}; };
} }

View File

@ -66,17 +66,17 @@ pub fn impl_wrap(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec, noargs: bool
quote! { quote! {
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_slf: *mut _pyo3::ffi::PyObject) -> *mut _pyo3::ffi::PyObject _slf: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject
{ {
const _LOCATION: &'static str = concat!( const _LOCATION: &'static str = concat!(
stringify!(#cls), ".", stringify!(#name), "()"); stringify!(#cls), ".", stringify!(#name), "()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf); let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
#body_to_result #body_to_result
_pyo3::callback::cb_convert( ::pyo3::callback::cb_convert(
_pyo3::callback::PyObjectCallbackConverter, _py, _result) ::pyo3::callback::PyObjectCallbackConverter, _py, _result)
} }
} }
} else { } else {
@ -85,22 +85,22 @@ pub fn impl_wrap(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec, noargs: bool
quote! { quote! {
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_slf: *mut _pyo3::ffi::PyObject, _slf: *mut ::pyo3::ffi::PyObject,
_args: *mut _pyo3::ffi::PyObject, _args: *mut ::pyo3::ffi::PyObject,
_kwargs: *mut _pyo3::ffi::PyObject) -> *mut _pyo3::ffi::PyObject _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject
{ {
use pyo3::ToPyPointer; use pyo3::ToPyPointer;
const _LOCATION: &'static str = concat!( const _LOCATION: &'static str = concat!(
stringify!(#cls), ".", stringify!(#name), "()"); stringify!(#cls), ".", stringify!(#name), "()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf); let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
let _args = _py.from_borrowed_ptr::<_pyo3::PyTuple>(_args); let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = _pyo3::argparse::get_kwargs(_py, _kwargs); let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
#body_to_result #body_to_result
_pyo3::callback::cb_convert( ::pyo3::callback::cb_convert(
_pyo3::callback::PyObjectCallbackConverter, _py, _result) ::pyo3::callback::PyObjectCallbackConverter, _py, _result)
} }
} }
} }
@ -114,22 +114,22 @@ pub fn impl_proto_wrap(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> Tok
quote! { quote! {
#[allow(unused_mut)] #[allow(unused_mut)]
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_slf: *mut _pyo3::ffi::PyObject, _slf: *mut ::pyo3::ffi::PyObject,
_args: *mut _pyo3::ffi::PyObject, _args: *mut ::pyo3::ffi::PyObject,
_kwargs: *mut _pyo3::ffi::PyObject) -> *mut _pyo3::ffi::PyObject _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject
{ {
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf); let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
let _args = _py.from_borrowed_ptr::<_pyo3::PyTuple>(_args); let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = _pyo3::argparse::get_kwargs(_py, _kwargs); let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
let _result = { let _result = {
#body #body
}; };
_pyo3::callback::cb_convert( ::pyo3::callback::cb_convert(
_pyo3::callback::PyObjectCallbackConverter, _py, _result) ::pyo3::callback::PyObjectCallbackConverter, _py, _result)
} }
} }
} }
@ -149,20 +149,20 @@ pub fn impl_wrap_new(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> Token
quote! { quote! {
#[allow(unused_mut)] #[allow(unused_mut)]
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_cls: *mut _pyo3::ffi::PyTypeObject, _cls: *mut ::pyo3::ffi::PyTypeObject,
_args: *mut _pyo3::ffi::PyObject, _args: *mut ::pyo3::ffi::PyObject,
_kwargs: *mut _pyo3::ffi::PyObject) -> *mut _pyo3::ffi::PyObject _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject
{ {
use std::ptr; use std::ptr;
use pyo3::typeob::PyTypeInfo; use pyo3::typeob::PyTypeInfo;
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
match _pyo3::typeob::PyRawObject::new(_py, #cls::type_object(), _cls) { match ::pyo3::typeob::PyRawObject::new(_py, #cls::type_object(), _cls) {
Ok(_obj) => { Ok(_obj) => {
let _args = _py.from_borrowed_ptr::<_pyo3::PyTuple>(_args); let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = _pyo3::argparse::get_kwargs(_py, _kwargs); let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
#body_to_result #body_to_result
@ -199,16 +199,16 @@ fn impl_wrap_init(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> TokenStr
quote! { quote! {
#[allow(unused_mut)] #[allow(unused_mut)]
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_slf: *mut _pyo3::ffi::PyObject, _slf: *mut ::pyo3::ffi::PyObject,
_args: *mut _pyo3::ffi::PyObject, _args: *mut ::pyo3::ffi::PyObject,
_kwargs: *mut _pyo3::ffi::PyObject) -> _pyo3::c_int _kwargs: *mut ::pyo3::ffi::PyObject) -> ::pyo3::c_int
{ {
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf); let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
let _args = _py.from_borrowed_ptr::<_pyo3::PyTuple>(_args); let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = _pyo3::argparse::get_kwargs(_py, _kwargs); let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
#body_to_result #body_to_result
match _result { match _result {
@ -237,20 +237,20 @@ pub fn impl_wrap_class(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> Tok
quote! { quote! {
#[allow(unused_mut)] #[allow(unused_mut)]
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_cls: *mut _pyo3::ffi::PyObject, _cls: *mut ::pyo3::ffi::PyObject,
_args: *mut _pyo3::ffi::PyObject, _args: *mut ::pyo3::ffi::PyObject,
_kwargs: *mut _pyo3::ffi::PyObject) -> *mut _pyo3::ffi::PyObject _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject
{ {
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
let _cls = _pyo3::PyType::from_type_ptr(_py, _cls as *mut _pyo3::ffi::PyTypeObject); let _cls = ::pyo3::PyType::from_type_ptr(_py, _cls as *mut ::pyo3::ffi::PyTypeObject);
let _args = _py.from_borrowed_ptr::<_pyo3::PyTuple>(_args); let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = _pyo3::argparse::get_kwargs(_py, _kwargs); let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
#body_to_result #body_to_result
_pyo3::callback::cb_convert( ::pyo3::callback::cb_convert(
_pyo3::callback::PyObjectCallbackConverter, _py, _result) ::pyo3::callback::PyObjectCallbackConverter, _py, _result)
} }
} }
} }
@ -270,19 +270,19 @@ pub fn impl_wrap_static(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> To
quote! { quote! {
#[allow(unused_mut)] #[allow(unused_mut)]
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_slf: *mut _pyo3::ffi::PyObject, _slf: *mut ::pyo3::ffi::PyObject,
_args: *mut _pyo3::ffi::PyObject, _args: *mut ::pyo3::ffi::PyObject,
_kwargs: *mut _pyo3::ffi::PyObject) -> *mut _pyo3::ffi::PyObject _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject
{ {
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
let _args = _py.from_borrowed_ptr::<_pyo3::PyTuple>(_args); let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = _pyo3::argparse::get_kwargs(_py, _kwargs); let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
#body_to_result #body_to_result
_pyo3::callback::cb_convert( ::pyo3::callback::cb_convert(
_pyo3::callback::PyObjectCallbackConverter, _py, _result) ::pyo3::callback::PyObjectCallbackConverter, _py, _result)
} }
} }
} }
@ -291,13 +291,13 @@ pub fn impl_wrap_static(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> To
pub(crate) fn impl_wrap_getter(cls: &syn::Type, name: &syn::Ident) -> TokenStream { pub(crate) fn impl_wrap_getter(cls: &syn::Type, name: &syn::Ident) -> TokenStream {
quote! { quote! {
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_slf: *mut _pyo3::ffi::PyObject, _: *mut _pyo3::c_void) -> *mut _pyo3::ffi::PyObject _slf: *mut ::pyo3::ffi::PyObject, _: *mut ::pyo3::c_void) -> *mut ::pyo3::ffi::PyObject
{ {
use std; use std;
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf); let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
match _slf.#name() { match _slf.#name() {
@ -323,16 +323,16 @@ pub(crate) fn impl_wrap_setter(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec
quote! { quote! {
#[allow(unused_mut)] #[allow(unused_mut)]
unsafe extern "C" fn __wrap( unsafe extern "C" fn __wrap(
_slf: *mut _pyo3::ffi::PyObject, _slf: *mut ::pyo3::ffi::PyObject,
_value: *mut _pyo3::ffi::PyObject, _: *mut _pyo3::c_void) -> _pyo3::c_int _value: *mut ::pyo3::ffi::PyObject, _: *mut ::pyo3::c_void) -> ::pyo3::c_int
{ {
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
let _pool = _pyo3::GILPool::new(); let _pool = ::pyo3::GILPool::new();
let _py = _pyo3::Python::assume_gil_acquired(); let _py = ::pyo3::Python::assume_gil_acquired();
let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf); let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
let _value = _py.from_borrowed_ptr(_value); let _value = _py.from_borrowed_ptr(_value);
let _result = match <#val_ty as _pyo3::FromPyObject>::extract(_value) { let _result = match <#val_ty as ::pyo3::FromPyObject>::extract(_value) {
Ok(_val) => _slf.#name(_val), Ok(_val) => _slf.#name(_val),
Err(e) => Err(e) Err(e) => Err(e)
}; };
@ -392,7 +392,7 @@ pub fn impl_arg_params(spec: &FnSpec, body: TokenStream) -> TokenStream {
params.push( params.push(
quote! { quote! {
_pyo3::argparse::ParamDescription{ ::pyo3::argparse::ParamDescription{
name: stringify!(#name), is_optional: #opt, kw_only: #kwonly} name: stringify!(#name), is_optional: #opt, kw_only: #kwonly}
} }
); );
@ -419,12 +419,12 @@ pub fn impl_arg_params(spec: &FnSpec, body: TokenStream) -> TokenStream {
// create array of arguments, and then parse // create array of arguments, and then parse
quote! { quote! {
const _PARAMS: &'static [_pyo3::argparse::ParamDescription<'static>] = &[ const _PARAMS: &'static [::pyo3::argparse::ParamDescription<'static>] = &[
#(#params),* #(#params),*
]; ];
let mut _output = [#(#placeholders),*]; let mut _output = [#(#placeholders),*];
match _pyo3::argparse::parse_args(Some(_LOCATION), _PARAMS, &_args, match ::pyo3::argparse::parse_args(Some(_LOCATION), _PARAMS, &_args,
_kwargs, #accept_args, #accept_kwargs, &mut _output) _kwargs, #accept_args, #accept_kwargs, &mut _output)
{ {
Ok(_) => { Ok(_) => {
@ -527,26 +527,26 @@ pub fn impl_py_method_def(name: &syn::Ident, doc: syn::Lit, spec: &FnSpec, wrapp
{ {
if spec.args.is_empty() { if spec.args.is_empty() {
quote! { quote! {
_pyo3::class::PyMethodDefType::Method({ ::pyo3::class::PyMethodDefType::Method({
#wrapper #wrapper
_pyo3::class::PyMethodDef { ::pyo3::class::PyMethodDef {
ml_name: stringify!(#name), ml_name: stringify!(#name),
ml_meth: _pyo3::class::PyMethodType::PyNoArgsFunction(__wrap), ml_meth: ::pyo3::class::PyMethodType::PyNoArgsFunction(__wrap),
ml_flags: _pyo3::ffi::METH_NOARGS, ml_flags: ::pyo3::ffi::METH_NOARGS,
ml_doc: #doc, ml_doc: #doc,
} }
}) })
} }
} else { } else {
quote! { quote! {
_pyo3::class::PyMethodDefType::Method({ ::pyo3::class::PyMethodDefType::Method({
#wrapper #wrapper
_pyo3::class::PyMethodDef { ::pyo3::class::PyMethodDef {
ml_name: stringify!(#name), ml_name: stringify!(#name),
ml_meth: _pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap),
ml_flags: _pyo3::ffi::METH_VARARGS | _pyo3::ffi::METH_KEYWORDS, ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS,
ml_doc: #doc, ml_doc: #doc,
} }
}) })
@ -557,13 +557,13 @@ pub fn impl_py_method_def(name: &syn::Ident, doc: syn::Lit, spec: &FnSpec, wrapp
pub fn impl_py_method_def_new(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream pub fn impl_py_method_def_new(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream
{ {
quote! { quote! {
_pyo3::class::PyMethodDefType::New({ ::pyo3::class::PyMethodDefType::New({
#wrapper #wrapper
_pyo3::class::PyMethodDef { ::pyo3::class::PyMethodDef {
ml_name: stringify!(#name), ml_name: stringify!(#name),
ml_meth: _pyo3::class::PyMethodType::PyNewFunc(__wrap), ml_meth: ::pyo3::class::PyMethodType::PyNewFunc(__wrap),
ml_flags: _pyo3::ffi::METH_VARARGS | _pyo3::ffi::METH_KEYWORDS, ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS,
ml_doc: #doc, ml_doc: #doc,
} }
}) })
@ -573,13 +573,13 @@ pub fn impl_py_method_def_new(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenS
pub fn impl_py_method_def_init(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream pub fn impl_py_method_def_init(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream
{ {
quote! { quote! {
_pyo3::class::PyMethodDefType::Init({ ::pyo3::class::PyMethodDefType::Init({
#wrapper #wrapper
_pyo3::class::PyMethodDef { ::pyo3::class::PyMethodDef {
ml_name: stringify!(#name), ml_name: stringify!(#name),
ml_meth: _pyo3::class::PyMethodType::PyInitFunc(__wrap), ml_meth: ::pyo3::class::PyMethodType::PyInitFunc(__wrap),
ml_flags: _pyo3::ffi::METH_VARARGS | _pyo3::ffi::METH_KEYWORDS, ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS,
ml_doc: #doc, ml_doc: #doc,
} }
}) })
@ -589,14 +589,14 @@ pub fn impl_py_method_def_init(name: &syn::Ident, doc: syn::Lit, wrapper: &Token
pub fn impl_py_method_def_class(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream pub fn impl_py_method_def_class(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream
{ {
quote! { quote! {
_pyo3::class::PyMethodDefType::Class({ ::pyo3::class::PyMethodDefType::Class({
#wrapper #wrapper
_pyo3::class::PyMethodDef { ::pyo3::class::PyMethodDef {
ml_name: stringify!(#name), ml_name: stringify!(#name),
ml_meth: _pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap),
ml_flags: _pyo3::ffi::METH_VARARGS | _pyo3::ffi::METH_KEYWORDS | ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS |
_pyo3::ffi::METH_CLASS, ::pyo3::ffi::METH_CLASS,
ml_doc: #doc, ml_doc: #doc,
} }
}) })
@ -606,13 +606,13 @@ pub fn impl_py_method_def_class(name: &syn::Ident, doc: syn::Lit, wrapper: &Toke
pub fn impl_py_method_def_static(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream pub fn impl_py_method_def_static(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream
{ {
quote! { quote! {
_pyo3::class::PyMethodDefType::Static({ ::pyo3::class::PyMethodDefType::Static({
#wrapper #wrapper
_pyo3::class::PyMethodDef { ::pyo3::class::PyMethodDef {
ml_name: stringify!(#name), ml_name: stringify!(#name),
ml_meth: _pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap),
ml_flags: _pyo3::ffi::METH_VARARGS | _pyo3::ffi::METH_KEYWORDS | _pyo3::ffi::METH_STATIC, ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS | ::pyo3::ffi::METH_STATIC,
ml_doc: #doc, ml_doc: #doc,
} }
}) })
@ -622,13 +622,13 @@ pub fn impl_py_method_def_static(name: &syn::Ident, doc: syn::Lit, wrapper: &Tok
pub fn impl_py_method_def_call(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream pub fn impl_py_method_def_call(name: &syn::Ident, doc: syn::Lit, wrapper: &TokenStream) -> TokenStream
{ {
quote! { quote! {
_pyo3::class::PyMethodDefType::Call({ ::pyo3::class::PyMethodDefType::Call({
#wrapper #wrapper
_pyo3::class::PyMethodDef { ::pyo3::class::PyMethodDef {
ml_name: stringify!(#name), ml_name: stringify!(#name),
ml_meth: _pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap),
ml_flags: _pyo3::ffi::METH_VARARGS | _pyo3::ffi::METH_KEYWORDS, ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS,
ml_doc: #doc, ml_doc: #doc,
} }
}) })
@ -650,10 +650,10 @@ pub(crate) fn impl_py_setter_def(name: &syn::Ident, doc: syn::Lit, setter: &Opti
}; };
quote! { quote! {
_pyo3::class::PyMethodDefType::Setter({ ::pyo3::class::PyMethodDefType::Setter({
#wrapper #wrapper
_pyo3::class::PySetterDef { ::pyo3::class::PySetterDef {
name: #n, name: #n,
meth: __wrap, meth: __wrap,
doc: #doc, doc: #doc,
@ -677,10 +677,10 @@ pub(crate) fn impl_py_getter_def(name: &syn::Ident, doc: syn::Lit, getter: &Opti
}; };
quote! { quote! {
_pyo3::class::PyMethodDefType::Getter({ ::pyo3::class::PyMethodDefType::Getter({
#wrapper #wrapper
_pyo3::class::PyGetterDef { ::pyo3::class::PyGetterDef {
name: #n, name: #n,
meth: __wrap, meth: __wrap,
doc: #doc, doc: #doc,

View File

@ -89,13 +89,13 @@ fn impl_proto_impl(
impl #proto for #ty impl #proto for #ty
{ {
#[inline] #[inline]
fn #name() -> Option<_pyo3::class::methods::PyMethodDef> { fn #name() -> Option<::pyo3::class::methods::PyMethodDef> {
#meth #meth
Some(_pyo3::class::PyMethodDef { Some(::pyo3::class::PyMethodDef {
ml_name: stringify!(#name), ml_name: stringify!(#name),
ml_meth: _pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap),
ml_flags: _pyo3::ffi::METH_VARARGS | _pyo3::ffi::METH_KEYWORDS, ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS,
ml_doc: ""}) ml_doc: ""})
} }
} }
@ -123,8 +123,6 @@ fn impl_proto_impl(
unused_qualifications, unused_variables, unused_qualifications, unused_variables,
unused_imports)] unused_imports)]
const #dummy_const: () = { const #dummy_const: () = {
use pyo3 as _pyo3;
#tokens #tokens
#(#py_methods)* #(#py_methods)*