home *** CD-ROM | disk | FTP | other *** search
/ Freelog 33 / Freelog033.iso / Progr / Python-2.2.1.exe / FRAMEOBJECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2001-08-29  |  3.1 KB  |  95 lines

  1.  
  2. /* Frame object interface */
  3.  
  4. #ifndef Py_FRAMEOBJECT_H
  5. #define Py_FRAMEOBJECT_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10. typedef struct {
  11.     int b_type;            /* what kind of block this is */
  12.     int b_handler;        /* where to jump to find handler */
  13.     int b_level;        /* value stack level to pop to */
  14. } PyTryBlock;
  15.  
  16. typedef struct _frame {
  17.     PyObject_VAR_HEAD
  18.     struct _frame *f_back;    /* previous frame, or NULL */
  19.     PyCodeObject *f_code;    /* code segment */
  20.     PyObject *f_builtins;    /* builtin symbol table (PyDictObject) */
  21.     PyObject *f_globals;    /* global symbol table (PyDictObject) */
  22.     PyObject *f_locals;        /* local symbol table (PyDictObject) */
  23.     PyObject **f_valuestack;    /* points after the last local */
  24.     /* Next free slot in f_valuestack.  Frame creation sets to f_valuestack.
  25.        Frame evaluation usually NULLs it, but a frame that yields sets it
  26.        to the current stack top. */
  27.     PyObject **f_stacktop;
  28.     PyObject *f_trace;        /* Trace function */
  29.     PyObject *f_exc_type, *f_exc_value, *f_exc_traceback;
  30.     PyThreadState *f_tstate;
  31.     int f_lasti;        /* Last instruction if called */
  32.     int f_lineno;        /* Current line number */
  33.     int f_restricted;        /* Flag set if restricted operations
  34.                    in this scope */
  35.     int f_iblock;        /* index in f_blockstack */
  36.     PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
  37.     int f_nlocals;        /* number of locals */
  38.     int f_ncells;
  39.     int f_nfreevars;
  40.     int f_stacksize;        /* size of value stack */
  41.     PyObject *f_localsplus[1];    /* locals+stack, dynamically sized */
  42. } PyFrameObject;
  43.  
  44.  
  45. /* Standard object interface */
  46.  
  47. extern DL_IMPORT(PyTypeObject) PyFrame_Type;
  48.  
  49. #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
  50.  
  51. DL_IMPORT(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
  52.                                        PyObject *, PyObject *);
  53.  
  54.  
  55. /* The rest of the interface is specific for frame objects */
  56.  
  57. /* Tuple access macros */
  58.  
  59. #ifndef Py_DEBUG
  60. #define GETITEM(v, i) PyTuple_GET_ITEM((PyTupleObject *)(v), (i))
  61. #define GETITEMNAME(v, i) \
  62.     PyString_AS_STRING((PyStringObject *)GETITEM((v), (i)))
  63. #else
  64. #define GETITEM(v, i) PyTuple_GetItem((v), (i))
  65. #define GETITEMNAME(v, i) PyString_AsString(GETITEM(v, i))
  66. #endif
  67.  
  68. #define GETUSTRINGVALUE(s) ((unsigned char *)PyString_AS_STRING(s))
  69.  
  70. /* Code access macros */
  71.  
  72. #define Getconst(f, i)    (GETITEM((f)->f_code->co_consts, (i)))
  73. #define Getname(f, i)    (GETITEMNAME((f)->f_code->co_names, (i)))
  74. #define Getnamev(f, i)    (GETITEM((f)->f_code->co_names, (i)))
  75.  
  76.  
  77. /* Block management functions */
  78.  
  79. DL_IMPORT(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int);
  80. DL_IMPORT(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *);
  81.  
  82. /* Extend the value stack */
  83.  
  84. DL_IMPORT(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int);
  85.  
  86. /* Conversions between "fast locals" and locals in dictionary */
  87.  
  88. DL_IMPORT(void) PyFrame_LocalsToFast(PyFrameObject *, int);
  89. DL_IMPORT(void) PyFrame_FastToLocals(PyFrameObject *);
  90.  
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif /* !Py_FRAMEOBJECT_H */
  95.