home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / TemaCD / webclean / !!!python!!! / BeOpen-Python-2.0.exe / CEVAL.H < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-15  |  3.5 KB  |  121 lines

  1. #ifndef Py_CEVAL_H
  2. #define Py_CEVAL_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7.  
  8. /* Interface to random parts in ceval.c */
  9.  
  10. DL_IMPORT(PyObject *) PyEval_CallObjectWithKeywords
  11.     (PyObject *, PyObject *, PyObject *);
  12.  
  13. /* DLL-level Backwards compatibility: */
  14. #undef PyEval_CallObject
  15. DL_IMPORT(PyObject *) PyEval_CallObject(PyObject *, PyObject *);
  16.  
  17. /* Inline this */
  18. #define PyEval_CallObject(func,arg) \
  19.         PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
  20.  
  21. DL_IMPORT(PyObject *) PyEval_CallFunction(PyObject *obj, char *format, ...);
  22. DL_IMPORT(PyObject *) PyEval_CallMethod(PyObject *obj,
  23.                                         char *methodname, char *format, ...);
  24.  
  25. DL_IMPORT(PyObject *) PyEval_GetBuiltins(void);
  26. DL_IMPORT(PyObject *) PyEval_GetGlobals(void);
  27. DL_IMPORT(PyObject *) PyEval_GetLocals(void);
  28. DL_IMPORT(PyObject *) PyEval_GetOwner(void);
  29. DL_IMPORT(PyObject *) PyEval_GetFrame(void);
  30. DL_IMPORT(int) PyEval_GetRestricted(void);
  31.  
  32. DL_IMPORT(int) Py_FlushLine(void);
  33.  
  34. DL_IMPORT(int) Py_AddPendingCall(int (*func)(void *), void *arg);
  35. DL_IMPORT(int) Py_MakePendingCalls(void);
  36.  
  37. DL_IMPORT(void) Py_SetRecursionLimit(int);
  38. DL_IMPORT(int) Py_GetRecursionLimit(void);
  39.  
  40. /* Interface for threads.
  41.  
  42.    A module that plans to do a blocking system call (or something else
  43.    that lasts a long time and doesn't touch Python data) can allow other
  44.    threads to run as follows:
  45.  
  46.     ...preparations here...
  47.     Py_BEGIN_ALLOW_THREADS
  48.     ...blocking system call here...
  49.     Py_END_ALLOW_THREADS
  50.     ...interpret result here...
  51.  
  52.    The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
  53.    {}-surrounded block.
  54.    To leave the block in the middle (e.g., with return), you must insert
  55.    a line containing Py_BLOCK_THREADS before the return, e.g.
  56.  
  57.     if (...premature_exit...) {
  58.         Py_BLOCK_THREADS
  59.         PyErr_SetFromErrno(PyExc_IOError);
  60.         return NULL;
  61.     }
  62.  
  63.    An alternative is:
  64.  
  65.     Py_BLOCK_THREADS
  66.     if (...premature_exit...) {
  67.         PyErr_SetFromErrno(PyExc_IOError);
  68.         return NULL;
  69.     }
  70.     Py_UNBLOCK_THREADS
  71.  
  72.    For convenience, that the value of 'errno' is restored across
  73.    Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
  74.  
  75.    WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
  76.    Py_END_ALLOW_THREADS!!!
  77.  
  78.    The function PyEval_InitThreads() should be called only from
  79.    initthread() in "threadmodule.c".
  80.  
  81.    Note that not yet all candidates have been converted to use this
  82.    mechanism!
  83. */
  84.  
  85. extern DL_IMPORT(PyThreadState *) PyEval_SaveThread(void);
  86. extern DL_IMPORT(void) PyEval_RestoreThread(PyThreadState *);
  87.  
  88. #ifdef WITH_THREAD
  89.  
  90. extern DL_IMPORT(void) PyEval_InitThreads(void);
  91. extern DL_IMPORT(void) PyEval_AcquireLock(void);
  92. extern DL_IMPORT(void) PyEval_ReleaseLock(void);
  93. extern DL_IMPORT(void) PyEval_AcquireThread(PyThreadState *tstate);
  94. extern DL_IMPORT(void) PyEval_ReleaseThread(PyThreadState *tstate);
  95. extern DL_IMPORT(void) PyEval_ReInitThreads(void);
  96.  
  97. #define Py_BEGIN_ALLOW_THREADS { \
  98.             PyThreadState *_save; \
  99.             _save = PyEval_SaveThread();
  100. #define Py_BLOCK_THREADS    PyEval_RestoreThread(_save);
  101. #define Py_UNBLOCK_THREADS    _save = PyEval_SaveThread();
  102. #define Py_END_ALLOW_THREADS    PyEval_RestoreThread(_save); \
  103.          }
  104.  
  105. #else /* !WITH_THREAD */
  106.  
  107. #define Py_BEGIN_ALLOW_THREADS {
  108. #define Py_BLOCK_THREADS
  109. #define Py_UNBLOCK_THREADS
  110. #define Py_END_ALLOW_THREADS }
  111.  
  112. #endif /* !WITH_THREAD */
  113.  
  114. extern DL_IMPORT(int) _PyEval_SliceIndex(PyObject *, int *);
  115.  
  116.  
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif /* !Py_CEVAL_H */
  121.