From a56147fa522203f7bf6d9e43a1dbaba611914a90 Mon Sep 17 00:00:00 2001 From: konstin Date: Sat, 16 Mar 2019 11:40:56 +0100 Subject: [PATCH] Replace `::pyo3::` with only `pyo3::` in the proc macros This makes reexporting the macro output possible in the 2018 edition --- pyo3-derive-backend/src/defs.rs | 226 ++++++++++++++-------------- pyo3-derive-backend/src/module.rs | 36 ++--- pyo3-derive-backend/src/pyclass.rs | 66 ++++---- pyo3-derive-backend/src/pyimpl.rs | 6 +- pyo3-derive-backend/src/pymethod.rs | 220 +++++++++++++-------------- pyo3-derive-backend/src/pyproto.rs | 8 +- 6 files changed, 281 insertions(+), 281 deletions(-) diff --git a/pyo3-derive-backend/src/defs.rs b/pyo3-derive-backend/src/defs.rs index 48238bac..7efae828 100644 --- a/pyo3-derive-backend/src/defs.rs +++ b/pyo3-derive-backend/src/defs.rs @@ -19,76 +19,76 @@ pub const OBJECT: Proto = Proto { name: "__getattr__", arg: "Name", pyres: true, - proto: "::pyo3::class::basic::PyObjectGetAttrProtocol", + proto: "pyo3::class::basic::PyObjectGetAttrProtocol", }, MethodProto::Ternary { name: "__setattr__", arg1: "Name", arg2: "Value", pyres: true, - proto: "::pyo3::class::basic::PyObjectSetAttrProtocol", + proto: "pyo3::class::basic::PyObjectSetAttrProtocol", }, MethodProto::Binary { name: "__delattr__", arg: "Name", pyres: true, - proto: "::pyo3::class::basic::PyObjectDelAttrProtocol", + proto: "pyo3::class::basic::PyObjectDelAttrProtocol", }, MethodProto::Unary { name: "__str__", pyres: true, - proto: "::pyo3::class::basic::PyObjectStrProtocol", + proto: "pyo3::class::basic::PyObjectStrProtocol", }, MethodProto::Unary { name: "__repr__", pyres: true, - proto: "::pyo3::class::basic::PyObjectReprProtocol", + proto: "pyo3::class::basic::PyObjectReprProtocol", }, MethodProto::Binary { name: "__format__", arg: "Format", pyres: true, - proto: "::pyo3::class::basic::PyObjectFormatProtocol", + proto: "pyo3::class::basic::PyObjectFormatProtocol", }, MethodProto::Unary { name: "__hash__", pyres: false, - proto: "::pyo3::class::basic::PyObjectHashProtocol", + proto: "pyo3::class::basic::PyObjectHashProtocol", }, MethodProto::Unary { name: "__bytes__", pyres: true, - proto: "::pyo3::class::basic::PyObjectBytesProtocol", + proto: "pyo3::class::basic::PyObjectBytesProtocol", }, MethodProto::Unary { name: "__unicode__", pyres: true, - proto: "::pyo3::class::basic::PyObjectUnicodeProtocol", + proto: "pyo3::class::basic::PyObjectUnicodeProtocol", }, MethodProto::Unary { name: "__bool__", pyres: false, - proto: "::pyo3::class::basic::PyObjectBoolProtocol", + proto: "pyo3::class::basic::PyObjectBoolProtocol", }, MethodProto::Binary { name: "__richcmp__", arg: "Other", pyres: true, - proto: "::pyo3::class::basic::PyObjectRichcmpProtocol", + proto: "pyo3::class::basic::PyObjectRichcmpProtocol", }, ], py_methods: &[ PyMethod { name: "__format__", - proto: "::pyo3::class::basic::FormatProtocolImpl", + proto: "pyo3::class::basic::FormatProtocolImpl", }, PyMethod { name: "__bytes__", - proto: "::pyo3::class::basic::BytesProtocolImpl", + proto: "pyo3::class::basic::BytesProtocolImpl", }, PyMethod { name: "__unicode__", - proto: "::pyo3::class::basic::UnicodeProtocolImpl", + proto: "pyo3::class::basic::UnicodeProtocolImpl", }, ], }; @@ -99,39 +99,39 @@ pub const ASYNC: Proto = Proto { MethodProto::Unary { name: "__await__", pyres: true, - proto: "::pyo3::class::pyasync::PyAsyncAwaitProtocol", + proto: "pyo3::class::pyasync::PyAsyncAwaitProtocol", }, MethodProto::Unary { name: "__aiter__", pyres: true, - proto: "::pyo3::class::pyasync::PyAsyncAiterProtocol", + proto: "pyo3::class::pyasync::PyAsyncAiterProtocol", }, MethodProto::Unary { name: "__anext__", pyres: true, - proto: "::pyo3::class::pyasync::PyAsyncAnextProtocol", + proto: "pyo3::class::pyasync::PyAsyncAnextProtocol", }, MethodProto::Unary { name: "__aenter__", pyres: true, - proto: "::pyo3::class::pyasync::PyAsyncAenterProtocol", + proto: "pyo3::class::pyasync::PyAsyncAenterProtocol", }, MethodProto::Quaternary { name: "__aexit__", arg1: "ExcType", arg2: "ExcValue", arg3: "Traceback", - proto: "::pyo3::class::pyasync::PyAsyncAexitProtocol", + proto: "pyo3::class::pyasync::PyAsyncAexitProtocol", }, ], py_methods: &[ PyMethod { name: "__aenter__", - proto: "::pyo3::class::pyasync::PyAsyncAenterProtocolImpl", + proto: "pyo3::class::pyasync::PyAsyncAenterProtocolImpl", }, PyMethod { name: "__aexit__", - proto: "::pyo3::class::pyasync::PyAsyncAexitProtocolImpl", + proto: "pyo3::class::pyasync::PyAsyncAexitProtocolImpl", }, ], }; @@ -142,12 +142,12 @@ pub const BUFFER: Proto = Proto { MethodProto::Unary { name: "bf_getbuffer", pyres: false, - proto: "::pyo3::class::buffer::PyBufferGetBufferProtocol", + proto: "pyo3::class::buffer::PyBufferGetBufferProtocol", }, MethodProto::Unary { name: "bf_releasebuffer", pyres: false, - proto: "::pyo3::class::buffer::PyBufferReleaseBufferProtocol", + proto: "pyo3::class::buffer::PyBufferReleaseBufferProtocol", }, ], py_methods: &[], @@ -159,24 +159,24 @@ pub const CONTEXT: Proto = Proto { MethodProto::Unary { name: "__enter__", pyres: true, - proto: "::pyo3::class::context::PyContextEnterProtocol", + proto: "pyo3::class::context::PyContextEnterProtocol", }, MethodProto::Quaternary { name: "__exit__", arg1: "ExcType", arg2: "ExcValue", arg3: "Traceback", - proto: "::pyo3::class::context::PyContextExitProtocol", + proto: "pyo3::class::context::PyContextExitProtocol", }, ], py_methods: &[ PyMethod { name: "__enter__", - proto: "::pyo3::class::context::PyContextEnterProtocolImpl", + proto: "pyo3::class::context::PyContextEnterProtocolImpl", }, PyMethod { name: "__exit__", - proto: "::pyo3::class::context::PyContextExitProtocolImpl", + proto: "pyo3::class::context::PyContextExitProtocolImpl", }, ], }; @@ -186,11 +186,11 @@ pub const GC: Proto = Proto { methods: &[ MethodProto::Free { name: "__traverse__", - proto: "::pyo3::class::gc::PyGCTraverseProtocol", + proto: "pyo3::class::gc::PyGCTraverseProtocol", }, MethodProto::Free { name: "__clear__", - proto: "::pyo3::class::gc::PyGCClearProtocol", + proto: "pyo3::class::gc::PyGCClearProtocol", }, ], py_methods: &[], @@ -204,36 +204,36 @@ pub const DESCR: Proto = Proto { arg1: "Inst", arg2: "Owner", pyres: true, - proto: "::pyo3::class::descr::PyDescrGetProtocol", + proto: "pyo3::class::descr::PyDescrGetProtocol", }, MethodProto::Ternary { name: "__set__", arg1: "Inst", arg2: "Value", pyres: true, - proto: "::pyo3::class::descr::PyDescrSetProtocol", + proto: "pyo3::class::descr::PyDescrSetProtocol", }, MethodProto::Binary { name: "__det__", arg: "Inst", pyres: false, - proto: "::pyo3::class::descr::PyDescrDelProtocol", + proto: "pyo3::class::descr::PyDescrDelProtocol", }, MethodProto::Binary { name: "__set_name__", arg: "Inst", pyres: false, - proto: "::pyo3::class::descr::PyDescrSetNameProtocol", + proto: "pyo3::class::descr::PyDescrSetNameProtocol", }, ], py_methods: &[ PyMethod { name: "__del__", - proto: "::pyo3::class::context::PyDescrDelProtocolImpl", + proto: "pyo3::class::context::PyDescrDelProtocolImpl", }, PyMethod { name: "__set_name__", - proto: "::pyo3::class::context::PyDescrNameProtocolImpl", + proto: "pyo3::class::context::PyDescrNameProtocolImpl", }, ], }; @@ -245,12 +245,12 @@ pub const ITER: Proto = Proto { MethodProto::Unary { name: "__iter__", pyres: true, - proto: "::pyo3::class::iter::PyIterIterProtocol", + proto: "pyo3::class::iter::PyIterIterProtocol", }, MethodProto::Unary { name: "__next__", pyres: true, - proto: "::pyo3::class::iter::PyIterNextProtocol", + proto: "pyo3::class::iter::PyIterNextProtocol", }, ], }; @@ -261,56 +261,56 @@ pub const MAPPING: Proto = Proto { MethodProto::Unary { name: "__len__", pyres: false, - proto: "::pyo3::class::mapping::PyMappingLenProtocol", + proto: "pyo3::class::mapping::PyMappingLenProtocol", }, MethodProto::Binary { name: "__getitem__", arg: "Key", pyres: true, - proto: "::pyo3::class::mapping::PyMappingGetItemProtocol", + proto: "pyo3::class::mapping::PyMappingGetItemProtocol", }, MethodProto::Ternary { name: "__setitem__", arg1: "Key", arg2: "Value", pyres: false, - proto: "::pyo3::class::mapping::PyMappingSetItemProtocol", + proto: "pyo3::class::mapping::PyMappingSetItemProtocol", }, MethodProto::Binary { name: "__delitem__", arg: "Key", pyres: false, - proto: "::pyo3::class::mapping::PyMappingDelItemProtocol", + proto: "pyo3::class::mapping::PyMappingDelItemProtocol", }, MethodProto::Binary { name: "__contains__", arg: "Value", pyres: false, - proto: "::pyo3::class::mapping::PyMappingContainsProtocol", + proto: "pyo3::class::mapping::PyMappingContainsProtocol", }, MethodProto::Unary { name: "__reversed__", pyres: true, - proto: "::pyo3::class::mapping::PyMappingReversedProtocol", + proto: "pyo3::class::mapping::PyMappingReversedProtocol", }, MethodProto::Unary { name: "__iter__", pyres: true, - proto: "::pyo3::class::mapping::PyMappingIterProtocol", + proto: "pyo3::class::mapping::PyMappingIterProtocol", }, ], py_methods: &[ PyMethod { name: "__iter__", - proto: "::pyo3::class::mapping::PyMappingIterProtocolImpl", + proto: "pyo3::class::mapping::PyMappingIterProtocolImpl", }, PyMethod { name: "__contains__", - proto: "::pyo3::class::mapping::PyMappingContainsProtocolImpl", + proto: "pyo3::class::mapping::PyMappingContainsProtocolImpl", }, PyMethod { name: "__reversed__", - proto: "::pyo3::class::mapping::PyMappingReversedProtocolImpl", + proto: "pyo3::class::mapping::PyMappingReversedProtocolImpl", }, ], }; @@ -380,56 +380,56 @@ pub const NUM: Proto = Proto { arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberAddProtocol", + proto: "pyo3::class::number::PyNumberAddProtocol", }, MethodProto::BinaryS { name: "__sub__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberSubProtocol", + proto: "pyo3::class::number::PyNumberSubProtocol", }, MethodProto::BinaryS { name: "__mul__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberMulProtocol", + proto: "pyo3::class::number::PyNumberMulProtocol", }, MethodProto::BinaryS { name: "__matmul__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberMatmulProtocol", + proto: "pyo3::class::number::PyNumberMatmulProtocol", }, MethodProto::BinaryS { name: "__truediv__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberTruedivProtocol", + proto: "pyo3::class::number::PyNumberTruedivProtocol", }, MethodProto::BinaryS { name: "__floordiv__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberFloordivProtocol", + proto: "pyo3::class::number::PyNumberFloordivProtocol", }, MethodProto::BinaryS { name: "__mod__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberModProtocol", + proto: "pyo3::class::number::PyNumberModProtocol", }, MethodProto::BinaryS { name: "__divmod__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberDivmodProtocol", + proto: "pyo3::class::number::PyNumberDivmodProtocol", }, MethodProto::TernaryS { name: "__pow__", @@ -437,317 +437,317 @@ pub const NUM: Proto = Proto { arg2: "Right", arg3: "Modulo", pyres: true, - proto: "::pyo3::class::number::PyNumberPowProtocol", + proto: "pyo3::class::number::PyNumberPowProtocol", }, MethodProto::BinaryS { name: "__lshift__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberLShiftProtocol", + proto: "pyo3::class::number::PyNumberLShiftProtocol", }, MethodProto::BinaryS { name: "__rshift__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberRShiftProtocol", + proto: "pyo3::class::number::PyNumberRShiftProtocol", }, MethodProto::BinaryS { name: "__and__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberAndProtocol", + proto: "pyo3::class::number::PyNumberAndProtocol", }, MethodProto::BinaryS { name: "__xor__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberXorProtocol", + proto: "pyo3::class::number::PyNumberXorProtocol", }, MethodProto::BinaryS { name: "__or__", arg1: "Left", arg2: "Right", pyres: true, - proto: "::pyo3::class::number::PyNumberOrProtocol", + proto: "pyo3::class::number::PyNumberOrProtocol", }, MethodProto::Binary { name: "__radd__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRAddProtocol", + proto: "pyo3::class::number::PyNumberRAddProtocol", }, MethodProto::Binary { name: "__rsub__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRSubProtocol", + proto: "pyo3::class::number::PyNumberRSubProtocol", }, MethodProto::Binary { name: "__rmul__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRMulProtocol", + proto: "pyo3::class::number::PyNumberRMulProtocol", }, MethodProto::Binary { name: "__rmatmul__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRMatmulProtocol", + proto: "pyo3::class::number::PyNumberRMatmulProtocol", }, MethodProto::Binary { name: "__rtruediv__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRTruedivProtocol", + proto: "pyo3::class::number::PyNumberRTruedivProtocol", }, MethodProto::Binary { name: "__rfloordiv__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRFloordivProtocol", + proto: "pyo3::class::number::PyNumberRFloordivProtocol", }, MethodProto::Binary { name: "__rmod__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRModProtocol", + proto: "pyo3::class::number::PyNumberRModProtocol", }, MethodProto::Binary { name: "__rdivmod__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRDivmodProtocol", + proto: "pyo3::class::number::PyNumberRDivmodProtocol", }, MethodProto::Ternary { name: "__rpow__", arg1: "Other", arg2: "Modulo", pyres: true, - proto: "::pyo3::class::number::PyNumberRPowProtocol", + proto: "pyo3::class::number::PyNumberRPowProtocol", }, MethodProto::Binary { name: "__rlshift__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRLShiftProtocol", + proto: "pyo3::class::number::PyNumberRLShiftProtocol", }, MethodProto::Binary { name: "__rrshift__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRRShiftProtocol", + proto: "pyo3::class::number::PyNumberRRShiftProtocol", }, MethodProto::Binary { name: "__rand__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRAndProtocol", + proto: "pyo3::class::number::PyNumberRAndProtocol", }, MethodProto::Binary { name: "__rxor__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberRXorProtocol", + proto: "pyo3::class::number::PyNumberRXorProtocol", }, MethodProto::Binary { name: "__ror__", arg: "Other", pyres: true, - proto: "::pyo3::class::number::PyNumberROrProtocol", + proto: "pyo3::class::number::PyNumberROrProtocol", }, MethodProto::Binary { name: "__iadd__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberIAddProtocol", + proto: "pyo3::class::number::PyNumberIAddProtocol", }, MethodProto::Binary { name: "__isub__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberISubProtocol", + proto: "pyo3::class::number::PyNumberISubProtocol", }, MethodProto::Binary { name: "__imul__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberIMulProtocol", + proto: "pyo3::class::number::PyNumberIMulProtocol", }, MethodProto::Binary { name: "__imatmul__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberIMatmulProtocol", + proto: "pyo3::class::number::PyNumberIMatmulProtocol", }, MethodProto::Binary { name: "__itruediv__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberITruedivProtocol", + proto: "pyo3::class::number::PyNumberITruedivProtocol", }, MethodProto::Binary { name: "__ifloordiv__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberIFloordivProtocol", + proto: "pyo3::class::number::PyNumberIFloordivProtocol", }, MethodProto::Binary { name: "__imod__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberIModProtocol", + proto: "pyo3::class::number::PyNumberIModProtocol", }, MethodProto::Ternary { name: "__ipow__", arg1: "Other", arg2: "Modulo", pyres: false, - proto: "::pyo3::class::number::PyNumberIPowProtocol", + proto: "pyo3::class::number::PyNumberIPowProtocol", }, MethodProto::Binary { name: "__ilshift__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberILShiftProtocol", + proto: "pyo3::class::number::PyNumberILShiftProtocol", }, MethodProto::Binary { name: "__irshift__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberIRShiftProtocol", + proto: "pyo3::class::number::PyNumberIRShiftProtocol", }, MethodProto::Binary { name: "__iand__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberIAndProtocol", + proto: "pyo3::class::number::PyNumberIAndProtocol", }, MethodProto::Binary { name: "__ixor__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberIXorProtocol", + proto: "pyo3::class::number::PyNumberIXorProtocol", }, MethodProto::Binary { name: "__ior__", arg: "Other", pyres: false, - proto: "::pyo3::class::number::PyNumberIOrProtocol", + proto: "pyo3::class::number::PyNumberIOrProtocol", }, MethodProto::Unary { name: "__neg__", pyres: true, - proto: "::pyo3::class::number::PyNumberNegProtocol", + proto: "pyo3::class::number::PyNumberNegProtocol", }, MethodProto::Unary { name: "__pos__", pyres: true, - proto: "::pyo3::class::number::PyNumberPosProtocol", + proto: "pyo3::class::number::PyNumberPosProtocol", }, MethodProto::Unary { name: "__abs__", pyres: true, - proto: "::pyo3::class::number::PyNumberAbsProtocol", + proto: "pyo3::class::number::PyNumberAbsProtocol", }, MethodProto::Unary { name: "__invert__", pyres: true, - proto: "::pyo3::class::number::PyNumberInvertProtocol", + proto: "pyo3::class::number::PyNumberInvertProtocol", }, MethodProto::Unary { name: "__complex__", pyres: true, - proto: "::pyo3::class::number::PyNumberComplexProtocol", + proto: "pyo3::class::number::PyNumberComplexProtocol", }, MethodProto::Unary { name: "__int__", pyres: true, - proto: "::pyo3::class::number::PyNumberIntProtocol", + proto: "pyo3::class::number::PyNumberIntProtocol", }, MethodProto::Unary { name: "__float__", pyres: true, - proto: "::pyo3::class::number::PyNumberFloatProtocol", + proto: "pyo3::class::number::PyNumberFloatProtocol", }, MethodProto::Unary { name: "__round__", pyres: true, - proto: "::pyo3::class::number::PyNumberRoundProtocol", + proto: "pyo3::class::number::PyNumberRoundProtocol", }, MethodProto::Unary { name: "__index__", pyres: true, - proto: "::pyo3::class::number::PyNumberIndexProtocol", + proto: "pyo3::class::number::PyNumberIndexProtocol", }, ], py_methods: &[ PyMethod { name: "__radd__", - proto: "::pyo3::class::number::PyNumberRAddProtocolImpl", + proto: "pyo3::class::number::PyNumberRAddProtocolImpl", }, PyMethod { name: "__rsub__", - proto: "::pyo3::class::number::PyNumberRSubProtocolImpl", + proto: "pyo3::class::number::PyNumberRSubProtocolImpl", }, PyMethod { name: "__rmul__", - proto: "::pyo3::class::number::PyNumberRMulProtocolImpl", + proto: "pyo3::class::number::PyNumberRMulProtocolImpl", }, PyMethod { name: "__rmatmul__", - proto: "::pyo3::class::number::PyNumberRMatmulProtocolImpl", + proto: "pyo3::class::number::PyNumberRMatmulProtocolImpl", }, PyMethod { name: "__rtruediv__", - proto: "::pyo3::class::number::PyNumberRTruedivProtocolImpl", + proto: "pyo3::class::number::PyNumberRTruedivProtocolImpl", }, PyMethod { name: "__rfloordiv__", - proto: "::pyo3::class::number::PyNumberRFloordivProtocolImpl", + proto: "pyo3::class::number::PyNumberRFloordivProtocolImpl", }, PyMethod { name: "__rmod__", - proto: "::pyo3::class::number::PyNumberRModProtocolImpl", + proto: "pyo3::class::number::PyNumberRModProtocolImpl", }, PyMethod { name: "__rdivmod__", - proto: "::pyo3::class::number::PyNumberRDivmodProtocolImpl", + proto: "pyo3::class::number::PyNumberRDivmodProtocolImpl", }, PyMethod { name: "__rpow__", - proto: "::pyo3::class::number::PyNumberRPowProtocolImpl", + proto: "pyo3::class::number::PyNumberRPowProtocolImpl", }, PyMethod { name: "__rlshift__", - proto: "::pyo3::class::number::PyNumberRLShiftProtocolImpl", + proto: "pyo3::class::number::PyNumberRLShiftProtocolImpl", }, PyMethod { name: "__rrshift__", - proto: "::pyo3::class::number::PyNumberRRShiftProtocolImpl", + proto: "pyo3::class::number::PyNumberRRShiftProtocolImpl", }, PyMethod { name: "__rand__", - proto: "::pyo3::class::number::PyNumberRAndProtocolImpl", + proto: "pyo3::class::number::PyNumberRAndProtocolImpl", }, PyMethod { name: "__rxor__", - proto: "::pyo3::class::number::PyNumberRXorProtocolImpl", + proto: "pyo3::class::number::PyNumberRXorProtocolImpl", }, PyMethod { name: "__ror__", - proto: "::pyo3::class::number::PyNumberROrProtocolImpl", + proto: "pyo3::class::number::PyNumberROrProtocolImpl", }, PyMethod { name: "__complex__", - proto: "::pyo3::class::number::PyNumberComplexProtocolImpl", + proto: "pyo3::class::number::PyNumberComplexProtocolImpl", }, PyMethod { name: "__round__", - proto: "::pyo3::class::number::PyNumberRoundProtocolImpl", + proto: "pyo3::class::number::PyNumberRoundProtocolImpl", }, ], }; diff --git a/pyo3-derive-backend/src/module.rs b/pyo3-derive-backend/src/module.rs index cd64de32..b583aaaf 100644 --- a/pyo3-derive-backend/src/module.rs +++ b/pyo3-derive-backend/src/module.rs @@ -21,8 +21,8 @@ pub fn py3_init(fnname: &Ident, name: &Ident, doc: syn::Lit) -> TokenStream { #[allow(non_snake_case)] /// This autogenerated function is called by the python interpreter when importing /// the module. - pub unsafe extern "C" fn #cb_name() -> *mut ::pyo3::ffi::PyObject { - ::pyo3::derive_utils::make_module(concat!(stringify!(#name), "\0"), #doc, #fnname) + pub unsafe extern "C" fn #cb_name() -> *mut pyo3::ffi::PyObject { + pyo3::derive_utils::make_module(concat!(stringify!(#name), "\0"), #doc, #fnname) } } } @@ -34,7 +34,7 @@ pub fn py2_init(fnname: &Ident, name: &Ident, doc: syn::Lit) -> TokenStream { #[no_mangle] #[allow(non_snake_case)] pub unsafe extern "C" fn #cb_name() { - ::pyo3::derive_utils::make_module(concat!(stringify!(#name), "\0"), #doc, #fnname) + pyo3::derive_utils::make_module(concat!(stringify!(#name), "\0"), #doc, #fnname) } } } @@ -190,20 +190,20 @@ pub fn add_fn_to_module( let doc = utils::get_doc(&func.attrs, true); let tokens = quote! { - fn #function_wrapper_ident(py: ::pyo3::Python) -> ::pyo3::PyObject { + fn #function_wrapper_ident(py: pyo3::Python) -> pyo3::PyObject { #wrapper - let _def = ::pyo3::class::PyMethodDef { + let _def = pyo3::class::PyMethodDef { ml_name: stringify!(#python_name), - ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), - ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS, + ml_meth: pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), + ml_flags: pyo3::ffi::METH_VARARGS | pyo3::ffi::METH_KEYWORDS, ml_doc: #doc, }; let function = unsafe { - ::pyo3::PyObject::from_owned_ptr_or_panic( + pyo3::PyObject::from_owned_ptr_or_panic( py, - ::pyo3::ffi::PyCFunction_New( + pyo3::ffi::PyCFunction_New( Box::into_raw(Box::new(_def.as_method_def())), ::std::ptr::null_mut() ) @@ -228,21 +228,21 @@ fn function_c_wrapper(name: &Ident, spec: &method::FnSpec<'_>) -> TokenStream { quote! { unsafe extern "C" fn __wrap( - _slf: *mut ::pyo3::ffi::PyObject, - _args: *mut ::pyo3::ffi::PyObject, - _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject + _slf: *mut pyo3::ffi::PyObject, + _args: *mut pyo3::ffi::PyObject, + _kwargs: *mut pyo3::ffi::PyObject) -> *mut pyo3::ffi::PyObject { const _LOCATION: &'static str = concat!(stringify!(#name), "()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); - let _args = _py.from_borrowed_ptr::<::pyo3::types::PyTuple>(_args); - let _kwargs: Option<&::pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); + let _args = _py.from_borrowed_ptr::(_args); + let _kwargs: Option<&pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); #body - ::pyo3::callback::cb_convert( - ::pyo3::callback::PyObjectCallbackConverter, _py, _result) + pyo3::callback::cb_convert( + pyo3::callback::PyObjectCallbackConverter, _py, _result) } } } diff --git a/pyo3-derive-backend/src/pyclass.rs b/pyo3-derive-backend/src/pyclass.rs index f11d44bf..731da712 100644 --- a/pyo3-derive-backend/src/pyclass.rs +++ b/pyo3-derive-backend/src/pyclass.rs @@ -37,7 +37,7 @@ impl Default for PyClassArgs { // We need the 0 as value for the constant we're later building using quote for when there // are no other flags flags: vec![parse_quote! {0}], - base: parse_quote! {::pyo3::types::PyObjectRef}, + base: parse_quote! {pyo3::types::PyObjectRef}, } } } @@ -110,16 +110,16 @@ impl PyClassArgs { let flag = exp.path.segments.first().unwrap().value().ident.to_string(); let path = match flag.as_str() { "gc" => { - parse_quote! {::pyo3::type_object::PY_TYPE_FLAG_GC} + parse_quote! {pyo3::type_object::PY_TYPE_FLAG_GC} } "weakref" => { - parse_quote! {::pyo3::type_object::PY_TYPE_FLAG_WEAKREF} + parse_quote! {pyo3::type_object::PY_TYPE_FLAG_WEAKREF} } "subclass" => { - parse_quote! {::pyo3::type_object::PY_TYPE_FLAG_BASETYPE} + parse_quote! {pyo3::type_object::PY_TYPE_FLAG_BASETYPE} } "dict" => { - parse_quote! {::pyo3::type_object::PY_TYPE_FLAG_DICT} + parse_quote! {pyo3::type_object::PY_TYPE_FLAG_DICT} } _ => { return Err(syn::Error::new_spanned( @@ -204,26 +204,26 @@ fn impl_inventory(cls: &syn::Ident) -> TokenStream { quote! { #[doc(hidden)] pub struct #inventory_cls { - methods: &'static [::pyo3::class::PyMethodDefType], + methods: &'static [pyo3::class::PyMethodDefType], } - impl ::pyo3::class::methods::PyMethodsInventory for #inventory_cls { - fn new(methods: &'static [::pyo3::class::PyMethodDefType]) -> Self { + impl pyo3::class::methods::PyMethodsInventory for #inventory_cls { + fn new(methods: &'static [pyo3::class::PyMethodDefType]) -> Self { Self { methods } } - fn get_methods(&self) -> &'static [::pyo3::class::PyMethodDefType] { + fn get_methods(&self) -> &'static [pyo3::class::PyMethodDefType] { self.methods } } - impl ::pyo3::class::methods::PyMethodsInventoryDispatch for #cls { + impl pyo3::class::methods::PyMethodsInventoryDispatch for #cls { type InventoryType = #inventory_cls; } - ::pyo3::inventory::collect!(#inventory_cls); + pyo3::inventory::collect!(#inventory_cls); } } @@ -241,16 +241,16 @@ fn impl_class( let extra = { if let Some(freelist) = &attr.freelist { quote! { - impl ::pyo3::freelist::PyObjectWithFreeList for #cls { + impl pyo3::freelist::PyObjectWithFreeList for #cls { #[inline] - 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 _; + 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 _; unsafe { if FREELIST.is_null() { FREELIST = Box::into_raw(Box::new( - ::pyo3::freelist::FreeList::with_capacity(#freelist))); + pyo3::freelist::FreeList::with_capacity(#freelist))); - <#cls as ::pyo3::type_object::PyTypeObject>::init_type(); + <#cls as pyo3::type_object::PyTypeObject>::init_type(); } &mut *FREELIST } @@ -259,7 +259,7 @@ fn impl_class( } } else { quote! { - impl ::pyo3::type_object::PyObjectAlloc for #cls {} + impl pyo3::type_object::PyObjectAlloc for #cls {} } } }; @@ -280,20 +280,20 @@ fn impl_class( let mut has_dict = false; for f in attr.flags.iter() { if let syn::Expr::Path(ref epath) = f { - if epath.path == parse_quote! {::pyo3::type_object::PY_TYPE_FLAG_WEAKREF} { + if epath.path == parse_quote! {pyo3::type_object::PY_TYPE_FLAG_WEAKREF} { has_weakref = true; - } else if epath.path == parse_quote! {::pyo3::type_object::PY_TYPE_FLAG_DICT} { + } else if epath.path == parse_quote! {pyo3::type_object::PY_TYPE_FLAG_DICT} { has_dict = true; } } } let weakref = if has_weakref { - quote! {std::mem::size_of::<*const ::pyo3::ffi::PyObject>()} + quote! {std::mem::size_of::<*const pyo3::ffi::PyObject>()} } else { quote! {0} }; let dict = if has_dict { - quote! {std::mem::size_of::<*const ::pyo3::ffi::PyObject>()} + quote! {std::mem::size_of::<*const pyo3::ffi::PyObject>()} } else { quote! {0} }; @@ -304,7 +304,7 @@ fn impl_class( let flags = &attr.flags; quote! { - impl ::pyo3::type_object::PyTypeInfo for #cls { + impl pyo3::type_object::PyTypeInfo for #cls { type Type = #cls; type BaseType = #base; @@ -319,22 +319,22 @@ fn impl_class( const OFFSET: isize = { // round base_size up to next multiple of align ( - (<#base as ::pyo3::type_object::PyTypeInfo>::SIZE + + (<#base as pyo3::type_object::PyTypeInfo>::SIZE + ::std::mem::align_of::<#cls>() - 1) / ::std::mem::align_of::<#cls>() * ::std::mem::align_of::<#cls>() ) as isize }; #[inline] - unsafe fn type_object() -> &'static mut ::pyo3::ffi::PyTypeObject { - static mut TYPE_OBJECT: ::pyo3::ffi::PyTypeObject = ::pyo3::ffi::PyTypeObject_INIT; + unsafe fn type_object() -> &'static mut pyo3::ffi::PyTypeObject { + static mut TYPE_OBJECT: pyo3::ffi::PyTypeObject = pyo3::ffi::PyTypeObject_INIT; &mut TYPE_OBJECT } } - impl ::pyo3::IntoPyObject for #cls { - fn into_object(self, py: ::pyo3::Python) -> ::pyo3::PyObject { - ::pyo3::Py::new(py, self).unwrap().into_object(py) + impl pyo3::IntoPyObject for #cls { + fn into_object(self, py: pyo3::Python) -> pyo3::PyObject { + pyo3::Py::new(py, self).unwrap().into_object(py) } } @@ -356,7 +356,7 @@ fn impl_descriptors(cls: &syn::Type, descriptors: Vec<(syn::Field, Vec)> FnType::Getter(_) => { quote! { impl #cls { - fn #name(&self) -> ::pyo3::PyResult<#field_ty> { + fn #name(&self) -> pyo3::PyResult<#field_ty> { Ok(self.#name.clone()) } } @@ -367,7 +367,7 @@ fn impl_descriptors(cls: &syn::Type, descriptors: Vec<(syn::Field, Vec)> syn::Ident::new(&format!("set_{}", name), Span::call_site()); quote! { 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; Ok(()) } @@ -430,10 +430,10 @@ fn impl_descriptors(cls: &syn::Type, descriptors: Vec<(syn::Field, Vec)> quote! { #(#methods)* - ::pyo3::inventory::submit! { + pyo3::inventory::submit! { #![crate = pyo3] { - type ClsInventory = <#cls as ::pyo3::class::methods::PyMethodsInventoryDispatch>::InventoryType; - ::new(&[#(#py_methods),*]) + type ClsInventory = <#cls as pyo3::class::methods::PyMethodsInventoryDispatch>::InventoryType; + ::new(&[#(#py_methods),*]) } } } diff --git a/pyo3-derive-backend/src/pyimpl.rs b/pyo3-derive-backend/src/pyimpl.rs index 2ca3bf91..431c0744 100644 --- a/pyo3-derive-backend/src/pyimpl.rs +++ b/pyo3-derive-backend/src/pyimpl.rs @@ -36,10 +36,10 @@ pub fn impl_methods(ty: &syn::Type, impls: &mut Vec) -> TokenStre } quote! { - ::pyo3::inventory::submit! { + pyo3::inventory::submit! { #![crate = pyo3] { - type TyInventory = <#ty as ::pyo3::class::methods::PyMethodsInventoryDispatch>::InventoryType; - ::new(&[#(#methods),*]) + type TyInventory = <#ty as pyo3::class::methods::PyMethodsInventoryDispatch>::InventoryType; + ::new(&[#(#methods),*]) } } } diff --git a/pyo3-derive-backend/src/pymethod.rs b/pyo3-derive-backend/src/pymethod.rs index 76bd4eec..010e0c0e 100644 --- a/pyo3-derive-backend/src/pymethod.rs +++ b/pyo3-derive-backend/src/pymethod.rs @@ -52,21 +52,21 @@ pub fn impl_wrap( if spec.args.is_empty() && noargs { quote! { 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!( stringify!(#cls), ".", stringify!(#name), "()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf); let _result = { - ::pyo3::derive_utils::IntoPyResult::into_py_result(#body) + pyo3::derive_utils::IntoPyResult::into_py_result(#body) }; - ::pyo3::callback::cb_convert( - ::pyo3::callback::PyObjectCallbackConverter, _py, _result) + pyo3::callback::cb_convert( + pyo3::callback::PyObjectCallbackConverter, _py, _result) } } } else { @@ -74,22 +74,22 @@ pub fn impl_wrap( quote! { unsafe extern "C" fn __wrap( - _slf: *mut ::pyo3::ffi::PyObject, - _args: *mut ::pyo3::ffi::PyObject, - _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject + _slf: *mut pyo3::ffi::PyObject, + _args: *mut pyo3::ffi::PyObject, + _kwargs: *mut pyo3::ffi::PyObject) -> *mut pyo3::ffi::PyObject { const _LOCATION: &'static str = concat!( stringify!(#cls), ".", stringify!(#name), "()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); 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); + let _args = _py.from_borrowed_ptr::(_args); + let _kwargs: Option<&pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); #body - ::pyo3::callback::cb_convert( - ::pyo3::callback::PyObjectCallbackConverter, _py, _result) + pyo3::callback::cb_convert( + pyo3::callback::PyObjectCallbackConverter, _py, _result) } } } @@ -103,21 +103,21 @@ pub fn impl_proto_wrap(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) -> quote! { #[allow(unused_mut)] unsafe extern "C" fn __wrap( - _slf: *mut ::pyo3::ffi::PyObject, - _args: *mut ::pyo3::ffi::PyObject, - _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject + _slf: *mut pyo3::ffi::PyObject, + _args: *mut pyo3::ffi::PyObject, + _kwargs: *mut pyo3::ffi::PyObject) -> *mut pyo3::ffi::PyObject { const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); 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); + let _args = _py.from_borrowed_ptr::(_args); + let _kwargs: Option<&pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); #body - ::pyo3::callback::cb_convert( - ::pyo3::callback::PyObjectCallbackConverter, _py, _result) + pyo3::callback::cb_convert( + pyo3::callback::PyObjectCallbackConverter, _py, _result) } } } @@ -132,24 +132,24 @@ pub fn impl_wrap_new(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) -> T quote! { #[allow(unused_mut)] unsafe extern "C" fn __wrap( - _cls: *mut ::pyo3::ffi::PyTypeObject, - _args: *mut ::pyo3::ffi::PyObject, - _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject + _cls: *mut pyo3::ffi::PyTypeObject, + _args: *mut pyo3::ffi::PyObject, + _kwargs: *mut pyo3::ffi::PyObject) -> *mut pyo3::ffi::PyObject { - use ::pyo3::type_object::PyTypeInfo; + use pyo3::type_object::PyTypeInfo; const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); - match ::pyo3::type_object::PyRawObject::new(_py, #cls::type_object(), _cls) { + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); + match pyo3::type_object::PyRawObject::new(_py, #cls::type_object(), _cls) { Ok(_obj) => { - let _args = _py.from_borrowed_ptr::<::pyo3::types::PyTuple>(_args); - let _kwargs: Option<&::pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); + let _args = _py.from_borrowed_ptr::(_args); + let _kwargs: Option<&pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); #body match _result { - Ok(_) => ::pyo3::IntoPyPointer::into_ptr(_obj), + Ok(_) => pyo3::IntoPyPointer::into_ptr(_obj), Err(e) => { e.restore(_py); ::std::ptr::null_mut() @@ -180,16 +180,16 @@ fn impl_wrap_init(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) -> Toke quote! { #[allow(unused_mut)] unsafe extern "C" fn __wrap( - _slf: *mut ::pyo3::ffi::PyObject, - _args: *mut ::pyo3::ffi::PyObject, - _kwargs: *mut ::pyo3::ffi::PyObject) -> libc::c_int + _slf: *mut pyo3::ffi::PyObject, + _args: *mut pyo3::ffi::PyObject, + _kwargs: *mut pyo3::ffi::PyObject) -> libc::c_int { const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); 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); + let _args = _py.from_borrowed_ptr::(_args); + let _kwargs: Option<&pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); #body @@ -214,21 +214,21 @@ pub fn impl_wrap_class(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) -> quote! { #[allow(unused_mut)] unsafe extern "C" fn __wrap( - _cls: *mut ::pyo3::ffi::PyObject, - _args: *mut ::pyo3::ffi::PyObject, - _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject + _cls: *mut pyo3::ffi::PyObject, + _args: *mut pyo3::ffi::PyObject, + _kwargs: *mut pyo3::ffi::PyObject) -> *mut pyo3::ffi::PyObject { const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); - let _cls = ::pyo3::types::PyType::from_type_ptr(_py, _cls as *mut ::pyo3::ffi::PyTypeObject); - let _args = _py.from_borrowed_ptr::<::pyo3::types::PyTuple>(_args); - let _kwargs: Option<&::pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); + let _cls = pyo3::types::PyType::from_type_ptr(_py, _cls as *mut pyo3::ffi::PyTypeObject); + let _args = _py.from_borrowed_ptr::(_args); + let _kwargs: Option<&pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); #body - ::pyo3::callback::cb_convert( - ::pyo3::callback::PyObjectCallbackConverter, _py, _result) + pyo3::callback::cb_convert( + pyo3::callback::PyObjectCallbackConverter, _py, _result) } } } @@ -243,20 +243,20 @@ pub fn impl_wrap_static(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) - quote! { #[allow(unused_mut)] unsafe extern "C" fn __wrap( - _slf: *mut ::pyo3::ffi::PyObject, - _args: *mut ::pyo3::ffi::PyObject, - _kwargs: *mut ::pyo3::ffi::PyObject) -> *mut ::pyo3::ffi::PyObject + _slf: *mut pyo3::ffi::PyObject, + _args: *mut pyo3::ffi::PyObject, + _kwargs: *mut pyo3::ffi::PyObject) -> *mut pyo3::ffi::PyObject { const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); - let _args = _py.from_borrowed_ptr::<::pyo3::types::PyTuple>(_args); - let _kwargs: Option<&::pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); + let _args = _py.from_borrowed_ptr::(_args); + let _kwargs: Option<&pyo3::types::PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs); #body - ::pyo3::callback::cb_convert( - ::pyo3::callback::PyObjectCallbackConverter, _py, _result) + pyo3::callback::cb_convert( + pyo3::callback::PyObjectCallbackConverter, _py, _result) } } } @@ -265,17 +265,17 @@ pub fn impl_wrap_static(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) - pub(crate) fn impl_wrap_getter(cls: &syn::Type, name: &syn::Ident) -> TokenStream { quote! { unsafe extern "C" fn __wrap( - _slf: *mut ::pyo3::ffi::PyObject, _: *mut ::std::os::raw::c_void) -> *mut ::pyo3::ffi::PyObject + _slf: *mut pyo3::ffi::PyObject, _: *mut ::std::os::raw::c_void) -> *mut pyo3::ffi::PyObject { const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf); match _slf.#name() { Ok(val) => { - ::pyo3::IntoPyPointer::into_ptr(val.into_object(_py)) + pyo3::IntoPyPointer::into_ptr(val.into_object(_py)) } Err(e) => { e.restore(_py); @@ -304,16 +304,16 @@ pub(crate) fn impl_wrap_setter( quote! { #[allow(unused_mut)] unsafe extern "C" fn __wrap( - _slf: *mut ::pyo3::ffi::PyObject, - _value: *mut ::pyo3::ffi::PyObject, _: *mut ::std::os::raw::c_void) -> libc::c_int + _slf: *mut pyo3::ffi::PyObject, + _value: *mut pyo3::ffi::PyObject, _: *mut ::std::os::raw::c_void) -> libc::c_int { const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()"); - let _pool = ::pyo3::GILPool::new(); - let _py = ::pyo3::Python::assume_gil_acquired(); + let _pool = pyo3::GILPool::new(); + let _py = pyo3::Python::assume_gil_acquired(); let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf); 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), Err(e) => Err(e) }; @@ -355,7 +355,7 @@ pub fn impl_arg_params(spec: &FnSpec<'_>, body: TokenStream) -> TokenStream { if spec.args.is_empty() { return quote! { let _result = { - ::pyo3::derive_utils::IntoPyResult::into_py_result(#body) + pyo3::derive_utils::IntoPyResult::into_py_result(#body) }; }; } @@ -371,7 +371,7 @@ pub fn impl_arg_params(spec: &FnSpec<'_>, body: TokenStream) -> TokenStream { let opt = bool_to_ident(arg.optional.is_some() || spec.default_value(&arg.name).is_some()); params.push(quote! { - ::pyo3::derive_utils::ParamDescription { + pyo3::derive_utils::ParamDescription { name: stringify!(#name), is_optional: #opt, kw_only: #kwonly @@ -394,8 +394,8 @@ pub fn impl_arg_params(spec: &FnSpec<'_>, body: TokenStream) -> TokenStream { // create array of arguments, and then parse quote! { - use ::pyo3::ObjectProtocol; - const PARAMS: &'static [::pyo3::derive_utils::ParamDescription] = &[ + use pyo3::ObjectProtocol; + const PARAMS: &'static [pyo3::derive_utils::ParamDescription] = &[ #(#params),* ]; @@ -403,7 +403,7 @@ pub fn impl_arg_params(spec: &FnSpec<'_>, body: TokenStream) -> TokenStream { // Workaround to use the question mark operator without rewriting everything let _result = (|| { - ::pyo3::derive_utils::parse_fn_args( + pyo3::derive_utils::parse_fn_args( Some(_LOCATION), PARAMS, &_args, @@ -415,7 +415,7 @@ pub fn impl_arg_params(spec: &FnSpec<'_>, body: TokenStream) -> TokenStream { #(#param_conversion)* - ::pyo3::derive_utils::IntoPyResult::into_py_result(#body) + pyo3::derive_utils::IntoPyResult::into_py_result(#body) })(); } } @@ -443,7 +443,7 @@ fn impl_arg_param( if spec.is_args(&name) { quote! { - let #arg_name = <#ty as ::pyo3::FromPyObject>::extract(_args.as_ref())?; + let #arg_name = <#ty as pyo3::FromPyObject>::extract(_args.as_ref())?; } } else if spec.is_kwargs(&name) { quote! { @@ -496,26 +496,26 @@ pub fn impl_py_method_def( ) -> TokenStream { if spec.args.is_empty() { quote! { - ::pyo3::class::PyMethodDefType::Method({ + pyo3::class::PyMethodDefType::Method({ #wrapper - ::pyo3::class::PyMethodDef { + pyo3::class::PyMethodDef { ml_name: stringify!(#name), - ml_meth: ::pyo3::class::PyMethodType::PyNoArgsFunction(__wrap), - ml_flags: ::pyo3::ffi::METH_NOARGS, + ml_meth: pyo3::class::PyMethodType::PyNoArgsFunction(__wrap), + ml_flags: pyo3::ffi::METH_NOARGS, ml_doc: #doc, } }) } } else { quote! { - ::pyo3::class::PyMethodDefType::Method({ + pyo3::class::PyMethodDefType::Method({ #wrapper - ::pyo3::class::PyMethodDef { + pyo3::class::PyMethodDef { ml_name: stringify!(#name), - ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), - ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS, + ml_meth: pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), + ml_flags: pyo3::ffi::METH_VARARGS | pyo3::ffi::METH_KEYWORDS, ml_doc: #doc, } }) @@ -529,13 +529,13 @@ pub fn impl_py_method_def_new( wrapper: &TokenStream, ) -> TokenStream { quote! { - ::pyo3::class::PyMethodDefType::New({ + pyo3::class::PyMethodDefType::New({ #wrapper - ::pyo3::class::PyMethodDef { + pyo3::class::PyMethodDef { ml_name: stringify!(#name), - ml_meth: ::pyo3::class::PyMethodType::PyNewFunc(__wrap), - ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS, + ml_meth: pyo3::class::PyMethodType::PyNewFunc(__wrap), + ml_flags: pyo3::ffi::METH_VARARGS | pyo3::ffi::METH_KEYWORDS, ml_doc: #doc, } }) @@ -548,13 +548,13 @@ pub fn impl_py_method_def_init( wrapper: &TokenStream, ) -> TokenStream { quote! { - ::pyo3::class::PyMethodDefType::Init({ + pyo3::class::PyMethodDefType::Init({ #wrapper - ::pyo3::class::PyMethodDef { + pyo3::class::PyMethodDef { ml_name: stringify!(#name), - ml_meth: ::pyo3::class::PyMethodType::PyInitFunc(__wrap), - ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS, + ml_meth: pyo3::class::PyMethodType::PyInitFunc(__wrap), + ml_flags: pyo3::ffi::METH_VARARGS | pyo3::ffi::METH_KEYWORDS, ml_doc: #doc, } }) @@ -567,14 +567,14 @@ pub fn impl_py_method_def_class( wrapper: &TokenStream, ) -> TokenStream { quote! { - ::pyo3::class::PyMethodDefType::Class({ + pyo3::class::PyMethodDefType::Class({ #wrapper - ::pyo3::class::PyMethodDef { + pyo3::class::PyMethodDef { ml_name: stringify!(#name), - ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), - ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS | - ::pyo3::ffi::METH_CLASS, + ml_meth: pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), + ml_flags: pyo3::ffi::METH_VARARGS | pyo3::ffi::METH_KEYWORDS | + pyo3::ffi::METH_CLASS, ml_doc: #doc, } }) @@ -587,13 +587,13 @@ pub fn impl_py_method_def_static( wrapper: &TokenStream, ) -> TokenStream { quote! { - ::pyo3::class::PyMethodDefType::Static({ + pyo3::class::PyMethodDefType::Static({ #wrapper - ::pyo3::class::PyMethodDef { + pyo3::class::PyMethodDef { ml_name: stringify!(#name), - ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), - ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS | ::pyo3::ffi::METH_STATIC, + ml_meth: pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), + ml_flags: pyo3::ffi::METH_VARARGS | pyo3::ffi::METH_KEYWORDS | pyo3::ffi::METH_STATIC, ml_doc: #doc, } }) @@ -606,13 +606,13 @@ pub fn impl_py_method_def_call( wrapper: &TokenStream, ) -> TokenStream { quote! { - ::pyo3::class::PyMethodDefType::Call({ + pyo3::class::PyMethodDefType::Call({ #wrapper - ::pyo3::class::PyMethodDef { + pyo3::class::PyMethodDef { ml_name: stringify!(#name), - ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), - ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS, + ml_meth: pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), + ml_flags: pyo3::ffi::METH_VARARGS | pyo3::ffi::METH_KEYWORDS, ml_doc: #doc, } }) @@ -637,10 +637,10 @@ pub(crate) fn impl_py_setter_def( }; quote! { - ::pyo3::class::PyMethodDefType::Setter({ + pyo3::class::PyMethodDefType::Setter({ #wrapper - ::pyo3::class::PySetterDef { + pyo3::class::PySetterDef { name: #n, meth: __wrap, doc: #doc, @@ -667,10 +667,10 @@ pub(crate) fn impl_py_getter_def( }; quote! { - ::pyo3::class::PyMethodDefType::Getter({ + pyo3::class::PyMethodDefType::Getter({ #wrapper - ::pyo3::class::PyGetterDef { + pyo3::class::PyGetterDef { name: #n, meth: __wrap, doc: #doc, diff --git a/pyo3-derive-backend/src/pyproto.rs b/pyo3-derive-backend/src/pyproto.rs index a551341f..b74bc26c 100644 --- a/pyo3-derive-backend/src/pyproto.rs +++ b/pyo3-derive-backend/src/pyproto.rs @@ -84,13 +84,13 @@ fn impl_proto_impl( impl #proto for #ty { #[inline] - fn #name() -> Option<::pyo3::class::methods::PyMethodDef> { + fn #name() -> Option { #meth - Some(::pyo3::class::PyMethodDef { + Some(pyo3::class::PyMethodDef { ml_name: stringify!(#name), - ml_meth: ::pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), - ml_flags: ::pyo3::ffi::METH_VARARGS | ::pyo3::ffi::METH_KEYWORDS, + ml_meth: pyo3::class::PyMethodType::PyCFunctionWithKeywords(__wrap), + ml_flags: pyo3::ffi::METH_VARARGS | pyo3::ffi::METH_KEYWORDS, ml_doc: "" }) }