home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activepython / ActivePython-2.1.1.msi / Python21_include_pystate.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-26  |  2.0 KB  |  92 lines

  1.  
  2. /* Thread and interpreter state structures and their interfaces */
  3.  
  4.  
  5. #ifndef Py_PYSTATE_H
  6. #define Py_PYSTATE_H
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10.  
  11. /* State shared between threads */
  12.  
  13. struct _ts; /* Forward */
  14. struct _is; /* Forward */
  15.  
  16. typedef struct _is {
  17.  
  18.     struct _is *next;
  19.     struct _ts *tstate_head;
  20.  
  21.     PyObject *modules;
  22.     PyObject *sysdict;
  23.     PyObject *builtins;
  24.  
  25.     int checkinterval;
  26.  
  27. } PyInterpreterState;
  28.  
  29.  
  30. /* State unique per thread */
  31.  
  32. struct _frame; /* Avoid including frameobject.h */
  33.  
  34. typedef struct _ts {
  35.  
  36.     struct _ts *next;
  37.     PyInterpreterState *interp;
  38.  
  39.     struct _frame *frame;
  40.     int recursion_depth;
  41.     int ticker;
  42.     int tracing;
  43.  
  44.     PyObject *sys_profilefunc;
  45.     PyObject *sys_tracefunc;
  46.  
  47.     PyObject *curexc_type;
  48.     PyObject *curexc_value;
  49.     PyObject *curexc_traceback;
  50.  
  51.     PyObject *exc_type;
  52.     PyObject *exc_value;
  53.     PyObject *exc_traceback;
  54.  
  55.     PyObject *dict;
  56.  
  57.     /* XXX signal handlers should also be here */
  58.  
  59. } PyThreadState;
  60.  
  61.  
  62. DL_IMPORT(PyInterpreterState *) PyInterpreterState_New(void);
  63. DL_IMPORT(void) PyInterpreterState_Clear(PyInterpreterState *);
  64. DL_IMPORT(void) PyInterpreterState_Delete(PyInterpreterState *);
  65.  
  66. DL_IMPORT(PyThreadState *) PyThreadState_New(PyInterpreterState *);
  67. DL_IMPORT(void) PyThreadState_Clear(PyThreadState *);
  68. DL_IMPORT(void) PyThreadState_Delete(PyThreadState *);
  69. #ifdef WITH_THREAD
  70. DL_IMPORT(void) PyThreadState_DeleteCurrent(void);
  71. #endif
  72.  
  73. DL_IMPORT(PyThreadState *) PyThreadState_Get(void);
  74. DL_IMPORT(PyThreadState *) PyThreadState_Swap(PyThreadState *);
  75. DL_IMPORT(PyObject *) PyThreadState_GetDict(void);
  76.  
  77.  
  78. /* Variable and macro for in-line access to current thread state */
  79.  
  80. extern DL_IMPORT(PyThreadState *) _PyThreadState_Current;
  81.  
  82. #ifdef Py_DEBUG
  83. #define PyThreadState_GET() PyThreadState_Get()
  84. #else
  85. #define PyThreadState_GET() (_PyThreadState_Current)
  86. #endif
  87.  
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif /* !Py_PYSTATE_H */
  92.