1 #ifndef Py_FRAMEOBJECT_H
2 #define Py_FRAMEOBJECT_H
7 /***********************************************************
8 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
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 or Corporation for National Research Initiatives or
19 CNRI not be used in advertising or publicity pertaining to
20 distribution of the software without specific, written prior
23 While CWI is the initial source for this software, a modified version
24 is made available by the Corporation for National Research Initiatives
25 (CNRI) at the Internet address ftp://ftp.python.org.
27 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
28 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
29 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
30 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
31 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
32 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
33 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34 PERFORMANCE OF THIS SOFTWARE.
36 ******************************************************************/
38 /* Frame object interface */
41 int b_type
; /* what kind of block this is */
42 int b_handler
; /* where to jump to find handler */
43 int b_level
; /* value stack level to pop to */
46 typedef struct _frame
{
48 struct _frame
*f_back
; /* previous frame, or NULL */
49 PyCodeObject
*f_code
; /* code segment */
50 PyObject
*f_builtins
; /* builtin symbol table (PyDictObject) */
51 PyObject
*f_globals
; /* global symbol table (PyDictObject) */
52 PyObject
*f_locals
; /* local symbol table (PyDictObject) */
53 PyObject
**f_valuestack
; /* points after the last local */
54 PyObject
*f_trace
; /* Trace function */
55 PyObject
*f_exc_type
, *f_exc_value
, *f_exc_traceback
;
56 PyThreadState
*f_tstate
;
57 int f_lasti
; /* Last instruction if called */
58 int f_lineno
; /* Current line number */
59 int f_restricted
; /* Flag set if restricted operations
61 int f_iblock
; /* index in f_blockstack */
62 PyTryBlock f_blockstack
[CO_MAXBLOCKS
]; /* for try and loop blocks */
63 int f_nlocals
; /* number of locals */
64 int f_stacksize
; /* size of value stack */
65 PyObject
*f_localsplus
[1]; /* locals+stack, dynamically sized */
69 /* Standard object interface */
71 extern DL_IMPORT(PyTypeObject
) PyFrame_Type
;
73 #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
75 DL_IMPORT(PyFrameObject
*) PyFrame_New
76 Py_PROTO((PyThreadState
*, PyCodeObject
*,
77 PyObject
*, PyObject
*));
80 /* The rest of the interface is specific for frame objects */
82 /* Tuple access macros */
85 #define GETITEM(v, i) PyTuple_GET_ITEM((PyTupleObject *)(v), (i))
86 #define GETITEMNAME(v, i) \
87 PyString_AS_STRING((PyStringObject *)GETITEM((v), (i)))
89 #define GETITEM(v, i) PyTuple_GetItem((v), (i))
90 #define GETITEMNAME(v, i) PyString_AsString(GETITEM(v, i))
93 #define GETUSTRINGVALUE(s) ((unsigned char *)PyString_AS_STRING(s))
95 /* Code access macros */
97 #define Getconst(f, i) (GETITEM((f)->f_code->co_consts, (i)))
98 #define Getname(f, i) (GETITEMNAME((f)->f_code->co_names, (i)))
99 #define Getnamev(f, i) (GETITEM((f)->f_code->co_names, (i)))
102 /* Block management functions */
104 DL_IMPORT(void) PyFrame_BlockSetup
Py_PROTO((PyFrameObject
*, int, int, int));
105 DL_IMPORT(PyTryBlock
*) PyFrame_BlockPop
Py_PROTO((PyFrameObject
*));
107 /* Extend the value stack */
109 DL_IMPORT(PyObject
**) PyFrame_ExtendStack
Py_PROTO((PyFrameObject
*, int, int));
111 /* Conversions between "fast locals" and locals in dictionary */
113 DL_IMPORT(void) PyFrame_LocalsToFast
Py_PROTO((PyFrameObject
*, int));
114 DL_IMPORT(void) PyFrame_FastToLocals
Py_PROTO((PyFrameObject
*));
119 #endif /* !Py_FRAMEOBJECT_H */