pub struct PyType {
pub base: Option<PyTypeRef>,
pub bases: PyRwLock<Vec<PyTypeRef>>,
pub mro: PyRwLock<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: PyRwLock<Vec<PyTypeRef>>
§mro: PyRwLock<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 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>
const __OWN_METHOD_DEFS: &'static [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
const __OWN_METHOD_DEFS: &'static [PyMethodDef] = _
fn __extend_py_class(ctx: &Context, class: &'static Py<PyType>)
fn __extend_slots(slots: &mut PyTypeSlots)
Source§impl Constructor for PyType
impl Constructor for PyType
type Args = FuncArgs
fn py_new(metatype: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult
fn slot_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult
const __OWN_METHOD_DEFS: &'static [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
const __OWN_METHOD_DEFS: &'static [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
const METHOD_DEFS: &'static [PyMethodDef]
fn impl_extend_class(ctx: &Context, class: &'static Py<PyType>)
fn extend_slots(slots: &mut PyTypeSlots)
fn extend_class(ctx: &Context, class: &'static Py<PyType>)where
Self: Sized,
fn make_class(ctx: &Context) -> PyTypeRefwhere
Self: StaticType + Sized,
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>
const __OWN_METHOD_DEFS: &'static [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<()>
const __OWN_METHOD_DEFS: &'static [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 !Freeze for PyType
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more