@@ -511,11 +511,11 @@ fn unit_variants_as_descriptors<'a>(
511
511
. map ( |var| gen_py_const ( & cls_type, & variant_to_attribute ( var) ) ) ;
512
512
513
513
quote ! {
514
- impl _pyo3:: class :: impl_ :: PyClassDescriptors <#cls>
515
- for _pyo3:: class :: impl_ :: PyClassImplCollector <#cls>
514
+ impl _pyo3:: impl_ :: pyclass :: PyClassDescriptors <#cls>
515
+ for _pyo3:: impl_ :: pyclass :: PyClassImplCollector <#cls>
516
516
{
517
- fn py_class_descriptors( self ) -> & ' static [ _pyo3:: class :: methods :: PyMethodDefType ] {
518
- static METHODS : & [ _pyo3:: class :: methods :: PyMethodDefType ] = & [ #( #py_methods) , * ] ;
517
+ fn py_class_descriptors( self ) -> & ' static [ _pyo3:: impl_ :: pymethods :: PyMethodDefType ] {
518
+ static METHODS : & [ _pyo3:: impl_ :: pymethods :: PyMethodDefType ] = & [ #( #py_methods) , * ] ;
519
519
METHODS
520
520
}
521
521
}
@@ -574,11 +574,11 @@ fn impl_descriptors(
574
574
. collect :: < syn:: Result < _ > > ( ) ?;
575
575
576
576
Ok ( quote ! {
577
- impl _pyo3:: class :: impl_ :: PyClassDescriptors <#cls>
578
- for _pyo3:: class :: impl_ :: PyClassImplCollector <#cls>
577
+ impl _pyo3:: impl_ :: pyclass :: PyClassDescriptors <#cls>
578
+ for _pyo3:: impl_ :: pyclass :: PyClassImplCollector <#cls>
579
579
{
580
- fn py_class_descriptors( self ) -> & ' static [ _pyo3:: class :: methods :: PyMethodDefType ] {
581
- static METHODS : & [ _pyo3:: class :: methods :: PyMethodDefType ] = & [ #( #py_methods) , * ] ;
580
+ fn py_class_descriptors( self ) -> & ' static [ _pyo3:: impl_ :: pymethods :: PyMethodDefType ] {
581
+ static METHODS : & [ _pyo3:: impl_ :: pymethods :: PyMethodDefType ] = & [ #( #py_methods) , * ] ;
582
582
METHODS
583
583
}
584
584
}
@@ -676,7 +676,7 @@ impl<'a> PyClassImplsBuilder<'a> {
676
676
} ;
677
677
678
678
let base_nativetype = if attr. has_extends {
679
- quote ! { <Self :: BaseType as _pyo3:: class :: impl_ :: PyClassBaseType >:: BaseNativeType }
679
+ quote ! { <Self :: BaseType as _pyo3:: impl_ :: pyclass :: PyClassBaseType >:: BaseNativeType }
680
680
} else {
681
681
quote ! { _pyo3:: PyAny }
682
682
} ;
@@ -749,13 +749,13 @@ impl<'a> PyClassImplsBuilder<'a> {
749
749
} ;
750
750
751
751
let thread_checker = if self . attr . has_unsendable {
752
- quote ! { _pyo3:: class :: impl_ :: ThreadCheckerImpl <#cls> }
752
+ quote ! { _pyo3:: impl_ :: pyclass :: ThreadCheckerImpl <#cls> }
753
753
} else if self . attr . has_extends {
754
754
quote ! {
755
- _pyo3:: class :: impl_ :: ThreadCheckerInherited <#cls, <#cls as _pyo3:: class :: impl_ :: PyClassImpl >:: BaseType >
755
+ _pyo3:: impl_ :: pyclass :: ThreadCheckerInherited <#cls, <#cls as _pyo3:: impl_ :: pyclass :: PyClassImpl >:: BaseType >
756
756
}
757
757
} else {
758
- quote ! { _pyo3:: class :: impl_ :: ThreadCheckerStub <#cls> }
758
+ quote ! { _pyo3:: impl_ :: pyclass :: ThreadCheckerStub <#cls> }
759
759
} ;
760
760
761
761
let ( for_each_py_method, methods_protos, inventory, inventory_class) = match self
@@ -775,22 +775,51 @@ impl<'a> PyClassImplsBuilder<'a> {
775
775
) ;
776
776
(
777
777
quote ! {
778
- for inventory in _pyo3:: inventory:: iter:: <<Self as _pyo3:: class :: impl_ :: PyClassImpl >:: Inventory >( ) {
779
- visitor( _pyo3:: class :: impl_ :: PyClassInventory :: methods( inventory) ) ;
778
+ for inventory in _pyo3:: inventory:: iter:: <<Self as _pyo3:: impl_ :: pyclass :: PyClassImpl >:: Inventory >( ) {
779
+ visitor( _pyo3:: impl_ :: pyclass :: PyClassInventory :: methods( inventory) ) ;
780
780
}
781
781
} ,
782
782
quote ! {
783
- for inventory in _pyo3:: inventory:: iter:: <<Self as _pyo3:: class :: impl_ :: PyClassImpl >:: Inventory >( ) {
784
- visitor( _pyo3:: class :: impl_ :: PyClassInventory :: slots( inventory) ) ;
783
+ for inventory in _pyo3:: inventory:: iter:: <<Self as _pyo3:: impl_ :: pyclass :: PyClassImpl >:: Inventory >( ) {
784
+ visitor( _pyo3:: impl_ :: pyclass :: PyClassInventory :: slots( inventory) ) ;
785
785
}
786
786
} ,
787
787
Some ( quote ! { type Inventory = #inventory_class_name; } ) ,
788
788
Some ( define_inventory_class ( & inventory_class_name) ) ,
789
789
)
790
790
}
791
791
} ;
792
+
793
+ let pyproto_method_visitors = if cfg ! ( feature = "pyproto" ) {
794
+ Some ( quote ! {
795
+ visitor( collector. object_protocol_methods( ) ) ;
796
+ visitor( collector. async_protocol_methods( ) ) ;
797
+ visitor( collector. descr_protocol_methods( ) ) ;
798
+ visitor( collector. mapping_protocol_methods( ) ) ;
799
+ visitor( collector. number_protocol_methods( ) ) ;
800
+ } )
801
+ } else {
802
+ None
803
+ } ;
804
+
805
+ let pyproto_proto_visitors = if cfg ! ( feature = "pyproto" ) {
806
+ Some ( quote ! {
807
+ visitor( collector. object_protocol_slots( ) ) ;
808
+ visitor( collector. number_protocol_slots( ) ) ;
809
+ visitor( collector. iter_protocol_slots( ) ) ;
810
+ visitor( collector. gc_protocol_slots( ) ) ;
811
+ visitor( collector. descr_protocol_slots( ) ) ;
812
+ visitor( collector. mapping_protocol_slots( ) ) ;
813
+ visitor( collector. sequence_protocol_slots( ) ) ;
814
+ visitor( collector. async_protocol_slots( ) ) ;
815
+ visitor( collector. buffer_protocol_slots( ) ) ;
816
+ } )
817
+ } else {
818
+ None
819
+ } ;
820
+
792
821
quote ! {
793
- impl _pyo3:: class :: impl_ :: PyClassImpl for #cls {
822
+ impl _pyo3:: impl_ :: pyclass :: PyClassImpl for #cls {
794
823
const DOC : & ' static str = #doc;
795
824
const IS_GC : bool = #is_gc;
796
825
const IS_BASETYPE : bool = #is_basetype;
@@ -802,48 +831,36 @@ impl<'a> PyClassImplsBuilder<'a> {
802
831
#inventory
803
832
804
833
fn for_each_method_def( visitor: & mut dyn :: std:: ops:: FnMut ( & [ _pyo3:: class:: PyMethodDefType ] ) ) {
805
- use _pyo3:: class :: impl_ :: * ;
834
+ use _pyo3:: impl_ :: pyclass :: * ;
806
835
let collector = PyClassImplCollector :: <Self >:: new( ) ;
807
836
#for_each_py_method;
808
837
visitor( collector. py_class_descriptors( ) ) ;
809
- visitor( collector. object_protocol_methods( ) ) ;
810
- visitor( collector. async_protocol_methods( ) ) ;
811
- visitor( collector. descr_protocol_methods( ) ) ;
812
- visitor( collector. mapping_protocol_methods( ) ) ;
813
- visitor( collector. number_protocol_methods( ) ) ;
838
+ #pyproto_method_visitors
814
839
}
815
840
fn get_new( ) -> :: std:: option:: Option <_pyo3:: ffi:: newfunc> {
816
- use _pyo3:: class :: impl_ :: * ;
841
+ use _pyo3:: impl_ :: pyclass :: * ;
817
842
let collector = PyClassImplCollector :: <Self >:: new( ) ;
818
843
collector. new_impl( )
819
844
}
820
845
fn get_alloc( ) -> :: std:: option:: Option <_pyo3:: ffi:: allocfunc> {
821
- use _pyo3:: class :: impl_ :: * ;
846
+ use _pyo3:: impl_ :: pyclass :: * ;
822
847
let collector = PyClassImplCollector :: <Self >:: new( ) ;
823
848
collector. alloc_impl( )
824
849
}
825
850
fn get_free( ) -> :: std:: option:: Option <_pyo3:: ffi:: freefunc> {
826
- use _pyo3:: class :: impl_ :: * ;
851
+ use _pyo3:: impl_ :: pyclass :: * ;
827
852
let collector = PyClassImplCollector :: <Self >:: new( ) ;
828
853
collector. free_impl( )
829
854
}
830
855
831
856
fn for_each_proto_slot( visitor: & mut dyn :: std:: ops:: FnMut ( & [ _pyo3:: ffi:: PyType_Slot ] ) ) {
832
857
// Implementation which uses dtolnay specialization to load all slots.
833
- use _pyo3:: class :: impl_ :: * ;
858
+ use _pyo3:: impl_ :: pyclass :: * ;
834
859
let collector = PyClassImplCollector :: <Self >:: new( ) ;
835
860
// This depends on Python implementation detail;
836
861
// an old slot entry will be overriden by newer ones.
837
862
visitor( collector. py_class_default_slots( ) ) ;
838
- visitor( collector. object_protocol_slots( ) ) ;
839
- visitor( collector. number_protocol_slots( ) ) ;
840
- visitor( collector. iter_protocol_slots( ) ) ;
841
- visitor( collector. gc_protocol_slots( ) ) ;
842
- visitor( collector. descr_protocol_slots( ) ) ;
843
- visitor( collector. mapping_protocol_slots( ) ) ;
844
- visitor( collector. sequence_protocol_slots( ) ) ;
845
- visitor( collector. async_protocol_slots( ) ) ;
846
- visitor( collector. buffer_protocol_slots( ) ) ;
863
+ #pyproto_proto_visitors
847
864
#methods_protos
848
865
}
849
866
@@ -861,7 +878,7 @@ impl<'a> PyClassImplsBuilder<'a> {
861
878
862
879
self . attr . freelist . as_ref ( ) . map_or ( quote ! { } , |freelist| {
863
880
quote ! {
864
- impl _pyo3:: class :: impl_ :: PyClassWithFreeList for #cls {
881
+ impl _pyo3:: impl_ :: pyclass :: PyClassWithFreeList for #cls {
865
882
#[ inline]
866
883
fn get_free_list( _py: _pyo3:: Python <' _>) -> & mut _pyo3:: impl_:: freelist:: FreeList <* mut _pyo3:: ffi:: PyObject > {
867
884
static mut FREELIST : * mut _pyo3:: impl_:: freelist:: FreeList <* mut _pyo3:: ffi:: PyObject > = 0 as * mut _;
@@ -875,17 +892,17 @@ impl<'a> PyClassImplsBuilder<'a> {
875
892
}
876
893
}
877
894
878
- impl _pyo3:: class :: impl_ :: PyClassAllocImpl <#cls> for _pyo3:: class :: impl_ :: PyClassImplCollector <#cls> {
895
+ impl _pyo3:: impl_ :: pyclass :: PyClassAllocImpl <#cls> for _pyo3:: impl_ :: pyclass :: PyClassImplCollector <#cls> {
879
896
#[ inline]
880
897
fn alloc_impl( self ) -> :: std:: option:: Option <_pyo3:: ffi:: allocfunc> {
881
- :: std:: option:: Option :: Some ( _pyo3:: class :: impl_ :: alloc_with_freelist:: <#cls>)
898
+ :: std:: option:: Option :: Some ( _pyo3:: impl_ :: pyclass :: alloc_with_freelist:: <#cls>)
882
899
}
883
900
}
884
901
885
- impl _pyo3:: class :: impl_ :: PyClassFreeImpl <#cls> for _pyo3:: class :: impl_ :: PyClassImplCollector <#cls> {
902
+ impl _pyo3:: impl_ :: pyclass :: PyClassFreeImpl <#cls> for _pyo3:: impl_ :: pyclass :: PyClassImplCollector <#cls> {
886
903
#[ inline]
887
904
fn free_impl( self ) -> :: std:: option:: Option <_pyo3:: ffi:: freefunc> {
888
- :: std:: option:: Option :: Some ( _pyo3:: class :: impl_ :: free_with_freelist:: <#cls>)
905
+ :: std:: option:: Option :: Some ( _pyo3:: impl_ :: pyclass :: free_with_freelist:: <#cls>)
889
906
}
890
907
}
891
908
}
@@ -928,7 +945,7 @@ fn define_inventory_class(inventory_class_name: &syn::Ident) -> TokenStream {
928
945
}
929
946
}
930
947
931
- impl _pyo3:: class :: impl_ :: PyClassInventory for #inventory_class_name {
948
+ impl _pyo3:: impl_ :: pyclass :: PyClassInventory for #inventory_class_name {
932
949
fn methods( & ' static self ) -> & ' static [ _pyo3:: class:: PyMethodDefType ] {
933
950
self . methods
934
951
}
0 commit comments