Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 1 | #ifndef Py_FRAMEOBJECT_H |
| 2 | #define Py_FRAMEOBJECT_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 7 | /*********************************************************** |
Guido van Rossum | 5799b52 | 1995-01-04 19:06:22 +0000 | [diff] [blame] | 8 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 9 | The Netherlands. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 10 | |
| 11 | All Rights Reserved |
| 12 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 13 | Permission to use, copy, modify, and distribute this software and its |
| 14 | documentation for any purpose and without fee is hereby granted, |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 15 | provided that the above copyright notice appear in all copies and that |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 16 | both that copyright notice and this permission notice appear in |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 17 | supporting documentation, and that the names of Stichting Mathematisch |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 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 |
| 21 | permission. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 22 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 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. |
| 26 | |
| 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. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 35 | |
| 36 | ******************************************************************/ |
| 37 | |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 38 | /* Frame object interface */ |
| 39 | |
| 40 | typedef struct { |
| 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 */ |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 44 | } PyTryBlock; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 45 | |
| 46 | typedef struct _frame { |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 47 | PyObject_HEAD |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 48 | struct _frame *f_back; /* previous frame, or NULL */ |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 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) */ |
Guido van Rossum | cdf578e | 1997-01-20 04:16:40 +0000 | [diff] [blame^] | 53 | PyObject **f_valuestack; /* points after the last local */ |
| 54 | PyObject *f_trace; /* Trace function */ |
Guido van Rossum | 088bc2a | 1992-01-14 18:32:11 +0000 | [diff] [blame] | 55 | int f_lasti; /* Last instruction if called */ |
| 56 | int f_lineno; /* Current line number */ |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 57 | int f_restricted; /* Flag set if restricted operations |
| 58 | in this scope */ |
Guido van Rossum | cdf578e | 1997-01-20 04:16:40 +0000 | [diff] [blame^] | 59 | int f_iblock; /* index in f_blockstack */ |
| 60 | PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ |
| 61 | int f_nlocals; /* number of locals */ |
| 62 | int f_stacksize; /* size of value stack */ |
| 63 | PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 64 | } PyFrameObject; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 65 | |
| 66 | |
| 67 | /* Standard object interface */ |
| 68 | |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 69 | extern DL_IMPORT(PyTypeObject) PyFrame_Type; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 70 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 71 | #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 72 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 73 | PyFrameObject * PyFrame_New |
| 74 | Py_PROTO((PyFrameObject *, PyCodeObject *, |
Guido van Rossum | cdf578e | 1997-01-20 04:16:40 +0000 | [diff] [blame^] | 75 | PyObject *, PyObject *)); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 76 | |
| 77 | |
| 78 | /* The rest of the interface is specific for frame objects */ |
| 79 | |
Guido van Rossum | 9381782 | 1995-01-17 16:01:01 +0000 | [diff] [blame] | 80 | /* Tuple access macros */ |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 81 | |
Guido van Rossum | 408027e | 1996-12-30 16:17:54 +0000 | [diff] [blame] | 82 | #ifndef Py_DEBUG |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 83 | #define GETITEM(v, i) PyTuple_GET_ITEM((PyTupleObject *)(v), (i)) |
| 84 | #define GETITEMNAME(v, i) \ |
| 85 | PyString_AS_STRING((PyStringObject *)GETITEM((v), (i))) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 86 | #else |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 87 | #define GETITEM(v, i) PyTuple_GetItem((v), (i)) |
| 88 | #define GETITEMNAME(v, i) PyString_AsString(GETITEM(v, i)) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 89 | #endif |
| 90 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 91 | #define GETUSTRINGVALUE(s) ((unsigned char *)PyString_AS_STRING(s)) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 92 | |
| 93 | /* Code access macros */ |
| 94 | |
| 95 | #define Getconst(f, i) (GETITEM((f)->f_code->co_consts, (i))) |
| 96 | #define Getname(f, i) (GETITEMNAME((f)->f_code->co_names, (i))) |
Guido van Rossum | d594c91 | 1991-04-03 19:03:22 +0000 | [diff] [blame] | 97 | #define Getnamev(f, i) (GETITEM((f)->f_code->co_names, (i))) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 98 | |
| 99 | |
| 100 | /* Block management functions */ |
| 101 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 102 | void PyFrame_BlockSetup Py_PROTO((PyFrameObject *, int, int, int)); |
| 103 | PyTryBlock *PyFrame_BlockPop Py_PROTO((PyFrameObject *)); |
Guido van Rossum | a9e7dc1 | 1992-10-18 18:53:57 +0000 | [diff] [blame] | 104 | |
| 105 | /* Extend the value stack */ |
| 106 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 107 | PyObject **PyFrame_ExtendStack Py_PROTO((PyFrameObject *, int, int)); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 108 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 109 | /* Conversions between "fast locals" and locals in dictionary */ |
| 110 | |
Guido van Rossum | 9381782 | 1995-01-17 16:01:01 +0000 | [diff] [blame] | 111 | void PyFrame_LocalsToFast Py_PROTO((PyFrameObject *, int)); |
| 112 | void PyFrame_FastToLocals Py_PROTO((PyFrameObject *)); |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 113 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 114 | #ifdef __cplusplus |
| 115 | } |
| 116 | #endif |
| 117 | #endif /* !Py_FRAMEOBJECT_H */ |