Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 1 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 2 | /* Function object interface */ |
| 3 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 4 | #ifndef Py_FUNCOBJECT_H |
| 5 | #define Py_FUNCOBJECT_H |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
Guido van Rossum | 2583165 | 1993-05-19 14:50:45 +0000 | [diff] [blame] | 10 | typedef struct { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 11 | PyObject_HEAD |
| 12 | PyObject *func_code; |
| 13 | PyObject *func_globals; |
| 14 | PyObject *func_defaults; |
Jeremy Hylton | 64949cb | 2001-01-25 20:06:59 +0000 | [diff] [blame] | 15 | PyObject *func_closure; |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 16 | PyObject *func_doc; |
| 17 | PyObject *func_name; |
Barry Warsaw | d6a9e84 | 2001-01-15 20:40:19 +0000 | [diff] [blame] | 18 | PyObject *func_dict; |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 19 | } PyFunctionObject; |
Guido van Rossum | 2583165 | 1993-05-19 14:50:45 +0000 | [diff] [blame] | 20 | |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 21 | extern DL_IMPORT(PyTypeObject) PyFunction_Type; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 22 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 23 | #define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 24 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 25 | extern DL_IMPORT(PyObject *) PyFunction_New(PyObject *, PyObject *); |
| 26 | extern DL_IMPORT(PyObject *) PyFunction_GetCode(PyObject *); |
| 27 | extern DL_IMPORT(PyObject *) PyFunction_GetGlobals(PyObject *); |
| 28 | extern DL_IMPORT(PyObject *) PyFunction_GetDefaults(PyObject *); |
| 29 | extern DL_IMPORT(int) PyFunction_SetDefaults(PyObject *, PyObject *); |
Jeremy Hylton | 64949cb | 2001-01-25 20:06:59 +0000 | [diff] [blame] | 30 | extern DL_IMPORT(PyObject *) PyFunction_GetClosure(PyObject *); |
| 31 | extern DL_IMPORT(int) PyFunction_SetClosure(PyObject *, PyObject *); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 32 | |
Guido van Rossum | ba0d061 | 1998-07-10 15:47:08 +0000 | [diff] [blame] | 33 | /* Macros for direct access to these values. Type checks are *not* |
| 34 | done, so use with care. */ |
| 35 | #define PyFunction_GET_CODE(func) \ |
| 36 | (((PyFunctionObject *)func) -> func_code) |
| 37 | #define PyFunction_GET_GLOBALS(func) \ |
| 38 | (((PyFunctionObject *)func) -> func_globals) |
| 39 | #define PyFunction_GET_DEFAULTS(func) \ |
| 40 | (((PyFunctionObject *)func) -> func_defaults) |
Jeremy Hylton | 64949cb | 2001-01-25 20:06:59 +0000 | [diff] [blame] | 41 | #define PyFunction_GET_CLOSURE(func) \ |
| 42 | (((PyFunctionObject *)func) -> func_closure) |
Guido van Rossum | ba0d061 | 1998-07-10 15:47:08 +0000 | [diff] [blame] | 43 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 44 | #ifdef __cplusplus |
| 45 | } |
| 46 | #endif |
| 47 | #endif /* !Py_FUNCOBJECT_H */ |