Struct rustpython_vm::builtins::PyType
source · pub struct PyType {
pub base: Option<PyTypeRef>,
pub bases: Vec<PyTypeRef>,
pub mro: Vec<PyTypeRef>,
pub subclasses: PyRwLock<Vec<PyRef<PyWeak>>>,
pub attributes: PyRwLock<IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>>,
pub slots: PyTypeSlots,
pub heaptype_ext: Option<Pin<Box<HeapTypeExt>>>,
}
Fields§
§base: Option<PyTypeRef>
§bases: Vec<PyTypeRef>
§mro: Vec<PyTypeRef>
§subclasses: PyRwLock<Vec<PyRef<PyWeak>>>
§attributes: PyRwLock<IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>>
§slots: PyTypeSlots
§heaptype_ext: Option<Pin<Box<HeapTypeExt>>>
Implementations§
source§impl PyType
impl PyType
pub fn new_simple_heap( name: &str, base: &PyTypeRef, ctx: &Context ) -> Result<PyRef<Self>, String>
pub fn new_heap( name: &str, bases: Vec<PyRef<Self>>, attrs: IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>, slots: PyTypeSlots, metaclass: PyRef<Self>, ctx: &Context ) -> Result<PyRef<Self>, String>
pub fn new_static( base: PyRef<Self>, attrs: IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>, slots: PyTypeSlots, metaclass: PyRef<Self> ) -> Result<PyRef<Self>, String>
pub fn iter_mro(&self) -> impl Iterator<Item = &PyType> + DoubleEndedIterator
pub fn set_str_attr<V: Into<PyObjectRef>>( &self, attr_name: &str, value: V, ctx: impl AsRef<Context> )
pub fn set_attr(&self, attr_name: &'static PyStrInterned, value: PyObjectRef)
sourcepub fn get_attr(&self, attr_name: &'static PyStrInterned) -> Option<PyObjectRef>
pub fn get_attr(&self, attr_name: &'static PyStrInterned) -> Option<PyObjectRef>
This is the internal get_attr implementation for fast lookup on a class.
pub fn get_direct_attr( &self, attr_name: &'static PyStrInterned ) -> Option<PyObjectRef>
pub fn get_super_attr( &self, attr_name: &'static PyStrInterned ) -> Option<PyObjectRef>
pub fn has_attr(&self, attr_name: &'static PyStrInterned) -> bool
pub fn get_attributes( &self ) -> IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>
pub fn slot_name(&self) -> BorrowedValue<'_, str>
pub fn name(&self) -> BorrowedValue<'_, str>
source§impl PyType
impl PyType
pub fn __name__(&self, vm: &VirtualMachine) -> PyStrRef
pub fn qualname(&self, vm: &VirtualMachine) -> PyObjectRef
pub fn module(&self, vm: &VirtualMachine) -> PyObjectRef
pub fn ror( zelf: PyObjectRef, other: PyObjectRef, vm: &VirtualMachine ) -> PyObjectRef
pub fn or( zelf: PyObjectRef, other: PyObjectRef, vm: &VirtualMachine ) -> PyObjectRef
Trait Implementations§
source§impl AsNumber for PyType
impl AsNumber for PyType
fn as_number() -> &'static PyNumberMethods
fn clone_exact(_zelf: &Py<Self>, _vm: &VirtualMachine) -> PyRef<Self>
fn number_downcast(num: PyNumber<'_>) -> &Py<Self>
fn number_downcast_exact(num: PyNumber<'_>, vm: &VirtualMachine) -> PyRef<Self>
fn __extend_method_def(method_defs: &mut Vec<PyMethodDef>)
fn __extend_py_class(ctx: &Context, class: &'static Py<PyType>)
fn __extend_slots(slots: &mut PyTypeSlots)
source§impl Callable for PyType
impl Callable for PyType
type Args = FuncArgs
fn call(zelf: &Py<Self>, args: FuncArgs, vm: &VirtualMachine) -> PyResult
fn slot_call(zelf: &PyObject, args: FuncArgs, vm: &VirtualMachine) -> PyResult
fn __call__(zelf: PyObjectRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult
fn __extend_method_def(method_defs: &mut Vec<PyMethodDef>)
fn __extend_py_class(ctx: &Context, class: &'static Py<PyType>)
fn __extend_slots(slots: &mut PyTypeSlots)
source§impl GetAttr for PyType
impl GetAttr for PyType
fn getattro( zelf: &Py<Self>, name_str: &Py<PyStr>, vm: &VirtualMachine ) -> PyResult
fn slot_getattro( obj: &PyObject, name: &Py<PyStr>, vm: &VirtualMachine ) -> PyResult
fn getattribute( zelf: PyRef<Self>, name: PyStrRef, vm: &VirtualMachine ) -> PyResult
fn __extend_method_def(method_defs: &mut Vec<PyMethodDef>)
fn __extend_py_class(ctx: &Context, class: &'static Py<PyType>)
fn __extend_slots(slots: &mut PyTypeSlots)
source§impl MaybeTraverse for PyType
impl MaybeTraverse for PyType
fn try_traverse(&self, tracer_fn: &mut TraverseFn<'_>)
source§impl PyClassDef for PyType
impl PyClassDef for PyType
source§impl PyClassImpl for PyType
impl PyClassImpl for PyType
const TP_FLAGS: PyTypeFlags = _
fn impl_extend_class(ctx: &Context, class: &'static Py<PyType>)
fn impl_extend_method_def(method_defs: &mut Vec<PyMethodDef>)
fn extend_slots(slots: &mut PyTypeSlots)
fn extend_class(ctx: &Context, class: &'static Py<PyType>)
fn make_class(ctx: &Context) -> PyTypeRefwhere Self: StaticType,
fn make_slots() -> PyTypeSlots
source§impl PyPayload for PyType
impl PyPayload for PyType
fn class(ctx: &Context) -> &'static Py<PyType>
fn into_pyobject(self, vm: &VirtualMachine) -> PyObjectRef
fn _into_ref(self, cls: PyTypeRef, ctx: &Context) -> PyRef<Self>
fn into_exact_ref(self, ctx: &Context) -> PyRefExact<Self>
fn into_ref(self, ctx: &Context) -> PyRef<Self>
fn into_ref_with_type( self, vm: &VirtualMachine, cls: PyTypeRef ) -> PyResult<PyRef<Self>>
source§impl Representable for PyType
impl Representable for PyType
fn repr_str(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<String>
fn slot_repr(zelf: &PyObject, vm: &VirtualMachine) -> PyResult<PyStrRef>
fn __repr__(zelf: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyStrRef>
fn repr(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyStrRef>
fn __extend_method_def(method_defs: &mut Vec<PyMethodDef>)
fn __extend_py_class(ctx: &Context, class: &'static Py<PyType>)
fn __extend_slots(slots: &mut PyTypeSlots)
source§impl SetAttr for PyType
impl SetAttr for PyType
fn setattro( zelf: &Py<Self>, attr_name: &Py<PyStr>, value: PySetterValue, vm: &VirtualMachine ) -> PyResult<()>
fn slot_setattro( obj: &PyObject, name: &Py<PyStr>, value: PySetterValue, vm: &VirtualMachine ) -> PyResult<()>
fn setattr( zelf: PyRef<Self>, name: PyStrRef, value: PyObjectRef, vm: &VirtualMachine ) -> PyResult<()>
fn delattr( zelf: PyRef<Self>, name: PyStrRef, vm: &VirtualMachine ) -> PyResult<()>
fn __extend_method_def(method_defs: &mut Vec<PyMethodDef>)
fn __extend_py_class(ctx: &Context, class: &'static Py<PyType>)
fn __extend_slots(slots: &mut PyTypeSlots)
source§impl StaticType for PyType
impl StaticType for PyType
fn static_cell() -> &'static StaticCell<PyTypeRef>
fn static_metaclass() -> &'static Py<PyType>
fn static_baseclass() -> &'static Py<PyType>
fn static_type() -> &'static Py<PyType>
fn init_manually(typ: PyTypeRef) -> &'static Py<PyType>
fn init_builtin_type() -> &'static Py<PyType>where Self: PyClassImpl,
fn create_static_type() -> PyTypeRefwhere Self: PyClassImpl,
Auto Trait Implementations§
impl !RefUnwindSafe for PyType
impl !Send for PyType
impl !Sync for PyType
impl Unpin for PyType
impl !UnwindSafe for PyType
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more