Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
4.8 KiB

  1. #ifndef Py_CEVAL_H
  2. #define Py_CEVAL_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /* Interface to random parts in ceval.c */
  7. PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
  8. PyObject *, PyObject *, PyObject *);
  9. /* DLL-level Backwards compatibility: */
  10. #undef PyEval_CallObject
  11. PyAPI_FUNC(PyObject *) PyEval_CallObject(PyObject *, PyObject *);
  12. /* Inline this */
  13. #define PyEval_CallObject(func,arg) \
  14. PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
  15. PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,
  16. const char *format, ...);
  17. PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
  18. const char *methodname,
  19. const char *format, ...);
  20. PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
  21. PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
  22. struct _frame; /* Avoid including frameobject.h */
  23. PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
  24. PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
  25. PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
  26. PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
  27. PyAPI_FUNC(int) PyEval_GetRestricted(void);
  28. /* Look at the current frame's (if any) code's co_flags, and turn on
  29. the corresponding compiler flags in cf->cf_flags. Return 1 if any
  30. flag was set, else return 0. */
  31. PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
  32. PyAPI_FUNC(int) Py_FlushLine(void);
  33. PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
  34. PyAPI_FUNC(int) Py_MakePendingCalls(void);
  35. /* Protection against deeply nested recursive calls */
  36. PyAPI_FUNC(void) Py_SetRecursionLimit(int);
  37. PyAPI_FUNC(int) Py_GetRecursionLimit(void);
  38. #define Py_EnterRecursiveCall(where) \
  39. (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \
  40. _Py_CheckRecursiveCall(where))
  41. #define Py_LeaveRecursiveCall() \
  42. (--PyThreadState_GET()->recursion_depth)
  43. PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where);
  44. PyAPI_DATA(int) _Py_CheckRecursionLimit;
  45. #ifdef USE_STACKCHECK
  46. # define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit)
  47. #else
  48. # define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
  49. #endif
  50. PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
  51. PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
  52. PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
  53. PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
  54. PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);
  55. /* this used to be handled on a per-thread basis - now just two globals */
  56. PyAPI_DATA(volatile int) _Py_Ticker;
  57. PyAPI_DATA(int) _Py_CheckInterval;
  58. /* Interface for threads.
  59. A module that plans to do a blocking system call (or something else
  60. that lasts a long time and doesn't touch Python data) can allow other
  61. threads to run as follows:
  62. ...preparations here...
  63. Py_BEGIN_ALLOW_THREADS
  64. ...blocking system call here...
  65. Py_END_ALLOW_THREADS
  66. ...interpret result here...
  67. The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
  68. {}-surrounded block.
  69. To leave the block in the middle (e.g., with return), you must insert
  70. a line containing Py_BLOCK_THREADS before the return, e.g.
  71. if (...premature_exit...) {
  72. Py_BLOCK_THREADS
  73. PyErr_SetFromErrno(PyExc_IOError);
  74. return NULL;
  75. }
  76. An alternative is:
  77. Py_BLOCK_THREADS
  78. if (...premature_exit...) {
  79. PyErr_SetFromErrno(PyExc_IOError);
  80. return NULL;
  81. }
  82. Py_UNBLOCK_THREADS
  83. For convenience, that the value of 'errno' is restored across
  84. Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
  85. WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
  86. Py_END_ALLOW_THREADS!!!
  87. The function PyEval_InitThreads() should be called only from
  88. initthread() in "threadmodule.c".
  89. Note that not yet all candidates have been converted to use this
  90. mechanism!
  91. */
  92. PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
  93. PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
  94. #ifdef WITH_THREAD
  95. PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
  96. PyAPI_FUNC(void) PyEval_InitThreads(void);
  97. PyAPI_FUNC(void) PyEval_AcquireLock(void);
  98. PyAPI_FUNC(void) PyEval_ReleaseLock(void);
  99. PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
  100. PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
  101. PyAPI_FUNC(void) PyEval_ReInitThreads(void);
  102. #define Py_BEGIN_ALLOW_THREADS { \
  103. PyThreadState *_save; \
  104. _save = PyEval_SaveThread();
  105. #define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
  106. #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
  107. #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
  108. }
  109. #else /* !WITH_THREAD */
  110. #define Py_BEGIN_ALLOW_THREADS {
  111. #define Py_BLOCK_THREADS
  112. #define Py_UNBLOCK_THREADS
  113. #define Py_END_ALLOW_THREADS }
  114. #endif /* !WITH_THREAD */
  115. PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #endif /* !Py_CEVAL_H */