Skip to content

Commit 6627658

Browse files
committed
Renew proc-macros for new #[pyproto] backend
1 parent eb8ff15 commit 6627658

File tree

11 files changed

+279
-311
lines changed

11 files changed

+279
-311
lines changed

guide/src/class.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -772,13 +772,23 @@ impl pyo3::class::methods::HasMethodsInventory for MyClass {
772772
}
773773
pyo3::inventory::collect!(Pyo3MethodsInventoryForMyClass);
774774

775-
impl pyo3::class::proto_methods::HasProtoRegistry for MyClass {
776-
fn registry() -> &'static pyo3::class::proto_methods::PyProtoRegistry {
777-
static REGISTRY: pyo3::class::proto_methods::PyProtoRegistry
778-
= pyo3::class::proto_methods::PyProtoRegistry::new();
779-
&REGISTRY
775+
776+
pub struct Pyo3ProtoInventoryForMyClass {
777+
def: pyo3::class::proto_methods::PyProtoMethodDef,
778+
}
779+
impl pyo3::class::proto_methods::PyProtoInventory for Pyo3ProtoInventoryForMyClass {
780+
fn new(def: pyo3::class::proto_methods::PyProtoMethodDef) -> Self {
781+
Self { def }
782+
}
783+
fn get(&'static self) -> &'static pyo3::class::proto_methods::PyProtoMethodDef {
784+
&self.def
780785
}
781786
}
787+
impl pyo3::class::proto_methods::HasProtoInventory for MyClass {
788+
type ProtoMethods = Pyo3ProtoInventoryForMyClass;
789+
}
790+
pyo3::inventory::collect!(Pyo3ProtoInventoryForMyClass);
791+
782792

783793
impl pyo3::pyclass::PyClassSend for MyClass {
784794
type ThreadChecker = pyo3::pyclass::ThreadCheckerStub<MyClass>;

0 commit comments

Comments
 (0)