home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Python 1.3 / source code / Include / ceval.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-17  |  3.7 KB  |  122 lines  |  [TEXT/R*ch]

  1. #ifndef Py_CEVAL_H
  2. #define Py_CEVAL_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /***********************************************************
  8. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  9. The Netherlands.
  10.  
  11.                         All Rights Reserved
  12.  
  13. Permission to use, copy, modify, and distribute this software and its 
  14. documentation for any purpose and without fee is hereby granted, 
  15. provided that the above copyright notice appear in all copies and that
  16. both that copyright notice and this permission notice appear in 
  17. supporting documentation, and that the names of Stichting Mathematisch
  18. Centrum or CWI not be used in advertising or publicity pertaining to
  19. distribution of the software without specific, written prior permission.
  20.  
  21. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  22. THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  23. FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  24. FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  25. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  26. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  27. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  28.  
  29. ******************************************************************/
  30.  
  31. /* Interface to random parts in ceval.c */
  32.  
  33. PyObject *PyEval_CallObject Py_PROTO((PyObject *, PyObject *));
  34. PyObject *PyEval_CallObjectWithKeywords
  35.     Py_PROTO((PyObject *, PyObject *, PyObject *));
  36.  
  37. PyObject *PyEval_GetBuiltins Py_PROTO((void));
  38. PyObject *PyEval_GetGlobals Py_PROTO((void));
  39. PyObject *PyEval_GetLocals Py_PROTO((void));
  40. PyObject *PyEval_GetOwner Py_PROTO((void));
  41. PyObject *PyEval_GetFrame Py_PROTO((void));
  42. int PyEval_GetRestricted Py_PROTO((void));
  43.  
  44. void Py_FlushLine Py_PROTO((void));
  45.  
  46. int Py_AddPendingCall Py_PROTO((int (*func) Py_PROTO((ANY *)), ANY *arg));
  47. int Py_MakePendingCalls Py_PROTO((void));
  48.  
  49.  
  50. /* Interface for threads.
  51.  
  52.    A module that plans to do a blocking system call (or something else
  53.    that lasts a long time and doesn't touch Python data) can allow other
  54.    threads to run as follows:
  55.  
  56.     ...preparations here...
  57.     Py_BEGIN_ALLOW_THREADS
  58.     ...blocking system call here...
  59.     Py_END_ALLOW_THREADS
  60.     ...interpret result here...
  61.  
  62.    The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
  63.    {}-surrounded block.
  64.    To leave the block in the middle (e.g., with return), you must insert
  65.    a line containing RET_SAVE before the return, e.g.
  66.  
  67.     if (...premature_exit...) {
  68.         Py_BLOCK_THREADS
  69.         PyErr_SetFromErrno(PyExc_IOError);
  70.         return NULL;
  71.     }
  72.  
  73.    An alternative is:
  74.  
  75.     Py_BLOCK_THREADS
  76.     if (...premature_exit...) {
  77.         PyErr_SetFromErrno(PyExc_IOError);
  78.         return NULL;
  79.     }
  80.     Py_UNBLOCK_THREADS
  81.  
  82.    For convenience, that the value of 'errno' is restored across
  83.    Py_END_ALLOW_THREADS and RET_SAVE.
  84.  
  85.    WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
  86.    Py_END_ALLOW_THREADS!!!
  87.  
  88.    The function PyEval_InitThreads() should be called only from
  89.    initthread() in "threadmodule.c".
  90.  
  91.    Note that not yet all candidates have been converted to use this
  92.    mechanism!
  93. */
  94.  
  95. extern void PyEval_InitThreads Py_PROTO((void));
  96. extern PyObject *PyEval_SaveThread Py_PROTO((void));
  97. extern void PyEval_RestoreThread Py_PROTO((PyObject *));
  98.  
  99. #ifdef WITH_THREAD
  100.  
  101. #define Py_BEGIN_ALLOW_THREADS { \
  102.             PyObject *_save; \
  103.             _save = PyEval_SaveThread();
  104. #define Py_BLOCK_THREADS    PyEval_RestoreThread(_save);
  105. #define Py_UNBLOCK_THREADS    _save = PyEval_SaveThread();
  106. #define Py_END_ALLOW_THREADS    PyEval_RestoreThread(_save); \
  107.          }
  108.  
  109. #else /* !WITH_THREAD */
  110.  
  111. #define Py_BEGIN_ALLOW_THREADS {
  112. #define Py_BLOCK_THREADS
  113. #define Py_UNBLOCK_THREADS
  114. #define Py_END_ALLOW_THREADS }
  115.  
  116. #endif /* !WITH_THREAD */
  117.  
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif /* !Py_CEVAL_H */
  122.