weakrefobject.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Weak references objects for Python. */
  2. #ifndef Py_WEAKREFOBJECT_H
  3. #define Py_WEAKREFOBJECT_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct _PyWeakReference PyWeakReference;
  8. PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
  9. PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
  10. PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
  11. #define PyWeakref_CheckRef(op) PyObject_TypeCheck((op), &_PyWeakref_RefType)
  12. #define PyWeakref_CheckRefExact(op) \
  13. Py_IS_TYPE((op), &_PyWeakref_RefType)
  14. #define PyWeakref_CheckProxy(op) \
  15. (Py_IS_TYPE((op), &_PyWeakref_ProxyType) \
  16. || Py_IS_TYPE((op), &_PyWeakref_CallableProxyType))
  17. #define PyWeakref_Check(op) \
  18. (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
  19. PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob,
  20. PyObject *callback);
  21. PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
  22. PyObject *callback);
  23. PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
  24. #ifndef Py_LIMITED_API
  25. # define Py_CPYTHON_WEAKREFOBJECT_H
  26. # include "cpython/weakrefobject.h"
  27. # undef Py_CPYTHON_WEAKREFOBJECT_H
  28. #endif
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32. #endif /* !Py_WEAKREFOBJECT_H */