diff --git a/ast/asdl_rs.py b/ast/asdl_rs.py index 9c1e6222d6..0e263f1fcf 100755 --- a/ast/asdl_rs.py +++ b/ast/asdl_rs.py @@ -386,7 +386,7 @@ def gen_classdef(self, name, fields, attrs, depth, base="AstNode"): self.emit(f"struct {structname};", depth) self.emit("#[pyimpl(flags(HAS_DICT, BASETYPE))]", depth) self.emit(f"impl {structname} {{", depth) - self.emit(f"#[extend_class]", depth + 1) + self.emit(f"#[py::extend_class]", depth + 1) self.emit("fn extend_class_with_fields(ctx: &Context, class: &'static Py) {", depth + 1) fields = ",".join(f"ctx.new_str(ascii!({json.dumps(f.name)})).into()" for f in fields) self.emit(f'class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![{fields}]).into());', depth + 2) diff --git a/derive/src/lib.rs b/derive/src/lib.rs index f3cef0eb46..aeb34396d9 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 d940f7611f..c47af84f0c 100644 --- a/derive/src/pyclass.rs +++ b/derive/src/pyclass.rs @@ -1,7 +1,8 @@ use super::Diagnostic; use crate::util::{ - path_eq, pyclass_ident_and_attrs, text_signature, ClassItemMeta, ContentItem, ContentItemInner, - ErrorVec, ItemMeta, ItemMetaInner, ItemNursery, SimpleItemMeta, ALL_ALLOWED_NAMES, + path_eq, pyclass_ident_and_attrs, text_signature, AttributeExt, ClassItemMeta, ContentItem, + ContentItemInner, ErrorVec, ItemMeta, ItemMetaInner, ItemNursery, SimpleItemMeta, + ALL_ALLOWED_NAMES, }; use proc_macro2::{Span, TokenStream}; use quote::{quote, quote_spanned, ToTokens}; @@ -35,7 +36,7 @@ impl std::fmt::Display for AttrName { Self::GetSet => "pyproperty", Self::Slot => "pyslot", Self::Attr => "pyattr", - Self::ExtendClass => "extend_class", + Self::ExtendClass => "pyextend_class", }; s.fmt(f) } @@ -51,7 +52,7 @@ impl FromStr for AttrName { "pyproperty" => Self::GetSet, "pyslot" => Self::Slot, "pyattr" => Self::Attr, - "extend_class" => Self::ExtendClass, + "pyextend_class" => Self::ExtendClass, s => { return Err(s.to_owned()); } @@ -373,7 +374,7 @@ pub(crate) fn impl_define_exception(exc_def: PyExceptionDef) -> Result, } -/// #[extend_class] +/// #[py::extend_class] struct ExtendClassItem { inner: ContentItemInner, } @@ -954,7 +955,7 @@ fn extract_impl_attrs(attr: AttributeArgs, item: &Ident) -> 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") { @@ -988,12 +989,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") } } } @@ -1061,14 +1062,11 @@ where while let Some((_, attr)) = iter.peek() { // take all cfgs but no py items let attr = *attr; - let attr_name = if let Some(ident) = attr.get_ident() { - ident.to_string() - } else { - continue; - }; - if attr_name == "cfg" { + let attr_path = attr.path_string(); + + if attr_path == "cfg" { cfgs.push(attr.clone()); - } else if ALL_ALLOWED_NAMES.contains(&attr_name.as_str()) { + } else if attr_path.starts_with("py") { break; } iter.next(); @@ -1076,24 +1074,21 @@ where for (i, attr) in iter { // take py items but no cfgs - let attr_name = if let Some(ident) = attr.get_ident() { - ident.to_string() - } else { - continue; - }; - if attr_name == "cfg" { + let attr_path = attr.path_string(); + if attr_path == "cfg" { return Err(syn::Error::new_spanned( attr, "#[py*] items must be placed under `cfgs`", )); } + let attr_name = attr_path.replace("::", ""); let attr_name = match AttrName::from_str(attr_name.as_str()) { Ok(name) => name, Err(wrong_name) => { 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 0b7b9326ba..4056cd97d4 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 name, diff --git a/derive/src/util.rs b/derive/src/util.rs index b378114488..1f4d3408d3 100644 --- a/derive/src/util.rs +++ b/derive/src/util.rs @@ -34,10 +34,15 @@ struct NurseryItem { sort_order: usize, } +pub fn path_to_string(path: &syn::Path) -> String { + let x = format!("{}", quote! {#path}); + x.replace(' ', "") +} + #[derive(Default)] pub(crate) struct ItemNursery(Vec); -pub(crate) struct ValidatedItemNursery(ItemNursery); +pub(crate) struct ValidItemNursery(ItemNursery); impl ItemNursery { pub fn add_item( @@ -58,7 +63,7 @@ impl ItemNursery { Ok(()) } - pub fn validate(self) -> Result { + pub fn validate(self) -> Result { let mut by_name: HashSet<(String, Vec)> = HashSet::new(); for item in &self.0 { for py_name in &item.py_names { @@ -71,11 +76,11 @@ impl ItemNursery { } } } - Ok(ValidatedItemNursery(self)) + Ok(ValidItemNursery(self)) } } -impl ToTokens for ValidatedItemNursery { +impl ToTokens for ValidItemNursery { fn to_tokens(&self, tokens: &mut TokenStream) { let mut sorted = self.0 .0.clone(); sorted.sort_by(|a, b| a.sort_order.cmp(&b.sort_order)); @@ -379,6 +384,7 @@ pub(crate) fn path_eq(path: &Path, s: &str) -> bool { } pub(crate) trait AttributeExt: SynAttributeExt { + fn path_string(&self) -> String; fn promoted_nested(&self) -> Result; fn ident_and_promoted_nested(&self) -> Result<(&Ident, PunctuatedNestedMeta)>; fn try_remove_name(&mut self, name: &str) -> Result>; @@ -388,9 +394,12 @@ pub(crate) trait AttributeExt: SynAttributeExt { } impl AttributeExt for Attribute { + fn path_string(&self) -> String { + path_to_string(&self.path) + } fn promoted_nested(&self) -> Result { let list = self.promoted_list().map_err(|mut e| { - let name = self.get_ident().unwrap().to_string(); + let name = self.path_string(); e.combine(syn::Error::new_spanned( self, format!( @@ -404,7 +413,15 @@ impl AttributeExt for Attribute { Ok(list.nested) } fn ident_and_promoted_nested(&self) -> Result<(&Ident, PunctuatedNestedMeta)> { - Ok((self.get_ident().unwrap(), self.promoted_nested()?)) + let ident = self.get_ident().unwrap_or_else(|| { + &self + .path + .segments + .last() + .expect("py:: paths always have segment") + .ident + }); + Ok((ident, self.promoted_nested()?)) } fn try_remove_name(&mut self, item_name: &str) -> Result> { diff --git a/stdlib/src/array.rs b/stdlib/src/array.rs index ee9bef2a82..4f915169fc 100644 --- a/stdlib/src/array.rs +++ b/stdlib/src/array.rs @@ -666,7 +666,7 @@ mod array { } } - #[pyimpl( + #[pyclass( flags(BASETYPE), with(Comparable, AsBuffer, AsMapping, Iterable, Constructor) )] @@ -1282,7 +1282,7 @@ mod array { array: PyArrayRef, } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl PyArrayIter {} impl IterNextIterable for PyArrayIter {} diff --git a/stdlib/src/contextvars.rs b/stdlib/src/contextvars.rs index 8cefad4bd2..7ebd5960c2 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 66848ca8fa..6b152482be 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/hashlib.rs b/stdlib/src/hashlib.rs index d375fa1899..702fab583f 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 79b31da2a2..7a2a1ce97c 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/pyexpat.rs b/stdlib/src/pyexpat.rs index 9fe308b4be..ae86e99ccc 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 { @@ -75,7 +75,7 @@ mod _pyexpat { .into_ref(vm)) } - #[extend_class] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { let mut attributes = class.attributes.write(); diff --git a/stdlib/src/pystruct.rs b/stdlib/src/pystruct.rs index 56668db882..69ed20607e 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 412f80c0ee..950d34ee90 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 8dffda854d..67b85975a8 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 70d6419747..1d3513f47d 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 29a0538326..644d64ecac 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 2015c5c4e1..f40dfcbb1e 100644 --- a/stdlib/src/socket.rs +++ b/stdlib/src/socket.rs @@ -544,7 +544,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 234e482aa8..15c1a5c65d 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 d8fad12192..ac25c4d1eb 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 37d1f39995..e6416872e3 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 16cf864a6a..c773175855 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 f60a56f2a4..1ecd102141 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 92162a82b8..5049aa2547 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 94fcdb5401..b471084a5d 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 faa8dc5ac0..6bfe454140 100644 --- a/vm/src/builtins/bytes.rs +++ b/vm/src/builtins/bytes.rs @@ -99,7 +99,7 @@ impl PyBytes { } } -#[pyimpl( +#[pyclass( flags(BASETYPE), with( AsMapping, @@ -659,7 +659,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 de7db8666d..4716339f0d 100644 --- a/vm/src/builtins/classmethod.rs +++ b/vm/src/builtins/classmethod.rs @@ -76,7 +76,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 888d8c949c..ff2257a536 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 9e4f5af904..a17b91ef0c 100644 --- a/vm/src/builtins/complex.rs +++ b/vm/src/builtins/complex.rs @@ -203,7 +203,7 @@ impl PyComplex { } } -#[pyimpl(flags(BASETYPE), with(Comparable, Hashable, Constructor))] +#[pyclass(flags(BASETYPE), with(Comparable, Hashable, Constructor))] 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 79f989f132..a6c769aacd 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 8be379ee1e..13c3fc6363 100644 --- a/vm/src/builtins/dict.rs +++ b/vm/src/builtins/dict.rs @@ -216,7 +216,7 @@ impl PyDict { // Python dict methods: #[allow(clippy::len_without_is_empty)] -#[pyimpl( +#[pyclass( with( Constructor, Initializer, @@ -668,7 +668,7 @@ impl Iterator for DictIter { } } -#[pyimpl] +#[pyclass] trait DictView: PyPayload + PyClassDef + Iterable where Self::ReverseIter: PyPayload, @@ -757,7 +757,7 @@ macro_rules! dict_view { } } - #[pyimpl(with(Constructor, IterNext))] + #[pyclass(with(Constructor, IterNext))] impl $iter_name { fn new(dict: PyDictRef) -> Self { $iter_name { @@ -830,7 +830,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(); @@ -942,7 +942,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(); @@ -1027,7 +1027,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 { @@ -1061,7 +1061,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 { @@ -1109,7 +1109,7 @@ impl AsSequence for PyDictItems { }; } -#[pyimpl(with(DictView, Constructor, Iterable, AsSequence))] +#[pyclass(with(DictView, Constructor, Iterable, AsSequence))] impl PyDictValues {} impl Unconstructible for PyDictValues {} diff --git a/vm/src/builtins/enumerate.rs b/vm/src/builtins/enumerate.rs index 491b2bde78..254fc1b148 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 bf0c5f4ec2..9e223d18b2 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 d83439b5eb..9f8e3798b7 100644 --- a/vm/src/builtins/float.rs +++ b/vm/src/builtins/float.rs @@ -192,7 +192,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 38fc48b7b0..27e9072591 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 f97fdad37a..936e2a11c9 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 ea85a16d72..cc1d55a0c4 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 4f1d6fedde..bc0ad0a87c 100644 --- a/vm/src/builtins/genericalias.rs +++ b/vm/src/builtins/genericalias.rs @@ -55,7 +55,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 91ac494860..29254d1cc0 100644 --- a/vm/src/builtins/getset.rs +++ b/vm/src/builtins/getset.rs @@ -302,7 +302,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 9a1ad9cfab..5d9c1a28fb 100644 --- a/vm/src/builtins/int.rs +++ b/vm/src/builtins/int.rs @@ -350,7 +350,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 98bdb4a414..795fedbd74 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 27a22ea284..492ca6cae3 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, @@ -537,7 +537,7 @@ impl PyPayload for PyListIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyListIterator { #[pymethod(magic)] fn length_hint(&self) -> usize { @@ -582,7 +582,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 8c65295f03..e93bc698f7 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 d603bca740..890ccdf026 100644 --- a/vm/src/builtins/mappingproxy.rs +++ b/vm/src/builtins/mappingproxy.rs @@ -56,7 +56,7 @@ impl Constructor for PyMappingProxy { } } -#[pyimpl(with(AsMapping, Iterable, Constructor, AsSequence))] +#[pyclass(with(AsMapping, Iterable, Constructor, AsSequence))] 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 61b28e3bc5..ab9293ca22 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 51922ba75f..df96d2dcbf 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 4227e3443b..aa13e2ee05 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 1be14365d0..3e39b45767 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 edf50ae27c..832de6512b 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 312a46efe0..cf252e76b4 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: PyIntRef, vm: &VirtualMachine) -> PyResult> { PyRange { @@ -523,7 +523,7 @@ impl PyPayload for PyLongRangeIterator { } } -#[pyimpl(with(Constructor, IterNext))] +#[pyclass(with(Constructor, IterNext))] impl PyLongRangeIterator { #[pymethod(magic)] fn length_hint(&self) -> BigInt { @@ -588,7 +588,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 a637b3b6ef..26e4efdc42 100644 --- a/vm/src/builtins/set.rs +++ b/vm/src/builtins/set.rs @@ -391,7 +391,7 @@ impl PySet { } } -#[pyimpl( +#[pyclass( with(Constructor, Initializer, AsSequence, Hashable, Comparable, Iterable), flags(BASETYPE) )] @@ -728,7 +728,7 @@ impl Constructor for PyFrozenSet { } } -#[pyimpl( +#[pyclass( flags(BASETYPE), with(Constructor, AsSequence, Hashable, Comparable, Iterable) )] @@ -967,7 +967,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 e2c26edcb8..d6f0c3fa59 100644 --- a/vm/src/builtins/singletons.rs +++ b/vm/src/builtins/singletons.rs @@ -39,7 +39,7 @@ impl Constructor for PyNone { } } -#[pyimpl(with(Constructor))] +#[pyclass(with(Constructor))] impl PyNone { #[pymethod(magic)] fn repr(&self) -> String { @@ -70,7 +70,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 e10ea058a6..9318efbaa3 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 88f8317d8f..1a01ff0995 100644 --- a/vm/src/builtins/staticmethod.rs +++ b/vm/src/builtins/staticmethod.rs @@ -66,7 +66,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 isabstractmethod(&self, vm: &VirtualMachine) -> PyObjectRef { diff --git a/vm/src/builtins/str.rs b/vm/src/builtins/str.rs index 1700795d6a..8511ecec9c 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 2a74cbb474..8601941540 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 731ccbd12b..98d9a3aedb 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 59ea9a6447..f095c75c45 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) )] @@ -425,7 +425,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 e0cc7e3370..e3f56ce67b 100644 --- a/vm/src/builtins/type.rs +++ b/vm/src/builtins/type.rs @@ -229,7 +229,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 813974b53c..5fe2bb5265 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 0c482d89d9..205c81be39 100644 --- a/vm/src/builtins/weakproxy.rs +++ b/vm/src/builtins/weakproxy.rs @@ -57,7 +57,7 @@ crate::common::static_cell! { static WEAK_SUBCLASS: PyTypeRef; } -#[pyimpl(with(SetAttr, Constructor))] +#[pyclass(with(SetAttr, Constructor))] impl PyWeakProxy { // TODO: callbacks #[pymethod(magic)] diff --git a/vm/src/builtins/weakref.rs b/vm/src/builtins/weakref.rs index e57fe25cbe..99fa681beb 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 7493ed136d..955e587978 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 48be00e1d5..3f216c6495 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 9f4c191be0..8725ce3184 100644 --- a/vm/src/protocol/buffer.rs +++ b/vm/src/protocol/buffer.rs @@ -400,7 +400,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 8c848ca1c0..7d080c7feb 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 7ee4f8fb2e..27d26854cb 100644 --- a/vm/src/stdlib/ast/gen.rs +++ b/vm/src/stdlib/ast/gen.rs @@ -7,13 +7,13 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -28,9 +28,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -42,9 +42,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -56,9 +56,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -73,13 +73,13 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -107,9 +107,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -137,9 +137,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -166,9 +166,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -189,9 +189,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -212,9 +212,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -239,9 +239,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -266,9 +266,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -294,9 +294,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -323,9 +323,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -352,9 +352,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -379,9 +379,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -406,9 +406,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -433,9 +433,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -460,9 +460,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -486,9 +486,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -514,9 +514,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -540,9 +540,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -563,9 +563,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -590,9 +590,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -613,9 +613,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -636,9 +636,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -659,9 +659,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr( @@ -678,9 +678,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr( @@ -697,9 +697,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr( @@ -716,13 +716,13 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -746,9 +746,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -772,9 +772,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -799,9 +799,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -825,9 +825,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -851,9 +851,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -878,9 +878,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -904,9 +904,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -927,9 +927,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -953,9 +953,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -979,9 +979,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1006,9 +1006,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1032,9 +1032,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1055,9 +1055,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1078,9 +1078,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1101,9 +1101,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1128,9 +1128,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1155,9 +1155,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1182,9 +1182,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1205,9 +1205,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1231,9 +1231,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1258,9 +1258,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1285,9 +1285,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1311,9 +1311,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1337,9 +1337,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1363,9 +1363,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1389,9 +1389,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1416,13 +1416,13 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1430,9 +1430,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1440,9 +1440,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1450,13 +1450,13 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1464,9 +1464,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1474,13 +1474,13 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1488,9 +1488,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1498,9 +1498,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1508,9 +1508,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1518,9 +1518,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1528,9 +1528,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1538,9 +1538,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1548,9 +1548,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1558,9 +1558,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1568,9 +1568,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1578,9 +1578,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1588,9 +1588,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1598,9 +1598,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1608,13 +1608,13 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1622,9 +1622,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1632,9 +1632,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1642,9 +1642,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1652,13 +1652,13 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1666,9 +1666,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1676,9 +1676,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1686,9 +1686,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1696,9 +1696,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1706,9 +1706,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1716,9 +1716,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1726,9 +1726,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1736,9 +1736,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1746,9 +1746,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![]).into()); class.set_attr(identifier!(ctx, _attributes), ctx.new_list(vec![]).into()); @@ -1756,9 +1756,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -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,9 +1783,9 @@ impl NodeKindExcepthandler {} base = "NodeKindExcepthandler" )] struct NodeExceptHandler; -#[pyimpl(flags(HAS_DICT, BASETYPE))] +#[pyclass(flags(HAS_DICT, BASETYPE))] impl NodeExceptHandler { - #[extend_class] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1810,9 +1810,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1832,9 +1832,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1859,9 +1859,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1885,9 +1885,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1902,9 +1902,9 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), @@ -1919,13 +1919,13 @@ 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] + #[py::extend_class] fn extend_class_with_fields(ctx: &Context, class: &'static Py) { class.set_attr( identifier!(ctx, _fields), diff --git a/vm/src/stdlib/builtins.rs b/vm/src/stdlib/builtins.rs index 4a051eb419..397a512802 100644 --- a/vm/src/stdlib/builtins.rs +++ b/vm/src/stdlib/builtins.rs @@ -39,7 +39,7 @@ mod builtins { }; use num_traits::{Signed, ToPrimitive, Zero}; - #[pyfunction] + #[py::function] fn abs(x: PyObjectRef, vm: &VirtualMachine) -> PyResult { vm._abs(&x) } diff --git a/vm/src/stdlib/collections.rs b/vm/src/stdlib/collections.rs index 59efa9a674..3cfe4e3efc 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) )] @@ -611,7 +611,7 @@ mod _collections { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyDequeIterator { pub(crate) fn new(deque: PyDequeRef) -> Self { PyDequeIterator { @@ -684,7 +684,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 a77d43d827..3c7e8184d3 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 { @@ -703,7 +703,7 @@ mod _io { #[pyclass(name = "_TextIOBase", base = "_IOBase")] struct _TextIOBase; - #[pyimpl(flags(BASETYPE))] + #[pyclass(flags(BASETYPE))] impl _TextIOBase {} #[derive(FromArgs, Clone)] @@ -1365,7 +1365,7 @@ mod _io { } } - #[pyimpl] + #[pyclass] trait BufferedMixin: PyPayload { const CLASS_NAME: &'static str; const READABLE: bool; @@ -1580,7 +1580,7 @@ mod _io { } } - #[pyimpl] + #[pyclass] trait BufferedReadable: PyPayload { type Reader: BufferedMixin; fn reader(&self) -> &Self::Reader; @@ -1682,7 +1682,7 @@ mod _io { } } - #[pyimpl( + #[pyclass( with(DefaultConstructor, BufferedMixin, BufferedReadable), flags(BASETYPE, HAS_DICT) )] @@ -1690,7 +1690,7 @@ mod _io { impl DefaultConstructor for BufferedReader {} - #[pyimpl] + #[pyclass] trait BufferedWritable: PyPayload { type Writer: BufferedMixin; fn writer(&self) -> &Self::Writer; @@ -1732,7 +1732,7 @@ mod _io { } } - #[pyimpl( + #[pyclass( with(DefaultConstructor, BufferedMixin, BufferedWritable), flags(BASETYPE, HAS_DICT) )] @@ -1768,7 +1768,7 @@ mod _io { } } - #[pyimpl( + #[pyclass( with(DefaultConstructor, BufferedMixin, BufferedReadable, BufferedWritable), flags(BASETYPE, HAS_DICT) )] @@ -1812,7 +1812,7 @@ mod _io { } } - #[pyimpl( + #[pyclass( with(DefaultConstructor, Initializer, BufferedReadable, BufferedWritable), flags(BASETYPE, HAS_DICT) )] @@ -2288,7 +2288,7 @@ mod _io { } } - #[pyimpl(with(DefaultConstructor, Initializer), flags(BASETYPE))] + #[pyclass(with(DefaultConstructor, Initializer), flags(BASETYPE))] impl TextIOWrapper { #[pymethod] fn seekable(&self, vm: &VirtualMachine) -> PyResult { @@ -3088,7 +3088,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() { @@ -3122,7 +3122,7 @@ mod _io { } } - #[pyimpl] + #[pyclass] impl StringIORef { //write string to underlying vector #[pymethod] @@ -3224,7 +3224,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() { @@ -3248,7 +3248,7 @@ mod _io { } } - #[pyimpl] + #[pyclass] impl BytesIORef { #[pymethod] fn write(self, data: ArgBytesLike, vm: &VirtualMachine) -> PyResult { @@ -3898,7 +3898,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 ed02cc5a6b..d81792f10d 100644 --- a/vm/src/stdlib/itertools.rs +++ b/vm/src/stdlib/itertools.rs @@ -30,7 +30,7 @@ mod decl { cached_iter: PyRwLock>, } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl PyItertoolsChain { #[pyslot] fn slot_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult { @@ -129,7 +129,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsCompress {} impl IterNextIterable for PyItertoolsCompress {} @@ -193,7 +193,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsCount { // TODO: Implement this // if (lz->cnt == PY_SSIZE_T_MAX) @@ -236,7 +236,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsCycle {} impl IterNextIterable for PyItertoolsCycle {} impl IterNext for PyItertoolsCycle { @@ -300,7 +300,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 { @@ -376,7 +376,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsStarmap {} impl IterNextIterable for PyItertoolsStarmap {} impl IterNext for PyItertoolsStarmap { @@ -431,7 +431,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsTakewhile {} impl IterNextIterable for PyItertoolsTakewhile {} impl IterNext for PyItertoolsTakewhile { @@ -496,7 +496,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsDropwhile {} impl IterNextIterable for PyItertoolsDropwhile {} impl IterNext for PyItertoolsDropwhile { @@ -599,7 +599,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsGroupBy { pub(super) fn advance( &self, @@ -675,7 +675,7 @@ mod decl { groupby: PyRef, } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl PyItertoolsGrouper {} impl IterNextIterable for PyItertoolsGrouper {} impl IterNext for PyItertoolsGrouper { @@ -746,7 +746,7 @@ mod decl { ))); } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl PyItertoolsIslice { #[pyslot] fn slot_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult { @@ -875,7 +875,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsFilterFalse { #[pymethod(magic)] fn reduce(zelf: PyRef) -> (PyTypeRef, (PyObjectRef, PyIter)) { @@ -943,7 +943,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsAccumulate {} impl IterNextIterable for PyItertoolsAccumulate {} @@ -1055,7 +1055,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); @@ -1133,7 +1133,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 { @@ -1236,7 +1236,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsCombinations {} impl IterNextIterable for PyItertoolsCombinations {} impl IterNext for PyItertoolsCombinations { @@ -1327,7 +1327,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsCombinationsWithReplacement {} impl IterNextIterable for PyItertoolsCombinationsWithReplacement {} @@ -1437,7 +1437,7 @@ mod decl { } } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsPermutations {} impl IterNextIterable for PyItertoolsPermutations {} impl IterNext for PyItertoolsPermutations { @@ -1540,7 +1540,7 @@ mod decl { fillvalue: PyObjectRef, } - #[pyimpl(with(IterNext, Constructor))] + #[pyclass(with(IterNext, Constructor))] impl PyItertoolsZipLongest {} impl IterNextIterable for PyItertoolsZipLongest {} impl IterNext for PyItertoolsZipLongest { @@ -1589,7 +1589,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 2ee0a516a3..33868db98f 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 8921a648d6..0d9b7f5455 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -700,7 +700,7 @@ pub(super) mod _os { ino: AtomicCell>, } - #[pyimpl] + #[pyclass] impl DirEntry { #[pyproperty] fn name(&self, vm: &VirtualMachine) -> PyResult { @@ -869,7 +869,7 @@ pub(super) mod _os { mode: OutputMode, } - #[pyimpl(with(IterNext))] + #[pyclass(with(IterNext))] impl ScandirIterator { #[pymethod] fn close(&self) { @@ -962,7 +962,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); @@ -1486,7 +1486,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")))] @@ -1704,7 +1704,7 @@ pub(super) mod _os { pub columns: usize, pub lines: usize, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl PyTerminalSize {} #[pyattr] @@ -1718,7 +1718,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 4b0dab9413..d3e77b994f 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 bb9d5ca212..4868a22a42 100644 --- a/vm/src/stdlib/pwd.rs +++ b/vm/src/stdlib/pwd.rs @@ -23,7 +23,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 2b6b88d9f2..8080217f31 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 404ad430e0..0a73d05b85 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 75ec330b9d..03e176f601 100644 --- a/vm/src/stdlib/sys.rs +++ b/vm/src/stdlib/sys.rs @@ -608,7 +608,7 @@ mod sys { warn_default_encoding: u8, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl Flags { fn from_settings(settings: &Settings) -> Self { Self { @@ -652,7 +652,7 @@ mod sys { radix: u32, rounds: i32, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl PyFloatInfo { const INFO: Self = PyFloatInfo { max: f64::MAX, @@ -683,7 +683,7 @@ mod sys { cutoff: usize, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl PyHashInfo { const INFO: Self = { use rustpython_common::hash::*; @@ -707,7 +707,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, //? @@ -725,7 +725,7 @@ mod sys { serial: usize, } - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl VersionInfo { pub const VERSION: VersionInfo = VersionInfo { major: version::MAJOR, @@ -760,7 +760,7 @@ mod sys { platform_version: (u32, u32, u32), } #[cfg(windows)] - #[pyimpl(with(PyStructSequence))] + #[pyclass(with(PyStructSequence))] impl WindowsVersion {} #[pyclass(noattr, name = "UnraisableHookArgs")] @@ -773,7 +773,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 13102e531b..a0784c5ff5 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 369b6e289e..8ec00aa8e4 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 275444e9d0..d301e122a6 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 ae3099a284..8b95eda100 100644 --- a/vm/src/types/slot.rs +++ b/vm/src/types/slot.rs @@ -560,7 +560,7 @@ impl PyType { } } -#[pyimpl] +#[pyclass] pub trait Constructor: PyPayload { type Args: FromArgs; @@ -574,7 +574,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] @@ -597,7 +597,7 @@ where } } -#[pyimpl] +#[pyclass] pub trait Initializer: PyPayload { type Args: FromArgs; @@ -618,7 +618,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] @@ -638,7 +638,7 @@ pub trait Destructor: PyPayload { fn del(zelf: &Py, vm: &VirtualMachine) -> PyResult<()>; } -#[pyimpl] +#[pyclass] pub trait Callable: PyPayload { type Args: FromArgs; @@ -660,7 +660,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( @@ -728,7 +728,7 @@ pub trait GetDescriptor: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait Hashable: PyPayload { #[inline] #[pyslot] @@ -765,7 +765,7 @@ where } } -#[pyimpl] +#[pyclass] pub trait Comparable: PyPayload { #[inline] #[pyslot] @@ -949,7 +949,7 @@ impl PyComparisonOp { } } -#[pyimpl] +#[pyclass] pub trait GetAttr: PyPayload { #[pyslot] fn slot_getattro(obj: &PyObject, name: PyStrRef, vm: &VirtualMachine) -> PyResult { @@ -969,7 +969,7 @@ pub trait GetAttr: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait SetAttr: PyPayload { #[pyslot] #[inline] @@ -1011,7 +1011,7 @@ pub trait SetAttr: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait AsBuffer: PyPayload { // TODO: `flags` parameter #[inline] @@ -1026,7 +1026,7 @@ pub trait AsBuffer: PyPayload { fn as_buffer(zelf: &Py, vm: &VirtualMachine) -> PyResult; } -#[pyimpl] +#[pyclass] pub trait AsMapping: PyPayload { const AS_MAPPING: PyMappingMethods; @@ -1042,7 +1042,7 @@ pub trait AsMapping: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait AsSequence: PyPayload { const AS_SEQUENCE: PySequenceMethods; @@ -1057,7 +1057,7 @@ pub trait AsSequence: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait AsNumber: PyPayload { const AS_NUMBER: PyNumberMethods; @@ -1072,7 +1072,7 @@ pub trait AsNumber: PyPayload { } } -#[pyimpl] +#[pyclass] pub trait Iterable: PyPayload { #[pyslot] #[pymethod(name = "__iter__")] @@ -1088,7 +1088,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 cda565319b..a5f45b4df4 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]; @@ -72,7 +72,7 @@ pub trait PyStructSequence: StaticType + PyClassImpl + Sized + 'static { vm.new_tuple((zelf.class().clone(), (vm.ctx.new_tuple(zelf.to_vec()),))) } - #[extend_class] + #[py::extend_class] fn extend_pyclass(ctx: &Context, class: &'static Py) { for (i, &name) in Self::FIELD_NAMES.iter().enumerate() { // cast i to a u8 so there's less to store in the getter closure. diff --git a/wasm/lib/src/browser_module.rs b/wasm/lib/src/browser_module.rs index 77618236ec..144f67e3fe 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 0764f546f3..08a8169245 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 {