home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Include / ceval.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-28  |  3.2 KB  |  117 lines  |  [TEXT/KAHL]

  1. #ifndef Py_CEVAL_H
  2. #define Py_CEVAL_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /***********************************************************
  8. Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
  9. Amsterdam, 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. object *call_object PROTO((object *, object *));
  34.  
  35. object *getglobals PROTO((void));
  36. object *getlocals PROTO((void));
  37. object *getowner PROTO((void));
  38. object *getframe PROTO((void));
  39.  
  40. void printtraceback PROTO((object *));
  41. void flushline PROTO((void));
  42.  
  43. int Py_AddPendingCall PROTO((int (*func) PROTO((ANY *)), ANY *arg));
  44. int Py_MakePendingCalls PROTO((void));
  45.  
  46.  
  47. /* Interface for threads.
  48.  
  49.    A module that plans to do a blocking system call (or something else
  50.    that lasts a long time and doesn't touch Python data) can allow other
  51.    threads to run as follows:
  52.  
  53.     ...preparations here...
  54.     BGN_SAVE
  55.     ...blocking system call here...
  56.     END_SAVE
  57.     ...interpretr result here...
  58.  
  59.    The BGN_SAVE/END_SAVE pair expands to a {}-surrounded block.
  60.    To leave the block in the middle (e.g., with return), you must insert
  61.    a line containing RET_SAVE before the return, e.g.
  62.  
  63.     if (...premature_exit...) {
  64.         RET_SAVE
  65.         err_errno(IOError);
  66.         return NULL;
  67.     }
  68.  
  69.    An alternative is:
  70.  
  71.     RET_SAVE
  72.     if (...premature_exit...) {
  73.         err_errno(IOError);
  74.         return NULL;
  75.     }
  76.     RES_SAVE
  77.  
  78.    For convenience, that the value of 'errno' is restored across
  79.    END_SAVE and RET_SAVE.
  80.  
  81.    WARNING: NEVER NEST CALLS TO BGN_SAVE AND END_SAVE!!!
  82.  
  83.    The function init_save_thread() should be called only from
  84.    initthread() in "threadmodule.c".
  85.  
  86.    Note that not yet all candidates have been converted to use this
  87.    mechanism!
  88. */
  89.  
  90. extern void init_save_thread PROTO((void));
  91. extern object *save_thread PROTO((void));
  92. extern void restore_thread PROTO((object *));
  93.  
  94. #ifdef WITH_THREAD
  95.  
  96. #define BGN_SAVE { \
  97.             object *_save; \
  98.             _save = save_thread();
  99. #define RET_SAVE    restore_thread(_save);
  100. #define RES_SAVE    _save = save_thread();
  101. #define END_SAVE    restore_thread(_save); \
  102.          }
  103.  
  104. #else /* !WITH_THREAD */
  105.  
  106. #define BGN_SAVE {
  107. #define RET_SAVE
  108. #define RES_SAVE
  109. #define END_SAVE }
  110.  
  111. #endif /* !WITH_THREAD */
  112.  
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116. #endif /* !Py_CEVAL_H */
  117.