mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-25 06:05:05 +00:00
Fixed several macros and constants that should not have been renamed: - _Py_CAST, _Py_NULL, _Py_RVALUE (internal utility macros) - Py_UNUSED (unused parameter macro) - Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT, Py_GE (comparison constants) - Py_RETURN_* macros (NONE, TRUE, FALSE, NOTIMPLEMENTED, RICHCOMPARE) - Py_READONLY, Py_ULL, Py_CONTEXT_SWITCHED - TyGC_Head in generated clinic files Build is still in progress with some remaining issues to resolve. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
72 lines
2.2 KiB
C
72 lines
2.2 KiB
C
/* Former class object interface -- now only bound methods are here */
|
|
|
|
/* Revealing some structures (not for general use) */
|
|
|
|
#ifndef Ty_LIMITED_API
|
|
#ifndef Ty_CLASSOBJECT_H
|
|
#define Ty_CLASSOBJECT_H
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct {
|
|
PyObject_HEAD
|
|
TyObject *im_func; /* The callable object implementing the method */
|
|
TyObject *im_self; /* The instance it is bound to */
|
|
TyObject *im_weakreflist; /* List of weak references */
|
|
vectorcallfunc vectorcall;
|
|
} PyMethodObject;
|
|
|
|
PyAPI_DATA(TyTypeObject) TyMethod_Type;
|
|
|
|
#define TyMethod_Check(op) Ty_IS_TYPE((op), &TyMethod_Type)
|
|
|
|
PyAPI_FUNC(TyObject *) TyMethod_New(TyObject *, TyObject *);
|
|
|
|
PyAPI_FUNC(TyObject *) TyMethod_Function(TyObject *);
|
|
PyAPI_FUNC(TyObject *) TyMethod_Self(TyObject *);
|
|
|
|
#define _PyMethod_CAST(meth) \
|
|
(assert(TyMethod_Check(meth)), _Py_CAST(PyMethodObject*, meth))
|
|
|
|
/* Static inline functions for direct access to these values.
|
|
Type checks are *not* done, so use with care. */
|
|
static inline TyObject* TyMethod_GET_FUNCTION(TyObject *meth) {
|
|
return _PyMethod_CAST(meth)->im_func;
|
|
}
|
|
#define TyMethod_GET_FUNCTION(meth) TyMethod_GET_FUNCTION(_TyObject_CAST(meth))
|
|
|
|
static inline TyObject* TyMethod_GET_SELF(TyObject *meth) {
|
|
return _PyMethod_CAST(meth)->im_self;
|
|
}
|
|
#define TyMethod_GET_SELF(meth) TyMethod_GET_SELF(_TyObject_CAST(meth))
|
|
|
|
typedef struct {
|
|
PyObject_HEAD
|
|
TyObject *func;
|
|
} PyInstanceMethodObject;
|
|
|
|
PyAPI_DATA(TyTypeObject) PyInstanceMethod_Type;
|
|
|
|
#define PyInstanceMethod_Check(op) Ty_IS_TYPE((op), &PyInstanceMethod_Type)
|
|
|
|
PyAPI_FUNC(TyObject *) PyInstanceMethod_New(TyObject *);
|
|
PyAPI_FUNC(TyObject *) PyInstanceMethod_Function(TyObject *);
|
|
|
|
#define _PyInstanceMethod_CAST(meth) \
|
|
(assert(PyInstanceMethod_Check(meth)), \
|
|
_Py_CAST(PyInstanceMethodObject*, meth))
|
|
|
|
/* Static inline function for direct access to these values.
|
|
Type checks are *not* done, so use with care. */
|
|
static inline TyObject* PyInstanceMethod_GET_FUNCTION(TyObject *meth) {
|
|
return _PyInstanceMethod_CAST(meth)->func;
|
|
}
|
|
#define PyInstanceMethod_GET_FUNCTION(meth) PyInstanceMethod_GET_FUNCTION(_TyObject_CAST(meth))
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif // !Ty_CLASSOBJECT_H
|
|
#endif // !Ty_LIMITED_API
|