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; |
Fred Drake | 6a1c87d | 2001-03-23 04:17:58 +0000 | [diff] [blame] | 19 | PyObject *func_weakreflist; |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 20 | } PyFunctionObject; |
Guido van Rossum | 2583165 | 1993-05-19 14:50:45 +0000 | [diff] [blame] | 21 | |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 22 | extern DL_IMPORT(PyTypeObject) PyFunction_Type; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 23 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 24 | #define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 25 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 26 | extern DL_IMPORT(PyObject *) PyFunction_New(PyObject *, PyObject *); |
| 27 | extern DL_IMPORT(PyObject *) PyFunction_GetCode(PyObject *); |
| 28 | extern DL_IMPORT(PyObject *) PyFunction_GetGlobals(PyObject *); |
| 29 | extern DL_IMPORT(PyObject *) PyFunction_GetDefaults(PyObject *); |
| 30 | extern DL_IMPORT(int) PyFunction_SetDefaults(PyObject *, PyObject *); |
Jeremy Hylton | 64949cb | 2001-01-25 20:06:59 +0000 | [diff] [blame] | 31 | extern DL_IMPORT(PyObject *) PyFunction_GetClosure(PyObject *); |
| 32 | extern DL_IMPORT(int) PyFunction_SetClosure(PyObject *, PyObject *); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 33 | |
Guido van Rossum | ba0d061 | 1998-07-10 15:47:08 +0000 | [diff] [blame] | 34 | /* Macros for direct access to these values. Type checks are *not* |
| 35 | done, so use with care. */ |
| 36 | #define PyFunction_GET_CODE(func) \ |
| 37 | (((PyFunctionObject *)func) -> func_code) |
| 38 | #define PyFunction_GET_GLOBALS(func) \ |
| 39 | (((PyFunctionObject *)func) -> func_globals) |
| 40 | #define PyFunction_GET_DEFAULTS(func) \ |
| 41 | (((PyFunctionObject *)func) -> func_defaults) |
Jeremy Hylton | 64949cb | 2001-01-25 20:06:59 +0000 | [diff] [blame] | 42 | #define PyFunction_GET_CLOSURE(func) \ |
| 43 | (((PyFunctionObject *)func) -> func_closure) |
Guido van Rossum | ba0d061 | 1998-07-10 15:47:08 +0000 | [diff] [blame] | 44 | |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 45 | /* The classmethod and staticmethod types lives here, too */ |
| 46 | extern DL_IMPORT(PyTypeObject) PyClassMethod_Type; |
| 47 | extern DL_IMPORT(PyTypeObject) PyStaticMethod_Type; |
| 48 | |
| 49 | extern DL_IMPORT(PyObject *) PyClassMethod_New(PyObject *); |
| 50 | extern DL_IMPORT(PyObject *) PyStaticMethod_New(PyObject *); |
| 51 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 52 | #ifdef __cplusplus |
| 53 | } |
| 54 | #endif |
| 55 | #endif /* !Py_FUNCOBJECT_H */ |