mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
fn class #[inline] (#5846)
This commit is contained in:
1 parent
0095941fb7
commit
f0c7cb26f7
43 files changed
+61
No files matched your search
@@ -7,6 +7,7 @@ pub(crate) fn impl_pypayload(input: DeriveInput) -> Result<TokenStream> {
|
||||
|
||||
let ret = quote! {
|
||||
impl ::rustpython_vm::PyPayload for #ty {
|
||||
#[inline]
|
||||
fn class(_ctx: &::rustpython_vm::vm::Context) -> &'static rustpython_vm::Py<::rustpython_vm::builtins::PyType> {
|
||||
<Self as ::rustpython_vm::class::StaticType>::static_type()
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ pub struct PyAsyncGen {
|
||||
type PyAsyncGenRef = PyRef<PyAsyncGen>;
|
||||
|
||||
impl PyPayload for PyAsyncGen {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.async_generator
|
||||
}
|
||||
@@ -141,6 +142,7 @@ impl Unconstructible for PyAsyncGen {}
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct PyAsyncGenWrappedValue(pub PyObjectRef);
|
||||
impl PyPayload for PyAsyncGenWrappedValue {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.async_generator_wrapped_value
|
||||
}
|
||||
@@ -190,6 +192,7 @@ pub(crate) struct PyAsyncGenASend {
|
||||
}
|
||||
|
||||
impl PyPayload for PyAsyncGenASend {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.async_generator_asend
|
||||
}
|
||||
@@ -283,6 +286,7 @@ pub(crate) struct PyAsyncGenAThrow {
|
||||
}
|
||||
|
||||
impl PyPayload for PyAsyncGenAThrow {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.async_generator_athrow
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ impl PyObjectRef {
|
||||
pub struct PyBool;
|
||||
|
||||
impl PyPayload for PyBool {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.bool_type
|
||||
}
|
||||
|
||||
@@ -884,6 +884,7 @@ pub struct PyByteArrayIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PyByteArrayIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.bytearray_iterator_type
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ impl AsRef<[u8]> for PyBytesRef {
|
||||
}
|
||||
|
||||
impl PyPayload for PyBytes {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.bytes_type
|
||||
}
|
||||
@@ -683,6 +684,7 @@ pub struct PyBytesIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PyBytesIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.bytes_iterator_type
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ impl From<PyObjectRef> for PyClassMethod {
|
||||
}
|
||||
|
||||
impl PyPayload for PyClassMethod {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.classmethod_type
|
||||
}
|
||||
|
||||
@@ -214,6 +214,7 @@ impl fmt::Debug for PyCode {
|
||||
}
|
||||
|
||||
impl PyPayload for PyCode {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.code_type
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ impl PyComplex {
|
||||
}
|
||||
|
||||
impl PyPayload for PyComplex {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.complex_type
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ pub struct PyCoroutine {
|
||||
}
|
||||
|
||||
impl PyPayload for PyCoroutine {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.coroutine_type
|
||||
}
|
||||
@@ -127,6 +128,7 @@ pub struct PyCoroutineWrapper {
|
||||
}
|
||||
|
||||
impl PyPayload for PyCoroutineWrapper {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.coroutine_wrapper_type
|
||||
}
|
||||
|
||||
@@ -823,6 +823,7 @@ macro_rules! dict_view {
|
||||
}
|
||||
|
||||
impl PyPayload for $iter_name {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.$iter_class
|
||||
}
|
||||
@@ -896,6 +897,7 @@ macro_rules! dict_view {
|
||||
}
|
||||
|
||||
impl PyPayload for $reverse_iter_name {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.$reverse_iter_class
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ pub struct PyEnumerate {
|
||||
}
|
||||
|
||||
impl PyPayload for PyEnumerate {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.enumerate_type
|
||||
}
|
||||
@@ -92,6 +93,7 @@ pub struct PyReverseSequenceIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PyReverseSequenceIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.reverse_iter_type
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ pub struct PyFilter {
|
||||
}
|
||||
|
||||
impl PyPayload for PyFilter {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.filter_type
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ impl PyFloat {
|
||||
}
|
||||
|
||||
impl PyPayload for PyFloat {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.float_type
|
||||
}
|
||||
|
||||
@@ -376,6 +376,7 @@ impl PyFunction {
|
||||
}
|
||||
|
||||
impl PyPayload for PyFunction {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.function_type
|
||||
}
|
||||
@@ -791,6 +792,7 @@ impl PyBoundMethod {
|
||||
}
|
||||
|
||||
impl PyPayload for PyBoundMethod {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.bound_method_type
|
||||
}
|
||||
@@ -823,6 +825,7 @@ pub(crate) struct PyCell {
|
||||
pub(crate) type PyCellRef = PyRef<PyCell>;
|
||||
|
||||
impl PyPayload for PyCell {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.cell_type
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ pub struct PyGenerator {
|
||||
}
|
||||
|
||||
impl PyPayload for PyGenerator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.generator_type
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ impl fmt::Debug for PyGenericAlias {
|
||||
}
|
||||
|
||||
impl PyPayload for PyGenericAlias {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.generic_alias_type
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ impl std::fmt::Debug for PyGetSet {
|
||||
}
|
||||
|
||||
impl PyPayload for PyGetSet {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.getset_type
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ where
|
||||
}
|
||||
|
||||
impl PyPayload for PyInt {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.int_type
|
||||
}
|
||||
|
||||
@@ -184,6 +184,7 @@ pub struct PySequenceIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PySequenceIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.iter_type
|
||||
}
|
||||
@@ -247,6 +248,7 @@ pub struct PyCallableIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PyCallableIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.callable_iterator
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ impl FromIterator<PyObjectRef> for PyList {
|
||||
}
|
||||
|
||||
impl PyPayload for PyList {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.list_type
|
||||
}
|
||||
@@ -538,6 +539,7 @@ pub struct PyListIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PyListIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.list_iterator_type
|
||||
}
|
||||
@@ -583,6 +585,7 @@ pub struct PyListReverseIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PyListReverseIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.list_reverseiterator_type
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct PyMap {
|
||||
}
|
||||
|
||||
impl PyPayload for PyMap {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.map_type
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ unsafe impl Traverse for MappingProxyInner {
|
||||
}
|
||||
|
||||
impl PyPayload for PyMappingProxy {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.mappingproxy_type
|
||||
}
|
||||
|
||||
@@ -1037,6 +1037,7 @@ impl Hashable for PyMemoryView {
|
||||
}
|
||||
|
||||
impl PyPayload for PyMemoryView {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.memoryview_type
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ pub struct PyModule {
|
||||
}
|
||||
|
||||
impl PyPayload for PyModule {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.module_type
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ use crate::{
|
||||
pub struct PyNamespace {}
|
||||
|
||||
impl PyPayload for PyNamespace {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.namespace_type
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ use itertools::Itertools;
|
||||
pub struct PyBaseObject;
|
||||
|
||||
impl PyPayload for PyBaseObject {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.object_type
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ pub struct PyProperty {
|
||||
}
|
||||
|
||||
impl PyPayload for PyProperty {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.property_type
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ pub struct PyRange {
|
||||
}
|
||||
|
||||
impl PyPayload for PyRange {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.range_type
|
||||
}
|
||||
@@ -533,6 +534,7 @@ pub struct PyLongRangeIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PyLongRangeIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.long_range_iterator_type
|
||||
}
|
||||
@@ -598,6 +600,7 @@ pub struct PyRangeIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PyRangeIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.range_iterator_type
|
||||
}
|
||||
|
||||
@@ -153,12 +153,14 @@ impl fmt::Debug for PyFrozenSet {
|
||||
}
|
||||
|
||||
impl PyPayload for PySet {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.set_type
|
||||
}
|
||||
}
|
||||
|
||||
impl PyPayload for PyFrozenSet {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.frozenset_type
|
||||
}
|
||||
@@ -1295,6 +1297,7 @@ impl fmt::Debug for PySetIterator {
|
||||
}
|
||||
|
||||
impl PyPayload for PySetIterator {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.set_iterator_type
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::{
|
||||
pub struct PyNone;
|
||||
|
||||
impl PyPayload for PyNone {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.none_type
|
||||
}
|
||||
@@ -77,6 +78,7 @@ impl AsNumber for PyNone {
|
||||
pub struct PyNotImplemented;
|
||||
|
||||
impl PyPayload for PyNotImplemented {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.not_implemented_type
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ pub struct PySlice {
|
||||
}
|
||||
|
||||
impl PyPayload for PySlice {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.slice_type
|
||||
}
|
||||
@@ -302,6 +303,7 @@ impl Representable for PySlice {
|
||||
pub struct PyEllipsis;
|
||||
|
||||
impl PyPayload for PyEllipsis {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.ellipsis_type
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ pub struct PyStaticMethod {
|
||||
}
|
||||
|
||||
impl PyPayload for PyStaticMethod {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.staticmethod_type
|
||||
}
|
||||
|
||||
@@ -1592,6 +1592,7 @@ pub(crate) fn encode_string(
|
||||
}
|
||||
|
||||
impl PyPayload for PyStr {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.str_type
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ impl PySuperInner {
|
||||
}
|
||||
|
||||
impl PyPayload for PySuper {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.super_type
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ pub struct PyTraceback {
|
||||
pub type PyTracebackRef = PyRef<PyTraceback>;
|
||||
|
||||
impl PyPayload for PyTraceback {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.traceback_type
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ impl fmt::Debug for PyTuple {
|
||||
}
|
||||
|
||||
impl PyPayload for PyTuple {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.tuple_type
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ impl fmt::Debug for PyType {
|
||||
}
|
||||
|
||||
impl PyPayload for PyType {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.type_type
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ impl fmt::Debug for PyUnion {
|
||||
}
|
||||
|
||||
impl PyPayload for PyUnion {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.union_type
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ pub struct PyWeakProxy {
|
||||
}
|
||||
|
||||
impl PyPayload for PyWeakProxy {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.weakproxy_type
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ pub struct WeakNewArgs {
|
||||
}
|
||||
|
||||
impl PyPayload for PyWeak {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.weakref_type
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ pub struct PyZip {
|
||||
}
|
||||
|
||||
impl PyPayload for PyZip {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.zip_type
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ impl std::fmt::Debug for PyBaseException {
|
||||
}
|
||||
|
||||
impl PyPayload for PyBaseException {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.exceptions.base_exception_type
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ pub struct Frame {
|
||||
}
|
||||
|
||||
impl PyPayload for Frame {
|
||||
#[inline]
|
||||
fn class(ctx: &Context) -> &'static Py<PyType> {
|
||||
ctx.types.frame_type
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user