From 055c5cfb97692ae91ad1c976847d26fb3af00c4f Mon Sep 17 00:00:00 2001 From: Jeong Yunwon Date: Mon, 30 May 2022 10:45:13 +0900 Subject: [PATCH] pyimpl -> pyclass --- derive/src/lib.rs | 16 +-- derive/src/pyclass.rs | 10 +- derive/src/pymodule.rs | 4 + stdlib/src/array.rs | 4 +- stdlib/src/contextvars.rs | 6 +- stdlib/src/csv.rs | 4 +- stdlib/src/grp.rs | 2 +- stdlib/src/hashlib.rs | 2 +- stdlib/src/json.rs | 2 +- stdlib/src/mmap.rs | 2 +- stdlib/src/pyexpat.rs | 2 +- stdlib/src/pystruct.rs | 4 +- stdlib/src/random.rs | 2 +- stdlib/src/re.rs | 4 +- stdlib/src/resource.rs | 2 +- stdlib/src/select.rs | 2 +- stdlib/src/socket.rs | 2 +- stdlib/src/ssl.rs | 4 +- stdlib/src/unicodedata.rs | 2 +- stdlib/src/zlib.rs | 4 +- vm/src/builtins/asyncgenerator.rs | 8 +- vm/src/builtins/bool.rs | 2 +- vm/src/builtins/builtinfunc.rs | 4 +- vm/src/builtins/bytearray.rs | 4 +- vm/src/builtins/bytes.rs | 4 +- vm/src/builtins/classmethod.rs | 2 +- vm/src/builtins/code.rs | 4 +- vm/src/builtins/complex.rs | 2 +- vm/src/builtins/coroutine.rs | 4 +- vm/src/builtins/dict.rs | 16 +-- vm/src/builtins/enumerate.rs | 4 +- vm/src/builtins/filter.rs | 2 +- vm/src/builtins/float.rs | 2 +- vm/src/builtins/frame.rs | 4 +- vm/src/builtins/function.rs | 6 +- vm/src/builtins/generator.rs | 2 +- vm/src/builtins/genericalias.rs | 2 +- vm/src/builtins/getset.rs | 2 +- vm/src/builtins/int.rs | 2 +- vm/src/builtins/iter.rs | 4 +- vm/src/builtins/list.rs | 6 +- vm/src/builtins/map.rs | 2 +- vm/src/builtins/mappingproxy.rs | 2 +- vm/src/builtins/memory.rs | 2 +- vm/src/builtins/module.rs | 2 +- vm/src/builtins/namespace.rs | 2 +- vm/src/builtins/object.rs | 2 +- vm/src/builtins/property.rs | 2 +- vm/src/builtins/range.rs | 6 +- vm/src/builtins/set.rs | 6 +- vm/src/builtins/singletons.rs | 4 +- vm/src/builtins/slice.rs | 4 +- vm/src/builtins/staticmethod.rs | 2 +- vm/src/builtins/str.rs | 4 +- vm/src/builtins/super.rs | 2 +- vm/src/builtins/traceback.rs | 2 +- vm/src/builtins/tuple.rs | 4 +- vm/src/builtins/type.rs | 2 +- vm/src/builtins/union.rs | 2 +- vm/src/builtins/weakproxy.rs | 2 +- vm/src/builtins/weakref.rs | 2 +- vm/src/builtins/zip.rs | 2 +- vm/src/exceptions.rs | 2 +- vm/src/protocol/buffer.rs | 2 +- vm/src/stdlib/ast.rs | 2 +- vm/src/stdlib/ast/gen.rs | 212 +++++++++++++++--------------- vm/src/stdlib/collections.rs | 6 +- vm/src/stdlib/io.rs | 34 ++--- vm/src/stdlib/itertools.rs | 40 +++--- vm/src/stdlib/operator.rs | 6 +- vm/src/stdlib/os.rs | 12 +- vm/src/stdlib/posix.rs | 2 +- vm/src/stdlib/pwd.rs | 2 +- vm/src/stdlib/sre.rs | 6 +- vm/src/stdlib/symtable.rs | 4 +- vm/src/stdlib/sys.rs | 14 +- vm/src/stdlib/thread.rs | 6 +- vm/src/stdlib/time.rs | 2 +- vm/src/stdlib/winreg.rs | 2 +- vm/src/types/slot.rs | 32 ++--- vm/src/types/structseq.rs | 2 +- wasm/lib/src/browser_module.rs | 4 +- wasm/lib/src/js_module.rs | 8 +- 83 files changed, 311 insertions(+), 313 deletions(-) diff --git a/derive/src/lib.rs b/derive/src/lib.rs index f3cef0eb4..aeb34396d 100644 --- a/derive/src/lib.rs +++ b/derive/src/lib.rs @@ -45,7 +45,11 @@ pub fn pyclass( ) -> proc_macro::TokenStream { let attr = parse_macro_input!(attr as AttributeArgs); let item = parse_macro_input!(item as Item); - result_to_tokens(pyclass::impl_pyclass(attr, item)) + if matches!(item, syn::Item::Impl(_) | syn::Item::Trait(_)) { + result_to_tokens(pyclass::impl_pyimpl(attr, item)) + } else { + result_to_tokens(pyclass::impl_pyclass(attr, item)) + } } /// This macro serves a goal of generating multiple @@ -76,16 +80,6 @@ pub fn pyexception( result_to_tokens(pyclass::impl_pyexception(attr, item)) } -#[proc_macro_attribute] -pub fn pyimpl( - attr: proc_macro::TokenStream, - item: proc_macro::TokenStream, -) -> proc_macro::TokenStream { - let attr = parse_macro_input!(attr as AttributeArgs); - let item = parse_macro_input!(item as Item); - result_to_tokens(pyclass::impl_pyimpl(attr, item)) -} - #[proc_macro_attribute] pub fn pymodule( attr: proc_macro::TokenStream, diff --git a/derive/src/pyclass.rs b/derive/src/pyclass.rs index 8aed20c34..e14630d89 100644 --- a/derive/src/pyclass.rs +++ b/derive/src/pyclass.rs @@ -373,7 +373,7 @@ pub(crate) fn impl_define_exception(exc_def: PyExceptionDef) -> Result Result path, meta => { - bail_span!(meta, "#[pyimpl(with(...))] arguments should be paths") + bail_span!(meta, "#[pyclass(with(...))] arguments should be paths") } }; let (extend_class, extend_slots) = if path_eq(&path, "PyRef") { @@ -993,12 +993,12 @@ fn extract_impl_attrs(attr: AttributeArgs, item: &Ident) -> Result { - bail_span!(meta, "#[pyimpl(flags(...))] arguments should be ident") + bail_span!(meta, "#[pyclass(flags(...))] arguments should be ident") } } } @@ -1098,7 +1098,7 @@ where if ALL_ALLOWED_NAMES.contains(&attr_name.as_str()) { return Err(syn::Error::new_spanned( attr, - format!("#[pyimpl] doesn't accept #[{}]", wrong_name), + format!("#[pyclass] doesn't accept #[{}]", wrong_name), )); } else { continue; diff --git a/derive/src/pymodule.rs b/derive/src/pymodule.rs index 0b7b9326b..4fdc5c562 100644 --- a/derive/src/pymodule.rs +++ b/derive/src/pymodule.rs @@ -69,6 +69,10 @@ pub fn impl_pymodule(attr: AttributeArgs, module_item: Item) -> Result>, } - #[pyimpl(with(IterNext), flags(HAS_DICT))] + #[pyclass(with(IterNext), flags(HAS_DICT))] impl PyArrayIter { #[pymethod(magic)] fn setstate(&self, state: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> { diff --git a/stdlib/src/contextvars.rs b/stdlib/src/contextvars.rs index 8cefad4bd..7ebd5960c 100644 --- a/stdlib/src/contextvars.rs +++ b/stdlib/src/contextvars.rs @@ -14,7 +14,7 @@ mod _contextvars { #[derive(Debug, PyPayload)] struct PyContext {} // not to confuse with vm::Context - #[pyimpl(with(Initializer))] + #[pyclass(with(Initializer))] impl PyContext { #[pymethod] fn run( @@ -99,7 +99,7 @@ mod _contextvars { default: OptionalArg, } - #[pyimpl(with(Initializer))] + #[pyclass(with(Initializer))] impl ContextVar { #[pyproperty] fn name(&self) -> String { @@ -172,7 +172,7 @@ mod _contextvars { old_value: PyObjectRef, } - #[pyimpl(with(Initializer))] + #[pyclass(with(Initializer))] impl ContextToken { #[pyproperty] fn var(&self, _vm: &VirtualMachine) -> PyObjectRef { diff --git a/stdlib/src/csv.rs b/stdlib/src/csv.rs index 66848ca8f..6b152482b 100644 --- a/stdlib/src/csv.rs +++ b/stdlib/src/csv.rs @@ -165,7 +165,7 @@ mod _csv { } } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl Reader {} impl IterNextIterable for Reader {} impl IterNext for Reader { @@ -255,7 +255,7 @@ mod _csv { } } - #[pyimpl] + #[pyclass] impl Writer { #[pymethod] fn writerow(&self, row: PyObjectRef, vm: &VirtualMachine) -> PyResult { diff --git a/stdlib/src/grp.rs b/stdlib/src/grp.rs index 3ccf63adf..78fd2f341 100644 --- a/stdlib/src/grp.rs +++ b/stdlib/src/grp.rs @@ -21,7 +21,7 @@ mod grp { gr_gid: u32, gr_mem: PyListRef, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl Group { fn from_unistd_group(group: unistd::Group, vm: &VirtualMachine) -> Self { let cstr_lossy = |s: std::ffi::CString| { diff --git a/stdlib/src/hashlib.rs b/stdlib/src/hashlib.rs index d375fa189..702fab583 100644 --- a/stdlib/src/hashlib.rs +++ b/stdlib/src/hashlib.rs @@ -58,7 +58,7 @@ mod hashlib { } } - #[pyimpl] + #[pyclass] impl PyHasher { fn new(name: &str, d: HashWrapper) -> Self { PyHasher { diff --git a/stdlib/src/json.rs b/stdlib/src/json.rs index 79b31da2a..7a2a1ce97 100644 --- a/stdlib/src/json.rs +++ b/stdlib/src/json.rs @@ -64,7 +64,7 @@ mod _json { } } - #[pyimpl(with(Callable, Constructor))] + #[pyclass(with(Callable, Constructor))] impl JsonScanner { fn parse( &self, diff --git a/stdlib/src/mmap.rs b/stdlib/src/mmap.rs index dff120498..994c6b324 100644 --- a/stdlib/src/mmap.rs +++ b/stdlib/src/mmap.rs @@ -458,7 +458,7 @@ mod mmap { }; } - #[pyimpl(with(Constructor, AsMapping, AsSequence, AsBuffer), flags(BASETYPE))] + #[pyclass(with(Constructor, AsMapping, AsSequence, AsBuffer), flags(BASETYPE))] impl PyMmap { fn as_bytes_mut(&self) -> BorrowedValueMut<[u8]> { PyMutexGuard::map(self.mmap.lock(), |m| { diff --git a/stdlib/src/pyexpat.rs b/stdlib/src/pyexpat.rs index 9fe308b4b..c865fc816 100644 --- a/stdlib/src/pyexpat.rs +++ b/stdlib/src/pyexpat.rs @@ -62,7 +62,7 @@ mod _pyexpat { vm.invoke(&handler.read().clone(), args).ok(); } - #[pyimpl] + #[pyclass] impl PyExpatLikeXmlParser { fn new(vm: &VirtualMachine) -> PyResult { Ok(PyExpatLikeXmlParser { diff --git a/stdlib/src/pystruct.rs b/stdlib/src/pystruct.rs index 56668db88..69ed20607 100644 --- a/stdlib/src/pystruct.rs +++ b/stdlib/src/pystruct.rs @@ -197,7 +197,7 @@ pub(crate) mod _struct { } } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl UnpackIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { @@ -256,7 +256,7 @@ pub(crate) mod _struct { } } - #[pyimpl(with(Constructor))] + #[pyclass(with(Constructor))] impl PyStruct { #[pyproperty] fn format(&self) -> PyStrRef { diff --git a/stdlib/src/random.rs b/stdlib/src/random.rs index 412f80c0e..950d34ee9 100644 --- a/stdlib/src/random.rs +++ b/stdlib/src/random.rs @@ -78,7 +78,7 @@ mod _random { } } - #[pyimpl(flags(BASETYPE), with(Constructor))] + #[pyclass(flags(BASETYPE), with(Constructor))] impl PyRandom { #[pymethod] fn random(&self) -> f64 { diff --git a/stdlib/src/re.rs b/stdlib/src/re.rs index 8dffda854..67b85975a 100644 --- a/stdlib/src/re.rs +++ b/stdlib/src/re.rs @@ -317,7 +317,7 @@ mod re { #[pyfunction] fn purge(_vm: &VirtualMachine) {} - #[pyimpl] + #[pyclass] impl PyPattern { #[pymethod(name = "match")] fn match_(&self, text: PyStrRef) -> Option { @@ -364,7 +364,7 @@ mod re { } } - #[pyimpl] + #[pyclass] impl PyMatch { #[pymethod] fn start(&self, group: OptionalArg, vm: &VirtualMachine) -> PyResult { diff --git a/stdlib/src/resource.rs b/stdlib/src/resource.rs index 70d641974..1d3513f47 100644 --- a/stdlib/src/resource.rs +++ b/stdlib/src/resource.rs @@ -82,7 +82,7 @@ mod resource { ru_nivcsw: libc::c_long, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl Rusage {} impl From for Rusage { diff --git a/stdlib/src/select.rs b/stdlib/src/select.rs index 1c72c7fd9..da3752636 100644 --- a/stdlib/src/select.rs +++ b/stdlib/src/select.rs @@ -308,7 +308,7 @@ mod decl { const DEFAULT_EVENTS: i16 = libc::POLLIN | libc::POLLPRI | libc::POLLOUT; - #[pyimpl] + #[pyclass] impl PyPoll { #[pymethod] fn register(&self, Fildes(fd): Fildes, eventmask: OptionalArg) { diff --git a/stdlib/src/socket.rs b/stdlib/src/socket.rs index 313c55ca0..ffd2ebede 100644 --- a/stdlib/src/socket.rs +++ b/stdlib/src/socket.rs @@ -1122,7 +1122,7 @@ mod _socket { } } - #[pyimpl(with(DefaultConstructor, Initializer), flags(BASETYPE))] + #[pyclass(with(DefaultConstructor, Initializer), flags(BASETYPE))] impl PySocket { fn _init( zelf: PyRef, diff --git a/stdlib/src/ssl.rs b/stdlib/src/ssl.rs index 234e482aa..15c1a5c65 100644 --- a/stdlib/src/ssl.rs +++ b/stdlib/src/ssl.rs @@ -497,7 +497,7 @@ mod _ssl { } } - #[pyimpl(flags(BASETYPE), with(Constructor))] + #[pyclass(flags(BASETYPE), with(Constructor))] impl PySslContext { fn builder(&self) -> PyRwLockWriteGuard<'_, SslContextBuilder> { self.ctx.write() @@ -903,7 +903,7 @@ mod _ssl { } } - #[pyimpl] + #[pyclass] impl PySslSocket { #[pyproperty] fn owner(&self) -> Option { diff --git a/stdlib/src/unicodedata.rs b/stdlib/src/unicodedata.rs index d8fad1219..ac25c4d1e 100644 --- a/stdlib/src/unicodedata.rs +++ b/stdlib/src/unicodedata.rs @@ -64,7 +64,7 @@ mod unicodedata { } } - #[pyimpl] + #[pyclass] impl Ucd { #[pymethod] fn category(&self, character: PyStrRef, vm: &VirtualMachine) -> PyResult { diff --git a/stdlib/src/zlib.rs b/stdlib/src/zlib.rs index 37d1f3999..e6416872e 100644 --- a/stdlib/src/zlib.rs +++ b/stdlib/src/zlib.rs @@ -288,7 +288,7 @@ mod zlib { unused_data: PyMutex, unconsumed_tail: PyMutex, } - #[pyimpl] + #[pyclass] impl PyDecompress { #[pyproperty] fn eof(&self) -> bool { @@ -447,7 +447,7 @@ mod zlib { inner: PyMutex, } - #[pyimpl] + #[pyclass] impl PyCompress { #[pymethod] fn compress(&self, data: ArgBytesLike, vm: &VirtualMachine) -> PyResult> { diff --git a/vm/src/builtins/asyncgenerator.rs b/vm/src/builtins/asyncgenerator.rs index 16cf864a6..c77317585 100644 --- a/vm/src/builtins/asyncgenerator.rs +++ b/vm/src/builtins/asyncgenerator.rs @@ -26,7 +26,7 @@ impl PyPayload for PyAsyncGen { } } -#[pyimpl(with(Constructor))] +#[pyclass(with(Constructor))] impl PyAsyncGen { pub fn as_coro(&self) -> &Coro { &self.inner @@ -140,7 +140,7 @@ impl PyPayload for PyAsyncGenWrappedValue { } } -#[pyimpl] +#[pyclass] impl PyAsyncGenWrappedValue {} impl PyAsyncGenWrappedValue { @@ -189,7 +189,7 @@ impl PyPayload for PyAsyncGenASend { } } -#[pyimpl(with(IterNext))] +#[pyclass(with(IterNext))] impl PyAsyncGenASend { #[pymethod(name = "__await__")] fn r#await(zelf: PyRef, _vm: &VirtualMachine) -> PyRef { @@ -284,7 +284,7 @@ impl PyPayload for PyAsyncGenAThrow { } } -#[pyimpl(with(IterNext))] +#[pyclass(with(IterNext))] impl PyAsyncGenAThrow { #[pymethod(name = "__await__")] fn r#await(zelf: PyRef, _vm: &VirtualMachine) -> PyRef { diff --git a/vm/src/builtins/bool.rs b/vm/src/builtins/bool.rs index f60a56f2a..1ecd10214 100644 --- a/vm/src/builtins/bool.rs +++ b/vm/src/builtins/bool.rs @@ -108,7 +108,7 @@ impl Constructor for PyBool { } } -#[pyimpl(with(Constructor))] +#[pyclass(with(Constructor))] impl PyBool { #[pymethod(magic)] fn repr(zelf: bool, vm: &VirtualMachine) -> PyStrRef { diff --git a/vm/src/builtins/builtinfunc.rs b/vm/src/builtins/builtinfunc.rs index 92162a82b..5049aa254 100644 --- a/vm/src/builtins/builtinfunc.rs +++ b/vm/src/builtins/builtinfunc.rs @@ -118,7 +118,7 @@ impl Callable for PyBuiltinFunction { } } -#[pyimpl(with(Callable, Constructor), flags(HAS_DICT))] +#[pyclass(with(Callable, Constructor), flags(HAS_DICT))] impl PyBuiltinFunction { #[pyproperty(magic)] fn module(&self, vm: &VirtualMachine) -> PyObjectRef { @@ -229,7 +229,7 @@ impl PyBuiltinMethod { } } -#[pyimpl(with(GetDescriptor, Callable, Constructor), flags(METHOD_DESCR))] +#[pyclass(with(GetDescriptor, Callable, Constructor), flags(METHOD_DESCR))] impl PyBuiltinMethod { #[pyproperty(magic)] fn name(&self) -> PyStrRef { diff --git a/vm/src/builtins/bytearray.rs b/vm/src/builtins/bytearray.rs index 3cf96574b..4c1f9715c 100644 --- a/vm/src/builtins/bytearray.rs +++ b/vm/src/builtins/bytearray.rs @@ -92,7 +92,7 @@ pub(crate) fn init(context: &Context) { PyByteArrayIterator::extend_class(context, context.types.bytearray_iterator_type); } -#[pyimpl( +#[pyclass( flags(BASETYPE), with( Constructor, @@ -854,7 +854,7 @@ impl PyPayload for PyByteArrayIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyByteArrayIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { diff --git a/vm/src/builtins/bytes.rs b/vm/src/builtins/bytes.rs index ff1d3d7b7..88f77f1df 100644 --- a/vm/src/builtins/bytes.rs +++ b/vm/src/builtins/bytes.rs @@ -100,7 +100,7 @@ impl PyBytes { } } -#[pyimpl( +#[pyclass( flags(BASETYPE), with( AsMapping, @@ -675,7 +675,7 @@ impl PyPayload for PyBytesIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyBytesIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { diff --git a/vm/src/builtins/classmethod.rs b/vm/src/builtins/classmethod.rs index 4bb4a2af9..53cf3679e 100644 --- a/vm/src/builtins/classmethod.rs +++ b/vm/src/builtins/classmethod.rs @@ -104,7 +104,7 @@ impl PyClassMethod { } } -#[pyimpl(with(GetDescriptor, Constructor), flags(BASETYPE, HAS_DICT))] +#[pyclass(with(GetDescriptor, Constructor), flags(BASETYPE, HAS_DICT))] impl PyClassMethod { #[pyproperty(magic)] fn func(&self) -> PyObjectRef { diff --git a/vm/src/builtins/code.rs b/vm/src/builtins/code.rs index 888d8c949..ff2257a53 100644 --- a/vm/src/builtins/code.rs +++ b/vm/src/builtins/code.rs @@ -157,10 +157,10 @@ impl PyPayload for PyCode { } } -#[pyimpl(with(PyRef))] +#[pyclass(with(PyRef))] impl PyCode {} -#[pyimpl] +#[pyclass] impl PyRef { #[pyslot] fn slot_new(_cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/builtins/complex.rs b/vm/src/builtins/complex.rs index 963e53817..3c0f9684c 100644 --- a/vm/src/builtins/complex.rs +++ b/vm/src/builtins/complex.rs @@ -206,7 +206,7 @@ impl PyComplex { } } -#[pyimpl(flags(BASETYPE), with(Comparable, Hashable, Constructor, AsNumber))] +#[pyclass(flags(BASETYPE), with(Comparable, Hashable, Constructor, AsNumber))] impl PyComplex { #[pymethod(magic)] fn complex(zelf: PyRef, vm: &VirtualMachine) -> PyRef { diff --git a/vm/src/builtins/coroutine.rs b/vm/src/builtins/coroutine.rs index 79f989f13..a6c769aac 100644 --- a/vm/src/builtins/coroutine.rs +++ b/vm/src/builtins/coroutine.rs @@ -22,7 +22,7 @@ impl PyPayload for PyCoroutine { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyCoroutine { pub fn as_coro(&self) -> &Coro { &self.inner @@ -126,7 +126,7 @@ impl PyPayload for PyCoroutineWrapper { } } -#[pyimpl(with(IterNext))] +#[pyclass(with(IterNext))] impl PyCoroutineWrapper { #[pymethod] fn send(zelf: PyRef, val: PyObjectRef, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/builtins/dict.rs b/vm/src/builtins/dict.rs index 9072acd9e..93a4c91f0 100644 --- a/vm/src/builtins/dict.rs +++ b/vm/src/builtins/dict.rs @@ -217,7 +217,7 @@ impl PyDict { // Python dict methods: #[allow(clippy::len_without_is_empty)] -#[pyimpl( +#[pyclass( with( Constructor, Initializer, @@ -669,7 +669,7 @@ impl Iterator for DictIter { } } -#[pyimpl] +#[pyclass] trait DictView: PyPayload + PyClassDef + Iterable where Self::ReverseIter: PyPayload, @@ -758,7 +758,7 @@ macro_rules! dict_view { } } - #[pyimpl(with(Constructor, IterNext))] + #[pyclass(with(Constructor, IterNext))] impl $iter_name { fn new(dict: PyDictRef) -> Self { $iter_name { @@ -831,7 +831,7 @@ macro_rules! dict_view { } } - #[pyimpl(with(Constructor, IterNext))] + #[pyclass(with(Constructor, IterNext))] impl $reverse_iter_name { fn new(dict: PyDictRef) -> Self { let size = dict.size(); @@ -943,7 +943,7 @@ dict_view! { } // Set operations defined on set-like views of the dictionary. -#[pyimpl] +#[pyclass] trait ViewSetOps: DictView { fn to_set(zelf: PyRef, vm: &VirtualMachine) -> PyResult { let len = zelf.dict().len(); @@ -1035,7 +1035,7 @@ trait ViewSetOps: DictView { } impl ViewSetOps for PyDictKeys {} -#[pyimpl(with(DictView, Constructor, Comparable, Iterable, ViewSetOps, AsSequence))] +#[pyclass(with(DictView, Constructor, Comparable, Iterable, ViewSetOps, AsSequence))] impl PyDictKeys { #[pymethod(magic)] fn contains(zelf: PyRef, key: PyObjectRef, vm: &VirtualMachine) -> PyResult { @@ -1074,7 +1074,7 @@ impl AsSequence for PyDictKeys { } impl ViewSetOps for PyDictItems {} -#[pyimpl(with(DictView, Constructor, Comparable, Iterable, ViewSetOps, AsSequence))] +#[pyclass(with(DictView, Constructor, Comparable, Iterable, ViewSetOps, AsSequence))] impl PyDictItems { #[pymethod(magic)] fn contains(zelf: PyRef, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult { @@ -1126,7 +1126,7 @@ impl AsSequence for PyDictItems { }; } -#[pyimpl(with(DictView, Constructor, Iterable, AsSequence))] +#[pyclass(with(DictView, Constructor, Iterable, AsSequence))] impl PyDictValues { #[pyproperty] fn mapping(zelf: PyRef) -> PyMappingProxy { diff --git a/vm/src/builtins/enumerate.rs b/vm/src/builtins/enumerate.rs index 491b2bde7..254fc1b14 100644 --- a/vm/src/builtins/enumerate.rs +++ b/vm/src/builtins/enumerate.rs @@ -51,7 +51,7 @@ impl Constructor for PyEnumerate { } } -#[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] +#[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyEnumerate { #[pyclassmethod(magic)] fn class_getitem(cls: PyTypeRef, args: PyObjectRef, vm: &VirtualMachine) -> PyGenericAlias { @@ -92,7 +92,7 @@ impl PyPayload for PyReverseSequenceIterator { } } -#[pyimpl(with(IterNext))] +#[pyclass(with(IterNext))] impl PyReverseSequenceIterator { pub fn new(obj: PyObjectRef, len: usize) -> Self { let position = len.saturating_sub(1); diff --git a/vm/src/builtins/filter.rs b/vm/src/builtins/filter.rs index bf0c5f4ec..9e223d18b 100644 --- a/vm/src/builtins/filter.rs +++ b/vm/src/builtins/filter.rs @@ -36,7 +36,7 @@ impl Constructor for PyFilter { } } -#[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] +#[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyFilter { #[pymethod(magic)] fn reduce(&self, vm: &VirtualMachine) -> (PyTypeRef, (PyObjectRef, PyIter)) { diff --git a/vm/src/builtins/float.rs b/vm/src/builtins/float.rs index 54c203832..fb52e06a7 100644 --- a/vm/src/builtins/float.rs +++ b/vm/src/builtins/float.rs @@ -187,7 +187,7 @@ fn float_from_string(val: PyObjectRef, vm: &VirtualMachine) -> PyResult { }) } -#[pyimpl(flags(BASETYPE), with(Comparable, Hashable, Constructor, AsNumber))] +#[pyclass(flags(BASETYPE), with(Comparable, Hashable, Constructor, AsNumber))] impl PyFloat { #[pymethod(magic)] fn format(&self, spec: PyStrRef, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/builtins/frame.rs b/vm/src/builtins/frame.rs index 38fc48b7b..27e907259 100644 --- a/vm/src/builtins/frame.rs +++ b/vm/src/builtins/frame.rs @@ -14,11 +14,11 @@ pub fn init(context: &Context) { FrameRef::extend_class(context, context.types.frame_type); } -#[pyimpl(with(Constructor, PyRef))] +#[pyclass(with(Constructor, PyRef))] impl Frame {} impl Unconstructible for Frame {} -#[pyimpl] +#[pyclass] impl FrameRef { #[pymethod(magic)] fn repr(self) -> String { diff --git a/vm/src/builtins/function.rs b/vm/src/builtins/function.rs index 78025ce85..cffba4ba9 100644 --- a/vm/src/builtins/function.rs +++ b/vm/src/builtins/function.rs @@ -327,7 +327,7 @@ impl PyPayload for PyFunction { } } -#[pyimpl(with(GetDescriptor, Callable), flags(HAS_DICT, METHOD_DESCR))] +#[pyclass(with(GetDescriptor, Callable), flags(HAS_DICT, METHOD_DESCR))] impl PyFunction { #[pyproperty(magic)] fn code(&self) -> PyRef { @@ -505,7 +505,7 @@ impl PyBoundMethod { } } -#[pyimpl(with(Callable, Comparable, GetAttr, Constructor), flags(HAS_DICT))] +#[pyclass(with(Callable, Comparable, GetAttr, Constructor), flags(HAS_DICT))] impl PyBoundMethod { #[pymethod(magic)] fn repr(&self, vm: &VirtualMachine) -> PyResult { @@ -596,7 +596,7 @@ impl Constructor for PyCell { } } -#[pyimpl(with(Constructor))] +#[pyclass(with(Constructor))] impl PyCell { pub fn new(contents: Option) -> Self { Self { diff --git a/vm/src/builtins/generator.rs b/vm/src/builtins/generator.rs index ea85a16d7..cc1d55a0c 100644 --- a/vm/src/builtins/generator.rs +++ b/vm/src/builtins/generator.rs @@ -25,7 +25,7 @@ impl PyPayload for PyGenerator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyGenerator { pub fn as_coro(&self) -> &Coro { &self.inner diff --git a/vm/src/builtins/genericalias.rs b/vm/src/builtins/genericalias.rs index 7e0c061e7..b2c1b6c8b 100644 --- a/vm/src/builtins/genericalias.rs +++ b/vm/src/builtins/genericalias.rs @@ -56,7 +56,7 @@ impl Constructor for PyGenericAlias { } } -#[pyimpl( +#[pyclass( with(AsMapping, Callable, Comparable, Constructor, GetAttr, Hashable), flags(BASETYPE) )] diff --git a/vm/src/builtins/getset.rs b/vm/src/builtins/getset.rs index cce32eb5a..52bd55141 100644 --- a/vm/src/builtins/getset.rs +++ b/vm/src/builtins/getset.rs @@ -236,7 +236,7 @@ impl PyGetSet { } } -#[pyimpl(with(GetDescriptor, Constructor))] +#[pyclass(with(GetDescriptor, Constructor))] impl PyGetSet { // Descriptor methods diff --git a/vm/src/builtins/int.rs b/vm/src/builtins/int.rs index 991b3d7ed..ff42fb452 100644 --- a/vm/src/builtins/int.rs +++ b/vm/src/builtins/int.rs @@ -349,7 +349,7 @@ impl PyInt { } } -#[pyimpl(flags(BASETYPE), with(Comparable, Hashable, Constructor, AsNumber))] +#[pyclass(flags(BASETYPE), with(Comparable, Hashable, Constructor, AsNumber))] impl PyInt { #[pymethod(name = "__radd__")] #[pymethod(magic)] diff --git a/vm/src/builtins/iter.rs b/vm/src/builtins/iter.rs index 98bdb4a41..795fedbd7 100644 --- a/vm/src/builtins/iter.rs +++ b/vm/src/builtins/iter.rs @@ -172,7 +172,7 @@ impl PyPayload for PySequenceIterator { } } -#[pyimpl(with(IterNext))] +#[pyclass(with(IterNext))] impl PySequenceIterator { pub fn new(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult { let seq = PySequence::try_protocol(obj.as_ref(), vm)?; @@ -229,7 +229,7 @@ impl PyPayload for PyCallableIterator { } } -#[pyimpl(with(IterNext))] +#[pyclass(with(IterNext))] impl PyCallableIterator { pub fn new(callable: ArgCallable, sentinel: PyObjectRef) -> Self { Self { diff --git a/vm/src/builtins/list.rs b/vm/src/builtins/list.rs index 0ab5eae69..3633ae375 100644 --- a/vm/src/builtins/list.rs +++ b/vm/src/builtins/list.rs @@ -88,7 +88,7 @@ pub(crate) struct SortOptions { pub type PyListRef = PyRef; -#[pyimpl( +#[pyclass( with( Constructor, Initializer, @@ -532,7 +532,7 @@ impl PyPayload for PyListIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyListIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { @@ -577,7 +577,7 @@ impl PyPayload for PyListReverseIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyListReverseIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { diff --git a/vm/src/builtins/map.rs b/vm/src/builtins/map.rs index 8c65295f0..e93bc698f 100644 --- a/vm/src/builtins/map.rs +++ b/vm/src/builtins/map.rs @@ -36,7 +36,7 @@ impl Constructor for PyMap { } } -#[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] +#[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyMap { #[pymethod(magic)] fn length_hint(&self, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/builtins/mappingproxy.rs b/vm/src/builtins/mappingproxy.rs index 173650169..d42bb9d8e 100644 --- a/vm/src/builtins/mappingproxy.rs +++ b/vm/src/builtins/mappingproxy.rs @@ -65,7 +65,7 @@ impl Constructor for PyMappingProxy { } } -#[pyimpl(with(AsMapping, Iterable, Constructor, AsSequence, Comparable))] +#[pyclass(with(AsMapping, Iterable, Constructor, AsSequence, Comparable))] impl PyMappingProxy { fn get_inner(&self, key: PyObjectRef, vm: &VirtualMachine) -> PyResult> { let opt = match &self.mapping { diff --git a/vm/src/builtins/memory.rs b/vm/src/builtins/memory.rs index 4549285d9..6d0e95cb3 100644 --- a/vm/src/builtins/memory.rs +++ b/vm/src/builtins/memory.rs @@ -61,7 +61,7 @@ impl Constructor for PyMemoryView { } } -#[pyimpl(with(Hashable, Comparable, AsBuffer, AsMapping, AsSequence, Constructor))] +#[pyclass(with(Hashable, Comparable, AsBuffer, AsMapping, AsSequence, Constructor))] impl PyMemoryView { fn parse_format(format: &str, vm: &VirtualMachine) -> PyResult { FormatSpec::parse(format.as_bytes(), vm) diff --git a/vm/src/builtins/module.rs b/vm/src/builtins/module.rs index 51922ba75..df96d2dcb 100644 --- a/vm/src/builtins/module.rs +++ b/vm/src/builtins/module.rs @@ -26,7 +26,7 @@ pub struct ModuleInitArgs { doc: Option, } -#[pyimpl(with(GetAttr, Initializer), flags(BASETYPE, HAS_DICT))] +#[pyclass(with(GetAttr, Initializer), flags(BASETYPE, HAS_DICT))] impl PyModule { // pub(crate) fn new(d: PyDictRef) -> Self { // PyModule { dict: d.into() } diff --git a/vm/src/builtins/namespace.rs b/vm/src/builtins/namespace.rs index 4227e3443..aa13e2ee0 100644 --- a/vm/src/builtins/namespace.rs +++ b/vm/src/builtins/namespace.rs @@ -39,7 +39,7 @@ impl PyNamespace { } } -#[pyimpl(flags(BASETYPE, HAS_DICT), with(Constructor, Initializer, Comparable))] +#[pyclass(flags(BASETYPE, HAS_DICT), with(Constructor, Initializer, Comparable))] impl PyNamespace { #[pymethod(magic)] fn repr(zelf: PyRef, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/builtins/object.rs b/vm/src/builtins/object.rs index 1be14365d..3e39b4576 100644 --- a/vm/src/builtins/object.rs +++ b/vm/src/builtins/object.rs @@ -25,7 +25,7 @@ impl PyPayload for PyBaseObject { } } -#[pyimpl(flags(BASETYPE))] +#[pyclass(flags(BASETYPE))] impl PyBaseObject { /// Create and return a new object. See help(type) for accurate signature. #[pyslot] diff --git a/vm/src/builtins/property.rs b/vm/src/builtins/property.rs index edf50ae27..832de6512 100644 --- a/vm/src/builtins/property.rs +++ b/vm/src/builtins/property.rs @@ -87,7 +87,7 @@ impl GetDescriptor for PyProperty { } } -#[pyimpl(with(Constructor, Initializer, GetDescriptor), flags(BASETYPE))] +#[pyclass(with(Constructor, Initializer, GetDescriptor), flags(BASETYPE))] impl PyProperty { // Descriptor methods diff --git a/vm/src/builtins/range.rs b/vm/src/builtins/range.rs index cc4062e5c..dfa57f119 100644 --- a/vm/src/builtins/range.rs +++ b/vm/src/builtins/range.rs @@ -179,7 +179,7 @@ pub fn init(context: &Context) { PyRangeIterator::extend_class(context, context.types.range_iterator_type); } -#[pyimpl(with(AsMapping, AsSequence, Hashable, Comparable, Iterable))] +#[pyclass(with(AsMapping, AsSequence, Hashable, Comparable, Iterable))] impl PyRange { fn new(cls: PyTypeRef, stop: PyObjectRef, vm: &VirtualMachine) -> PyResult> { PyRange { @@ -531,7 +531,7 @@ impl PyPayload for PyLongRangeIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyLongRangeIterator { #[pymethod(magic)] fn length_hint(&self) -> BigInt { @@ -596,7 +596,7 @@ impl PyPayload for PyRangeIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyRangeIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { diff --git a/vm/src/builtins/set.rs b/vm/src/builtins/set.rs index a12c8656f..42707139c 100644 --- a/vm/src/builtins/set.rs +++ b/vm/src/builtins/set.rs @@ -492,7 +492,7 @@ fn reduce_set( )) } -#[pyimpl( +#[pyclass( with(Constructor, Initializer, AsSequence, Hashable, Comparable, Iterable), flags(BASETYPE) )] @@ -820,7 +820,7 @@ impl Constructor for PyFrozenSet { } } -#[pyimpl( +#[pyclass( flags(BASETYPE), with(Constructor, AsSequence, Hashable, Comparable, Iterable) )] @@ -1073,7 +1073,7 @@ impl PyPayload for PySetIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PySetIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { diff --git a/vm/src/builtins/singletons.rs b/vm/src/builtins/singletons.rs index 3f510bed8..1f863e8d5 100644 --- a/vm/src/builtins/singletons.rs +++ b/vm/src/builtins/singletons.rs @@ -43,7 +43,7 @@ impl Constructor for PyNone { } } -#[pyimpl(with(Constructor, AsNumber))] +#[pyclass(with(Constructor, AsNumber))] impl PyNone { #[pymethod(magic)] fn repr(&self) -> String { @@ -84,7 +84,7 @@ impl Constructor for PyNotImplemented { } } -#[pyimpl(with(Constructor))] +#[pyclass(with(Constructor))] impl PyNotImplemented { // TODO: As per https://bugs.python.org/issue35712, using NotImplemented // in boolean contexts will need to raise a DeprecationWarning in 3.9 diff --git a/vm/src/builtins/slice.rs b/vm/src/builtins/slice.rs index e10ea058a..9318efbaa 100644 --- a/vm/src/builtins/slice.rs +++ b/vm/src/builtins/slice.rs @@ -25,7 +25,7 @@ impl PyPayload for PySlice { } } -#[pyimpl(with(Hashable, Comparable))] +#[pyclass(with(Hashable, Comparable))] impl PySlice { #[pyproperty] fn start(&self, vm: &VirtualMachine) -> PyObjectRef { @@ -278,7 +278,7 @@ impl Constructor for PyEllipsis { } } -#[pyimpl(with(Constructor))] +#[pyclass(with(Constructor))] impl PyEllipsis { #[pymethod(magic)] fn repr(&self) -> String { diff --git a/vm/src/builtins/staticmethod.rs b/vm/src/builtins/staticmethod.rs index 5198bc04a..8a74a5ead 100644 --- a/vm/src/builtins/staticmethod.rs +++ b/vm/src/builtins/staticmethod.rs @@ -73,7 +73,7 @@ impl PyStaticMethod { } } -#[pyimpl(with(Callable, GetDescriptor, Constructor), flags(BASETYPE, HAS_DICT))] +#[pyclass(with(Callable, GetDescriptor, Constructor), flags(BASETYPE, HAS_DICT))] impl PyStaticMethod { #[pyproperty(magic)] fn func(&self) -> PyObjectRef { diff --git a/vm/src/builtins/str.rs b/vm/src/builtins/str.rs index 42f59389d..502e29365 100644 --- a/vm/src/builtins/str.rs +++ b/vm/src/builtins/str.rs @@ -247,7 +247,7 @@ impl PyPayload for PyStrIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyStrIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { @@ -394,7 +394,7 @@ impl PyStr { } } -#[pyimpl( +#[pyclass( flags(BASETYPE), with(AsMapping, AsSequence, Hashable, Comparable, Iterable, Constructor) )] diff --git a/vm/src/builtins/super.rs b/vm/src/builtins/super.rs index 2a74cbb47..860194154 100644 --- a/vm/src/builtins/super.rs +++ b/vm/src/builtins/super.rs @@ -97,7 +97,7 @@ impl Constructor for PySuper { } } -#[pyimpl(with(GetAttr, GetDescriptor, Constructor))] +#[pyclass(with(GetAttr, GetDescriptor, Constructor))] impl PySuper { fn new(typ: PyTypeRef, obj: PyObjectRef, vm: &VirtualMachine) -> PyResult { let obj = if vm.is_none(&obj) { diff --git a/vm/src/builtins/traceback.rs b/vm/src/builtins/traceback.rs index 731ccbd12..98d9a3aed 100644 --- a/vm/src/builtins/traceback.rs +++ b/vm/src/builtins/traceback.rs @@ -18,7 +18,7 @@ impl PyPayload for PyTraceback { } } -#[pyimpl] +#[pyclass] impl PyTraceback { pub fn new(next: Option>, frame: FrameRef, lasti: u32, lineno: usize) -> Self { PyTraceback { diff --git a/vm/src/builtins/tuple.rs b/vm/src/builtins/tuple.rs index ce6d0cfbe..74d8bce20 100644 --- a/vm/src/builtins/tuple.rs +++ b/vm/src/builtins/tuple.rs @@ -172,7 +172,7 @@ impl PyTuple { } } -#[pyimpl( +#[pyclass( flags(BASETYPE), with(AsMapping, AsSequence, Hashable, Comparable, Iterable, Constructor) )] @@ -413,7 +413,7 @@ impl PyPayload for PyTupleIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyTupleIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { diff --git a/vm/src/builtins/type.rs b/vm/src/builtins/type.rs index 4bc294171..6a4bed174 100644 --- a/vm/src/builtins/type.rs +++ b/vm/src/builtins/type.rs @@ -283,7 +283,7 @@ impl PyTypeRef { } } -#[pyimpl(with(GetAttr, SetAttr, Callable), flags(BASETYPE))] +#[pyclass(with(GetAttr, SetAttr, Callable), flags(BASETYPE))] impl PyType { // bound method for every type pub(crate) fn __new__(zelf: PyRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/builtins/union.rs b/vm/src/builtins/union.rs index 31da9a439..d2584d1b9 100644 --- a/vm/src/builtins/union.rs +++ b/vm/src/builtins/union.rs @@ -32,7 +32,7 @@ impl PyPayload for PyUnion { } } -#[pyimpl(with(Hashable, Comparable, AsMapping), flags(BASETYPE))] +#[pyclass(with(Hashable, Comparable, AsMapping), flags(BASETYPE))] impl PyUnion { pub fn new(args: PyTupleRef, vm: &VirtualMachine) -> Self { let parameters = make_parameters(&args, vm); diff --git a/vm/src/builtins/weakproxy.rs b/vm/src/builtins/weakproxy.rs index 9ab7ad2a9..53a9f785b 100644 --- a/vm/src/builtins/weakproxy.rs +++ b/vm/src/builtins/weakproxy.rs @@ -58,7 +58,7 @@ crate::common::static_cell! { static WEAK_SUBCLASS: PyTypeRef; } -#[pyimpl(with(GetAttr, SetAttr, Constructor, Comparable, AsSequence, AsMapping))] +#[pyclass(with(GetAttr, SetAttr, Constructor, Comparable, AsSequence, AsMapping))] impl PyWeakProxy { fn try_upgrade(&self, vm: &VirtualMachine) -> PyResult { self.weak.upgrade().ok_or_else(|| new_reference_error(vm)) diff --git a/vm/src/builtins/weakref.rs b/vm/src/builtins/weakref.rs index e57fe25cb..99fa681be 100644 --- a/vm/src/builtins/weakref.rs +++ b/vm/src/builtins/weakref.rs @@ -47,7 +47,7 @@ impl Constructor for PyWeak { } } -#[pyimpl(with(Callable, Hashable, Comparable, Constructor), flags(BASETYPE))] +#[pyclass(with(Callable, Hashable, Comparable, Constructor), flags(BASETYPE))] impl PyWeak { #[pymethod(magic)] fn repr(zelf: PyRef) -> String { diff --git a/vm/src/builtins/zip.rs b/vm/src/builtins/zip.rs index 7493ed136..955e58797 100644 --- a/vm/src/builtins/zip.rs +++ b/vm/src/builtins/zip.rs @@ -40,7 +40,7 @@ impl Constructor for PyZip { } } -#[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] +#[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyZip { #[pymethod(magic)] fn reduce(zelf: PyRef, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/exceptions.rs b/vm/src/exceptions.rs index 4ebdcede2..177c83f3f 100644 --- a/vm/src/exceptions.rs +++ b/vm/src/exceptions.rs @@ -412,7 +412,7 @@ macro_rules! extend_exception { }; } -#[pyimpl(flags(BASETYPE, HAS_DICT))] +#[pyclass(flags(BASETYPE, HAS_DICT))] impl PyBaseException { pub(crate) fn new(args: Vec, vm: &VirtualMachine) -> PyBaseException { PyBaseException { diff --git a/vm/src/protocol/buffer.rs b/vm/src/protocol/buffer.rs index 6e97fe1b7..4a6b5dc93 100644 --- a/vm/src/protocol/buffer.rs +++ b/vm/src/protocol/buffer.rs @@ -401,7 +401,7 @@ pub struct VecBuffer { data: PyMutex>, } -#[pyimpl(flags(BASETYPE), with(Constructor))] +#[pyclass(flags(BASETYPE), with(Constructor))] impl VecBuffer { pub fn take(&self) -> Vec { std::mem::take(&mut self.data.lock()) diff --git a/vm/src/stdlib/ast.rs b/vm/src/stdlib/ast.rs index 8c848ca1c..7d080c7fe 100644 --- a/vm/src/stdlib/ast.rs +++ b/vm/src/stdlib/ast.rs @@ -30,7 +30,7 @@ mod _ast { #[derive(Debug, PyPayload)] pub(crate) struct AstNode; - #[pyimpl(flags(BASETYPE, HAS_DICT))] + #[pyclass(flags(BASETYPE, HAS_DICT))] impl AstNode { #[pyslot] #[pymethod(magic)] diff --git a/vm/src/stdlib/ast/gen.rs b/vm/src/stdlib/ast/gen.rs index 7ee4f8fb2..c2980892d 100644 --- a/vm/src/stdlib/ast/gen.rs +++ b/vm/src/stdlib/ast/gen.rs @@ -7,11 +7,11 @@ use crate::common::ascii; #[pyclass(module = "_ast", name = "mod", base = "AstNode")] struct NodeKindMod; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindMod {} #[pyclass(module = "_ast", name = "Module", base = "NodeKindMod")] struct NodeModule; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeModule { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -28,7 +28,7 @@ impl NodeModule { } #[pyclass(module = "_ast", name = "Interactive", base = "NodeKindMod")] struct NodeInteractive; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeInteractive { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -42,7 +42,7 @@ impl NodeInteractive { } #[pyclass(module = "_ast", name = "Expression", base = "NodeKindMod")] struct NodeExpression; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeExpression { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -56,7 +56,7 @@ impl NodeExpression { } #[pyclass(module = "_ast", name = "FunctionType", base = "NodeKindMod")] struct NodeFunctionType; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeFunctionType { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -73,11 +73,11 @@ impl NodeFunctionType { } #[pyclass(module = "_ast", name = "stmt", base = "AstNode")] struct NodeKindStmt; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindStmt {} #[pyclass(module = "_ast", name = "FunctionDef", base = "NodeKindStmt")] struct NodeFunctionDef; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeFunctionDef { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -107,7 +107,7 @@ impl NodeFunctionDef { } #[pyclass(module = "_ast", name = "AsyncFunctionDef", base = "NodeKindStmt")] struct NodeAsyncFunctionDef; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAsyncFunctionDef { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -137,7 +137,7 @@ impl NodeAsyncFunctionDef { } #[pyclass(module = "_ast", name = "ClassDef", base = "NodeKindStmt")] struct NodeClassDef; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeClassDef { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -166,7 +166,7 @@ impl NodeClassDef { } #[pyclass(module = "_ast", name = "Return", base = "NodeKindStmt")] struct NodeReturn; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeReturn { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -189,7 +189,7 @@ impl NodeReturn { } #[pyclass(module = "_ast", name = "Delete", base = "NodeKindStmt")] struct NodeDelete; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeDelete { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -212,7 +212,7 @@ impl NodeDelete { } #[pyclass(module = "_ast", name = "Assign", base = "NodeKindStmt")] struct NodeAssign; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAssign { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -239,7 +239,7 @@ impl NodeAssign { } #[pyclass(module = "_ast", name = "AugAssign", base = "NodeKindStmt")] struct NodeAugAssign; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAugAssign { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -266,7 +266,7 @@ impl NodeAugAssign { } #[pyclass(module = "_ast", name = "AnnAssign", base = "NodeKindStmt")] struct NodeAnnAssign; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAnnAssign { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -294,7 +294,7 @@ impl NodeAnnAssign { } #[pyclass(module = "_ast", name = "For", base = "NodeKindStmt")] struct NodeFor; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeFor { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -323,7 +323,7 @@ impl NodeFor { } #[pyclass(module = "_ast", name = "AsyncFor", base = "NodeKindStmt")] struct NodeAsyncFor; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAsyncFor { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -352,7 +352,7 @@ impl NodeAsyncFor { } #[pyclass(module = "_ast", name = "While", base = "NodeKindStmt")] struct NodeWhile; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeWhile { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -379,7 +379,7 @@ impl NodeWhile { } #[pyclass(module = "_ast", name = "If", base = "NodeKindStmt")] struct NodeIf; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeIf { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -406,7 +406,7 @@ impl NodeIf { } #[pyclass(module = "_ast", name = "With", base = "NodeKindStmt")] struct NodeWith; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeWith { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -433,7 +433,7 @@ impl NodeWith { } #[pyclass(module = "_ast", name = "AsyncWith", base = "NodeKindStmt")] struct NodeAsyncWith; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAsyncWith { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -460,7 +460,7 @@ impl NodeAsyncWith { } #[pyclass(module = "_ast", name = "Raise", base = "NodeKindStmt")] struct NodeRaise; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeRaise { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -486,7 +486,7 @@ impl NodeRaise { } #[pyclass(module = "_ast", name = "Try", base = "NodeKindStmt")] struct NodeTry; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeTry { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -514,7 +514,7 @@ impl NodeTry { } #[pyclass(module = "_ast", name = "Assert", base = "NodeKindStmt")] struct NodeAssert; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAssert { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -540,7 +540,7 @@ impl NodeAssert { } #[pyclass(module = "_ast", name = "Import", base = "NodeKindStmt")] struct NodeImport; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeImport { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -563,7 +563,7 @@ impl NodeImport { } #[pyclass(module = "_ast", name = "ImportFrom", base = "NodeKindStmt")] struct NodeImportFrom; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeImportFrom { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -590,7 +590,7 @@ impl NodeImportFrom { } #[pyclass(module = "_ast", name = "Global", base = "NodeKindStmt")] struct NodeGlobal; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeGlobal { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -613,7 +613,7 @@ impl NodeGlobal { } #[pyclass(module = "_ast", name = "Nonlocal", base = "NodeKindStmt")] struct NodeNonlocal; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeNonlocal { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -636,7 +636,7 @@ impl NodeNonlocal { } #[pyclass(module = "_ast", name = "Expr", base = "NodeKindStmt")] struct NodeExpr; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeExpr { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -659,7 +659,7 @@ impl NodeExpr { } #[pyclass(module = "_ast", name = "Pass", base = "NodeKindStmt")] struct NodePass; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodePass { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -678,7 +678,7 @@ impl NodePass { } #[pyclass(module = "_ast", name = "Break", base = "NodeKindStmt")] struct NodeBreak; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeBreak { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -697,7 +697,7 @@ impl NodeBreak { } #[pyclass(module = "_ast", name = "Continue", base = "NodeKindStmt")] struct NodeContinue; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeContinue { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -716,11 +716,11 @@ impl NodeContinue { } #[pyclass(module = "_ast", name = "expr", base = "AstNode")] struct NodeKindExpr; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindExpr {} #[pyclass(module = "_ast", name = "BoolOp", base = "NodeKindExpr")] struct NodeBoolOp; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeBoolOp { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -746,7 +746,7 @@ impl NodeBoolOp { } #[pyclass(module = "_ast", name = "NamedExpr", base = "NodeKindExpr")] struct NodeNamedExpr; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeNamedExpr { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -772,7 +772,7 @@ impl NodeNamedExpr { } #[pyclass(module = "_ast", name = "BinOp", base = "NodeKindExpr")] struct NodeBinOp; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeBinOp { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -799,7 +799,7 @@ impl NodeBinOp { } #[pyclass(module = "_ast", name = "UnaryOp", base = "NodeKindExpr")] struct NodeUnaryOp; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeUnaryOp { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -825,7 +825,7 @@ impl NodeUnaryOp { } #[pyclass(module = "_ast", name = "Lambda", base = "NodeKindExpr")] struct NodeLambda; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeLambda { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -851,7 +851,7 @@ impl NodeLambda { } #[pyclass(module = "_ast", name = "IfExp", base = "NodeKindExpr")] struct NodeIfExp; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeIfExp { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -878,7 +878,7 @@ impl NodeIfExp { } #[pyclass(module = "_ast", name = "Dict", base = "NodeKindExpr")] struct NodeDict; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeDict { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -904,7 +904,7 @@ impl NodeDict { } #[pyclass(module = "_ast", name = "Set", base = "NodeKindExpr")] struct NodeSet; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeSet { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -927,7 +927,7 @@ impl NodeSet { } #[pyclass(module = "_ast", name = "ListComp", base = "NodeKindExpr")] struct NodeListComp; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeListComp { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -953,7 +953,7 @@ impl NodeListComp { } #[pyclass(module = "_ast", name = "SetComp", base = "NodeKindExpr")] struct NodeSetComp; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeSetComp { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -979,7 +979,7 @@ impl NodeSetComp { } #[pyclass(module = "_ast", name = "DictComp", base = "NodeKindExpr")] struct NodeDictComp; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeDictComp { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1006,7 +1006,7 @@ impl NodeDictComp { } #[pyclass(module = "_ast", name = "GeneratorExp", base = "NodeKindExpr")] struct NodeGeneratorExp; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeGeneratorExp { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1032,7 +1032,7 @@ impl NodeGeneratorExp { } #[pyclass(module = "_ast", name = "Await", base = "NodeKindExpr")] struct NodeAwait; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAwait { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1055,7 +1055,7 @@ impl NodeAwait { } #[pyclass(module = "_ast", name = "Yield", base = "NodeKindExpr")] struct NodeYield; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeYield { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1078,7 +1078,7 @@ impl NodeYield { } #[pyclass(module = "_ast", name = "YieldFrom", base = "NodeKindExpr")] struct NodeYieldFrom; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeYieldFrom { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1101,7 +1101,7 @@ impl NodeYieldFrom { } #[pyclass(module = "_ast", name = "Compare", base = "NodeKindExpr")] struct NodeCompare; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeCompare { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1128,7 +1128,7 @@ impl NodeCompare { } #[pyclass(module = "_ast", name = "Call", base = "NodeKindExpr")] struct NodeCall; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeCall { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1155,7 +1155,7 @@ impl NodeCall { } #[pyclass(module = "_ast", name = "FormattedValue", base = "NodeKindExpr")] struct NodeFormattedValue; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeFormattedValue { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1182,7 +1182,7 @@ impl NodeFormattedValue { } #[pyclass(module = "_ast", name = "JoinedStr", base = "NodeKindExpr")] struct NodeJoinedStr; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeJoinedStr { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1205,7 +1205,7 @@ impl NodeJoinedStr { } #[pyclass(module = "_ast", name = "Constant", base = "NodeKindExpr")] struct NodeConstant; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeConstant { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1231,7 +1231,7 @@ impl NodeConstant { } #[pyclass(module = "_ast", name = "Attribute", base = "NodeKindExpr")] struct NodeAttribute; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAttribute { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1258,7 +1258,7 @@ impl NodeAttribute { } #[pyclass(module = "_ast", name = "Subscript", base = "NodeKindExpr")] struct NodeSubscript; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeSubscript { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1285,7 +1285,7 @@ impl NodeSubscript { } #[pyclass(module = "_ast", name = "Starred", base = "NodeKindExpr")] struct NodeStarred; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeStarred { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1311,7 +1311,7 @@ impl NodeStarred { } #[pyclass(module = "_ast", name = "Name", base = "NodeKindExpr")] struct NodeName; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeName { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1337,7 +1337,7 @@ impl NodeName { } #[pyclass(module = "_ast", name = "List", base = "NodeKindExpr")] struct NodeList; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeList { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1363,7 +1363,7 @@ impl NodeList { } #[pyclass(module = "_ast", name = "Tuple", base = "NodeKindExpr")] struct NodeTuple; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeTuple { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1389,7 +1389,7 @@ impl NodeTuple { } #[pyclass(module = "_ast", name = "Slice", base = "NodeKindExpr")] struct NodeSlice; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeSlice { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1416,11 +1416,11 @@ impl NodeSlice { } #[pyclass(module = "_ast", name = "expr_context", base = "AstNode")] struct NodeKindExprContext; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindExprContext {} #[pyclass(module = "_ast", name = "Load", base = "NodeKindExprContext")] struct NodeLoad; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeLoad { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1430,7 +1430,7 @@ impl NodeLoad { } #[pyclass(module = "_ast", name = "Store", base = "NodeKindExprContext")] struct NodeStore; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeStore { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1440,7 +1440,7 @@ impl NodeStore { } #[pyclass(module = "_ast", name = "Del", base = "NodeKindExprContext")] struct NodeDel; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeDel { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1450,11 +1450,11 @@ impl NodeDel { } #[pyclass(module = "_ast", name = "boolop", base = "AstNode")] struct NodeKindBoolop; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindBoolop {} #[pyclass(module = "_ast", name = "And", base = "NodeKindBoolop")] struct NodeAnd; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAnd { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1464,7 +1464,7 @@ impl NodeAnd { } #[pyclass(module = "_ast", name = "Or", base = "NodeKindBoolop")] struct NodeOr; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeOr { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1474,11 +1474,11 @@ impl NodeOr { } #[pyclass(module = "_ast", name = "operator", base = "AstNode")] struct NodeKindOperator; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindOperator {} #[pyclass(module = "_ast", name = "Add", base = "NodeKindOperator")] struct NodeAdd; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeAdd { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1488,7 +1488,7 @@ impl NodeAdd { } #[pyclass(module = "_ast", name = "Sub", base = "NodeKindOperator")] struct NodeSub; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeSub { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1498,7 +1498,7 @@ impl NodeSub { } #[pyclass(module = "_ast", name = "Mult", base = "NodeKindOperator")] struct NodeMult; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeMult { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1508,7 +1508,7 @@ impl NodeMult { } #[pyclass(module = "_ast", name = "MatMult", base = "NodeKindOperator")] struct NodeMatMult; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeMatMult { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1518,7 +1518,7 @@ impl NodeMatMult { } #[pyclass(module = "_ast", name = "Div", base = "NodeKindOperator")] struct NodeDiv; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeDiv { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1528,7 +1528,7 @@ impl NodeDiv { } #[pyclass(module = "_ast", name = "Mod", base = "NodeKindOperator")] struct NodeMod; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeMod { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1538,7 +1538,7 @@ impl NodeMod { } #[pyclass(module = "_ast", name = "Pow", base = "NodeKindOperator")] struct NodePow; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodePow { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1548,7 +1548,7 @@ impl NodePow { } #[pyclass(module = "_ast", name = "LShift", base = "NodeKindOperator")] struct NodeLShift; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeLShift { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1558,7 +1558,7 @@ impl NodeLShift { } #[pyclass(module = "_ast", name = "RShift", base = "NodeKindOperator")] struct NodeRShift; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeRShift { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1568,7 +1568,7 @@ impl NodeRShift { } #[pyclass(module = "_ast", name = "BitOr", base = "NodeKindOperator")] struct NodeBitOr; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeBitOr { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1578,7 +1578,7 @@ impl NodeBitOr { } #[pyclass(module = "_ast", name = "BitXor", base = "NodeKindOperator")] struct NodeBitXor; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeBitXor { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1588,7 +1588,7 @@ impl NodeBitXor { } #[pyclass(module = "_ast", name = "BitAnd", base = "NodeKindOperator")] struct NodeBitAnd; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeBitAnd { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1598,7 +1598,7 @@ impl NodeBitAnd { } #[pyclass(module = "_ast", name = "FloorDiv", base = "NodeKindOperator")] struct NodeFloorDiv; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeFloorDiv { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1608,11 +1608,11 @@ impl NodeFloorDiv { } #[pyclass(module = "_ast", name = "unaryop", base = "AstNode")] struct NodeKindUnaryop; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindUnaryop {} #[pyclass(module = "_ast", name = "Invert", base = "NodeKindUnaryop")] struct NodeInvert; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeInvert { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1622,7 +1622,7 @@ impl NodeInvert { } #[pyclass(module = "_ast", name = "Not", base = "NodeKindUnaryop")] struct NodeNot; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeNot { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1632,7 +1632,7 @@ impl NodeNot { } #[pyclass(module = "_ast", name = "UAdd", base = "NodeKindUnaryop")] struct NodeUAdd; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeUAdd { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1642,7 +1642,7 @@ impl NodeUAdd { } #[pyclass(module = "_ast", name = "USub", base = "NodeKindUnaryop")] struct NodeUSub; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeUSub { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1652,11 +1652,11 @@ impl NodeUSub { } #[pyclass(module = "_ast", name = "cmpop", base = "AstNode")] struct NodeKindCmpop; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindCmpop {} #[pyclass(module = "_ast", name = "Eq", base = "NodeKindCmpop")] struct NodeEq; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeEq { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1666,7 +1666,7 @@ impl NodeEq { } #[pyclass(module = "_ast", name = "NotEq", base = "NodeKindCmpop")] struct NodeNotEq; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeNotEq { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1676,7 +1676,7 @@ impl NodeNotEq { } #[pyclass(module = "_ast", name = "Lt", base = "NodeKindCmpop")] struct NodeLt; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeLt { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1686,7 +1686,7 @@ impl NodeLt { } #[pyclass(module = "_ast", name = "LtE", base = "NodeKindCmpop")] struct NodeLtE; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeLtE { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1696,7 +1696,7 @@ impl NodeLtE { } #[pyclass(module = "_ast", name = "Gt", base = "NodeKindCmpop")] struct NodeGt; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeGt { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1706,7 +1706,7 @@ impl NodeGt { } #[pyclass(module = "_ast", name = "GtE", base = "NodeKindCmpop")] struct NodeGtE; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeGtE { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1716,7 +1716,7 @@ impl NodeGtE { } #[pyclass(module = "_ast", name = "Is", base = "NodeKindCmpop")] struct NodeIs; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeIs { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1726,7 +1726,7 @@ impl NodeIs { } #[pyclass(module = "_ast", name = "IsNot", base = "NodeKindCmpop")] struct NodeIsNot; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeIsNot { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1736,7 +1736,7 @@ impl NodeIsNot { } #[pyclass(module = "_ast", name = "In", base = "NodeKindCmpop")] struct NodeIn; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeIn { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1746,7 +1746,7 @@ impl NodeIn { } #[pyclass(module = "_ast", name = "NotIn", base = "NodeKindCmpop")] struct NodeNotIn; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeNotIn { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1756,7 +1756,7 @@ impl NodeNotIn { } #[pyclass(module = "_ast", name = "comprehension", base = "AstNode")] struct Nodecomprehension; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl Nodecomprehension { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1775,7 +1775,7 @@ impl Nodecomprehension { } #[pyclass(module = "_ast", name = "excepthandler", base = "AstNode")] struct NodeKindExcepthandler; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindExcepthandler {} #[pyclass( module = "_ast", @@ -1783,7 +1783,7 @@ impl NodeKindExcepthandler {} base = "NodeKindExcepthandler" )] struct NodeExceptHandler; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeExceptHandler { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1810,7 +1810,7 @@ impl NodeExceptHandler { } #[pyclass(module = "_ast", name = "arguments", base = "AstNode")] struct Nodearguments; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl Nodearguments { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1832,7 +1832,7 @@ impl Nodearguments { } #[pyclass(module = "_ast", name = "arg", base = "AstNode")] struct Nodearg; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl Nodearg { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1859,7 +1859,7 @@ impl Nodearg { } #[pyclass(module = "_ast", name = "keyword", base = "AstNode")] struct Nodekeyword; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl Nodekeyword { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1885,7 +1885,7 @@ impl Nodekeyword { } #[pyclass(module = "_ast", name = "alias", base = "AstNode")] struct Nodealias; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl Nodealias { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1902,7 +1902,7 @@ impl Nodealias { } #[pyclass(module = "_ast", name = "withitem", base = "AstNode")] struct Nodewithitem; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl Nodewithitem { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { @@ -1919,11 +1919,11 @@ impl Nodewithitem { } #[pyclass(module = "_ast", name = "type_ignore", base = "AstNode")] struct NodeKindTypeIgnore; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeKindTypeIgnore {} #[pyclass(module = "_ast", name = "TypeIgnore", base = "NodeKindTypeIgnore")] struct NodeTypeIgnore; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeTypeIgnore { #[extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { diff --git a/vm/src/stdlib/collections.rs b/vm/src/stdlib/collections.rs index a34c29afe..f6995276d 100644 --- a/vm/src/stdlib/collections.rs +++ b/vm/src/stdlib/collections.rs @@ -54,7 +54,7 @@ mod _collections { } } - #[pyimpl( + #[pyclass( flags(BASETYPE), with(Constructor, Initializer, AsSequence, Comparable, Hashable, Iterable) )] @@ -609,7 +609,7 @@ mod _collections { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyDequeIterator { pub(crate) fn new(deque: PyDequeRef) -> Self { PyDequeIterator { @@ -682,7 +682,7 @@ mod _collections { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyReverseDequeIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { diff --git a/vm/src/stdlib/io.rs b/vm/src/stdlib/io.rs index 40152444d..ebe8acc90 100644 --- a/vm/src/stdlib/io.rs +++ b/vm/src/stdlib/io.rs @@ -379,7 +379,7 @@ mod _io { #[derive(Debug, PyPayload)] struct _IOBase; - #[pyimpl(with(IterNext, Destructor), flags(BASETYPE, HAS_DICT))] + #[pyclass(with(IterNext, Destructor), flags(BASETYPE, HAS_DICT))] impl _IOBase { #[pymethod] fn seek( @@ -587,7 +587,7 @@ mod _io { #[pyclass(name = "_RawIOBase", base = "_IOBase")] pub(super) struct _RawIOBase; - #[pyimpl(flags(BASETYPE, HAS_DICT))] + #[pyclass(flags(BASETYPE, HAS_DICT))] impl _RawIOBase { #[pymethod] fn read(instance: PyObjectRef, size: OptionalSize, vm: &VirtualMachine) -> PyResult { @@ -645,7 +645,7 @@ mod _io { #[pyclass(name = "_BufferedIOBase", base = "_IOBase")] struct _BufferedIOBase; - #[pyimpl(flags(BASETYPE))] + #[pyclass(flags(BASETYPE))] impl _BufferedIOBase { #[pymethod] fn read(zelf: PyObjectRef, _size: OptionalArg, vm: &VirtualMachine) -> PyResult { @@ -704,7 +704,7 @@ mod _io { #[derive(Debug, PyPayload)] struct _TextIOBase; - #[pyimpl(flags(BASETYPE))] + #[pyclass(flags(BASETYPE))] impl _TextIOBase { #[pyproperty] fn encoding(&self, vm: &VirtualMachine) -> PyObjectRef { @@ -1371,7 +1371,7 @@ mod _io { } } - #[pyimpl] + #[pyclass] trait BufferedMixin: PyPayload { const CLASS_NAME: &'static str; const READABLE: bool; @@ -1586,7 +1586,7 @@ mod _io { } } - #[pyimpl] + #[pyclass] trait BufferedReadable: PyPayload { type Reader: BufferedMixin; fn reader(&self) -> &Self::Reader; @@ -1688,7 +1688,7 @@ mod _io { } } - #[pyimpl( + #[pyclass( with(DefaultConstructor, BufferedMixin, BufferedReadable), flags(BASETYPE, HAS_DICT) )] @@ -1696,7 +1696,7 @@ mod _io { impl DefaultConstructor for BufferedReader {} - #[pyimpl] + #[pyclass] trait BufferedWritable: PyPayload { type Writer: BufferedMixin; fn writer(&self) -> &Self::Writer; @@ -1738,7 +1738,7 @@ mod _io { } } - #[pyimpl( + #[pyclass( with(DefaultConstructor, BufferedMixin, BufferedWritable), flags(BASETYPE, HAS_DICT) )] @@ -1774,7 +1774,7 @@ mod _io { } } - #[pyimpl( + #[pyclass( with(DefaultConstructor, BufferedMixin, BufferedReadable, BufferedWritable), flags(BASETYPE, HAS_DICT) )] @@ -1818,7 +1818,7 @@ mod _io { } } - #[pyimpl( + #[pyclass( with(DefaultConstructor, Initializer, BufferedReadable, BufferedWritable), flags(BASETYPE, HAS_DICT) )] @@ -2294,7 +2294,7 @@ mod _io { } } - #[pyimpl(with(DefaultConstructor, Initializer), flags(BASETYPE))] + #[pyclass(with(DefaultConstructor, Initializer), flags(BASETYPE))] impl TextIOWrapper { #[pymethod] fn seekable(&self, vm: &VirtualMachine) -> PyResult { @@ -3100,7 +3100,7 @@ mod _io { } } - #[pyimpl(flags(BASETYPE, HAS_DICT), with(PyRef, Constructor))] + #[pyclass(flags(BASETYPE, HAS_DICT), with(PyRef, Constructor))] impl StringIO { fn buffer(&self, vm: &VirtualMachine) -> PyResult> { if !self.closed.load() { @@ -3134,7 +3134,7 @@ mod _io { } } - #[pyimpl] + #[pyclass] impl StringIORef { //write string to underlying vector #[pymethod] @@ -3236,7 +3236,7 @@ mod _io { } } - #[pyimpl(flags(BASETYPE, HAS_DICT), with(PyRef, Constructor))] + #[pyclass(flags(BASETYPE, HAS_DICT), with(PyRef, Constructor))] impl BytesIO { fn buffer(&self, vm: &VirtualMachine) -> PyResult> { if !self.closed.load() { @@ -3260,7 +3260,7 @@ mod _io { } } - #[pyimpl] + #[pyclass] impl BytesIORef { #[pymethod] fn write(self, data: ArgBytesLike, vm: &VirtualMachine) -> PyResult { @@ -3910,7 +3910,7 @@ mod fileio { } } - #[pyimpl(with(DefaultConstructor, Initializer), flags(BASETYPE, HAS_DICT))] + #[pyclass(with(DefaultConstructor, Initializer), flags(BASETYPE, HAS_DICT))] impl FileIO { #[pyproperty] fn closed(&self) -> bool { diff --git a/vm/src/stdlib/itertools.rs b/vm/src/stdlib/itertools.rs index 63b37b619..7dba83646 100644 --- a/vm/src/stdlib/itertools.rs +++ b/vm/src/stdlib/itertools.rs @@ -28,7 +28,7 @@ mod decl { active: PyRwLock>, } - #[pyimpl(with(IterNext), flags(BASETYPE))] + #[pyclass(with(IterNext), flags(BASETYPE))] impl PyItertoolsChain { #[pyslot] fn slot_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult { @@ -140,7 +140,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] + #[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyItertoolsCompress { #[pymethod(magic)] fn reduce(zelf: PyRef) -> (PyTypeRef, (PyIter, PyIter)) { @@ -209,7 +209,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsCount { // TODO: Implement this // if (lz->cnt == PY_SSIZE_T_MAX) @@ -263,7 +263,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] + #[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyItertoolsCycle {} impl IterNextIterable for PyItertoolsCycle {} impl IterNext for PyItertoolsCycle { @@ -327,7 +327,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] + #[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyItertoolsRepeat { #[pymethod(magic)] fn length_hint(&self, vm: &VirtualMachine) -> PyResult { @@ -403,7 +403,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] + #[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyItertoolsStarmap { #[pymethod(magic)] fn reduce(zelf: PyRef) -> (PyTypeRef, (PyObjectRef, PyIter)) { @@ -466,7 +466,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] + #[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyItertoolsTakewhile {} impl IterNextIterable for PyItertoolsTakewhile {} impl IterNext for PyItertoolsTakewhile { @@ -531,7 +531,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] + #[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyItertoolsDropwhile {} impl IterNextIterable for PyItertoolsDropwhile {} impl IterNext for PyItertoolsDropwhile { @@ -634,7 +634,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsGroupBy { pub(super) fn advance( &self, @@ -710,7 +710,7 @@ mod decl { groupby: PyRef, } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl PyItertoolsGrouper {} impl IterNextIterable for PyItertoolsGrouper {} impl IterNext for PyItertoolsGrouper { @@ -781,7 +781,7 @@ mod decl { ))) } - #[pyimpl(with(IterNext), flags(BASETYPE))] + #[pyclass(with(IterNext), flags(BASETYPE))] impl PyItertoolsIslice { #[pyslot] fn slot_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult { @@ -910,7 +910,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] + #[pyclass(with(IterNext, Constructor), flags(BASETYPE))] impl PyItertoolsFilterFalse { #[pymethod(magic)] fn reduce(zelf: PyRef) -> (PyTypeRef, (PyObjectRef, PyIter)) { @@ -978,7 +978,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsAccumulate {} impl IterNextIterable for PyItertoolsAccumulate {} @@ -1090,7 +1090,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsTee { fn from_iter(iterator: PyIter, vm: &VirtualMachine) -> PyResult { let class = PyItertoolsTee::class(vm); @@ -1168,7 +1168,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsProduct { fn update_idxs(&self, mut idxs: PyRwLockWriteGuard<'_, Vec>) { if idxs.len() == 0 { @@ -1271,7 +1271,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsCombinations {} impl IterNextIterable for PyItertoolsCombinations {} impl IterNext for PyItertoolsCombinations { @@ -1362,7 +1362,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsCombinationsWithReplacement {} impl IterNextIterable for PyItertoolsCombinationsWithReplacement {} @@ -1472,7 +1472,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsPermutations {} impl IterNextIterable for PyItertoolsPermutations {} impl IterNext for PyItertoolsPermutations { @@ -1575,7 +1575,7 @@ mod decl { fillvalue: PyObjectRef, } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsZipLongest {} impl IterNextIterable for PyItertoolsZipLongest {} impl IterNext for PyItertoolsZipLongest { @@ -1624,7 +1624,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsPairwise {} impl IterNextIterable for PyItertoolsPairwise {} impl IterNext for PyItertoolsPairwise { diff --git a/vm/src/stdlib/operator.rs b/vm/src/stdlib/operator.rs index fdfe04587..a355f1d6b 100644 --- a/vm/src/stdlib/operator.rs +++ b/vm/src/stdlib/operator.rs @@ -430,7 +430,7 @@ mod _operator { attrs: Vec, } - #[pyimpl(with(Callable, Constructor))] + #[pyclass(with(Callable, Constructor))] impl PyAttrGetter { #[pymethod(magic)] fn repr(zelf: PyRef, vm: &VirtualMachine) -> PyResult { @@ -526,7 +526,7 @@ mod _operator { items: Vec, } - #[pyimpl(with(Callable, Constructor))] + #[pyclass(with(Callable, Constructor))] impl PyItemGetter { #[pymethod(magic)] fn repr(zelf: PyRef, vm: &VirtualMachine) -> PyResult { @@ -595,7 +595,7 @@ mod _operator { args: FuncArgs, } - #[pyimpl(with(Callable, Constructor))] + #[pyclass(with(Callable, Constructor))] impl PyMethodCaller { #[pymethod(magic)] fn repr(zelf: PyRef, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index c2bfe1743..b5934e303 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -701,7 +701,7 @@ pub(super) mod _os { ino: AtomicCell>, } - #[pyimpl] + #[pyclass] impl DirEntry { #[pyproperty] fn name(&self, vm: &VirtualMachine) -> PyResult { @@ -870,7 +870,7 @@ pub(super) mod _os { mode: OutputMode, } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl ScandirIterator { #[pymethod] fn close(&self) { @@ -963,7 +963,7 @@ pub(super) mod _os { pub st_ctime_ns: i128, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl StatResult { fn from_stat(stat: &StatStruct, vm: &VirtualMachine) -> Self { let (atime, mtime, ctime); @@ -1487,7 +1487,7 @@ pub(super) mod _os { } #[cfg(all(any(unix, windows), not(target_os = "redox")))] - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl TimesResult {} #[cfg(all(any(unix, windows), not(target_os = "redox")))] @@ -1706,7 +1706,7 @@ pub(super) mod _os { pub columns: usize, pub lines: usize, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl PyTerminalSize {} #[pyattr] @@ -1720,7 +1720,7 @@ pub(super) mod _os { pub machine: String, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl UnameResult {} pub(super) fn support_funcs() -> Vec { diff --git a/vm/src/stdlib/posix.rs b/vm/src/stdlib/posix.rs index 5ce342ffe..09697e5c5 100644 --- a/vm/src/stdlib/posix.rs +++ b/vm/src/stdlib/posix.rs @@ -534,7 +534,7 @@ pub mod module { } } - #[pyimpl(with(Constructor))] + #[pyclass(with(Constructor))] impl SchedParam { #[pyproperty] fn sched_priority(&self, vm: &VirtualMachine) -> PyObjectRef { diff --git a/vm/src/stdlib/pwd.rs b/vm/src/stdlib/pwd.rs index f44b04179..77356260b 100644 --- a/vm/src/stdlib/pwd.rs +++ b/vm/src/stdlib/pwd.rs @@ -24,7 +24,7 @@ mod pwd { pw_dir: String, pw_shell: String, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl Passwd {} impl From for Passwd { diff --git a/vm/src/stdlib/sre.rs b/vm/src/stdlib/sre.rs index a4bb7b01a..251302944 100644 --- a/vm/src/stdlib/sre.rs +++ b/vm/src/stdlib/sre.rs @@ -134,7 +134,7 @@ mod _sre { pub isbytes: bool, } - #[pyimpl(with(Hashable, Comparable))] + #[pyclass(with(Hashable, Comparable))] impl Pattern { fn with_str_drive PyResult>( &self, @@ -551,7 +551,7 @@ mod _sre { regs: Vec<(isize, isize)>, } - #[pyimpl(with(AsMapping))] + #[pyclass(with(AsMapping))] impl Match { pub(crate) fn new(state: &State, pattern: PyRef, string: PyObjectRef) -> Self { let mut regs = vec![(state.start as isize, state.string_position as isize)]; @@ -805,7 +805,7 @@ mod _sre { must_advance: AtomicCell, } - #[pyimpl] + #[pyclass] impl SreScanner { #[pyproperty] fn pattern(&self) -> PyRef { diff --git a/vm/src/stdlib/symtable.rs b/vm/src/stdlib/symtable.rs index 404ad430e..0a73d05b8 100644 --- a/vm/src/stdlib/symtable.rs +++ b/vm/src/stdlib/symtable.rs @@ -50,7 +50,7 @@ mod symtable { } } - #[pyimpl] + #[pyclass] impl PySymbolTable { #[pymethod] fn get_name(&self) -> String { @@ -163,7 +163,7 @@ mod symtable { } } - #[pyimpl] + #[pyclass] impl PySymbol { #[pymethod] fn get_name(&self) -> String { diff --git a/vm/src/stdlib/sys.rs b/vm/src/stdlib/sys.rs index 4cfb1ba8d..92b5aef99 100644 --- a/vm/src/stdlib/sys.rs +++ b/vm/src/stdlib/sys.rs @@ -614,7 +614,7 @@ mod sys { warn_default_encoding: u8, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl Flags { fn from_settings(settings: &Settings) -> Self { Self { @@ -658,7 +658,7 @@ mod sys { radix: u32, rounds: i32, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl PyFloatInfo { const INFO: Self = PyFloatInfo { max: f64::MAX, @@ -689,7 +689,7 @@ mod sys { cutoff: usize, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl PyHashInfo { const INFO: Self = { use rustpython_common::hash::*; @@ -713,7 +713,7 @@ mod sys { bits_per_digit: usize, sizeof_digit: usize, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl PyIntInfo { const INFO: Self = PyIntInfo { bits_per_digit: 30, //? @@ -731,7 +731,7 @@ mod sys { serial: usize, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl VersionInfo { pub const VERSION: VersionInfo = VersionInfo { major: version::MAJOR, @@ -766,7 +766,7 @@ mod sys { platform_version: (u32, u32, u32), } #[cfg(windows)] - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl WindowsVersion {} #[pyclass(noattr, name = "UnraisableHookArgs")] @@ -779,7 +779,7 @@ mod sys { pub object: PyObjectRef, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl UnraisableHookArgs {} } diff --git a/vm/src/stdlib/thread.rs b/vm/src/stdlib/thread.rs index 13102e531..a0784c5ff 100644 --- a/vm/src/stdlib/thread.rs +++ b/vm/src/stdlib/thread.rs @@ -104,7 +104,7 @@ pub(crate) mod _thread { } } - #[pyimpl(with(Constructor))] + #[pyclass(with(Constructor))] impl Lock { #[pymethod] #[pymethod(name = "acquire_lock")] @@ -159,7 +159,7 @@ pub(crate) mod _thread { } } - #[pyimpl] + #[pyclass] impl RLock { #[pyslot] fn slot_new(cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult { @@ -322,7 +322,7 @@ pub(crate) mod _thread { data: ThreadLocal, } - #[pyimpl(with(GetAttr, SetAttr), flags(BASETYPE))] + #[pyclass(with(GetAttr, SetAttr), flags(BASETYPE))] impl Local { fn ldict(&self, vm: &VirtualMachine) -> PyDictRef { self.data.get_or(|| vm.ctx.new_dict()).clone() diff --git a/vm/src/stdlib/time.rs b/vm/src/stdlib/time.rs index e8624156d..e406c9178 100644 --- a/vm/src/stdlib/time.rs +++ b/vm/src/stdlib/time.rs @@ -335,7 +335,7 @@ mod time { } } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl PyStructTime { fn new(vm: &VirtualMachine, tm: NaiveDateTime, isdst: i32) -> Self { PyStructTime { diff --git a/vm/src/stdlib/winreg.rs b/vm/src/stdlib/winreg.rs index 275444e9d..d301e122a 100644 --- a/vm/src/stdlib/winreg.rs +++ b/vm/src/stdlib/winreg.rs @@ -78,7 +78,7 @@ mod winreg { } } - #[pyimpl] + #[pyclass] impl PyHkey { #[pymethod] fn Close(&self) { diff --git a/vm/src/types/slot.rs b/vm/src/types/slot.rs index b9c021e1f..78cd5b94c 100644 --- a/vm/src/types/slot.rs +++ b/vm/src/types/slot.rs @@ -440,7 +440,7 @@ impl PyType { } } -#[pyimpl] +#[pyclass] pub trait Constructor: PyPayload { type Args: FromArgs; @@ -454,7 +454,7 @@ pub trait Constructor: PyPayload { fn py_new(cls: PyTypeRef, args: Self::Args, vm: &VirtualMachine) -> PyResult; } -#[pyimpl] +#[pyclass] pub trait DefaultConstructor: PyPayload + Default { #[inline] #[pyslot] @@ -477,7 +477,7 @@ where } } -#[pyimpl] +#[pyclass] pub trait Initializer: PyPayload { type Args: FromArgs; @@ -498,7 +498,7 @@ pub trait Initializer: PyPayload { fn init(zelf: PyRef, args: Self::Args, vm: &VirtualMachine) -> PyResult<()>; } -#[pyimpl] +#[pyclass] pub trait Destructor: PyPayload { #[inline] // for __del__ #[pyslot] @@ -518,7 +518,7 @@ pub trait Destructor: PyPayload { fn del(zelf: &Py, vm: &VirtualMachine) -> PyResult<()>; } -#[pyimpl] +#[pyclass] pub trait Callable: PyPayload { type Args: FromArgs; @@ -540,7 +540,7 @@ pub trait Callable: PyPayload { fn call(zelf: &Py, args: Self::Args, vm: &VirtualMachine) -> PyResult; } -#[pyimpl] +#[pyclass] pub trait GetDescriptor: PyPayload { #[pyslot] fn descr_get( @@ -608,7 +608,7 @@ pub trait GetDescriptor: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait Hashable: PyPayload { #[inline] #[pyslot] @@ -645,7 +645,7 @@ where } } -#[pyimpl] +#[pyclass] pub trait Comparable: PyPayload { #[inline] #[pyslot] @@ -829,7 +829,7 @@ impl PyComparisonOp { } } -#[pyimpl] +#[pyclass] pub trait GetAttr: PyPayload { #[pyslot] fn slot_getattro(obj: &PyObject, name: PyStrRef, vm: &VirtualMachine) -> PyResult { @@ -849,7 +849,7 @@ pub trait GetAttr: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait SetAttr: PyPayload { #[pyslot] #[inline] @@ -891,7 +891,7 @@ pub trait SetAttr: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait AsBuffer: PyPayload { // TODO: `flags` parameter #[inline] @@ -906,7 +906,7 @@ pub trait AsBuffer: PyPayload { fn as_buffer(zelf: &Py, vm: &VirtualMachine) -> PyResult; } -#[pyimpl] +#[pyclass] pub trait AsMapping: PyPayload { const AS_MAPPING: PyMappingMethods; @@ -922,7 +922,7 @@ pub trait AsMapping: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait AsSequence: PyPayload { const AS_SEQUENCE: PySequenceMethods; @@ -937,7 +937,7 @@ pub trait AsSequence: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait AsNumber: PyPayload { #[pyslot] fn as_number() -> &'static PyNumberMethods; @@ -947,7 +947,7 @@ pub trait AsNumber: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait Iterable: PyPayload { #[pyslot] #[pymethod(name = "__iter__")] @@ -963,7 +963,7 @@ pub trait Iterable: PyPayload { } // `Iterator` fits better, but to avoid confusion with rust std::iter::Iterator -#[pyimpl(with(Iterable))] +#[pyclass(with(Iterable))] pub trait IterNext: PyPayload + Iterable { #[pyslot] fn slot_iternext(zelf: &PyObject, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/types/structseq.rs b/vm/src/types/structseq.rs index cda565319..b3d2c5f50 100644 --- a/vm/src/types/structseq.rs +++ b/vm/src/types/structseq.rs @@ -5,7 +5,7 @@ use crate::{ AsObject, Py, PyObjectRef, PyPayload, PyRef, PyResult, VirtualMachine, }; -#[pyimpl] +#[pyclass] pub trait PyStructSequence: StaticType + PyClassImpl + Sized + 'static { const FIELD_NAMES: &'static [&'static str]; diff --git a/wasm/lib/src/browser_module.rs b/wasm/lib/src/browser_module.rs index 77618236e..144f67e3f 100644 --- a/wasm/lib/src/browser_module.rs +++ b/wasm/lib/src/browser_module.rs @@ -166,7 +166,7 @@ mod _browser { doc: web_sys::Document, } - #[pyimpl] + #[pyclass] impl Document { #[pymethod] fn query(&self, query: PyStrRef, vm: &VirtualMachine) -> PyResult { @@ -198,7 +198,7 @@ mod _browser { elem: web_sys::Element, } - #[pyimpl] + #[pyclass] impl Element { #[pymethod] fn get_attr( diff --git a/wasm/lib/src/js_module.rs b/wasm/lib/src/js_module.rs index 0764f546f..08a816924 100644 --- a/wasm/lib/src/js_module.rs +++ b/wasm/lib/src/js_module.rs @@ -90,7 +90,7 @@ mod _js { } } - #[pyimpl] + #[pyclass] impl PyJsValue { #[inline] pub fn new(value: impl Into) -> PyJsValue { @@ -301,7 +301,7 @@ mod _js { } } - #[pyimpl] + #[pyclass] impl JsClosure { fn new(obj: PyObjectRef, once: bool, vm: &VirtualMachine) -> PyResult { let wasm_vm = WASMVirtualMachine { @@ -396,7 +396,7 @@ mod _js { PyRejected(PyBaseExceptionRef), } - #[pyimpl] + #[pyclass] impl PyPromise { pub fn new(value: Promise) -> PyPromise { PyPromise { @@ -566,7 +566,7 @@ mod _js { } } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl AwaitPromise { #[pymethod] fn send(&self, val: Option, vm: &VirtualMachine) -> PyResult {