home *** CD-ROM | disk | FTP | other *** search
/ Freelog 33 / Freelog033.iso / Progr / Python-2.2.1.exe / PYSTATE.H < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-19  |  2.8 KB  |  114 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. #ifdef HAVE_DLOPEN
  27.     int dlopenflags;
  28. #endif
  29.  
  30. } PyInterpreterState;
  31.  
  32.  
  33. /* State unique per thread */
  34.  
  35. struct _frame; /* Avoid including frameobject.h */
  36.  
  37. /* Py_tracefunc return -1 when raising an exception, or 0 for success. */
  38. typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
  39.  
  40. /* The following values are used for 'what' for tracefunc functions: */
  41. #define PyTrace_CALL 0
  42. #define PyTrace_EXCEPTION 1
  43. #define PyTrace_LINE 2
  44. #define PyTrace_RETURN 3
  45.  
  46. typedef struct _ts {
  47.  
  48.     struct _ts *next;
  49.     PyInterpreterState *interp;
  50.  
  51.     struct _frame *frame;
  52.     int recursion_depth;
  53.     int ticker;
  54.     int tracing;
  55.     int use_tracing;
  56.  
  57.     Py_tracefunc c_profilefunc;
  58.     Py_tracefunc c_tracefunc;
  59.     PyObject *c_profileobj;
  60.     PyObject *c_traceobj;
  61.  
  62.     PyObject *curexc_type;
  63.     PyObject *curexc_value;
  64.     PyObject *curexc_traceback;
  65.  
  66.     PyObject *exc_type;
  67.     PyObject *exc_value;
  68.     PyObject *exc_traceback;
  69.  
  70.     PyObject *dict;
  71.  
  72.     /* XXX signal handlers should also be here */
  73.  
  74. } PyThreadState;
  75.  
  76.  
  77. DL_IMPORT(PyInterpreterState *) PyInterpreterState_New(void);
  78. DL_IMPORT(void) PyInterpreterState_Clear(PyInterpreterState *);
  79. DL_IMPORT(void) PyInterpreterState_Delete(PyInterpreterState *);
  80.  
  81. DL_IMPORT(PyThreadState *) PyThreadState_New(PyInterpreterState *);
  82. DL_IMPORT(void) PyThreadState_Clear(PyThreadState *);
  83. DL_IMPORT(void) PyThreadState_Delete(PyThreadState *);
  84. #ifdef WITH_THREAD
  85. DL_IMPORT(void) PyThreadState_DeleteCurrent(void);
  86. #endif
  87.  
  88. DL_IMPORT(PyThreadState *) PyThreadState_Get(void);
  89. DL_IMPORT(PyThreadState *) PyThreadState_Swap(PyThreadState *);
  90. DL_IMPORT(PyObject *) PyThreadState_GetDict(void);
  91.  
  92.  
  93. /* Variable and macro for in-line access to current thread state */
  94.  
  95. extern DL_IMPORT(PyThreadState *) _PyThreadState_Current;
  96.  
  97. #ifdef Py_DEBUG
  98. #define PyThreadState_GET() PyThreadState_Get()
  99. #else
  100. #define PyThreadState_GET() (_PyThreadState_Current)
  101. #endif
  102.  
  103. /* Routines for advanced debuggers, requested by David Beazley.
  104.    Don't use unless you know what you are doing! */
  105. DL_IMPORT(PyInterpreterState *) PyInterpreterState_Head(void);
  106. DL_IMPORT(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
  107. DL_IMPORT(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
  108. DL_IMPORT(PyThreadState *) PyThreadState_Next(PyThreadState *);
  109.  
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif /* !Py_PYSTATE_H */
  114.