Counter Strike : Global Offensive Source Code

75 lines
2.4 KiB

  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. /* PyWeakReference is the base struct for the Python ReferenceType, ProxyType,
  9. * and CallableProxyType.
  10. */
  11. struct _PyWeakReference {
  12. PyObject_HEAD
  13. /* The object to which this is a weak reference, or Py_None if none.
  14. * Note that this is a stealth reference: wr_object's refcount is
  15. * not incremented to reflect this pointer.
  16. */
  17. PyObject *wr_object;
  18. /* A callable to invoke when wr_object dies, or NULL if none. */
  19. PyObject *wr_callback;
  20. /* A cache for wr_object's hash code. As usual for hashes, this is -1
  21. * if the hash code isn't known yet.
  22. */
  23. long hash;
  24. /* If wr_object is weakly referenced, wr_object has a doubly-linked NULL-
  25. * terminated list of weak references to it. These are the list pointers.
  26. * If wr_object goes away, wr_object is set to Py_None, and these pointers
  27. * have no meaning then.
  28. */
  29. PyWeakReference *wr_prev;
  30. PyWeakReference *wr_next;
  31. };
  32. PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
  33. PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
  34. PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
  35. #define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType)
  36. #define PyWeakref_CheckRefExact(op) \
  37. ((op)->ob_type == &_PyWeakref_RefType)
  38. #define PyWeakref_CheckProxy(op) \
  39. (((op)->ob_type == &_PyWeakref_ProxyType) || \
  40. ((op)->ob_type == &_PyWeakref_CallableProxyType))
  41. /* This macro calls PyWeakref_CheckRef() last since that can involve a
  42. function call; this makes it more likely that the function call
  43. will be avoided. */
  44. #define PyWeakref_Check(op) \
  45. (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
  46. PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob,
  47. PyObject *callback);
  48. PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
  49. PyObject *callback);
  50. PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
  51. PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
  52. PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
  53. #define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object)
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif /* !Py_WEAKREFOBJECT_H */